Closed Bug 1697504 Opened 5 years ago Closed 5 years ago

Prefer JSObject subclasses in CacheIR code to avoid emitting unreachable code

Categories

(Core :: JavaScript Engine: JIT, enhancement, P1)

enhancement

Tracking

()

RESOLVED FIXED
88 Branch
Tracking Status
firefox88 --- fixed

People

(Reporter: anba, Assigned: anba)

Details

Attachments

(21 files)

48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review

TestMatchingReceiver has if-statements to handle ProxyObject and TypedObject types, even though this function is only called with NativeObject. This can easily be fixed if we properly pass NativeObject* instead of JSObject* through all callers. As part of this bug, I'll also remove unnecessary rooting, for example in IRGenerator::emitIdGuard, which contains a rooted and a non-rooted parameter, which is slightly confusing.

Use NativeObject* for the no-gc variant of NativeLookupPropertyInline and
then update all callers to use NativeObject*, too.

Depends on D107838

Use NativeObject* for EmitCallGetterResultGuards, this allows us to directly
call TestMatchingNativeReceiver.

Depends on D107839

Similar to part 3, this allows to directly call TestMatchingNativeReceiver().

Depends on D107841

Similar to part 3, this allows to directly call TestMatchingNativeReceiver().

Depends on D107842

Similar to part 3, this allows to directly call TestMatchingNativeReceiver().

TestMatchingReceiver() is no longer used, so we can remove it now, too.

Depends on D107843

GuardTypeDescr is no longer used after part 6.

Also removes the corresponding MacroAssembler methods.

Depends on D107844

Part 7 showed that there are incorrect includes to "wasm/TypedObject.h".
(MacroAssembler used TypedObject without including it.)

Depends on D107845

Use NativeObject* in GeneratePrototypeHoleGuards, GuardReceiverProto, and
ShapeGuardProtoChain, so it's more obvious why calling JSObject::staticPrototype()
is correct.

Depends on D107846

Pass through NativeObject* to TestMatchingHolder() instead of asserting
the argument JSObject is a native object.

Depends on D107847

IsCacheableGetPropReadSlot() and IsCacheableGetPropCall() are only applicable
for native objects, therefore use NativeObject* for both functions.

Depends on D107848

Similar to part 11, use NativeObject* for these two functions.

Depends on D107849

IsCacheableProtoChain() is only called with NativeObject*. Also turn all
IsCacheableProtoChain() checks into assertions to match the current code.

The comment about lookupProperty potentially modifying the prototype chain
dates back to bug 729099. At that point of time, the code was calling
JSObject::lookupProperty() (today's js::LookupProperty()), which could
indeed modify the prototype chain. But today CacheIR is always calling
js::LookupPropertyPure() (or similar functions), which can't alter any
prototypes.

Depends on D107850

Using NativeObject* doesn't give any extra value except for documenting which
types of objects we currently expect here.

Depends on D107851

No functions called in CanAttachNativeGetProp() can GC, so we can safely use
raw pointers.

Depends on D107852

The DOMInstanceClassHasProtoAtDepth call in CanAttachDOMCall() can't be
analysed by the hazard analysis because it happens through a pointer to a
function. This means any GC values must either be rooted or alternatively
JS::AutoSuppressGCAnalysis could be used to disable the hazard analysis.

Consistently use handles for both functions so callers can't use raw pointers
without causing a compiler error.

Depends on D107854

Replace more rooted variables with raw pointers. Also avoids in some places
to have rooted and raw pointers next to each other.

Depends on D107855

Severity: -- → N/A
Priority: -- → P1
Attachment #9208138 - Attachment description: Bug 1697504 - Part 16: Consistently use handles in CanAttachDOMCall and CanAttachDOMGetterSetter. r=jandem! → Bug 1697504 - Part 16: Use raw pointers in CanAttachDOMCall and CanAttachDOMGetterSetter. r=jandem!
Pushed by andre.bargull@gmail.com: https://hg.mozilla.org/integration/autoland/rev/6091f772179c Part 1: Use ProxyObject* instead of JSObject* in various CacheIR methods. r=jandem https://hg.mozilla.org/integration/autoland/rev/1a1d48764556 Part 2: Return a NativeObject* for the no-gc variant of NativeLookupPropertyInline. r=jandem https://hg.mozilla.org/integration/autoland/rev/655671c2ec69 Part 3: Use NativeObject* in EmitCallGetterResultGuards. r=jandem https://hg.mozilla.org/integration/autoland/rev/3c84769b0a00 Part 4: Use NativeObject* in HasPropIRGenerator::tryAttachSlotDoesNotExist(). r=jandem https://hg.mozilla.org/integration/autoland/rev/0daa0d35c49c Part 5: Use NativeObject* in SetPropIRGenerator::tryAttachSetter(). r=jandem https://hg.mozilla.org/integration/autoland/rev/1ea7ec3d8f5c Part 6: Use NativeObject* in EmitReadSlotGuard. r=jandem https://hg.mozilla.org/integration/autoland/rev/766614ff771c Part 7: Remove GuardTypeDescr CacheIR op. r=jandem https://hg.mozilla.org/integration/autoland/rev/3cdb584bd4a0 Part 8: Fix includes to "wasm/TypedObject.h". r=jandem https://hg.mozilla.org/integration/autoland/rev/94be6f952008 Part 9: Use NativeObject* in GeneratePrototypeHoleGuards, GuardReceiverProto, and ShapeGuardProtoChain. r=jandem https://hg.mozilla.org/integration/autoland/rev/711b00030864 Part 10: Use NativeObject* in TestMatchingHolder. r=jandem https://hg.mozilla.org/integration/autoland/rev/ccf84078cea2 Part 11: Use NativeObject* for IsCacheableGetProp{ReadSlot,Call}(). r=jandem https://hg.mozilla.org/integration/autoland/rev/04321bf57b5b Part 12: Use NativeObject* for IsCacheableSetPropCall{Native,Scripted}(). r=jandem https://hg.mozilla.org/integration/autoland/rev/3a2ced62cd9f Part 13: Use NativeObject* for IsCacheableProtoChain. r=jandem https://hg.mozilla.org/integration/autoland/rev/ed113f45c482 Part 14: Use NativeObject* for remaining functions. r=jandem https://hg.mozilla.org/integration/autoland/rev/861100e3f84b Part 15: Use raw pointers in CanAttachNativeGetProp. r=jandem https://hg.mozilla.org/integration/autoland/rev/6ed359874293 Part 16: Use raw pointers in CanAttachDOMCall and CanAttachDOMGetterSetter. r=jandem https://hg.mozilla.org/integration/autoland/rev/a1e3663e5bc0 Part 17: Avoid more unnecessary rooting in CacheIR. r=jandem https://hg.mozilla.org/integration/autoland/rev/8d7bba4146f5 Part 18: Add missing 'static' modifier. r=jandem https://hg.mozilla.org/integration/autoland/rev/b551678dc0de Part 19: Remove unnecessary rooting from CanAttachGlobalName. r=jandem https://hg.mozilla.org/integration/autoland/rev/98642a9e548e Part 20: Remove unnecessary rooting from CanAttachSetter. r=jandem https://hg.mozilla.org/integration/autoland/rev/8249396ef069 Part 21: Remove unnecessary rooting from CanAttachNativeSetSlot. r=jandem
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: