diff options
author | Gaming4JC <g4jc@hyperbola.info> | 2019-06-08 17:11:49 -0400 |
---|---|---|
committer | Gaming4JC <g4jc@hyperbola.info> | 2019-07-18 22:38:19 -0400 |
commit | 668254e2b2a7b4f1d6da703275b89f3753096f71 (patch) | |
tree | 6120c3a0456fc1983f30685d17920a92b3397998 /js/src/jsobjinlines.h | |
parent | afb28a43d481075a244b0e18faa8447dfadacf8f (diff) | |
download | UXP-668254e2b2a7b4f1d6da703275b89f3753096f71.tar UXP-668254e2b2a7b4f1d6da703275b89f3753096f71.tar.gz UXP-668254e2b2a7b4f1d6da703275b89f3753096f71.tar.lz UXP-668254e2b2a7b4f1d6da703275b89f3753096f71.tar.xz UXP-668254e2b2a7b4f1d6da703275b89f3753096f71.zip |
903389 - Fix uses of ClassMethodIsNative.
Diffstat (limited to 'js/src/jsobjinlines.h')
-rw-r--r-- | js/src/jsobjinlines.h | 44 |
1 files changed, 13 insertions, 31 deletions
diff --git a/js/src/jsobjinlines.h b/js/src/jsobjinlines.h index b1d817bca..7028310ce 100644 --- a/js/src/jsobjinlines.h +++ b/js/src/jsobjinlines.h @@ -557,48 +557,30 @@ IsNativeFunction(const js::Value& v, JSNative native) return IsFunctionObject(v, &fun) && fun->maybeNative() == native; } -/* - * When we have an object of a builtin class, we don't quite know what its - * valueOf/toString methods are, since these methods may have been overwritten - * or shadowed. However, we can still do better than the general case by - * hard-coding the necessary properties for us to find the native we expect. - * - * TODO: a per-thread shape-based cache would be faster and simpler. - */ +// Return whether looking up a method on 'obj' definitely resolves to the +// original specified native function. The method may conservatively return +// 'false' in the case of proxies or other non-native objects. static MOZ_ALWAYS_INLINE bool -ClassMethodIsNative(JSContext* cx, NativeObject* obj, const Class* clasp, jsid methodid, JSNative native) +HasNativeMethodPure(JSObject* obj, PropertyName* name, JSNative native, JSContext* cx) { - MOZ_ASSERT(obj->getClass() == clasp); - Value v; - if (!HasDataProperty(cx, obj, methodid, &v)) { - JSObject* proto = obj->staticPrototype(); - if (!proto || proto->getClass() != clasp || !HasDataProperty(cx, &proto->as<NativeObject>(), methodid, &v)) - return false; - } + if (!GetPropertyPure(cx, obj, NameToId(name), &v)) + return false; return IsNativeFunction(v, native); } -// Return whether looking up 'valueOf' on 'obj' definitely resolves to the -// original Object.prototype.valueOf. The method may conservatively return -// 'false' in the case of proxies or other non-native objects. +// Return whether 'obj' definitely has no @@toPrimitive method. static MOZ_ALWAYS_INLINE bool -HasObjectValueOf(JSObject* obj, JSContext* cx) +HasNoToPrimitiveMethodPure(JSObject* obj, JSContext* cx) { - if (obj->is<ProxyObject>() || !obj->isNative()) + jsid id = SYMBOL_TO_JSID(cx->wellKnownSymbols().toPrimitive); + JSObject* pobj; + Shape* shape; + if (!LookupPropertyPure(cx, obj, id, &pobj, &shape)) return false; - jsid valueOf = NameToId(cx->names().valueOf); - - Value v; - while (!HasDataProperty(cx, &obj->as<NativeObject>(), valueOf, &v)) { - obj = obj->staticPrototype(); - if (!obj || obj->is<ProxyObject>() || !obj->isNative()) - return false; - } - - return IsNativeFunction(v, obj_valueOf); + return !shape; } /* ES6 draft rev 28 (2014 Oct 14) 7.1.14 */ |