diff --git a/dom/xbl/nsXBLBinding.cpp b/dom/xbl/nsXBLBinding.cpp index 8d40864c335..47ef01a69ce 100644 --- a/dom/xbl/nsXBLBinding.cpp +++ b/dom/xbl/nsXBLBinding.cpp @@ -1128,9 +1128,7 @@ nsXBLBinding::LookupMember(JSContext* aCx, JS::Handle aId, { JSAutoCompartment ac(aCx, xblScope); JS::Rooted id(aCx, aId); - if (!JS_WrapId(aCx, &id) || - !LookupMemberInternal(aCx, name, id, aDesc, xblScope)) - { + if (!LookupMemberInternal(aCx, name, id, aDesc, xblScope)) { return false; } } diff --git a/dom/xbl/nsXBLProtoImplField.cpp b/dom/xbl/nsXBLProtoImplField.cpp index a32e8c2d4fb..a4dd1624c02 100644 --- a/dom/xbl/nsXBLProtoImplField.cpp +++ b/dom/xbl/nsXBLProtoImplField.cpp @@ -333,7 +333,7 @@ nsXBLProtoImplField::InstallAccessors(JSContext* aCx, // First, enter the XBL scope, and compile the functions there. JSAutoCompartment ac(aCx, scopeObject); JS::Rooted wrappedClassObj(aCx, JS::ObjectValue(*aTargetClassObject)); - if (!JS_WrapValue(aCx, &wrappedClassObj) || !JS_WrapId(aCx, &id)) + if (!JS_WrapValue(aCx, &wrappedClassObj)) return NS_ERROR_OUT_OF_MEMORY; JS::Rooted get(aCx, @@ -359,9 +359,7 @@ nsXBLProtoImplField::InstallAccessors(JSContext* aCx, // Now, re-enter the class object's scope, wrap the getters/setters, and define // them there. JSAutoCompartment ac2(aCx, aTargetClassObject); - if (!JS_WrapObject(aCx, &get) || !JS_WrapObject(aCx, &set) || - !JS_WrapId(aCx, &id)) - { + if (!JS_WrapObject(aCx, &get) || !JS_WrapObject(aCx, &set)) { return NS_ERROR_OUT_OF_MEMORY; } diff --git a/js/jsd/jsd_val.cpp b/js/jsd/jsd_val.cpp index abff6cc3409..da625eaf54d 100644 --- a/js/jsd/jsd_val.cpp +++ b/js/jsd/jsd_val.cpp @@ -513,8 +513,6 @@ jsd_GetValueProperty(JSDContext* jsdc, JSDValue* jsdval, JSString* nameStr) JSAutoCompartment ac(cx, obj); JS::RootedId id(cx, nameid); - if(!JS_WrapId(cx, &id)) - return nullptr; if(!JS_GetOwnPropertyDescriptorById(cx, obj, id, &desc)) return nullptr; if(!desc.object()) diff --git a/js/src/jsapi.cpp b/js/src/jsapi.cpp index c4b98018564..99398676bd3 100644 --- a/js/src/jsapi.cpp +++ b/js/src/jsapi.cpp @@ -1069,19 +1069,6 @@ JS_WrapValue(JSContext *cx, MutableHandleValue vp) return cx->compartment()->wrap(cx, vp); } -JS_PUBLIC_API(bool) -JS_WrapId(JSContext *cx, JS::MutableHandleId idp) -{ - AssertHeapIsIdle(cx); - CHECK_REQUEST(cx); - jsid id = idp.get(); - if (JSID_IS_STRING(id)) - JS::ExposeGCThingToActiveJS(JSID_TO_STRING(id), JSTRACE_STRING); - else if (JSID_IS_SYMBOL(id)) - JS::ExposeGCThingToActiveJS(JSID_TO_STRING(id), JSTRACE_STRING); - return true; -} - /* * Identity remapping. Not for casual consumers. * diff --git a/js/src/jsapi.h b/js/src/jsapi.h index f42d9af3b92..86afaa0f2cb 100644 --- a/js/src/jsapi.h +++ b/js/src/jsapi.h @@ -1648,9 +1648,6 @@ JS_WrapObject(JSContext *cx, JS::MutableHandleObject objp); extern JS_PUBLIC_API(bool) JS_WrapValue(JSContext *cx, JS::MutableHandleValue vp); -extern JS_PUBLIC_API(bool) -JS_WrapId(JSContext *cx, JS::MutableHandleId idp); - extern JS_PUBLIC_API(JSObject *) JS_TransplantObject(JSContext *cx, JS::HandleObject origobj, JS::HandleObject target); diff --git a/js/src/jscompartment.cpp b/js/src/jscompartment.cpp index 9c2608c6aa3..075ad6828c1 100644 --- a/js/src/jscompartment.cpp +++ b/js/src/jscompartment.cpp @@ -460,23 +460,6 @@ JSCompartment::wrap(JSContext *cx, MutableHandleObject obj, HandleObject existin return putWrapper(cx, CrossCompartmentKey(key), ObjectValue(*obj)); } -bool -JSCompartment::wrapId(JSContext *cx, jsid *idp) -{ - MOZ_ASSERT(*idp != JSID_VOID, "JSID_VOID is an out-of-band sentinel value"); - if (JSID_IS_INT(*idp)) - return true; - RootedValue value(cx, IdToValue(*idp)); - if (!wrap(cx, &value)) - return false; - RootedId id(cx); - if (!ValueToId(cx, value, &id)) - return false; - - *idp = id; - return true; -} - bool JSCompartment::wrap(JSContext *cx, PropertyOp *propp) { @@ -515,18 +498,6 @@ JSCompartment::wrap(JSContext *cx, MutableHandle desc) return wrap(cx, desc.value()); } -bool -JSCompartment::wrap(JSContext *cx, AutoIdVector &props) -{ - jsid *vector = props.begin(); - int length = props.length(); - for (size_t n = 0; n < size_t(length); ++n) { - if (!wrapId(cx, &vector[n])) - return false; - } - return true; -} - bool JSCompartment::wrap(JSContext *cx, MutableHandle desc) { diff --git a/js/src/jscompartment.h b/js/src/jscompartment.h index 32617e980fc..04d13e0b573 100644 --- a/js/src/jscompartment.h +++ b/js/src/jscompartment.h @@ -317,11 +317,9 @@ struct JSCompartment bool wrap(JSContext *cx, js::HeapPtrString *strp); bool wrap(JSContext *cx, JS::MutableHandleObject obj, JS::HandleObject existingArg = js::NullPtr()); - bool wrapId(JSContext *cx, jsid *idp); bool wrap(JSContext *cx, js::PropertyOp *op); bool wrap(JSContext *cx, js::StrictPropertyOp *op); bool wrap(JSContext *cx, JS::MutableHandle desc); - bool wrap(JSContext *cx, js::AutoIdVector &props); bool wrap(JSContext *cx, JS::MutableHandle desc); bool putWrapper(JSContext *cx, const js::CrossCompartmentKey& wrapped, const js::Value& wrapper); diff --git a/js/src/jsfriendapi.cpp b/js/src/jsfriendapi.cpp index ce30839289d..f3b9cdbf27a 100644 --- a/js/src/jsfriendapi.cpp +++ b/js/src/jsfriendapi.cpp @@ -264,12 +264,6 @@ JS_WrapPropertyDescriptor(JSContext *cx, JS::MutableHandlecompartment()->wrap(cx, desc); } -JS_FRIEND_API(bool) -JS_WrapAutoIdVector(JSContext *cx, js::AutoIdVector &props) -{ - return cx->compartment()->wrap(cx, props); -} - JS_FRIEND_API(void) JS_TraceShapeCycleCollectorChildren(JSTracer *trc, void *shape) { diff --git a/js/src/jsobj.cpp b/js/src/jsobj.cpp index 3bedf51bb41..780e8866daf 100644 --- a/js/src/jsobj.cpp +++ b/js/src/jsobj.cpp @@ -1847,8 +1847,6 @@ JS_CopyPropertyFrom(JSContext *cx, HandleId id, HandleObject target, RootedId wrappedId(cx, id); if (!cx->compartment()->wrap(cx, &desc)) return false; - if (!cx->compartment()->wrapId(cx, wrappedId.address())) - return false; bool ignored; return DefineOwnProperty(cx, target, wrappedId, desc, &ignored); diff --git a/js/src/jswrapper.cpp b/js/src/jswrapper.cpp index 5db847b4548..ff5f9b4e8d1 100644 --- a/js/src/jswrapper.cpp +++ b/js/src/jswrapper.cpp @@ -230,10 +230,9 @@ bool CrossCompartmentWrapper::getPropertyDescriptor(JSContext *cx, HandleObject wrapper, HandleId id, MutableHandle desc) { - RootedId idCopy(cx, id); PIERCE(cx, wrapper, - cx->compartment()->wrapId(cx, idCopy.address()), - Wrapper::getPropertyDescriptor(cx, wrapper, idCopy, desc), + NOTHING, + Wrapper::getPropertyDescriptor(cx, wrapper, id, desc), cx->compartment()->wrap(cx, desc)); } @@ -241,10 +240,9 @@ bool CrossCompartmentWrapper::getOwnPropertyDescriptor(JSContext *cx, HandleObject wrapper, HandleId id, MutableHandle desc) { - RootedId idCopy(cx, id); PIERCE(cx, wrapper, - cx->compartment()->wrapId(cx, idCopy.address()), - Wrapper::getOwnPropertyDescriptor(cx, wrapper, idCopy, desc), + NOTHING, + Wrapper::getOwnPropertyDescriptor(cx, wrapper, id, desc), cx->compartment()->wrap(cx, desc)); } @@ -252,11 +250,10 @@ bool CrossCompartmentWrapper::defineProperty(JSContext *cx, HandleObject wrapper, HandleId id, MutableHandle desc) { - RootedId idCopy(cx, id); Rooted desc2(cx, desc); PIERCE(cx, wrapper, - cx->compartment()->wrapId(cx, idCopy.address()) && cx->compartment()->wrap(cx, &desc2), - Wrapper::defineProperty(cx, wrapper, idCopy, &desc2), + cx->compartment()->wrap(cx, &desc2), + Wrapper::defineProperty(cx, wrapper, id, &desc2), NOTHING); } @@ -267,16 +264,15 @@ CrossCompartmentWrapper::getOwnPropertyNames(JSContext *cx, HandleObject wrapper PIERCE(cx, wrapper, NOTHING, Wrapper::getOwnPropertyNames(cx, wrapper, props), - cx->compartment()->wrap(cx, props)); + NOTHING); } bool CrossCompartmentWrapper::delete_(JSContext *cx, HandleObject wrapper, HandleId id, bool *bp) { - RootedId idCopy(cx, id); PIERCE(cx, wrapper, - cx->compartment()->wrapId(cx, idCopy.address()), - Wrapper::delete_(cx, wrapper, idCopy, bp), + NOTHING, + Wrapper::delete_(cx, wrapper, id, bp), NOTHING); } @@ -286,26 +282,24 @@ CrossCompartmentWrapper::enumerate(JSContext *cx, HandleObject wrapper, AutoIdVe PIERCE(cx, wrapper, NOTHING, Wrapper::enumerate(cx, wrapper, props), - cx->compartment()->wrap(cx, props)); + NOTHING); } bool CrossCompartmentWrapper::has(JSContext *cx, HandleObject wrapper, HandleId id, bool *bp) { - RootedId idCopy(cx, id); PIERCE(cx, wrapper, - cx->compartment()->wrapId(cx, idCopy.address()), - Wrapper::has(cx, wrapper, idCopy, bp), + NOTHING, + Wrapper::has(cx, wrapper, id, bp), NOTHING); } bool CrossCompartmentWrapper::hasOwn(JSContext *cx, HandleObject wrapper, HandleId id, bool *bp) { - RootedId idCopy(cx, id); PIERCE(cx, wrapper, - cx->compartment()->wrapId(cx, idCopy.address()), - Wrapper::hasOwn(cx, wrapper, idCopy, bp), + NOTHING, + Wrapper::hasOwn(cx, wrapper, id, bp), NOTHING); } @@ -314,16 +308,12 @@ CrossCompartmentWrapper::get(JSContext *cx, HandleObject wrapper, HandleObject r HandleId id, MutableHandleValue vp) { RootedObject receiverCopy(cx, receiver); - RootedId idCopy(cx, id); { AutoCompartment call(cx, wrappedObject(wrapper)); - if (!cx->compartment()->wrap(cx, &receiverCopy) || - !cx->compartment()->wrapId(cx, idCopy.address())) - { + if (!cx->compartment()->wrap(cx, &receiverCopy)) return false; - } - if (!Wrapper::get(cx, wrapper, receiverCopy, idCopy, vp)) + if (!Wrapper::get(cx, wrapper, receiverCopy, id, vp)) return false; } return cx->compartment()->wrap(cx, vp); @@ -334,12 +324,10 @@ CrossCompartmentWrapper::set(JSContext *cx, HandleObject wrapper, HandleObject r HandleId id, bool strict, MutableHandleValue vp) { RootedObject receiverCopy(cx, receiver); - RootedId idCopy(cx, id); PIERCE(cx, wrapper, cx->compartment()->wrap(cx, &receiverCopy) && - cx->compartment()->wrapId(cx, idCopy.address()) && cx->compartment()->wrap(cx, vp), - Wrapper::set(cx, wrapper, receiverCopy, idCopy, strict, vp), + Wrapper::set(cx, wrapper, receiverCopy, id, strict, vp), NOTHING); } @@ -349,7 +337,7 @@ CrossCompartmentWrapper::keys(JSContext *cx, HandleObject wrapper, AutoIdVector PIERCE(cx, wrapper, NOTHING, Wrapper::keys(cx, wrapper, props), - cx->compartment()->wrap(cx, props)); + NOTHING); } /* @@ -408,8 +396,6 @@ Reify(JSContext *cx, JSCompartment *origin, MutableHandleValue vp) if (!ValueToId(cx, v, &id)) return false; keys.infallibleAppend(id); - if (!origin->wrapId(cx, keys[i].address())) - return false; } } diff --git a/js/src/vm/Debugger.cpp b/js/src/vm/Debugger.cpp index efc66cb81bc..aefb31da107 100644 --- a/js/src/vm/Debugger.cpp +++ b/js/src/vm/Debugger.cpp @@ -5248,8 +5248,6 @@ DebuggerObject_getOwnPropertyDescriptor(JSContext *cx, unsigned argc, Value *vp) { Maybe ac; ac.construct(cx, obj); - if (!cx->compartment()->wrapId(cx, id.address())) - return false; ErrorCopier ec(ac, dbg->toJSObject()); if (!GetOwnPropertyDescriptor(cx, obj, id, &desc)) @@ -5340,8 +5338,6 @@ DebuggerObject_defineProperty(JSContext *cx, unsigned argc, Value *vp) { Maybe ac; ac.construct(cx, obj); - if (!cx->compartment()->wrapId(cx, id.address())) - return false; if (!cx->compartment()->wrap(cx, &desc)) return false; if (!desc.makeObject(cx)) @@ -5385,8 +5381,6 @@ DebuggerObject_defineProperties(JSContext *cx, unsigned argc, Value *vp) Maybe ac; ac.construct(cx, obj); for (size_t i = 0; i < n; i++) { - if (!cx->compartment()->wrapId(cx, ids[i].address())) - return false; if (!cx->compartment()->wrap(cx, descs[i])) return false; if (descs[i].descriptorValue().isUndefined() && !descs[i].makeObject(cx)) @@ -5419,11 +5413,9 @@ DebuggerObject_deleteProperty(JSContext *cx, unsigned argc, Value *vp) Maybe ac; ac.construct(cx, obj); - if (!cx->compartment()->wrapId(cx, id.address())) - return false; + ErrorCopier ec(ac, dbg->toJSObject()); bool succeeded; - ErrorCopier ec(ac, dbg->toJSObject()); if (!JSObject::deleteGeneric(cx, obj, id, &succeeded)) return false; args.rval().setBoolean(succeeded); @@ -5992,8 +5984,6 @@ DebuggerEnv_names(JSContext *cx, unsigned argc, Value *vp) for (size_t i = 0, len = keys.length(); i < len; i++) { id = keys[i]; if (JSID_IS_ATOM(id) && IsIdentifier(JSID_TO_ATOM(id))) { - if (!cx->compartment()->wrapId(cx, id.address())) - return false; if (!NewbornArrayPush(cx, arr, StringValue(JSID_TO_STRING(id)))) return false; } @@ -6015,8 +6005,6 @@ DebuggerEnv_find(JSContext *cx, unsigned argc, Value *vp) { Maybe ac; ac.construct(cx, env); - if (!cx->compartment()->wrapId(cx, id.address())) - return false; /* This can trigger resolve hooks. */ ErrorCopier ec(ac, dbg->toJSObject()); @@ -6047,8 +6035,6 @@ DebuggerEnv_getVariable(JSContext *cx, unsigned argc, Value *vp) { Maybe ac; ac.construct(cx, env); - if (!cx->compartment()->wrapId(cx, id.address())) - return false; /* This can trigger getters. */ ErrorCopier ec(ac, dbg->toJSObject()); @@ -6089,7 +6075,7 @@ DebuggerEnv_setVariable(JSContext *cx, unsigned argc, Value *vp) { Maybe ac; ac.construct(cx, env); - if (!cx->compartment()->wrapId(cx, id.address()) || !cx->compartment()->wrap(cx, &v)) + if (!cx->compartment()->wrap(cx, &v)) return false; /* This can trigger setters. */ diff --git a/js/xpconnect/wrappers/XrayWrapper.cpp b/js/xpconnect/wrappers/XrayWrapper.cpp index 38295e22f86..ef11332ac68 100644 --- a/js/xpconnect/wrappers/XrayWrapper.cpp +++ b/js/xpconnect/wrappers/XrayWrapper.cpp @@ -473,7 +473,7 @@ SilentFailure(JSContext *cx, HandleId id, const char *reason) bool JSXrayTraits::getOwnPropertyFromTargetIfSafe(JSContext *cx, HandleObject target, HandleObject wrapper, - HandleId idArg, + HandleId id, MutableHandle outDesc) { // Note - This function operates in the target compartment, because it @@ -483,9 +483,6 @@ bool JSXrayTraits::getOwnPropertyFromTargetIfSafe(JSContext *cx, MOZ_ASSERT(WrapperFactory::IsXrayWrapper(wrapper)); MOZ_ASSERT(outDesc.object() == nullptr); - RootedId id(cx, idArg); - if (!JS_WrapId(cx, &id)) - return false; Rooted desc(cx); if (!JS_GetOwnPropertyDescriptorById(cx, target, id, &desc)) return false; @@ -842,7 +839,7 @@ JSXrayTraits::enumerateNames(JSContext *cx, HandleObject wrapper, unsigned flags props.infallibleAppend(id); } } - return JS_WrapAutoIdVector(cx, props); + return true; } else if (IsTypedArrayKey(key)) { uint32_t length = JS_GetTypedArrayLength(target); // TypedArrays enumerate every indexed property in range, but @@ -1729,8 +1726,6 @@ XPCWrappedNativeXrayTraits::enumerateNames(JSContext *cx, HandleObject wrapper, if (!js::GetPropertyNames(cx, target, flags, &wnProps)) return false; } - if (!JS_WrapAutoIdVector(cx, wnProps)) - return false; // Go through the properties we got and enumerate all native ones. if (!props.reserve(wnProps.length())) @@ -2504,8 +2499,6 @@ XrayWrapper::enumerate(JSContext *cx, HandleObject wrapper, unsign if (!js::GetPropertyNames(cx, expando, flags, &props)) return false; } - if (!JS_WrapAutoIdVector(cx, props)) - return false; return Traits::singleton.enumerateNames(cx, wrapper, flags, props); }