Bug 1323190 - Remove Proxy friendapi. r=arai
authorTom Schuster <evilpies@gmail.com>
Wed, 04 Jan 2017 12:07:58 +0100
changeset 375183 67504d1d45931ed177c0d9e8001018f7903cea59
parent 375182 d31df518cb6ec920cf9ab7accb67682298f8a9f8
child 375184 a6ac89909ecce9608f39eb1072413849090a9c97
push id1419
push userjlund@mozilla.com
push dateMon, 10 Apr 2017 20:44:07 +0000
treeherdermozilla-release@5e6801b73ef6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersarai
bugs1323190
milestone53.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1323190 - Remove Proxy friendapi. r=arai
js/src/jsfriendapi.h
js/src/proxy/Proxy.cpp
js/src/proxy/Proxy.h
js/src/vm/ProxyObject.h
--- a/js/src/jsfriendapi.h
+++ b/js/src/jsfriendapi.h
@@ -359,71 +359,18 @@ extern JS_FRIEND_DATA(const js::ObjectOp
         JS_NULL_CLASS_SPEC,                                                             \
         extPtr,                                                                         \
         &js::ProxyObjectOps                                                             \
     }
 
 #define PROXY_CLASS_DEF(name, flags) \
   PROXY_CLASS_WITH_EXT(name, flags, &js::ProxyClassExtension)
 
-/*
- * Proxy stubs, similar to JS_*Stub, for embedder proxy class definitions.
- *
- * NB: Should not be called directly.
- */
-
-extern JS_FRIEND_API(bool)
-proxy_LookupProperty(JSContext* cx, JS::HandleObject obj, JS::HandleId id, JS::MutableHandleObject objp,
-                    JS::MutableHandle<Shape*> propp);
-extern JS_FRIEND_API(bool)
-proxy_DefineProperty(JSContext* cx, JS::HandleObject obj, JS::HandleId id,
-                     JS::Handle<JS::PropertyDescriptor> desc,
-                     JS::ObjectOpResult& result);
-extern JS_FRIEND_API(bool)
-proxy_HasProperty(JSContext* cx, JS::HandleObject obj, JS::HandleId id, bool* foundp);
-extern JS_FRIEND_API(bool)
-proxy_GetProperty(JSContext* cx, JS::HandleObject obj, JS::HandleValue receiver, JS::HandleId id,
-                  JS::MutableHandleValue vp);
-extern JS_FRIEND_API(bool)
-proxy_SetProperty(JSContext* cx, JS::HandleObject obj, JS::HandleId id, JS::HandleValue bp,
-                  JS::HandleValue receiver, JS::ObjectOpResult& result);
-extern JS_FRIEND_API(bool)
-proxy_GetOwnPropertyDescriptor(JSContext* cx, JS::HandleObject obj, JS::HandleId id,
-                               JS::MutableHandle<JS::PropertyDescriptor> desc);
-extern JS_FRIEND_API(bool)
-proxy_DeleteProperty(JSContext* cx, JS::HandleObject obj, JS::HandleId id,
-                     JS::ObjectOpResult& result);
-
-extern JS_FRIEND_API(void)
-proxy_Trace(JSTracer* trc, JSObject* obj);
 extern JS_FRIEND_API(JSObject*)
 proxy_WeakmapKeyDelegate(JSObject* obj);
-extern JS_FRIEND_API(bool)
-proxy_Convert(JSContext* cx, JS::HandleObject proxy, JSType hint, JS::MutableHandleValue vp);
-extern JS_FRIEND_API(void)
-proxy_Finalize(FreeOp* fop, JSObject* obj);
-extern JS_FRIEND_API(void)
-proxy_ObjectMoved(JSObject* obj, const JSObject* old);
-extern JS_FRIEND_API(bool)
-proxy_HasInstance(JSContext* cx, JS::HandleObject proxy, JS::MutableHandleValue v, bool* bp);
-extern JS_FRIEND_API(bool)
-proxy_Call(JSContext* cx, unsigned argc, JS::Value* vp);
-extern JS_FRIEND_API(bool)
-proxy_Construct(JSContext* cx, unsigned argc, JS::Value* vp);
-extern JS_FRIEND_API(JSObject*)
-proxy_innerObject(JSObject* obj);
-extern JS_FRIEND_API(bool)
-proxy_Watch(JSContext* cx, JS::HandleObject obj, JS::HandleId id, JS::HandleObject callable);
-extern JS_FRIEND_API(bool)
-proxy_Unwatch(JSContext* cx, JS::HandleObject obj, JS::HandleId id);
-extern JS_FRIEND_API(bool)
-proxy_GetElements(JSContext* cx, JS::HandleObject proxy, uint32_t begin, uint32_t end,
-                  ElementAdder* adder);
-extern JS_FRIEND_API(JSString*)
-proxy_FunToString(JSContext* cx, JS::HandleObject proxy, unsigned indent);
 
 /**
  * A class of objects that return source code on demand.
  *
  * When code is compiled with setSourceIsLazy(true), SpiderMonkey doesn't
  * retain the source code (and doesn't do lazy bytecode generation). If we ever
  * need the source code, say, in response to a call to Function.prototype.
  * toSource or Debugger.Source.prototype.text, then we call the 'load' member
--- a/js/src/proxy/Proxy.cpp
+++ b/js/src/proxy/Proxy.cpp
@@ -538,84 +538,42 @@ Proxy::getElements(JSContext* cx, Handle
 
 /* static */ void
 Proxy::trace(JSTracer* trc, JSObject* proxy)
 {
     const BaseProxyHandler* handler = proxy->as<ProxyObject>().handler();
     handler->trace(trc, proxy);
 }
 
-bool
-js::proxy_LookupProperty(JSContext* cx, HandleObject obj, HandleId id,
-                         MutableHandleObject objp, MutableHandleShape propp)
+static bool
+proxy_LookupProperty(JSContext* cx, HandleObject obj, HandleId id,
+                     MutableHandleObject objp, MutableHandleShape propp)
 {
     bool found;
     if (!Proxy::has(cx, obj, id, &found))
         return false;
 
     if (found) {
         MarkNonNativePropertyFound<CanGC>(propp);
         objp.set(obj);
     } else {
         objp.set(nullptr);
         propp.set(nullptr);
     }
     return true;
 }
 
-bool
-js::proxy_DefineProperty(JSContext* cx, HandleObject obj, HandleId id,
-                         Handle<PropertyDescriptor> desc,
-                         ObjectOpResult& result)
-{
-    return Proxy::defineProperty(cx, obj, id, desc, result);
-}
-
-bool
-js::proxy_HasProperty(JSContext* cx, JS::HandleObject obj, JS::HandleId id, bool* foundp)
-{
-    return Proxy::has(cx, obj, id, foundp);
-}
-
-bool
-js::proxy_GetProperty(JSContext* cx, HandleObject obj, HandleValue receiver, HandleId id,
-                      MutableHandleValue vp)
-{
-    return Proxy::get(cx, obj, receiver, id, vp);
-}
-
-bool
-js::proxy_SetProperty(JSContext* cx, HandleObject obj, HandleId id, HandleValue v,
-                      HandleValue receiver, ObjectOpResult& result)
-{
-    return Proxy::set(cx, obj, id, v, receiver, result);
-}
-
-bool
-js::proxy_GetOwnPropertyDescriptor(JSContext* cx, HandleObject obj, HandleId id,
-                                   MutableHandle<PropertyDescriptor> desc)
-{
-    return Proxy::getOwnPropertyDescriptor(cx, obj, id, desc);
-}
-
-bool
-js::proxy_DeleteProperty(JSContext* cx, HandleObject obj, HandleId id, ObjectOpResult& result)
+static bool
+proxy_DeleteProperty(JSContext* cx, HandleObject obj, HandleId id, ObjectOpResult& result)
 {
     if (!Proxy::delete_(cx, obj, id, result))
         return false;
     return SuppressDeletedProperty(cx, obj, id); // XXX is this necessary?
 }
 
-void
-js::proxy_Trace(JSTracer* trc, JSObject* obj)
-{
-    MOZ_ASSERT(obj->is<ProxyObject>());
-    ProxyObject::trace(trc, obj);
-}
-
 /* static */ void
 ProxyObject::trace(JSTracer* trc, JSObject* obj)
 {
     ProxyObject* proxy = &obj->as<ProxyObject>();
 
     TraceEdge(trc, &proxy->shape_, "ProxyObject_shape");
 
 #ifdef DEBUG
@@ -651,41 +609,35 @@ ProxyObject::trace(JSTracer* trc, JSObje
 
 JSObject*
 js::proxy_WeakmapKeyDelegate(JSObject* obj)
 {
     MOZ_ASSERT(obj->is<ProxyObject>());
     return obj->as<ProxyObject>().handler()->weakmapKeyDelegate(obj);
 }
 
-void
-js::proxy_Finalize(FreeOp* fop, JSObject* obj)
+static void
+proxy_Finalize(FreeOp* fop, JSObject* obj)
 {
     // Suppress a bogus warning about finalize().
     JS::AutoSuppressGCAnalysis nogc;
 
     MOZ_ASSERT(obj->is<ProxyObject>());
     obj->as<ProxyObject>().handler()->finalize(fop, obj);
-    js_free(detail::GetProxyDataLayout(obj)->values);
+    js_free(js::detail::GetProxyDataLayout(obj)->values);
 }
 
-void
-js::proxy_ObjectMoved(JSObject* obj, const JSObject* old)
+static void
+proxy_ObjectMoved(JSObject* obj, const JSObject* old)
 {
     MOZ_ASSERT(obj->is<ProxyObject>());
     obj->as<ProxyObject>().handler()->objectMoved(obj, old);
 }
 
 bool
-js::proxy_HasInstance(JSContext* cx, HandleObject proxy, MutableHandleValue v, bool* bp)
-{
-    return Proxy::hasInstance(cx, proxy, v, bp);
-}
-
-bool
 js::proxy_Call(JSContext* cx, unsigned argc, Value* vp)
 {
     CallArgs args = CallArgsFromVp(argc, vp);
     RootedObject proxy(cx, &args.callee());
     MOZ_ASSERT(proxy->is<ProxyObject>());
     return Proxy::call(cx, proxy, args);
 }
 
@@ -693,72 +645,47 @@ bool
 js::proxy_Construct(JSContext* cx, unsigned argc, Value* vp)
 {
     CallArgs args = CallArgsFromVp(argc, vp);
     RootedObject proxy(cx, &args.callee());
     MOZ_ASSERT(proxy->is<ProxyObject>());
     return Proxy::construct(cx, proxy, args);
 }
 
-bool
-js::proxy_Watch(JSContext* cx, HandleObject obj, HandleId id, HandleObject callable)
-{
-    return Proxy::watch(cx, obj, id, callable);
-}
-
-bool
-js::proxy_Unwatch(JSContext* cx, HandleObject obj, HandleId id)
-{
-    return Proxy::unwatch(cx, obj, id);
-}
-
-bool
-js::proxy_GetElements(JSContext* cx, HandleObject proxy, uint32_t begin, uint32_t end,
-                      ElementAdder* adder)
-{
-    return Proxy::getElements(cx, proxy, begin, end, adder);
-}
-
-JSString*
-js::proxy_FunToString(JSContext* cx, HandleObject proxy, unsigned indent)
-{
-    return Proxy::fun_toString(cx, proxy, indent);
-}
-
 const ClassOps js::ProxyClassOps = {
     nullptr,                 /* addProperty */
     nullptr,                 /* delProperty */
     nullptr,                 /* getProperty */
     nullptr,                 /* setProperty */
     nullptr,                 /* enumerate   */
     nullptr,                 /* resolve     */
     nullptr,                 /* mayResolve  */
-    js::proxy_Finalize,      /* finalize    */
+    proxy_Finalize,          /* finalize    */
     nullptr,                 /* call        */
-    js::proxy_HasInstance,   /* hasInstance */
+    Proxy::hasInstance,      /* hasInstance */
     nullptr,                 /* construct   */
-    js::proxy_Trace,         /* trace       */
+    ProxyObject::trace,      /* trace       */
 };
 
 const ClassExtension js::ProxyClassExtension = PROXY_MAKE_EXT(
-    js::proxy_ObjectMoved
+    proxy_ObjectMoved
 );
 
 const ObjectOps js::ProxyObjectOps = {
-    js::proxy_LookupProperty,
-    js::proxy_DefineProperty,
-    js::proxy_HasProperty,
-    js::proxy_GetProperty,
-    js::proxy_SetProperty,
-    js::proxy_GetOwnPropertyDescriptor,
-    js::proxy_DeleteProperty,
-    js::proxy_Watch, js::proxy_Unwatch,
-    js::proxy_GetElements,
+    proxy_LookupProperty,
+    Proxy::defineProperty,
+    Proxy::has,
+    Proxy::get,
+    Proxy::set,
+    Proxy::getOwnPropertyDescriptor,
+    proxy_DeleteProperty,
+    Proxy::watch, Proxy::unwatch,
+    Proxy::getElements,
     nullptr,  /* enumerate */
-    js::proxy_FunToString
+    Proxy::fun_toString
 };
 
 const Class js::ProxyObject::proxyClass =
     PROXY_CLASS_DEF("Proxy", JSCLASS_HAS_CACHED_PROTO(JSProto_Proxy));
 
 const Class* const js::ProxyClassPtr = &js::ProxyObject::proxyClass;
 
 JS_FRIEND_API(JSObject*)
--- a/js/src/proxy/Proxy.h
+++ b/js/src/proxy/Proxy.h
@@ -69,11 +69,16 @@ class Proxy
     static bool unwatch(JSContext* cx, HandleObject proxy, HandleId id);
 
     static bool getElements(JSContext* cx, HandleObject obj, uint32_t begin, uint32_t end,
                             ElementAdder* adder);
 
     static void trace(JSTracer* trc, JSObject* obj);
 };
 
+bool
+proxy_Call(JSContext* cx, unsigned argc, Value* vp);
+bool
+proxy_Construct(JSContext* cx, unsigned argc, Value* vp);
+
 } /* namespace js */
 
 #endif /* proxy_Proxy_h */
--- a/js/src/vm/ProxyObject.h
+++ b/js/src/vm/ProxyObject.h
@@ -86,23 +86,20 @@ class ProxyObject : public ShapedObject
         return reinterpret_cast<GCPtrValue*>(&detail::GetProxyDataLayout(this)->values->extraSlots[n]);
     }
 
     static bool isValidProxyClass(const Class* clasp) {
         // Since we can take classes from the outside, make sure that they
         // are "sane". They have to quack enough like proxies for us to belive
         // they should be treated as such.
 
-        // proxy_Trace is just a trivial wrapper around ProxyObject::trace for
-        // friend api exposure.
-
         // Proxy classes are not allowed to have call or construct hooks directly. Their
         // callability is instead decided by handler()->isCallable().
         return clasp->isProxy() &&
-               clasp->isTrace(proxy_Trace) &&
+               clasp->isTrace(ProxyObject::trace) &&
                !clasp->getCall() && !clasp->getConstruct();
     }
 
   public:
     static unsigned grayLinkExtraSlot(JSObject* obj);
 
     void renew(JSContext* cx, const BaseProxyHandler* handler, const Value& priv);