From 7a6aff2c7e5dd20ec78db40029680c4f84098dff Mon Sep 17 00:00:00 2001 From: Tom Schuster Date: Tue, 24 Oct 2017 20:48:14 +0200 Subject: [PATCH] Bug 638054 - Remove watch class-hook and proxy trap r=jorendorff,bz --- dom/base/nsGlobalWindow.cpp | 19 ------------------- dom/bindings/BindingUtils.cpp | 2 -- dom/bindings/Codegen.py | 6 +++--- dom/bindings/DOMJSProxyHandler.cpp | 13 ------------- dom/bindings/DOMJSProxyHandler.h | 5 ----- js/public/Class.h | 14 ++------------ js/public/Proxy.h | 6 ------ js/src/jsobj.cpp | 6 ------ js/src/jsobj.h | 2 -- js/src/proxy/BaseProxyHandler.cpp | 14 -------------- js/src/proxy/Proxy.cpp | 17 ----------------- js/src/proxy/Proxy.h | 3 --- js/src/vm/EnvironmentObject.cpp | 3 --- js/src/vm/UnboxedObject.cpp | 10 ---------- js/src/vm/UnboxedObject.h | 1 - 15 files changed, 5 insertions(+), 116 deletions(-) diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp index f935c58201cb..ce0617d36f3e 100644 --- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -1125,11 +1125,6 @@ public: return false; } - bool watch(JSContext *cx, JS::Handle proxy, - JS::Handle id, JS::Handle callable) const override; - bool unwatch(JSContext *cx, JS::Handle proxy, - JS::Handle id) const override; - static const nsOuterWindowProxy singleton; protected: @@ -1478,20 +1473,6 @@ nsOuterWindowProxy::AppendIndexedPropertyNames(JSContext *cx, JSObject *proxy, return true; } -bool -nsOuterWindowProxy::watch(JSContext *cx, JS::Handle proxy, - JS::Handle id, JS::Handle callable) const -{ - return js::WatchGuts(cx, proxy, id, callable); -} - -bool -nsOuterWindowProxy::unwatch(JSContext *cx, JS::Handle proxy, - JS::Handle id) const -{ - return js::UnwatchGuts(cx, proxy, id); -} - size_t nsOuterWindowProxy::objectMoved(JSObject *obj, JSObject *old) const { diff --git a/dom/bindings/BindingUtils.cpp b/dom/bindings/BindingUtils.cpp index 91ed4c64d860..41e9a5d9021e 100644 --- a/dom/bindings/BindingUtils.cpp +++ b/dom/bindings/BindingUtils.cpp @@ -2067,8 +2067,6 @@ const js::ObjectOps sInterfaceObjectClassObjectOps = { nullptr, /* setProperty */ nullptr, /* getOwnPropertyDescriptor */ nullptr, /* deleteProperty */ - nullptr, /* watch */ - nullptr, /* unwatch */ nullptr, /* getElements */ InterfaceObjectToString, /* funToString */ }; diff --git a/dom/bindings/Codegen.py b/dom/bindings/Codegen.py index cd8fa2d596e1..11948e54dc47 100644 --- a/dom/bindings/Codegen.py +++ b/dom/bindings/Codegen.py @@ -13556,9 +13556,9 @@ class CGDictionary(CGThing): # continues to match the list in test_Object.prototype_props.html if (member.identifier.name in ["constructor", "toSource", "toString", "toLocaleString", "valueOf", - "watch", "unwatch", "hasOwnProperty", "isPrototypeOf", - "propertyIsEnumerable", "__defineGetter__", "__defineSetter__", - "__lookupGetter__", "__lookupSetter__", "__proto__"]): + "hasOwnProperty", "isPrototypeOf", "propertyIsEnumerable", + "__defineGetter__", "__defineSetter__", "__lookupGetter__", + "__lookupSetter__", "__proto__"]): raise TypeError("'%s' member of %s dictionary shadows " "a property of Object.prototype, and Xrays to " "Object can't handle that.\n" diff --git a/dom/bindings/DOMJSProxyHandler.cpp b/dom/bindings/DOMJSProxyHandler.cpp index ef16fa875b1f..7968fbda905a 100644 --- a/dom/bindings/DOMJSProxyHandler.cpp +++ b/dom/bindings/DOMJSProxyHandler.cpp @@ -233,19 +233,6 @@ DOMProxyHandler::delete_(JSContext* cx, JS::Handle proxy, return result.succeed(); } -bool -BaseDOMProxyHandler::watch(JSContext* cx, JS::Handle proxy, JS::Handle id, - JS::Handle callable) const -{ - return js::WatchGuts(cx, proxy, id, callable); -} - -bool -BaseDOMProxyHandler::unwatch(JSContext* cx, JS::Handle proxy, JS::Handle id) const -{ - return js::UnwatchGuts(cx, proxy, id); -} - bool BaseDOMProxyHandler::ownPropertyKeys(JSContext* cx, JS::Handle proxy, diff --git a/dom/bindings/DOMJSProxyHandler.h b/dom/bindings/DOMJSProxyHandler.h index 85cb84148707..0f012dd959ac 100644 --- a/dom/bindings/DOMJSProxyHandler.h +++ b/dom/bindings/DOMJSProxyHandler.h @@ -66,11 +66,6 @@ public: virtual bool getOwnEnumerablePropertyKeys(JSContext* cx, JS::Handle proxy, JS::AutoIdVector &props) const override; - bool watch(JSContext* cx, JS::Handle proxy, JS::Handle id, - JS::Handle callable) const override; - bool unwatch(JSContext* cx, JS::Handle proxy, - JS::Handle id) const override; - protected: // Hook for subclasses to implement shared ownPropertyKeys()/keys() // functionality. The "flags" argument is either JSITER_OWNONLY (for keys()) diff --git a/js/public/Class.h b/js/public/Class.h index e8f3908657f3..9ca4f391570c 100644 --- a/js/public/Class.h +++ b/js/public/Class.h @@ -537,12 +537,6 @@ typedef bool (* DeletePropertyOp)(JSContext* cx, JS::HandleObject obj, JS::HandleId id, JS::ObjectOpResult& result); -typedef bool -(* WatchOp)(JSContext* cx, JS::HandleObject obj, JS::HandleId id, JS::HandleObject callable); - -typedef bool -(* UnwatchOp)(JSContext* cx, JS::HandleObject obj, JS::HandleId id); - class JS_FRIEND_API(ElementAdder) { public: @@ -741,8 +735,6 @@ struct JS_STATIC_CLASS ObjectOps SetPropertyOp setProperty; GetOwnPropertyOp getOwnPropertyDescriptor; DeletePropertyOp deleteProperty; - WatchOp watch; - UnwatchOp unwatch; GetElementsOp getElements; JSFunToStringOp funToString; }; @@ -896,8 +888,8 @@ struct JS_STATIC_CLASS Class * Objects of this class aren't native objects. They don't have Shapes that * describe their properties and layout. Classes using this flag must * provide their own property behavior, either by being proxy classes (do - * this) or by overriding all the ObjectOps except getElements, watch and - * unwatch (don't do this). + * this) or by overriding all the ObjectOps except getElements + * (don't do this). */ static const uint32_t NON_NATIVE = JSCLASS_INTERNAL_FLAG2; @@ -974,8 +966,6 @@ struct JS_STATIC_CLASS Class const { return oOps ? oOps->getOwnPropertyDescriptor : nullptr; } DeletePropertyOp getOpsDeleteProperty() const { return oOps ? oOps->deleteProperty : nullptr; } - WatchOp getOpsWatch() const { return oOps ? oOps->watch : nullptr; } - UnwatchOp getOpsUnwatch() const { return oOps ? oOps->unwatch : nullptr; } GetElementsOp getOpsGetElements() const { return oOps ? oOps->getElements : nullptr; } JSFunToStringOp getOpsFunToString() const { return oOps ? oOps->funToString : nullptr; } }; diff --git a/js/public/Proxy.h b/js/public/Proxy.h index 125c11feb7d9..78311f077539 100644 --- a/js/public/Proxy.h +++ b/js/public/Proxy.h @@ -344,12 +344,6 @@ class JS_FRIEND_API(BaseProxyHandler) virtual bool isCallable(JSObject* obj) const; virtual bool isConstructor(JSObject* obj) const; - // These two hooks must be overridden, or not overridden, in tandem -- no - // overriding just one! - virtual bool watch(JSContext* cx, JS::HandleObject proxy, JS::HandleId id, - JS::HandleObject callable) const; - virtual bool unwatch(JSContext* cx, JS::HandleObject proxy, JS::HandleId id) const; - virtual bool getElements(JSContext* cx, HandleObject proxy, uint32_t begin, uint32_t end, ElementAdder* adder) const; diff --git a/js/src/jsobj.cpp b/js/src/jsobj.cpp index 0f060b7ba5df..a2fa74293bb8 100644 --- a/js/src/jsobj.cpp +++ b/js/src/jsobj.cpp @@ -3037,9 +3037,6 @@ js::UnwatchGuts(JSContext* cx, JS::HandleObject origObj, JS::HandleId id) bool js::WatchProperty(JSContext* cx, HandleObject obj, HandleId id, HandleObject callable) { - if (WatchOp op = obj->getOpsWatch()) - return op(cx, obj, id, callable); - if (!obj->isNative() || obj->is()) { JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_CANT_WATCH, obj->getClass()->name); @@ -3052,9 +3049,6 @@ js::WatchProperty(JSContext* cx, HandleObject obj, HandleId id, HandleObject cal bool js::UnwatchProperty(JSContext* cx, HandleObject obj, HandleId id) { - if (UnwatchOp op = obj->getOpsUnwatch()) - return op(cx, obj, id); - return UnwatchGuts(cx, obj, id); } diff --git a/js/src/jsobj.h b/js/src/jsobj.h index 2151fae04a2f..731c366084b6 100644 --- a/js/src/jsobj.h +++ b/js/src/jsobj.h @@ -118,8 +118,6 @@ class JSObject : public js::gc::Cell js::GetOwnPropertyOp getOpsGetOwnPropertyDescriptor() const { return getClass()->getOpsGetOwnPropertyDescriptor(); } js::DeletePropertyOp getOpsDeleteProperty() const { return getClass()->getOpsDeleteProperty(); } - js::WatchOp getOpsWatch() const { return getClass()->getOpsWatch(); } - js::UnwatchOp getOpsUnwatch() const { return getClass()->getOpsUnwatch(); } js::GetElementsOp getOpsGetElements() const { return getClass()->getOpsGetElements(); } JSFunToStringOp getOpsFunToString() const { return getClass()->getOpsFunToString(); } diff --git a/js/src/proxy/BaseProxyHandler.cpp b/js/src/proxy/BaseProxyHandler.cpp index 25d649f93ca2..ca3c0ef6da27 100644 --- a/js/src/proxy/BaseProxyHandler.cpp +++ b/js/src/proxy/BaseProxyHandler.cpp @@ -408,20 +408,6 @@ BaseProxyHandler::setImmutablePrototype(JSContext* cx, HandleObject proxy, bool* return true; } -bool -BaseProxyHandler::watch(JSContext* cx, HandleObject proxy, HandleId id, HandleObject callable) const -{ - JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_CANT_WATCH, - proxy->getClass()->name); - return false; -} - -bool -BaseProxyHandler::unwatch(JSContext* cx, HandleObject proxy, HandleId id) const -{ - return true; -} - bool BaseProxyHandler::getElements(JSContext* cx, HandleObject proxy, uint32_t begin, uint32_t end, ElementAdder* adder) const diff --git a/js/src/proxy/Proxy.cpp b/js/src/proxy/Proxy.cpp index 6def6c5a936b..01e377d3686d 100644 --- a/js/src/proxy/Proxy.cpp +++ b/js/src/proxy/Proxy.cpp @@ -624,22 +624,6 @@ Proxy::boxedValue_unbox(JSContext* cx, HandleObject proxy, MutableHandleValue vp JSObject * const TaggedProto::LazyProto = reinterpret_cast(0x1); -/* static */ bool -Proxy::watch(JSContext* cx, JS::HandleObject proxy, JS::HandleId id, JS::HandleObject callable) -{ - if (!CheckRecursionLimit(cx)) - return false; - return proxy->as().handler()->watch(cx, proxy, id, callable); -} - -/* static */ bool -Proxy::unwatch(JSContext* cx, JS::HandleObject proxy, JS::HandleId id) -{ - if (!CheckRecursionLimit(cx)) - return false; - return proxy->as().handler()->unwatch(cx, proxy, id); -} - /* static */ bool Proxy::getElements(JSContext* cx, HandleObject proxy, uint32_t begin, uint32_t end, ElementAdder* adder) @@ -823,7 +807,6 @@ const ObjectOps js::ProxyObjectOps = { Proxy::set, Proxy::getOwnPropertyDescriptor, proxy_DeleteProperty, - Proxy::watch, Proxy::unwatch, Proxy::getElements, Proxy::fun_toString }; diff --git a/js/src/proxy/Proxy.h b/js/src/proxy/Proxy.h index afc64b01a722..027098cf4fb1 100644 --- a/js/src/proxy/Proxy.h +++ b/js/src/proxy/Proxy.h @@ -67,9 +67,6 @@ class Proxy static RegExpShared* regexp_toShared(JSContext* cx, HandleObject proxy); static bool boxedValue_unbox(JSContext* cx, HandleObject proxy, MutableHandleValue vp); - static bool watch(JSContext* cx, HandleObject proxy, HandleId id, HandleObject callable); - static bool unwatch(JSContext* cx, HandleObject proxy, HandleId id); - static bool getElements(JSContext* cx, HandleObject obj, uint32_t begin, uint32_t end, ElementAdder* adder); diff --git a/js/src/vm/EnvironmentObject.cpp b/js/src/vm/EnvironmentObject.cpp index 922650b00724..33fd4061913a 100644 --- a/js/src/vm/EnvironmentObject.cpp +++ b/js/src/vm/EnvironmentObject.cpp @@ -405,7 +405,6 @@ const ObjectOps ModuleEnvironmentObject::objectOps_ = { ModuleEnvironmentObject::setProperty, ModuleEnvironmentObject::getOwnPropertyDescriptor, ModuleEnvironmentObject::deleteProperty, - nullptr, nullptr, /* watch/unwatch */ nullptr, /* getElements */ nullptr }; @@ -857,7 +856,6 @@ static const ObjectOps WithEnvironmentObjectOps = { with_SetProperty, with_GetOwnPropertyDescriptor, with_DeleteProperty, - nullptr, nullptr, /* watch/unwatch */ nullptr, /* getElements */ nullptr, }; @@ -1224,7 +1222,6 @@ static const ObjectOps RuntimeLexicalErrorObjectObjectOps = { lexicalError_SetProperty, lexicalError_GetOwnPropertyDescriptor, lexicalError_DeleteProperty, - nullptr, nullptr, /* watch/unwatch */ nullptr, /* getElements */ nullptr, /* this */ }; diff --git a/js/src/vm/UnboxedObject.cpp b/js/src/vm/UnboxedObject.cpp index e54d9ba949b4..d8422158301b 100644 --- a/js/src/vm/UnboxedObject.cpp +++ b/js/src/vm/UnboxedObject.cpp @@ -895,14 +895,6 @@ UnboxedPlainObject::obj_deleteProperty(JSContext* cx, HandleObject obj, HandleId return DeleteProperty(cx, obj, id, result); } -/* static */ bool -UnboxedPlainObject::obj_watch(JSContext* cx, HandleObject obj, HandleId id, HandleObject callable) -{ - if (!convertToNative(cx, obj)) - return false; - return WatchProperty(cx, obj, id, callable); -} - /* static */ bool UnboxedPlainObject::newEnumerate(JSContext* cx, HandleObject obj, AutoIdVector& properties, bool enumerableOnly) @@ -946,8 +938,6 @@ static const ObjectOps UnboxedPlainObjectObjectOps = { UnboxedPlainObject::obj_setProperty, UnboxedPlainObject::obj_getOwnPropertyDescriptor, UnboxedPlainObject::obj_deleteProperty, - UnboxedPlainObject::obj_watch, - nullptr, /* No unwatch needed, as watch() converts the object to native */ nullptr, /* getElements */ nullptr /* funToString */ }; diff --git a/js/src/vm/UnboxedObject.h b/js/src/vm/UnboxedObject.h index 089a45d4afc0..b64a69efdf83 100644 --- a/js/src/vm/UnboxedObject.h +++ b/js/src/vm/UnboxedObject.h @@ -260,7 +260,6 @@ class UnboxedPlainObject : public UnboxedObject static bool newEnumerate(JSContext* cx, HandleObject obj, AutoIdVector& properties, bool enumerableOnly); - static bool obj_watch(JSContext* cx, HandleObject obj, HandleId id, HandleObject callable); inline const UnboxedLayout& layout() const;