diff --git a/js/src/jit/IonCaches.cpp b/js/src/jit/IonCaches.cpp index 0650a934f2e..6a7d949d59b 100644 --- a/js/src/jit/IonCaches.cpp +++ b/js/src/jit/IonCaches.cpp @@ -2340,15 +2340,14 @@ GetElementIC::attachGetProp(JSContext *cx, IonScript *ion, HandleObject obj, RootedObject holder(cx); RootedShape shape(cx); - if (!JSObject::lookupProperty(cx, obj, name, &holder, &shape)) + + GetPropertyIC::NativeGetPropCacheability canCache = + CanAttachNativeGetProp(cx, *this, obj, name, &holder, &shape); + + if (canCache == GetPropertyIC::CanAttachError) return false; - RootedScript script(cx); - jsbytecode *pc; - getScriptedLocation(&script, &pc); - - if (!IsCacheableGetPropReadSlot(obj, holder, shape) && - !IsCacheableNoProperty(obj, holder, shape, pc, output())) { + if (canCache != GetPropertyIC::CanAttachReadSlot) { IonSpew(IonSpew_InlineCaches, "GETELEM uncacheable property"); return true; } diff --git a/js/src/jit/IonCaches.h b/js/src/jit/IonCaches.h index 132d8bbc0d6..d738543926a 100644 --- a/js/src/jit/IonCaches.h +++ b/js/src/jit/IonCaches.h @@ -705,6 +705,18 @@ class GetElementIC : public RepatchIonCache hasDenseStub_ = true; } + // Helpers for CanAttachNativeGetProp + typedef JSContext * Context; + static bool doPropertyLookup(Context cx, HandleObject obj, HandlePropertyName name, + MutableHandleObject holder, MutableHandleShape shape) { + return JSObject::lookupProperty(cx, obj, name, holder, shape); + } + bool allowGetters() const { return false; } + bool lookupNeedsIdempotentChain() const { return false; } + bool canMonitorSingletonUndefinedSlot(HandleObject holder, HandleShape shape) const { + return monitoredResult(); + } + static bool canAttachGetProp(JSObject *obj, const Value &idval, jsid id); static bool canAttachDenseElement(JSObject *obj, const Value &idval); static bool canAttachTypedArrayElement(JSObject *obj, const Value &idval,