diff --git a/dom/bindings/Codegen.py b/dom/bindings/Codegen.py index d2972fe95b44..0ca2d58a9b2b 100644 --- a/dom/bindings/Codegen.py +++ b/dom/bindings/Codegen.py @@ -392,21 +392,13 @@ class CGDOMJSClass(CGThing): ${objectMoved} /* objectMovedOp */ }, { - nullptr, /* lookupGeneric */ nullptr, /* lookupProperty */ - nullptr, /* lookupElement */ - nullptr, /* defineGeneric */ nullptr, /* defineProperty */ - nullptr, /* defineElement */ - nullptr, /* getGeneric */ nullptr, /* getProperty */ - nullptr, /* getElement */ - nullptr, /* setGeneric */ nullptr, /* setProperty */ - nullptr, /* setElement */ nullptr, /* getOwnPropertyDescriptor */ - nullptr, /* setGenericAttributes */ - nullptr, /* deleteGeneric */ + nullptr, /* setPropertyAttributes */ + nullptr, /* deleteProperty */ nullptr, /* watch */ nullptr, /* unwatch */ nullptr, /* getElements */ diff --git a/dom/plugins/base/nsJSNPRuntime.cpp b/dom/plugins/base/nsJSNPRuntime.cpp index ba3d1c9b9522..562fde7fec76 100644 --- a/dom/plugins/base/nsJSNPRuntime.cpp +++ b/dom/plugins/base/nsJSNPRuntime.cpp @@ -222,21 +222,13 @@ const static js::Class sNPObjectJSWrapperClass = NPObjWrapper_ObjectMoved }, { - nullptr, // lookupGeneric nullptr, // lookupProperty - nullptr, // lookupElement - nullptr, // defineGeneric nullptr, // defineProperty - nullptr, // defineElement - nullptr, // getGeneric nullptr, // getProperty - nullptr, // getElement - nullptr, // setGeneric nullptr, // setProperty - nullptr, // setElement nullptr, // getOwnPropertyDescriptor - nullptr, // setGenericAttributes - nullptr, // deleteGeneric + nullptr, // setPropertyAttributes + nullptr, // deleteProperty nullptr, nullptr, // watch/unwatch nullptr, // getElements NPObjWrapper_Enumerate, diff --git a/js/public/Class.h b/js/public/Class.h index 8d3a08ad066b..27991c9df34a 100644 --- a/js/public/Class.h +++ b/js/public/Class.h @@ -162,49 +162,24 @@ typedef void namespace js { typedef bool -(* LookupGenericOp)(JSContext *cx, JS::HandleObject obj, JS::HandleId id, - JS::MutableHandleObject objp, JS::MutableHandle propp); +(* LookupPropertyOp)(JSContext *cx, JS::HandleObject obj, JS::HandleId id, + JS::MutableHandleObject objp, JS::MutableHandle propp); typedef bool -(* LookupPropOp)(JSContext *cx, JS::HandleObject obj, JS::Handle name, - JS::MutableHandleObject objp, JS::MutableHandle propp); +(* DefinePropertyOp)(JSContext *cx, JS::HandleObject obj, JS::HandleId id, JS::HandleValue value, + JSPropertyOp getter, JSStrictPropertyOp setter, unsigned attrs); typedef bool -(* LookupElementOp)(JSContext *cx, JS::HandleObject obj, uint32_t index, - JS::MutableHandleObject objp, JS::MutableHandle propp); +(* GetPropertyOp)(JSContext *cx, JS::HandleObject obj, JS::HandleObject receiver, JS::HandleId id, + JS::MutableHandleValue vp); typedef bool -(* DefineGenericOp)(JSContext *cx, JS::HandleObject obj, JS::HandleId id, JS::HandleValue value, - JSPropertyOp getter, JSStrictPropertyOp setter, unsigned attrs); -typedef bool -(* DefinePropOp)(JSContext *cx, JS::HandleObject obj, JS::Handle name, - JS::HandleValue value, JSPropertyOp getter, JSStrictPropertyOp setter, - unsigned attrs); -typedef bool -(* DefineElementOp)(JSContext *cx, JS::HandleObject obj, uint32_t index, JS::HandleValue value, - JSPropertyOp getter, JSStrictPropertyOp setter, unsigned attrs); -typedef bool -(* GenericIdOp)(JSContext *cx, JS::HandleObject obj, JS::HandleObject receiver, JS::HandleId id, - JS::MutableHandleValue vp); -typedef bool -(* PropertyIdOp)(JSContext *cx, JS::HandleObject obj, JS::HandleObject receiver, - JS::Handle name, JS::MutableHandleValue vp); -typedef bool -(* ElementIdOp)(JSContext *cx, JS::HandleObject obj, JS::HandleObject receiver, uint32_t index, - JS::MutableHandleValue vp); -typedef bool -(* StrictGenericIdOp)(JSContext *cx, JS::HandleObject obj, JS::HandleId id, - JS::MutableHandleValue vp, bool strict); -typedef bool -(* StrictPropertyIdOp)(JSContext *cx, JS::HandleObject obj, JS::Handle name, - JS::MutableHandleValue vp, bool strict); -typedef bool -(* StrictElementIdOp)(JSContext *cx, JS::HandleObject obj, uint32_t index, - JS::MutableHandleValue vp, bool strict); +(* SetPropertyOp)(JSContext *cx, JS::HandleObject obj, JS::HandleId id, + JS::MutableHandleValue vp, bool strict); typedef bool (* GetOwnPropertyOp)(JSContext *cx, JS::HandleObject obj, JS::HandleId id, JS::MutableHandle desc); typedef bool -(* GenericAttributesOp)(JSContext *cx, JS::HandleObject obj, JS::HandleId id, unsigned *attrsp); +(* SetAttributesOp)(JSContext *cx, JS::HandleObject obj, JS::HandleId id, unsigned *attrsp); typedef bool -(* DeleteGenericOp)(JSContext *cx, JS::HandleObject obj, JS::HandleId id, bool *succeeded); +(* DeletePropertyOp)(JSContext *cx, JS::HandleObject obj, JS::HandleId id, bool *succeeded); typedef bool (* WatchOp)(JSContext *cx, JS::HandleObject obj, JS::HandleId id, JS::HandleObject callable); @@ -366,21 +341,13 @@ struct ClassExtension struct ObjectOps { - LookupGenericOp lookupGeneric; - LookupPropOp lookupProperty; - LookupElementOp lookupElement; - DefineGenericOp defineGeneric; - DefinePropOp defineProperty; - DefineElementOp defineElement; - GenericIdOp getGeneric; - PropertyIdOp getProperty; - ElementIdOp getElement; - StrictGenericIdOp setGeneric; - StrictPropertyIdOp setProperty; - StrictElementIdOp setElement; + LookupPropertyOp lookupProperty; + DefinePropertyOp defineProperty; + GetPropertyOp getProperty; + SetPropertyOp setProperty; GetOwnPropertyOp getOwnPropertyDescriptor; - GenericAttributesOp setGenericAttributes; - DeleteGenericOp deleteGeneric; + SetAttributesOp setAttributes; + DeletePropertyOp deleteProperty; WatchOp watch; UnwatchOp unwatch; GetElementsOp getElements; @@ -390,7 +357,6 @@ struct ObjectOps #define JS_NULL_OBJECT_OPS \ {nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, \ - nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, \ nullptr, nullptr, nullptr, nullptr} } // namespace js @@ -402,7 +368,7 @@ typedef void (*JSClassInternal)(); struct JSClass { JS_CLASS_MEMBERS(JSFinalizeOp); - void *reserved[32]; + void *reserved[24]; }; #define JSCLASS_HAS_PRIVATE (1<<0) // objects have private slot diff --git a/js/src/builtin/TypedObject.cpp b/js/src/builtin/TypedObject.cpp index 058791c7693c..a751aa5181aa 100644 --- a/js/src/builtin/TypedObject.cpp +++ b/js/src/builtin/TypedObject.cpp @@ -1681,8 +1681,8 @@ OutlineTypedObject::obj_trace(JSTracer *trc, JSObject *object) } bool -TypedObject::obj_lookupGeneric(JSContext *cx, HandleObject obj, HandleId id, - MutableHandleObject objp, MutableHandleShape propp) +TypedObject::obj_lookupProperty(JSContext *cx, HandleObject obj, HandleId id, + MutableHandleObject objp, MutableHandleShape propp) { MOZ_ASSERT(obj->is()); @@ -1730,20 +1730,9 @@ TypedObject::obj_lookupGeneric(JSContext *cx, HandleObject obj, HandleId id, return LookupProperty(cx, proto, id, objp, propp); } -bool -TypedObject::obj_lookupProperty(JSContext *cx, - HandleObject obj, - HandlePropertyName name, - MutableHandleObject objp, - MutableHandleShape propp) -{ - RootedId id(cx, NameToId(name)); - return obj_lookupGeneric(cx, obj, id, objp, propp); -} - bool TypedObject::obj_lookupElement(JSContext *cx, HandleObject obj, uint32_t index, - MutableHandleObject objp, MutableHandleShape propp) + MutableHandleObject objp, MutableHandleShape propp) { MOZ_ASSERT(obj->is()); MarkNonNativePropertyFound(propp); @@ -1772,35 +1761,15 @@ ReportPropertyError(JSContext *cx, } bool -TypedObject::obj_defineGeneric(JSContext *cx, HandleObject obj, HandleId id, HandleValue v, - PropertyOp getter, StrictPropertyOp setter, unsigned attrs) +TypedObject::obj_defineProperty(JSContext *cx, HandleObject obj, HandleId id, HandleValue v, + PropertyOp getter, StrictPropertyOp setter, unsigned attrs) { return ReportPropertyError(cx, JSMSG_UNDEFINED_PROP, id); } bool -TypedObject::obj_defineProperty(JSContext *cx, HandleObject obj, - HandlePropertyName name, HandleValue v, - PropertyOp getter, StrictPropertyOp setter, unsigned attrs) -{ - Rooted id(cx, NameToId(name)); - return obj_defineGeneric(cx, obj, id, v, getter, setter, attrs); -} - -bool -TypedObject::obj_defineElement(JSContext *cx, HandleObject obj, uint32_t index, HandleValue v, - PropertyOp getter, StrictPropertyOp setter, unsigned attrs) -{ - AutoRooterGetterSetter gsRoot(cx, attrs, &getter, &setter); - Rooted id(cx); - if (!IndexToId(cx, index, &id)) - return false; - return obj_defineGeneric(cx, obj, id, v, getter, setter, attrs); -} - -bool -TypedObject::obj_getGeneric(JSContext *cx, HandleObject obj, HandleObject receiver, - HandleId id, MutableHandleValue vp) +TypedObject::obj_getProperty(JSContext *cx, HandleObject obj, HandleObject receiver, + HandleId id, MutableHandleValue vp) { MOZ_ASSERT(obj->is()); Rooted typedObj(cx, &obj->as()); @@ -1856,17 +1825,9 @@ TypedObject::obj_getGeneric(JSContext *cx, HandleObject obj, HandleObject receiv return GetProperty(cx, proto, receiver, id, vp); } -bool -TypedObject::obj_getProperty(JSContext *cx, HandleObject obj, HandleObject receiver, - HandlePropertyName name, MutableHandleValue vp) -{ - RootedId id(cx, NameToId(name)); - return obj_getGeneric(cx, obj, receiver, id, vp); -} - bool TypedObject::obj_getElement(JSContext *cx, HandleObject obj, HandleObject receiver, - uint32_t index, MutableHandleValue vp) + uint32_t index, MutableHandleValue vp) { MOZ_ASSERT(obj->is()); Rooted typedObj(cx, &obj->as()); @@ -1894,10 +1855,10 @@ TypedObject::obj_getElement(JSContext *cx, HandleObject obj, HandleObject receiv /*static*/ bool TypedObject::obj_getArrayElement(JSContext *cx, - Handle typedObj, - Handle typeDescr, - uint32_t index, - MutableHandleValue vp) + Handle typedObj, + Handle typeDescr, + uint32_t index, + MutableHandleValue vp) { if (index >= (size_t) typedObj->length()) { vp.setUndefined(); @@ -1910,8 +1871,8 @@ TypedObject::obj_getArrayElement(JSContext *cx, } bool -TypedObject::obj_setGeneric(JSContext *cx, HandleObject obj, HandleId id, - MutableHandleValue vp, bool strict) +TypedObject::obj_setProperty(JSContext *cx, HandleObject obj, HandleId id, + MutableHandleValue vp, bool strict) { MOZ_ASSERT(obj->is()); Rooted typedObj(cx, &obj->as()); @@ -1953,18 +1914,9 @@ TypedObject::obj_setGeneric(JSContext *cx, HandleObject obj, HandleId id, return ReportTypedObjTypeError(cx, JSMSG_OBJECT_NOT_EXTENSIBLE, typedObj); } -bool -TypedObject::obj_setProperty(JSContext *cx, HandleObject obj, - HandlePropertyName name, MutableHandleValue vp, - bool strict) -{ - RootedId id(cx, NameToId(name)); - return obj_setGeneric(cx, obj, id, vp, strict); -} - bool TypedObject::obj_setElement(JSContext *cx, HandleObject obj, uint32_t index, - MutableHandleValue vp, bool strict) + MutableHandleValue vp, bool strict) { MOZ_ASSERT(obj->is()); Rooted typedObj(cx, &obj->as()); @@ -2087,8 +2039,8 @@ IsOwnId(JSContext *cx, HandleObject obj, HandleId id) } bool -TypedObject::obj_setGenericAttributes(JSContext *cx, HandleObject obj, - HandleId id, unsigned *attrsp) +TypedObject::obj_setPropertyAttributes(JSContext *cx, HandleObject obj, HandleId id, + unsigned *attrsp) { if (IsOwnId(cx, obj, id)) return ReportPropertyError(cx, JSMSG_CANT_REDEFINE_PROP, id); @@ -2103,7 +2055,7 @@ TypedObject::obj_setGenericAttributes(JSContext *cx, HandleObject obj, } bool -TypedObject::obj_deleteGeneric(JSContext *cx, HandleObject obj, HandleId id, bool *succeeded) +TypedObject::obj_deleteProperty(JSContext *cx, HandleObject obj, HandleId id, bool *succeeded) { if (IsOwnId(cx, obj, id)) return ReportPropertyError(cx, JSMSG_CANT_DELETE, id); @@ -2370,21 +2322,13 @@ LazyArrayBufferTable::sizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf) JS_NULL_CLASS_SPEC, \ JS_NULL_CLASS_EXT, \ { \ - TypedObject::obj_lookupGeneric, \ TypedObject::obj_lookupProperty, \ - TypedObject::obj_lookupElement, \ - TypedObject::obj_defineGeneric, \ TypedObject::obj_defineProperty, \ - TypedObject::obj_defineElement, \ - TypedObject::obj_getGeneric, \ TypedObject::obj_getProperty, \ - TypedObject::obj_getElement, \ - TypedObject::obj_setGeneric, \ TypedObject::obj_setProperty, \ - TypedObject::obj_setElement, \ TypedObject::obj_getOwnPropertyDescriptor, \ - TypedObject::obj_setGenericAttributes, \ - TypedObject::obj_deleteGeneric, \ + TypedObject::obj_setPropertyAttributes, \ + TypedObject::obj_deleteProperty, \ nullptr, nullptr, /* watch/unwatch */ \ nullptr, /* getElements */ \ TypedObject::obj_enumerate, \ diff --git a/js/src/builtin/TypedObject.h b/js/src/builtin/TypedObject.h index d24a21e04080..b14a19e95ca8 100644 --- a/js/src/builtin/TypedObject.h +++ b/js/src/builtin/TypedObject.h @@ -525,52 +525,35 @@ class TypedObject : public JSObject MutableHandleValue vp); protected: - static bool obj_lookupGeneric(JSContext *cx, HandleObject obj, - HandleId id, MutableHandleObject objp, - MutableHandleShape propp); - static bool obj_lookupProperty(JSContext *cx, HandleObject obj, - HandlePropertyName name, - MutableHandleObject objp, + HandleId id, MutableHandleObject objp, MutableHandleShape propp); - static bool obj_lookupElement(JSContext *cx, HandleObject obj, - uint32_t index, MutableHandleObject objp, - MutableHandleShape propp); + static bool obj_lookupElement(JSContext *cx, HandleObject obj, uint32_t index, + MutableHandleObject objp, MutableHandleShape propp); - static bool obj_defineGeneric(JSContext *cx, HandleObject obj, HandleId id, HandleValue v, - PropertyOp getter, StrictPropertyOp setter, unsigned attrs); - - static bool obj_defineProperty(JSContext *cx, HandleObject obj, - HandlePropertyName name, HandleValue v, + static bool obj_defineProperty(JSContext *cx, HandleObject obj, HandleId id, HandleValue v, PropertyOp getter, StrictPropertyOp setter, unsigned attrs); - static bool obj_defineElement(JSContext *cx, HandleObject obj, uint32_t index, HandleValue v, - PropertyOp getter, StrictPropertyOp setter, unsigned attrs); - - static bool obj_getGeneric(JSContext *cx, HandleObject obj, HandleObject receiver, - HandleId id, MutableHandleValue vp); - static bool obj_getProperty(JSContext *cx, HandleObject obj, HandleObject receiver, - HandlePropertyName name, MutableHandleValue vp); + HandleId id, MutableHandleValue vp); static bool obj_getElement(JSContext *cx, HandleObject obj, HandleObject receiver, uint32_t index, MutableHandleValue vp); - static bool obj_setGeneric(JSContext *cx, HandleObject obj, HandleId id, - MutableHandleValue vp, bool strict); - static bool obj_setProperty(JSContext *cx, HandleObject obj, HandlePropertyName name, + static bool obj_setProperty(JSContext *cx, HandleObject obj, HandleId id, MutableHandleValue vp, bool strict); + static bool obj_setElement(JSContext *cx, HandleObject obj, uint32_t index, MutableHandleValue vp, bool strict); static bool obj_getOwnPropertyDescriptor(JSContext *cx, HandleObject obj, HandleId id, MutableHandle desc); - static bool obj_setGenericAttributes(JSContext *cx, HandleObject obj, - HandleId id, unsigned *attrsp); + static bool obj_setPropertyAttributes(JSContext *cx, HandleObject obj, + HandleId id, unsigned *attrsp); - static bool obj_deleteGeneric(JSContext *cx, HandleObject obj, HandleId id, bool *succeeded); + static bool obj_deleteProperty(JSContext *cx, HandleObject obj, HandleId id, bool *succeeded); static bool obj_enumerate(JSContext *cx, HandleObject obj, AutoIdVector &properties); diff --git a/js/src/jit/IonBuilder.cpp b/js/src/jit/IonBuilder.cpp index c177782b49a2..11b4456e0e28 100644 --- a/js/src/jit/IonBuilder.cpp +++ b/js/src/jit/IonBuilder.cpp @@ -6814,7 +6814,7 @@ static bool ClassHasEffectlessLookup(const Class *clasp, PropertyName *name) { return (clasp == &UnboxedPlainObject::class_) || - (clasp->isNative() && !clasp->ops.lookupGeneric); + (clasp->isNative() && !clasp->ops.lookupProperty); } static bool @@ -9367,11 +9367,11 @@ IonBuilder::objectsHaveCommonPrototype(types::TemporaryTypeSet *types, PropertyN } // Look for a getter/setter on the class itself which may need - // to be called. Ignore the getGeneric hook for typed arrays, it + // to be called. Ignore the getProperty op for typed arrays, it // only handles integers and forwards names to the prototype. - if (isGetter && clasp->ops.getGeneric && !IsAnyTypedArrayClass(clasp)) + if (isGetter && clasp->ops.getProperty && !IsAnyTypedArrayClass(clasp)) return false; - if (!isGetter && clasp->ops.setGeneric) + if (!isGetter && clasp->ops.setProperty) return false; // Test for isOwnProperty() without freezing. If we end up diff --git a/js/src/jsarray.cpp b/js/src/jsarray.cpp index 4d7ab3267505..6c6e79655ebc 100644 --- a/js/src/jsarray.cpp +++ b/js/src/jsarray.cpp @@ -2715,7 +2715,7 @@ struct SortComparatorIndexes // Returns all indexed properties in the range [begin, end) found on |obj| or // its proto chain. This function does not handle proxies, objects with -// resolve/lookupGeneric hooks or indexed getters, as those can introduce +// resolve/lookupProperty hooks or indexed getters, as those can introduce // new properties. In those cases, *success is set to |false|. static bool GetIndexedPropertiesInRange(JSContext *cx, HandleObject obj, uint32_t begin, uint32_t end, @@ -2727,7 +2727,7 @@ GetIndexedPropertiesInRange(JSContext *cx, HandleObject obj, uint32_t begin, uin // properties. JSObject *pobj = obj; do { - if (!pobj->isNative() || pobj->getClass()->resolve || pobj->getOps()->lookupGeneric) + if (!pobj->isNative() || pobj->getClass()->resolve || pobj->getOps()->lookupProperty) return true; } while ((pobj = pobj->getProto())); diff --git a/js/src/jsfriendapi.h b/js/src/jsfriendapi.h index eff85ecd50a1..14b66eedb53e 100644 --- a/js/src/jsfriendapi.h +++ b/js/src/jsfriendapi.h @@ -297,21 +297,13 @@ namespace js { JS_NULL_CLASS_SPEC, \ ext, \ { \ - js::proxy_LookupGeneric, \ js::proxy_LookupProperty, \ - js::proxy_LookupElement, \ - js::proxy_DefineGeneric, \ js::proxy_DefineProperty, \ - js::proxy_DefineElement, \ - js::proxy_GetGeneric, \ js::proxy_GetProperty, \ - js::proxy_GetElement, \ - js::proxy_SetGeneric, \ js::proxy_SetProperty, \ - js::proxy_SetElement, \ js::proxy_GetOwnPropertyDescriptor, \ - js::proxy_SetGenericAttributes, \ - js::proxy_DeleteGeneric, \ + js::proxy_SetPropertyAttributes, \ + js::proxy_DeleteProperty, \ js::proxy_Watch, js::proxy_Unwatch, \ js::proxy_GetElements, \ nullptr, /* enumerate */ \ @@ -335,49 +327,25 @@ namespace js { */ extern JS_FRIEND_API(bool) -proxy_LookupGeneric(JSContext *cx, JS::HandleObject obj, JS::HandleId id, JS::MutableHandleObject objp, +proxy_LookupProperty(JSContext *cx, JS::HandleObject obj, JS::HandleId id, JS::MutableHandleObject objp, JS::MutableHandle propp); extern JS_FRIEND_API(bool) -proxy_LookupProperty(JSContext *cx, JS::HandleObject obj, JS::Handle name, - JS::MutableHandleObject objp, JS::MutableHandle propp); +proxy_DefineProperty(JSContext *cx, JS::HandleObject obj, JS::HandleId id, JS::HandleValue value, + JSPropertyOp getter, JSStrictPropertyOp setter, unsigned attrs); extern JS_FRIEND_API(bool) -proxy_LookupElement(JSContext *cx, JS::HandleObject obj, uint32_t index, JS::MutableHandleObject objp, - JS::MutableHandle propp); +proxy_GetProperty(JSContext *cx, JS::HandleObject obj, JS::HandleObject receiver, JS::HandleId id, + JS::MutableHandleValue vp); extern JS_FRIEND_API(bool) -proxy_DefineGeneric(JSContext *cx, JS::HandleObject obj, JS::HandleId id, JS::HandleValue value, - JSPropertyOp getter, JSStrictPropertyOp setter, unsigned attrs); -extern JS_FRIEND_API(bool) -proxy_DefineProperty(JSContext *cx, JS::HandleObject obj, JS::Handle name, - JS::HandleValue value, JSPropertyOp getter, JSStrictPropertyOp setter, - unsigned attrs); -extern JS_FRIEND_API(bool) -proxy_DefineElement(JSContext *cx, JS::HandleObject obj, uint32_t index, JS::HandleValue value, - JSPropertyOp getter, JSStrictPropertyOp setter, unsigned attrs); -extern JS_FRIEND_API(bool) -proxy_GetGeneric(JSContext *cx, JS::HandleObject obj, JS::HandleObject receiver, JS::HandleId id, - JS::MutableHandleValue vp); -extern JS_FRIEND_API(bool) -proxy_GetProperty(JSContext *cx, JS::HandleObject obj, JS::HandleObject receiver, - JS::Handle name, JS::MutableHandleValue vp); -extern JS_FRIEND_API(bool) -proxy_GetElement(JSContext *cx, JS::HandleObject obj, JS::HandleObject receiver, uint32_t index, - JS::MutableHandleValue vp); -extern JS_FRIEND_API(bool) -proxy_SetGeneric(JSContext *cx, JS::HandleObject obj, JS::HandleId id, - JS::MutableHandleValue bp, bool strict); -extern JS_FRIEND_API(bool) -proxy_SetProperty(JSContext *cx, JS::HandleObject obj, JS::Handle name, +proxy_SetProperty(JSContext *cx, JS::HandleObject obj, JS::HandleId id, JS::MutableHandleValue bp, bool strict); extern JS_FRIEND_API(bool) -proxy_SetElement(JSContext *cx, JS::HandleObject obj, uint32_t index, JS::MutableHandleValue vp, - bool strict); -extern JS_FRIEND_API(bool) proxy_GetOwnPropertyDescriptor(JSContext *cx, JS::HandleObject obj, JS::HandleId id, JS::MutableHandle desc); extern JS_FRIEND_API(bool) -proxy_SetGenericAttributes(JSContext *cx, JS::HandleObject obj, JS::HandleId id, unsigned *attrsp); +proxy_SetPropertyAttributes(JSContext *cx, JS::HandleObject obj, JS::HandleId id, + unsigned *attrsp); extern JS_FRIEND_API(bool) -proxy_DeleteGeneric(JSContext *cx, JS::HandleObject obj, JS::HandleId id, bool *succeeded); +proxy_DeleteProperty(JSContext *cx, JS::HandleObject obj, JS::HandleId id, bool *succeeded); extern JS_FRIEND_API(void) proxy_Trace(JSTracer *trc, JSObject *obj); diff --git a/js/src/jsinfer.cpp b/js/src/jsinfer.cpp index 4dabf360b41d..99c8c76912cd 100644 --- a/js/src/jsinfer.cpp +++ b/js/src/jsinfer.cpp @@ -2432,8 +2432,8 @@ static inline bool ClassCanHaveExtraProperties(const Class *clasp) { return clasp->resolve - || clasp->ops.lookupGeneric - || clasp->ops.getGeneric + || clasp->ops.lookupProperty + || clasp->ops.getProperty || IsAnyTypedArrayClass(clasp); } diff --git a/js/src/jsobj.cpp b/js/src/jsobj.cpp index cfddfb0230ff..651cb9948d91 100644 --- a/js/src/jsobj.cpp +++ b/js/src/jsobj.cpp @@ -538,7 +538,7 @@ DefinePropertyOnObject(JSContext *cx, HandleNativeObject obj, HandleId id, const { /* 8.12.9 step 1. */ RootedShape shape(cx); - MOZ_ASSERT(!obj->getOps()->lookupGeneric); + MOZ_ASSERT(!obj->getOps()->lookupProperty); if (!NativeLookupOwnProperty(cx, obj, id, &shape)) return false; @@ -962,7 +962,7 @@ js::StandardDefineProperty(JSContext *cx, HandleObject obj, HandleId id, const P if (obj->is() && !obj->as().convertToNative(cx)) return false; - if (obj->getOps()->lookupGeneric) { + if (obj->getOps()->lookupProperty) { if (obj->is()) { Rooted pd(cx); desc.populatePropertyDescriptor(obj, &pd); @@ -1036,7 +1036,7 @@ js::DefineProperties(JSContext *cx, HandleObject obj, HandleObject props) if (obj->is() && !obj->as().convertToNative(cx)) return false; - if (obj->getOps()->lookupGeneric) { + if (obj->getOps()->lookupProperty) { if (obj->is()) { Rooted pd(cx); for (size_t i = 0, len = ids.length(); i < len; i++) { @@ -1175,7 +1175,7 @@ js::SetIntegrityLevel(JSContext *cx, HandleObject obj, IntegrityLevel level) // Ordinarily ArraySetLength handles this, but we're going behind its back // right now, so we must do this manually. Neither the custom property - // tree mutations nor the setGenericAttributes call in the above code will + // tree mutations nor the setPropertyAttributes call in the above code will // do this for us. // // ArraySetLength also implements the capacity <= length invariant for @@ -1780,34 +1780,22 @@ JSObject::nonNativeSetProperty(JSContext *cx, HandleObject obj, HandleObject rec } if (obj->is()) return Proxy::set(cx, obj, receiver, id, strict, vp); - return obj->getOps()->setGeneric(cx, obj, id, vp, strict); + return obj->getOps()->setProperty(cx, obj, id, vp, strict); } /* static */ bool JSObject::nonNativeSetElement(JSContext *cx, HandleObject obj, HandleObject receiver, uint32_t index, MutableHandleValue vp, bool strict) { - if (MOZ_UNLIKELY(obj->watched())) { - RootedId id(cx); - if (!IndexToId(cx, index, &id)) - return false; - - WatchpointMap *wpmap = cx->compartment()->watchpointMap; - if (wpmap && !wpmap->triggerWatchpoint(cx, obj, id, vp)) - return false; - } - if (obj->is()) { - RootedId id(cx); - return IndexToId(cx, index, &id) && - Proxy::set(cx, obj, receiver, id, strict, vp); - } - return obj->getOps()->setElement(cx, obj, index, vp, strict); + RootedId id(cx); + if (!IndexToId(cx, index, &id)) + return false; + return nonNativeSetProperty(cx, obj, receiver, id, vp, strict); } JS_FRIEND_API(bool) JS_CopyPropertyFrom(JSContext *cx, HandleId id, HandleObject target, - HandleObject obj, - PropertyCopyBehavior copyBehavior) + HandleObject obj, PropertyCopyBehavior copyBehavior) { // |obj| and |cx| are generally not same-compartment with |target| here. assertSameCompartment(cx, obj, id); @@ -2925,11 +2913,11 @@ bool js::LookupProperty(JSContext *cx, HandleObject obj, js::HandleId id, MutableHandleObject objp, MutableHandleShape propp) { - /* NB: The logic of lookupGeneric is implicitly reflected in + /* NB: The logic of lookupProperty is implicitly reflected in * BaselineIC.cpp's |EffectlesslyLookupProperty| logic. * If this changes, please remember to update the logic there as well. */ - if (LookupGenericOp op = obj->getOps()->lookupGeneric) + if (LookupPropertyOp op = obj->getOps()->lookupProperty) return op(cx, obj, id, objp, propp); return NativeLookupProperty(cx, obj.as(), id, objp, propp); } @@ -2964,7 +2952,7 @@ js::LookupNameNoGC(JSContext *cx, PropertyName *name, JSObject *scopeChain, MOZ_ASSERT(!*objp && !*pobjp && !*propp); for (JSObject *scope = scopeChain; scope; scope = scope->enclosingScope()) { - if (scope->getOps()->lookupGeneric) + if (scope->getOps()->lookupProperty) return false; if (!LookupPropertyInline(cx, &scope->as(), NameToId(name), pobjp, propp)) return false; @@ -3301,7 +3289,7 @@ js::DefineProperty(ExclusiveContext *cx, HandleObject obj, HandleId id, HandleVa MOZ_ASSERT(setter != JS_StrictPropertyStub); MOZ_ASSERT(!(attrs & JSPROP_PROPOP_ACCESSORS)); - DefineGenericOp op = obj->getOps()->defineGeneric; + DefinePropertyOp op = obj->getOps()->defineProperty; if (op) { if (!cx->shouldBeJSContext()) return false; @@ -3326,13 +3314,10 @@ js::DefineElement(ExclusiveContext *cx, HandleObject obj, uint32_t index, Handle MOZ_ASSERT(getter != JS_PropertyStub); MOZ_ASSERT(setter != JS_StrictPropertyStub); - DefineElementOp op = obj->getOps()->defineElement; - if (op) { - if (!cx->shouldBeJSContext()) - return false; - return op(cx->asJSContext(), obj, index, value, getter, setter, attrs); - } - return NativeDefineElement(cx, obj.as(), index, value, getter, setter, attrs); + RootedId id(cx); + if (!IndexToId(cx, index, &id)) + return false; + return DefineProperty(cx, obj, id, value, getter, setter, attrs); } @@ -4131,7 +4116,7 @@ JSObject::hasIdempotentProtoChain() const if (resolve && resolve != js::fun_resolve && resolve != js::str_resolve) return false; - if (obj->getOps()->lookupProperty || obj->getOps()->lookupGeneric || obj->getOps()->lookupElement) + if (obj->getOps()->lookupProperty) return false; obj = obj->getProto(); diff --git a/js/src/jsobjinlines.h b/js/src/jsobjinlines.h index beaca9565a04..ba8de8a14879 100644 --- a/js/src/jsobjinlines.h +++ b/js/src/jsobjinlines.h @@ -157,9 +157,6 @@ inline bool js::GetElement(JSContext *cx, HandleObject obj, HandleObject receiver, uint32_t index, MutableHandleValue vp) { - if (ElementIdOp op = obj->getOps()->getElement) - return op(cx, obj, receiver, index, vp); - RootedId id(cx); if (!IndexToId(cx, index, &id)) return false; @@ -169,7 +166,7 @@ js::GetElement(JSContext *cx, HandleObject obj, HandleObject receiver, uint32_t inline bool js::GetElementNoGC(JSContext *cx, JSObject *obj, JSObject *receiver, uint32_t index, Value *vp) { - if (obj->getOps()->getElement) + if (obj->getOps()->getProperty) return false; if (index > JSID_INT_MAX) @@ -181,7 +178,7 @@ inline bool js::DeleteProperty(JSContext *cx, HandleObject obj, HandleId id, bool *succeeded) { types::MarkTypePropertyNonData(cx, obj, id); - if (DeleteGenericOp op = obj->getOps()->deleteGeneric) + if (DeletePropertyOp op = obj->getOps()->deleteProperty) return op(cx, obj, id, succeeded); return NativeDeleteProperty(cx, obj.as(), id, succeeded); } @@ -202,7 +199,7 @@ inline bool js::SetPropertyAttributes(JSContext *cx, HandleObject obj, HandleId id, unsigned *attrsp) { types::MarkTypePropertyNonData(cx, obj, id); - GenericAttributesOp op = obj->getOps()->setGenericAttributes; + SetAttributesOp op = obj->getOps()->setAttributes; if (op) return op(cx, obj, id, attrsp); return NativeSetPropertyAttributes(cx, obj.as(), id, attrsp); diff --git a/js/src/proxy/Proxy.cpp b/js/src/proxy/Proxy.cpp index d7bba22c1dba..0093f513a23f 100644 --- a/js/src/proxy/Proxy.cpp +++ b/js/src/proxy/Proxy.cpp @@ -551,8 +551,8 @@ js::proxy_innerObject(JSObject *obj) } bool -js::proxy_LookupGeneric(JSContext *cx, HandleObject obj, HandleId id, - MutableHandleObject objp, MutableHandleShape propp) +js::proxy_LookupProperty(JSContext *cx, HandleObject obj, HandleId id, + MutableHandleObject objp, MutableHandleShape propp) { bool found; if (!Proxy::has(cx, obj, id, &found)) @@ -569,26 +569,8 @@ js::proxy_LookupGeneric(JSContext *cx, HandleObject obj, HandleId id, } bool -js::proxy_LookupProperty(JSContext *cx, HandleObject obj, HandlePropertyName name, - MutableHandleObject objp, MutableHandleShape propp) -{ - RootedId id(cx, NameToId(name)); - return proxy_LookupGeneric(cx, obj, id, objp, propp); -} - -bool -js::proxy_LookupElement(JSContext *cx, HandleObject obj, uint32_t index, - MutableHandleObject objp, MutableHandleShape propp) -{ - RootedId id(cx); - if (!IndexToId(cx, index, &id)) - return false; - return proxy_LookupGeneric(cx, obj, id, objp, propp); -} - -bool -js::proxy_DefineGeneric(JSContext *cx, HandleObject obj, HandleId id, HandleValue value, - PropertyOp getter, StrictPropertyOp setter, unsigned attrs) +js::proxy_DefineProperty(JSContext *cx, HandleObject obj, HandleId id, HandleValue value, + PropertyOp getter, StrictPropertyOp setter, unsigned attrs) { Rooted desc(cx); desc.object().set(obj); @@ -600,71 +582,17 @@ js::proxy_DefineGeneric(JSContext *cx, HandleObject obj, HandleId id, HandleValu } bool -js::proxy_DefineProperty(JSContext *cx, HandleObject obj, HandlePropertyName name, HandleValue value, - PropertyOp getter, StrictPropertyOp setter, unsigned attrs) -{ - Rooted id(cx, NameToId(name)); - return proxy_DefineGeneric(cx, obj, id, value, getter, setter, attrs); -} - -bool -js::proxy_DefineElement(JSContext *cx, HandleObject obj, uint32_t index, HandleValue value, - PropertyOp getter, StrictPropertyOp setter, unsigned attrs) -{ - RootedId id(cx); - if (!IndexToId(cx, index, &id)) - return false; - return proxy_DefineGeneric(cx, obj, id, value, getter, setter, attrs); -} - -bool -js::proxy_GetGeneric(JSContext *cx, HandleObject obj, HandleObject receiver, HandleId id, - MutableHandleValue vp) +js::proxy_GetProperty(JSContext *cx, HandleObject obj, HandleObject receiver, HandleId id, + MutableHandleValue vp) { return Proxy::get(cx, obj, receiver, id, vp); } bool -js::proxy_GetProperty(JSContext *cx, HandleObject obj, HandleObject receiver, HandlePropertyName name, - MutableHandleValue vp) -{ - Rooted id(cx, NameToId(name)); - return proxy_GetGeneric(cx, obj, receiver, id, vp); -} - -bool -js::proxy_GetElement(JSContext *cx, HandleObject obj, HandleObject receiver, uint32_t index, - MutableHandleValue vp) -{ - RootedId id(cx); - if (!IndexToId(cx, index, &id)) - return false; - return proxy_GetGeneric(cx, obj, receiver, id, vp); -} - -bool -js::proxy_SetGeneric(JSContext *cx, HandleObject obj, HandleId id, - MutableHandleValue vp, bool strict) -{ - return Proxy::set(cx, obj, obj, id, strict, vp); -} - -bool -js::proxy_SetProperty(JSContext *cx, HandleObject obj, HandlePropertyName name, +js::proxy_SetProperty(JSContext *cx, HandleObject obj, HandleId id, MutableHandleValue vp, bool strict) { - Rooted id(cx, NameToId(name)); - return proxy_SetGeneric(cx, obj, id, vp, strict); -} - -bool -js::proxy_SetElement(JSContext *cx, HandleObject obj, uint32_t index, - MutableHandleValue vp, bool strict) -{ - RootedId id(cx); - if (!IndexToId(cx, index, &id)) - return false; - return proxy_SetGeneric(cx, obj, id, vp, strict); + return Proxy::set(cx, obj, obj, id, strict, vp); } bool @@ -675,7 +603,7 @@ js::proxy_GetOwnPropertyDescriptor(JSContext *cx, HandleObject obj, HandleId id, } bool -js::proxy_SetGenericAttributes(JSContext *cx, HandleObject obj, HandleId id, unsigned *attrsp) +js::proxy_SetPropertyAttributes(JSContext *cx, HandleObject obj, HandleId id, unsigned *attrsp) { /* Lookup the current property descriptor so we have setter/getter/value. */ Rooted desc(cx); @@ -686,7 +614,7 @@ js::proxy_SetGenericAttributes(JSContext *cx, HandleObject obj, HandleId id, uns } bool -js::proxy_DeleteGeneric(JSContext *cx, HandleObject obj, HandleId id, bool *succeeded) +js::proxy_DeleteProperty(JSContext *cx, HandleObject obj, HandleId id, bool *succeeded) { bool deleted; if (!Proxy::delete_(cx, obj, id, &deleted)) diff --git a/js/src/vm/NativeObject.h b/js/src/vm/NativeObject.h index 562fd16e89f5..66bb7c1d0812 100644 --- a/js/src/vm/NativeObject.h +++ b/js/src/vm/NativeObject.h @@ -1387,8 +1387,7 @@ inline bool js::GetProperty(JSContext *cx, HandleObject obj, HandleObject receiver, HandleId id, MutableHandleValue vp) { - MOZ_ASSERT(!!obj->getOps()->getGeneric == !!obj->getOps()->getProperty); - if (GenericIdOp op = obj->getOps()->getGeneric) + if (GetPropertyOp op = obj->getOps()->getProperty) return op(cx, obj, receiver, id, vp); return NativeGetProperty(cx, obj.as(), receiver, id, vp); } @@ -1396,7 +1395,7 @@ js::GetProperty(JSContext *cx, HandleObject obj, HandleObject receiver, HandleId inline bool js::GetPropertyNoGC(JSContext *cx, JSObject *obj, JSObject *receiver, jsid id, Value *vp) { - if (obj->getOps()->getGeneric) + if (obj->getOps()->getProperty) return false; return NativeGetPropertyNoGC(cx, &obj->as(), receiver, id, vp); } @@ -1405,7 +1404,7 @@ inline bool js::SetProperty(JSContext *cx, HandleObject obj, HandleObject receiver, HandleId id, MutableHandleValue vp, bool strict) { - if (obj->getOps()->setGeneric) + if (obj->getOps()->setProperty) return JSObject::nonNativeSetProperty(cx, obj, receiver, id, vp, strict); return NativeSetProperty(cx, obj.as(), receiver, id, Qualified, vp, strict); } @@ -1414,7 +1413,7 @@ inline bool js::SetElement(JSContext *cx, HandleObject obj, HandleObject receiver, uint32_t index, MutableHandleValue vp, bool strict) { - if (obj->getOps()->setElement) + if (obj->getOps()->setProperty) return JSObject::nonNativeSetElement(cx, obj, receiver, index, vp, strict); return NativeSetElement(cx, obj.as(), receiver, index, vp, strict); } diff --git a/js/src/vm/ScopeObject.cpp b/js/src/vm/ScopeObject.cpp index 5da65b9e8296..d4ec087c9de1 100644 --- a/js/src/vm/ScopeObject.cpp +++ b/js/src/vm/ScopeObject.cpp @@ -461,105 +461,35 @@ DynamicWithObject::create(JSContext *cx, HandleObject object, HandleObject enclo } static bool -with_LookupGeneric(JSContext *cx, HandleObject obj, HandleId id, - MutableHandleObject objp, MutableHandleShape propp) +with_LookupProperty(JSContext *cx, HandleObject obj, HandleId id, + MutableHandleObject objp, MutableHandleShape propp) { RootedObject actual(cx, &obj->as().object()); return LookupProperty(cx, actual, id, objp, propp); } static bool -with_LookupProperty(JSContext *cx, HandleObject obj, HandlePropertyName name, - MutableHandleObject objp, MutableHandleShape propp) -{ - Rooted id(cx, NameToId(name)); - return with_LookupGeneric(cx, obj, id, objp, propp); -} - -static bool -with_LookupElement(JSContext *cx, HandleObject obj, uint32_t index, - MutableHandleObject objp, MutableHandleShape propp) -{ - RootedId id(cx); - if (!IndexToId(cx, index, &id)) - return false; - return with_LookupGeneric(cx, obj, id, objp, propp); -} - -static bool -with_DefineGeneric(JSContext *cx, HandleObject obj, HandleId id, HandleValue value, - JSPropertyOp getter, JSStrictPropertyOp setter, unsigned attrs) +with_DefineProperty(JSContext *cx, HandleObject obj, HandleId id, HandleValue value, + JSPropertyOp getter, JSStrictPropertyOp setter, unsigned attrs) { RootedObject actual(cx, &obj->as().object()); return DefineProperty(cx, actual, id, value, getter, setter, attrs); } static bool -with_DefineProperty(JSContext *cx, HandleObject obj, HandlePropertyName name, HandleValue value, - JSPropertyOp getter, JSStrictPropertyOp setter, unsigned attrs) -{ - Rooted id(cx, NameToId(name)); - return with_DefineGeneric(cx, obj, id, value, getter, setter, attrs); -} - -static bool -with_DefineElement(JSContext *cx, HandleObject obj, uint32_t index, HandleValue value, - JSPropertyOp getter, JSStrictPropertyOp setter, unsigned attrs) -{ - RootedId id(cx); - if (!IndexToId(cx, index, &id)) - return false; - return with_DefineGeneric(cx, obj, id, value, getter, setter, attrs); -} - -static bool -with_GetGeneric(JSContext *cx, HandleObject obj, HandleObject receiver, HandleId id, - MutableHandleValue vp) +with_GetProperty(JSContext *cx, HandleObject obj, HandleObject receiver, HandleId id, + MutableHandleValue vp) { RootedObject actual(cx, &obj->as().object()); return GetProperty(cx, actual, actual, id, vp); } static bool -with_GetProperty(JSContext *cx, HandleObject obj, HandleObject receiver, HandlePropertyName name, - MutableHandleValue vp) -{ - RootedId id(cx, NameToId(name)); - return with_GetGeneric(cx, obj, receiver, id, vp); -} - -static bool -with_GetElement(JSContext *cx, HandleObject obj, HandleObject receiver, uint32_t index, - MutableHandleValue vp) -{ - RootedId id(cx); - if (!IndexToId(cx, index, &id)) - return false; - return with_GetGeneric(cx, obj, receiver, id, vp); -} - -static bool -with_SetGeneric(JSContext *cx, HandleObject obj, HandleId id, - MutableHandleValue vp, bool strict) -{ - RootedObject actual(cx, &obj->as().object()); - return SetProperty(cx, actual, actual, id, vp, strict); -} - -static bool -with_SetProperty(JSContext *cx, HandleObject obj, HandlePropertyName name, +with_SetProperty(JSContext *cx, HandleObject obj, HandleId id, MutableHandleValue vp, bool strict) { RootedObject actual(cx, &obj->as().object()); - return SetProperty(cx, actual, actual, name, vp, strict); -} - -static bool -with_SetElement(JSContext *cx, HandleObject obj, uint32_t index, - MutableHandleValue vp, bool strict) -{ - RootedObject actual(cx, &obj->as().object()); - return SetElement(cx, actual, actual, index, vp, strict); + return SetProperty(cx, actual, actual, id, vp, strict); } static bool @@ -571,14 +501,14 @@ with_GetOwnPropertyDescriptor(JSContext *cx, HandleObject obj, HandleId id, } static bool -with_SetGenericAttributes(JSContext *cx, HandleObject obj, HandleId id, unsigned *attrsp) +with_SetPropertyAttributes(JSContext *cx, HandleObject obj, HandleId id, unsigned *attrsp) { RootedObject actual(cx, &obj->as().object()); return SetPropertyAttributes(cx, actual, id, attrsp); } static bool -with_DeleteGeneric(JSContext *cx, HandleObject obj, HandleId id, bool *succeeded) +with_DeleteProperty(JSContext *cx, HandleObject obj, HandleId id, bool *succeeded) { RootedObject actual(cx, &obj->as().object()); return DeleteProperty(cx, actual, id, succeeded); @@ -616,21 +546,13 @@ const Class DynamicWithObject::class_ = { JS_NULL_CLASS_SPEC, JS_NULL_CLASS_EXT, { - with_LookupGeneric, with_LookupProperty, - with_LookupElement, - with_DefineGeneric, with_DefineProperty, - with_DefineElement, - with_GetGeneric, with_GetProperty, - with_GetElement, - with_SetGeneric, with_SetProperty, - with_SetElement, with_GetOwnPropertyDescriptor, - with_SetGenericAttributes, - with_DeleteGeneric, + with_SetPropertyAttributes, + with_DeleteProperty, nullptr, nullptr, /* watch/unwatch */ nullptr, /* getElements */ nullptr, /* enumerate (native enumeration of target doesn't work) */ @@ -988,81 +910,27 @@ ReportUninitializedLexicalId(JSContext *cx, HandleId id) } static bool -uninitialized_LookupGeneric(JSContext *cx, HandleObject obj, HandleId id, - MutableHandleObject objp, MutableHandleShape propp) +uninitialized_LookupProperty(JSContext *cx, HandleObject obj, HandleId id, + MutableHandleObject objp, MutableHandleShape propp) { ReportUninitializedLexicalId(cx, id); return false; } static bool -uninitialized_LookupProperty(JSContext *cx, HandleObject obj, HandlePropertyName name, - MutableHandleObject objp, MutableHandleShape propp) -{ - Rooted id(cx, NameToId(name)); - return uninitialized_LookupGeneric(cx, obj, id, objp, propp); -} - -static bool -uninitialized_LookupElement(JSContext *cx, HandleObject obj, uint32_t index, - MutableHandleObject objp, MutableHandleShape propp) -{ - RootedId id(cx); - if (!IndexToId(cx, index, &id)) - return false; - return uninitialized_LookupGeneric(cx, obj, id, objp, propp); -} - -static bool -uninitialized_GetGeneric(JSContext *cx, HandleObject obj, HandleObject receiver, HandleId id, - MutableHandleValue vp) +uninitialized_GetProperty(JSContext *cx, HandleObject obj, HandleObject receiver, HandleId id, + MutableHandleValue vp) { ReportUninitializedLexicalId(cx, id); return false; } static bool -uninitialized_GetProperty(JSContext *cx, HandleObject obj, HandleObject receiver, - HandlePropertyName name, MutableHandleValue vp) -{ - RootedId id(cx, NameToId(name)); - return uninitialized_GetGeneric(cx, obj, receiver, id, vp); -} - -static bool -uninitialized_GetElement(JSContext *cx, HandleObject obj, HandleObject receiver, uint32_t index, - MutableHandleValue vp) -{ - RootedId id(cx); - if (!IndexToId(cx, index, &id)) - return false; - return uninitialized_GetGeneric(cx, obj, receiver, id, vp); -} - -static bool -uninitialized_SetGeneric(JSContext *cx, HandleObject obj, HandleId id, - MutableHandleValue vp, bool strict) -{ - ReportUninitializedLexicalId(cx, id); - return false; -} - -static bool -uninitialized_SetProperty(JSContext *cx, HandleObject obj, HandlePropertyName name, +uninitialized_SetProperty(JSContext *cx, HandleObject obj, HandleId id, MutableHandleValue vp, bool strict) { - RootedId id(cx, NameToId(name)); - return uninitialized_SetGeneric(cx, obj, id, vp, strict); -} - -static bool -uninitialized_SetElement(JSContext *cx, HandleObject obj, uint32_t index, - MutableHandleValue vp, bool strict) -{ - RootedId id(cx); - if (!IndexToId(cx, index, &id)) - return false; - return uninitialized_SetGeneric(cx, obj, id, vp, strict); + ReportUninitializedLexicalId(cx, id); + return false; } static bool @@ -1074,14 +942,14 @@ uninitialized_GetOwnPropertyDescriptor(JSContext *cx, HandleObject obj, HandleId } static bool -uninitialized_SetGenericAttributes(JSContext *cx, HandleObject obj, HandleId id, unsigned *attrsp) +uninitialized_SetPropertyAttributes(JSContext *cx, HandleObject obj, HandleId id, unsigned *attrsp) { ReportUninitializedLexicalId(cx, id); return false; } static bool -uninitialized_DeleteGeneric(JSContext *cx, HandleObject obj, HandleId id, bool *succeeded) +uninitialized_DeleteProperty(JSContext *cx, HandleObject obj, HandleId id, bool *succeeded) { ReportUninitializedLexicalId(cx, id); return false; @@ -1106,21 +974,13 @@ const Class UninitializedLexicalObject::class_ = { JS_NULL_CLASS_SPEC, JS_NULL_CLASS_EXT, { - uninitialized_LookupGeneric, uninitialized_LookupProperty, - uninitialized_LookupElement, - nullptr, /* defineGeneric */ nullptr, /* defineProperty */ - nullptr, /* defineElement */ - uninitialized_GetGeneric, uninitialized_GetProperty, - uninitialized_GetElement, - uninitialized_SetGeneric, uninitialized_SetProperty, - uninitialized_SetElement, uninitialized_GetOwnPropertyDescriptor, - uninitialized_SetGenericAttributes, - uninitialized_DeleteGeneric, + uninitialized_SetPropertyAttributes, + uninitialized_DeleteProperty, nullptr, nullptr, /* watch/unwatch */ nullptr, /* getElements */ nullptr, /* enumerate (native enumeration of target doesn't work) */ diff --git a/js/src/vm/UnboxedObject.cpp b/js/src/vm/UnboxedObject.cpp index c2d5517ba647..ba03c3ff56c4 100644 --- a/js/src/vm/UnboxedObject.cpp +++ b/js/src/vm/UnboxedObject.cpp @@ -241,9 +241,9 @@ UnboxedPlainObject::create(JSContext *cx, HandleObjectGroup group, NewObjectKind } /* static */ bool -UnboxedPlainObject::obj_lookupGeneric(JSContext *cx, HandleObject obj, - HandleId id, MutableHandleObject objp, - MutableHandleShape propp) +UnboxedPlainObject::obj_lookupProperty(JSContext *cx, HandleObject obj, + HandleId id, MutableHandleObject objp, + MutableHandleShape propp) { if (obj->as().layout().lookup(id)) { MarkNonNativePropertyFound(propp); @@ -262,29 +262,8 @@ UnboxedPlainObject::obj_lookupGeneric(JSContext *cx, HandleObject obj, } /* static */ bool -UnboxedPlainObject::obj_lookupProperty(JSContext *cx, HandleObject obj, - HandlePropertyName name, - MutableHandleObject objp, - MutableHandleShape propp) -{ - RootedId id(cx, NameToId(name)); - return obj_lookupGeneric(cx, obj, id, objp, propp); -} - -/* static */ bool -UnboxedPlainObject::obj_lookupElement(JSContext *cx, HandleObject obj, - uint32_t index, MutableHandleObject objp, - MutableHandleShape propp) -{ - RootedId id(cx); - if (!IndexToId(cx, index, &id)) - return false; - return obj_lookupGeneric(cx, obj, id, objp, propp); -} - -/* static */ bool -UnboxedPlainObject::obj_defineGeneric(JSContext *cx, HandleObject obj, HandleId id, HandleValue v, - PropertyOp getter, StrictPropertyOp setter, unsigned attrs) +UnboxedPlainObject::obj_defineProperty(JSContext *cx, HandleObject obj, HandleId id, HandleValue v, + PropertyOp getter, StrictPropertyOp setter, unsigned attrs) { if (!obj->as().convertToNative(cx)) return false; @@ -293,28 +272,8 @@ UnboxedPlainObject::obj_defineGeneric(JSContext *cx, HandleObject obj, HandleId } /* static */ bool -UnboxedPlainObject::obj_defineProperty(JSContext *cx, HandleObject obj, - HandlePropertyName name, HandleValue v, - PropertyOp getter, StrictPropertyOp setter, unsigned attrs) -{ - Rooted id(cx, NameToId(name)); - return obj_defineGeneric(cx, obj, id, v, getter, setter, attrs); -} - -/* static */ bool -UnboxedPlainObject::obj_defineElement(JSContext *cx, HandleObject obj, uint32_t index, HandleValue v, - PropertyOp getter, StrictPropertyOp setter, unsigned attrs) -{ - AutoRooterGetterSetter gsRoot(cx, attrs, &getter, &setter); - RootedId id(cx); - if (!IndexToId(cx, index, &id)) - return false; - return obj_defineGeneric(cx, obj, id, v, getter, setter, attrs); -} - -/* static */ bool -UnboxedPlainObject::obj_getGeneric(JSContext *cx, HandleObject obj, HandleObject receiver, - HandleId id, MutableHandleValue vp) +UnboxedPlainObject::obj_getProperty(JSContext *cx, HandleObject obj, HandleObject receiver, + HandleId id, MutableHandleValue vp) { const UnboxedLayout &layout = obj->as().layout(); @@ -333,26 +292,8 @@ UnboxedPlainObject::obj_getGeneric(JSContext *cx, HandleObject obj, HandleObject } /* static */ bool -UnboxedPlainObject::obj_getProperty(JSContext *cx, HandleObject obj, HandleObject receiver, - HandlePropertyName name, MutableHandleValue vp) -{ - RootedId id(cx, NameToId(name)); - return obj_getGeneric(cx, obj, receiver, id, vp); -} - -/* static */ bool -UnboxedPlainObject::obj_getElement(JSContext *cx, HandleObject obj, HandleObject receiver, - uint32_t index, MutableHandleValue vp) -{ - RootedId id(cx); - if (!IndexToId(cx, index, &id)) - return false; - return obj_getGeneric(cx, obj, receiver, id, vp); -} - -/* static */ bool -UnboxedPlainObject::obj_setGeneric(JSContext *cx, HandleObject obj, HandleId id, - MutableHandleValue vp, bool strict) +UnboxedPlainObject::obj_setProperty(JSContext *cx, HandleObject obj, HandleId id, + MutableHandleValue vp, bool strict) { const UnboxedLayout &layout = obj->as().layout(); @@ -375,24 +316,6 @@ UnboxedPlainObject::obj_setGeneric(JSContext *cx, HandleObject obj, HandleId id, return SetProperty(cx, proto, obj, id, vp, strict); } -/* static */ bool -UnboxedPlainObject::obj_setProperty(JSContext *cx, HandleObject obj, HandlePropertyName name, - MutableHandleValue vp, bool strict) -{ - RootedId id(cx, NameToId(name)); - return obj_setGeneric(cx, obj, id, vp, strict); -} - -/* static */ bool -UnboxedPlainObject::obj_setElement(JSContext *cx, HandleObject obj, uint32_t index, - MutableHandleValue vp, bool strict) -{ - RootedId id(cx); - if (!IndexToId(cx, index, &id)) - return false; - return obj_setGeneric(cx, obj, id, vp, strict); -} - /* static */ bool UnboxedPlainObject::obj_getOwnPropertyDescriptor(JSContext *cx, HandleObject obj, HandleId id, MutableHandle desc) @@ -411,8 +334,8 @@ UnboxedPlainObject::obj_getOwnPropertyDescriptor(JSContext *cx, HandleObject obj } /* static */ bool -UnboxedPlainObject::obj_setGenericAttributes(JSContext *cx, HandleObject obj, - HandleId id, unsigned *attrsp) +UnboxedPlainObject::obj_setPropertyAttributes(JSContext *cx, HandleObject obj, + HandleId id, unsigned *attrsp) { if (!obj->as().convertToNative(cx)) return false; @@ -420,7 +343,8 @@ UnboxedPlainObject::obj_setGenericAttributes(JSContext *cx, HandleObject obj, } /* static */ bool -UnboxedPlainObject::obj_deleteGeneric(JSContext *cx, HandleObject obj, HandleId id, bool *succeeded) +UnboxedPlainObject::obj_deleteProperty(JSContext *cx, HandleObject obj, HandleId id, + bool *succeeded) { if (!obj->as().convertToNative(cx)) return false; @@ -464,21 +388,13 @@ const Class UnboxedPlainObject::class_ = { JS_NULL_CLASS_SPEC, JS_NULL_CLASS_EXT, { - UnboxedPlainObject::obj_lookupGeneric, UnboxedPlainObject::obj_lookupProperty, - UnboxedPlainObject::obj_lookupElement, - UnboxedPlainObject::obj_defineGeneric, UnboxedPlainObject::obj_defineProperty, - UnboxedPlainObject::obj_defineElement, - UnboxedPlainObject::obj_getGeneric, UnboxedPlainObject::obj_getProperty, - UnboxedPlainObject::obj_getElement, - UnboxedPlainObject::obj_setGeneric, UnboxedPlainObject::obj_setProperty, - UnboxedPlainObject::obj_setElement, UnboxedPlainObject::obj_getOwnPropertyDescriptor, - UnboxedPlainObject::obj_setGenericAttributes, - UnboxedPlainObject::obj_deleteGeneric, + UnboxedPlainObject::obj_setPropertyAttributes, + UnboxedPlainObject::obj_deleteProperty, UnboxedPlainObject::obj_watch, nullptr, /* No unwatch needed, as watch() converts the object to native */ nullptr, /* getElements */ diff --git a/js/src/vm/UnboxedObject.h b/js/src/vm/UnboxedObject.h index bc4aaff31345..32f833728030 100644 --- a/js/src/vm/UnboxedObject.h +++ b/js/src/vm/UnboxedObject.h @@ -131,52 +131,26 @@ class UnboxedPlainObject : public JSObject public: static const Class class_; - static bool obj_lookupGeneric(JSContext *cx, HandleObject obj, - HandleId id, MutableHandleObject objp, - MutableHandleShape propp); - static bool obj_lookupProperty(JSContext *cx, HandleObject obj, - HandlePropertyName name, - MutableHandleObject objp, + HandleId id, MutableHandleObject objp, MutableHandleShape propp); - static bool obj_lookupElement(JSContext *cx, HandleObject obj, - uint32_t index, MutableHandleObject objp, - MutableHandleShape propp); - - static bool obj_defineGeneric(JSContext *cx, HandleObject obj, HandleId id, HandleValue v, - PropertyOp getter, StrictPropertyOp setter, unsigned attrs); - - static bool obj_defineProperty(JSContext *cx, HandleObject obj, - HandlePropertyName name, HandleValue v, + static bool obj_defineProperty(JSContext *cx, HandleObject obj, HandleId id, HandleValue v, PropertyOp getter, StrictPropertyOp setter, unsigned attrs); - static bool obj_defineElement(JSContext *cx, HandleObject obj, uint32_t index, HandleValue v, - PropertyOp getter, StrictPropertyOp setter, unsigned attrs); - - static bool obj_getGeneric(JSContext *cx, HandleObject obj, HandleObject receiver, - HandleId id, MutableHandleValue vp); - static bool obj_getProperty(JSContext *cx, HandleObject obj, HandleObject receiver, - HandlePropertyName name, MutableHandleValue vp); + HandleId id, MutableHandleValue vp); - static bool obj_getElement(JSContext *cx, HandleObject obj, HandleObject receiver, - uint32_t index, MutableHandleValue vp); - - static bool obj_setGeneric(JSContext *cx, HandleObject obj, HandleId id, - MutableHandleValue vp, bool strict); - static bool obj_setProperty(JSContext *cx, HandleObject obj, HandlePropertyName name, + static bool obj_setProperty(JSContext *cx, HandleObject obj, HandleId id, MutableHandleValue vp, bool strict); - static bool obj_setElement(JSContext *cx, HandleObject obj, uint32_t index, - MutableHandleValue vp, bool strict); static bool obj_getOwnPropertyDescriptor(JSContext *cx, HandleObject obj, HandleId id, MutableHandle desc); - static bool obj_setGenericAttributes(JSContext *cx, HandleObject obj, - HandleId id, unsigned *attrsp); + static bool obj_setPropertyAttributes(JSContext *cx, HandleObject obj, + HandleId id, unsigned *attrsp); - static bool obj_deleteGeneric(JSContext *cx, HandleObject obj, HandleId id, bool *succeeded); + static bool obj_deleteProperty(JSContext *cx, HandleObject obj, HandleId id, bool *succeeded); static bool obj_enumerate(JSContext *cx, HandleObject obj, AutoIdVector &properties); static bool obj_watch(JSContext *cx, HandleObject obj, HandleId id, HandleObject callable); diff --git a/js/xpconnect/src/XPCWrappedNativeJSOps.cpp b/js/xpconnect/src/XPCWrappedNativeJSOps.cpp index 80b64e07b1db..979aec86e685 100644 --- a/js/xpconnect/src/XPCWrappedNativeJSOps.cpp +++ b/js/xpconnect/src/XPCWrappedNativeJSOps.cpp @@ -681,21 +681,13 @@ const XPCWrappedNativeJSClass XPC_WN_NoHelper_JSClass = { // ObjectOps { - nullptr, // lookupGeneric nullptr, // lookupProperty - nullptr, // lookupElement - nullptr, // defineGeneric nullptr, // defineProperty - nullptr, // defineElement - nullptr, // getGeneric nullptr, // getProperty - nullptr, // getElement - nullptr, // setGeneric nullptr, // setProperty - nullptr, // setElement nullptr, // getOwnPropertyDescriptor - nullptr, // setGenericAttributes - nullptr, // deleteGeneric + nullptr, // setPropertyAttributes + nullptr, // deleteProperty nullptr, nullptr, // watch/unwatch nullptr, // getElements nullptr, // enumerate diff --git a/js/xpconnect/src/xpcprivate.h b/js/xpconnect/src/xpcprivate.h index 441b73cc952d..f4276482df97 100644 --- a/js/xpconnect/src/xpcprivate.h +++ b/js/xpconnect/src/xpcprivate.h @@ -973,21 +973,13 @@ XPC_WN_JSOp_ThisObject(JSContext *cx, JS::HandleObject obj); // Macros to initialize Object or Function like XPC_WN classes #define XPC_WN_WithCall_ObjectOps \ { \ - nullptr, /* lookupGeneric */ \ nullptr, /* lookupProperty */ \ - nullptr, /* lookupElement */ \ - nullptr, /* defineGeneric */ \ nullptr, /* defineProperty */ \ - nullptr, /* defineElement */ \ - nullptr, /* getGeneric */ \ nullptr, /* getProperty */ \ - nullptr, /* getElement */ \ - nullptr, /* setGeneric */ \ nullptr, /* setProperty */ \ - nullptr, /* setElement */ \ nullptr, /* getOwnPropertyDescriptor */ \ - nullptr, /* setGenericAttributes */ \ - nullptr, /* deleteGeneric */ \ + nullptr, /* setPropertyAttributes */ \ + nullptr, /* deleteProperty */ \ nullptr, nullptr, /* watch/unwatch */ \ nullptr, /* getElements */ \ nullptr, /* enumerate */ \ @@ -996,21 +988,13 @@ XPC_WN_JSOp_ThisObject(JSContext *cx, JS::HandleObject obj); #define XPC_WN_NoCall_ObjectOps \ { \ - nullptr, /* lookupGeneric */ \ nullptr, /* lookupProperty */ \ - nullptr, /* lookupElement */ \ - nullptr, /* defineGeneric */ \ nullptr, /* defineProperty */ \ - nullptr, /* defineElement */ \ - nullptr, /* getGeneric */ \ nullptr, /* getProperty */ \ - nullptr, /* getElement */ \ - nullptr, /* setGeneric */ \ nullptr, /* setProperty */ \ - nullptr, /* setElement */ \ nullptr, /* getOwnPropertyDescriptor */ \ - nullptr, /* setGenericAttributes */ \ - nullptr, /* deleteGeneric */ \ + nullptr, /* setPropertyAttributes */ \ + nullptr, /* deleteProperty */ \ nullptr, nullptr, /* watch/unwatch */ \ nullptr, /* getElements */ \ nullptr, /* enumerate */ \