From 8129026433a1452e67644566be79ad0ad708cd5b Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Thu, 5 Sep 2013 16:08:57 -0700 Subject: [PATCH] Bug 912411 (part 2) - Move JSID_{VOID,EMPTY}HANDLE from jsapi.{h,cpp} to Id.{h,cpp}. r=luke. --HG-- extra : rebase_source : 5fb68bf5079e3261fdca6cb99717d3a502c878f3 --- js/public/Id.h | 3 +++ js/src/jit/BaselineIC.cpp | 4 ++-- js/src/jsapi.cpp | 5 ----- js/src/jsapi.h | 7 ------- js/src/jsproxy.cpp | 18 +++++++++--------- js/src/vm/Id.cpp | 6 ++++++ js/xpconnect/src/xpcprivate.h | 2 +- js/xpconnect/wrappers/AccessCheck.h | 4 ++-- js/xpconnect/wrappers/ChromeObjectWrapper.cpp | 1 + 9 files changed, 24 insertions(+), 26 deletions(-) diff --git a/js/public/Id.h b/js/public/Id.h index b4bacbf0aa79..1205b4174c55 100644 --- a/js/public/Id.h +++ b/js/public/Id.h @@ -157,4 +157,7 @@ extern JS_PUBLIC_DATA(const jsid) JSID_EMPTY; # define JSID_EMPTY ((jsid)JSID_TYPE_OBJECT) #endif +extern JS_PUBLIC_DATA(const JS::Handle) JSID_VOIDHANDLE; +extern JS_PUBLIC_DATA(const JS::Handle) JSID_EMPTYHANDLE; + #endif /* js_Id_h */ diff --git a/js/src/jit/BaselineIC.cpp b/js/src/jit/BaselineIC.cpp index 14d43049d3c0..0ffd262bc268 100644 --- a/js/src/jit/BaselineIC.cpp +++ b/js/src/jit/BaselineIC.cpp @@ -4719,7 +4719,7 @@ DoSetElemFallback(JSContext *cx, BaselineFrame *frame, ICSetElem_Fallback *stub, ICUpdatedStub *denseStub = compiler.getStub(compiler.getStubSpace(script)); if (!denseStub) return false; - if (!denseStub->addUpdateStubForValue(cx, script, obj, JS::JSID_VOIDHANDLE, rhs)) + if (!denseStub->addUpdateStubForValue(cx, script, obj, JSID_VOIDHANDLE, rhs)) return false; stub->addNewStub(denseStub); @@ -4733,7 +4733,7 @@ DoSetElemFallback(JSContext *cx, BaselineFrame *frame, ICSetElem_Fallback *stub, ICUpdatedStub *denseStub = compiler.getStub(compiler.getStubSpace(script)); if (!denseStub) return false; - if (!denseStub->addUpdateStubForValue(cx, script, obj, JS::JSID_VOIDHANDLE, rhs)) + if (!denseStub->addUpdateStubForValue(cx, script, obj, JSID_VOIDHANDLE, rhs)) return false; stub->addNewStub(denseStub); diff --git a/js/src/jsapi.cpp b/js/src/jsapi.cpp index 28e89ff3190b..a2685bfcf644 100644 --- a/js/src/jsapi.cpp +++ b/js/src/jsapi.cpp @@ -107,11 +107,6 @@ using js::frontend::Parser; #define JS_ADDRESSOF_VA_LIST(ap) (&(ap)) #endif -const jsid voidIdValue = JSID_VOID; -const jsid emptyIdValue = JSID_EMPTY; -const HandleId JS::JSID_VOIDHANDLE = HandleId::fromMarkedLocation(&voidIdValue); -const HandleId JS::JSID_EMPTYHANDLE = HandleId::fromMarkedLocation(&emptyIdValue); - /* Make sure that jschar is two bytes unsigned integer */ JS_STATIC_ASSERT((jschar)-1 > 0); JS_STATIC_ASSERT(sizeof(jschar) == 2); diff --git a/js/src/jsapi.h b/js/src/jsapi.h index b2721ffa52cb..4bcdeb81ed96 100644 --- a/js/src/jsapi.h +++ b/js/src/jsapi.h @@ -4580,11 +4580,4 @@ extern JS_PUBLIC_API(JSObject *) JS_DecodeInterpretedFunction(JSContext *cx, const void *data, uint32_t length, JSPrincipals *principals, JSPrincipals *originPrincipals); -namespace JS { - -extern JS_PUBLIC_DATA(const Handle) JSID_VOIDHANDLE; -extern JS_PUBLIC_DATA(const Handle) JSID_EMPTYHANDLE; - -} /* namespace JS */ - #endif /* jsapi_h */ diff --git a/js/src/jsproxy.cpp b/js/src/jsproxy.cpp index 19f276ec85d0..70904010d3b6 100644 --- a/js/src/jsproxy.cpp +++ b/js/src/jsproxy.cpp @@ -2362,7 +2362,7 @@ Proxy::getOwnPropertyNames(JSContext *cx, HandleObject proxy, AutoIdVector &prop { JS_CHECK_RECURSION(cx, return false); BaseProxyHandler *handler = proxy->as().handler(); - AutoEnterPolicy policy(cx, handler, proxy, JS::JSID_VOIDHANDLE, BaseProxyHandler::GET, true); + AutoEnterPolicy policy(cx, handler, proxy, JSID_VOIDHANDLE, BaseProxyHandler::GET, true); if (!policy.allowed()) return policy.returnValue(); return proxy->as().handler()->getOwnPropertyNames(cx, proxy, props); @@ -2405,7 +2405,7 @@ Proxy::enumerate(JSContext *cx, HandleObject proxy, AutoIdVector &props) { JS_CHECK_RECURSION(cx, return false); BaseProxyHandler *handler = proxy->as().handler(); - AutoEnterPolicy policy(cx, handler, proxy, JS::JSID_VOIDHANDLE, BaseProxyHandler::GET, true); + AutoEnterPolicy policy(cx, handler, proxy, JSID_VOIDHANDLE, BaseProxyHandler::GET, true); if (!policy.allowed()) return policy.returnValue(); if (!handler->hasPrototype()) @@ -2543,7 +2543,7 @@ Proxy::keys(JSContext *cx, HandleObject proxy, AutoIdVector &props) { JS_CHECK_RECURSION(cx, return false); BaseProxyHandler *handler = proxy->as().handler(); - AutoEnterPolicy policy(cx, handler, proxy, JS::JSID_VOIDHANDLE, BaseProxyHandler::GET, true); + AutoEnterPolicy policy(cx, handler, proxy, JSID_VOIDHANDLE, BaseProxyHandler::GET, true); if (!policy.allowed()) return policy.returnValue(); return handler->keys(cx, proxy, props); @@ -2556,7 +2556,7 @@ Proxy::iterate(JSContext *cx, HandleObject proxy, unsigned flags, MutableHandleV BaseProxyHandler *handler = proxy->as().handler(); vp.setUndefined(); // default result if we refuse to perform this action if (!handler->hasPrototype()) { - AutoEnterPolicy policy(cx, handler, proxy, JS::JSID_VOIDHANDLE, + AutoEnterPolicy policy(cx, handler, proxy, JSID_VOIDHANDLE, BaseProxyHandler::GET, true); // If the policy denies access but wants us to return true, we need // to hand a valid (empty) iterator object to the caller. @@ -2601,7 +2601,7 @@ Proxy::call(JSContext *cx, HandleObject proxy, const CallArgs &args) // Because vp[0] is JS_CALLEE on the way in and JS_RVAL on the way out, we // can only set our default value once we're sure that we're not calling the // trap. - AutoEnterPolicy policy(cx, handler, proxy, JS::JSID_VOIDHANDLE, + AutoEnterPolicy policy(cx, handler, proxy, JSID_VOIDHANDLE, BaseProxyHandler::CALL, true); if (!policy.allowed()) { args.rval().setUndefined(); @@ -2620,7 +2620,7 @@ Proxy::construct(JSContext *cx, HandleObject proxy, const CallArgs &args) // Because vp[0] is JS_CALLEE on the way in and JS_RVAL on the way out, we // can only set our default value once we're sure that we're not calling the // trap. - AutoEnterPolicy policy(cx, handler, proxy, JS::JSID_VOIDHANDLE, + AutoEnterPolicy policy(cx, handler, proxy, JSID_VOIDHANDLE, BaseProxyHandler::CALL, true); if (!policy.allowed()) { args.rval().setUndefined(); @@ -2647,7 +2647,7 @@ Proxy::hasInstance(JSContext *cx, HandleObject proxy, MutableHandleValue v, bool JS_CHECK_RECURSION(cx, return false); BaseProxyHandler *handler = proxy->as().handler(); *bp = false; // default result if we refuse to perform this action - AutoEnterPolicy policy(cx, handler, proxy, JS::JSID_VOIDHANDLE, BaseProxyHandler::GET, true); + AutoEnterPolicy policy(cx, handler, proxy, JSID_VOIDHANDLE, BaseProxyHandler::GET, true); if (!policy.allowed()) return policy.returnValue(); return proxy->as().handler()->hasInstance(cx, proxy, v, bp); @@ -2670,7 +2670,7 @@ Proxy::className(JSContext *cx, HandleObject proxy) return "too much recursion"; BaseProxyHandler *handler = proxy->as().handler(); - AutoEnterPolicy policy(cx, handler, proxy, JS::JSID_VOIDHANDLE, + AutoEnterPolicy policy(cx, handler, proxy, JSID_VOIDHANDLE, BaseProxyHandler::GET, /* mayThrow = */ false); // Do the safe thing if the policy rejects. if (!policy.allowed()) { @@ -2684,7 +2684,7 @@ Proxy::fun_toString(JSContext *cx, HandleObject proxy, unsigned indent) { JS_CHECK_RECURSION(cx, return NULL); BaseProxyHandler *handler = proxy->as().handler(); - AutoEnterPolicy policy(cx, handler, proxy, JS::JSID_VOIDHANDLE, + AutoEnterPolicy policy(cx, handler, proxy, JSID_VOIDHANDLE, BaseProxyHandler::GET, /* mayThrow = */ false); // Do the safe thing if the policy rejects. if (!policy.allowed()) { diff --git a/js/src/vm/Id.cpp b/js/src/vm/Id.cpp index 9bd49c03cb78..d70780d59e6b 100644 --- a/js/src/vm/Id.cpp +++ b/js/src/vm/Id.cpp @@ -5,9 +5,15 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "js/Id.h" +#include "js/RootingAPI.h" #ifdef JS_USE_JSID_STRUCT_TYPES const jsid JSID_VOID = { size_t(JSID_TYPE_VOID) }; const jsid JSID_EMPTY = { size_t(JSID_TYPE_OBJECT) }; #endif +static const jsid voidIdValue = JSID_VOID; +static const jsid emptyIdValue = JSID_EMPTY; +const JS::HandleId JSID_VOIDHANDLE = JS::HandleId::fromMarkedLocation(&voidIdValue); +const JS::HandleId JSID_EMPTYHANDLE = JS::HandleId::fromMarkedLocation(&emptyIdValue); + diff --git a/js/xpconnect/src/xpcprivate.h b/js/xpconnect/src/xpcprivate.h index 7aa790c63d52..340471159634 100644 --- a/js/xpconnect/src/xpcprivate.h +++ b/js/xpconnect/src/xpcprivate.h @@ -1024,7 +1024,7 @@ public: JSContext* cx = GetDefaultJSContext(), JS::HandleObject obj = JS::NullPtr(), JS::HandleObject funobj = JS::NullPtr(), - JS::HandleId id = JS::JSID_VOIDHANDLE, + JS::HandleId id = JSID_VOIDHANDLE, unsigned argc = NO_ARGS, jsval *argv = nullptr, jsval *rval = nullptr); diff --git a/js/xpconnect/wrappers/AccessCheck.h b/js/xpconnect/wrappers/AccessCheck.h index 3571d5522eb1..169e3e32112b 100644 --- a/js/xpconnect/wrappers/AccessCheck.h +++ b/js/xpconnect/wrappers/AccessCheck.h @@ -8,8 +8,8 @@ #ifndef __AccessCheck_h__ #define __AccessCheck_h__ -#include "jsapi.h" #include "jswrapper.h" +#include "js/Id.h" class nsIPrincipal; @@ -76,7 +76,7 @@ struct CrossOriginAccessiblePropertiesOnly : public Policy { } static bool deny(js::Wrapper::Action act, JS::HandleId id) { // Silently fail for enumerate-like operations. - if (act == js::Wrapper::GET && id == JS::JSID_VOIDHANDLE) + if (act == js::Wrapper::GET && id == JSID_VOIDHANDLE) return true; return false; } diff --git a/js/xpconnect/wrappers/ChromeObjectWrapper.cpp b/js/xpconnect/wrappers/ChromeObjectWrapper.cpp index 15468dce7779..4b19eeafbde5 100644 --- a/js/xpconnect/wrappers/ChromeObjectWrapper.cpp +++ b/js/xpconnect/wrappers/ChromeObjectWrapper.cpp @@ -1,4 +1,5 @@ #include "ChromeObjectWrapper.h" +#include "jsapi.h" using namespace JS;