diff --git a/js/src/proxy/BaseProxyHandler.cpp b/js/src/proxy/BaseProxyHandler.cpp index 49d596624aa7..4099255f52eb 100644 --- a/js/src/proxy/BaseProxyHandler.cpp +++ b/js/src/proxy/BaseProxyHandler.cpp @@ -139,7 +139,8 @@ BaseProxyHandler::get(JSContext* cx, HandleObject proxy, HandleValue receiver, } // Step 7. - return InvokeGetter(cx, receiver, ObjectValue(*getter), vp); + RootedValue getterFunc(cx, ObjectValue(*getter)); + return CallGetter(cx, receiver, getterFunc, vp); } bool @@ -241,7 +242,7 @@ js::SetPropertyIgnoringNamedGetter(JSContext* cx, HandleObject obj, HandleId id, if (!setter) return result.fail(JSMSG_GETTER_ONLY); RootedValue setterValue(cx, ObjectValue(*setter)); - if (!InvokeSetter(cx, receiver, setterValue, v)) + if (!CallSetter(cx, receiver, setterValue, v)) return false; return result.succeed(); } diff --git a/js/src/vm/Interpreter.cpp b/js/src/vm/Interpreter.cpp index 7a8d17e6437d..1755cd4678cf 100644 --- a/js/src/vm/Interpreter.cpp +++ b/js/src/vm/Interpreter.cpp @@ -629,24 +629,22 @@ js::InternalConstructWithProvidedThis(JSContext* cx, HandleValue fval, HandleVal } bool -js::InvokeGetter(JSContext* cx, const Value& thisv, Value fval, MutableHandleValue rval) +js::CallGetter(JSContext* cx, HandleValue thisv, HandleValue getter, MutableHandleValue rval) { - /* - * Invoke could result in another try to get or set the same id again, see - * bug 355497. - */ + // Invoke could result in another try to get or set the same id again, see + // bug 355497. JS_CHECK_RECURSION(cx, return false); - return Invoke(cx, thisv, fval, 0, nullptr, rval); + return Invoke(cx, thisv, getter, 0, nullptr, rval); } bool -js::InvokeSetter(JSContext* cx, const Value& thisv, Value fval, HandleValue v) +js::CallSetter(JSContext* cx, HandleValue thisv, HandleValue setter, HandleValue v) { JS_CHECK_RECURSION(cx, return false); RootedValue ignored(cx); - return Invoke(cx, thisv, fval, 1, v.address(), &ignored); + return Invoke(cx, thisv, setter, 1, v.address(), &ignored); } bool diff --git a/js/src/vm/Interpreter.h b/js/src/vm/Interpreter.h index 10e8e1f8d178..6082cefab590 100644 --- a/js/src/vm/Interpreter.h +++ b/js/src/vm/Interpreter.h @@ -74,10 +74,10 @@ Invoke(JSContext* cx, const Value& thisv, const Value& fval, unsigned argc, cons * getter/setter calls. */ extern bool -InvokeGetter(JSContext* cx, const Value& thisv, Value fval, MutableHandleValue rval); +CallGetter(JSContext* cx, HandleValue thisv, HandleValue getter, MutableHandleValue rval); extern bool -InvokeSetter(JSContext* cx, const Value& thisv, Value fval, HandleValue v); +CallSetter(JSContext* cx, HandleValue thisv, HandleValue setter, HandleValue rval); // ES6 7.3.13 Construct(F, argumentsList, newTarget). All parameters are // required, hopefully forcing callers to be careful not to (say) blindly pass diff --git a/js/src/vm/NativeObject.cpp b/js/src/vm/NativeObject.cpp index 219f42fd5856..7612e33a7730 100644 --- a/js/src/vm/NativeObject.cpp +++ b/js/src/vm/NativeObject.cpp @@ -1731,8 +1731,8 @@ CallGetter(JSContext* cx, HandleObject obj, HandleValue receiver, HandleShape sh MOZ_ASSERT(!shape->hasDefaultGetter()); if (shape->hasGetterValue()) { - Value fval = shape->getterValue(); - return InvokeGetter(cx, receiver, fval, vp); + RootedValue getter(cx, shape->getterValue()); + return js::CallGetter(cx, receiver, getter, vp); } // In contrast to normal getters JSGetterOps always want the holder. @@ -2348,9 +2348,11 @@ SetExistingProperty(JSContext* cx, HandleNativeObject obj, HandleId id, HandleVa MOZ_ASSERT_IF(!shape->hasSetterObject(), shape->hasDefaultSetter()); if (shape->hasDefaultSetter()) return result.fail(JSMSG_GETTER_ONLY); - Value setter = ObjectValue(*shape->setterObject()); - if (!InvokeSetter(cx, receiver, setter, v)) + + RootedValue setter(cx, ObjectValue(*shape->setterObject())); + if (!js::CallSetter(cx, receiver, setter, v)) return false; + return result.succeed(); }