From fe7928449548101791583090668d364f86aa1f9f Mon Sep 17 00:00:00 2001 From: Jim Blandy Date: Thu, 4 Jun 2015 11:58:10 -0700 Subject: [PATCH] Bug 1163520: Make IsInternalFunctionObject take its argument by reference, as it must not be nullptr. r=shu --HG-- extra : rebase_source : 31a5457c85adf992f5ad9c7a384e5cf9aa173d75 --- js/src/jsapi-tests/testLookup.cpp | 2 +- js/src/jsfun.cpp | 4 ++-- js/src/jsobjinlines.h | 10 +++++----- js/src/vm/UbiNode.cpp | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/js/src/jsapi-tests/testLookup.cpp b/js/src/jsapi-tests/testLookup.cpp index 09900af72055..178d1cf520ee 100644 --- a/js/src/jsapi-tests/testLookup.cpp +++ b/js/src/jsapi-tests/testLookup.cpp @@ -31,7 +31,7 @@ BEGIN_TEST(testLookup_bug522590) CHECK(r.isObject()); JSObject* funobj = &r.toObject(); CHECK(funobj->is()); - CHECK(!js::IsInternalFunctionObject(funobj)); + CHECK(!js::IsInternalFunctionObject(*funobj)); return true; } diff --git a/js/src/jsfun.cpp b/js/src/jsfun.cpp index be5ffdd2cf29..fd2e8c8dd4be 100644 --- a/js/src/jsfun.cpp +++ b/js/src/jsfun.cpp @@ -374,7 +374,7 @@ ResolveInterpretedFunctionPrototype(JSContext* cx, HandleFunction fun, HandleId // Assert that fun is not a compiler-created function object, which // must never leak to script or embedding code and then be mutated. // Also assert that fun is not bound, per the ES5 15.3.4.5 ref above. - MOZ_ASSERT(!IsInternalFunctionObject(fun)); + MOZ_ASSERT(!IsInternalFunctionObject(*fun)); MOZ_ASSERT(!fun->isBoundFunction()); // Make the prototype object an instance of Object with the same parent as @@ -461,7 +461,7 @@ fun_resolve(JSContext* cx, HandleObject obj, HandleId id, bool* resolvedp) bool isLength = JSID_IS_ATOM(id, cx->names().length); if (isLength || JSID_IS_ATOM(id, cx->names().name)) { - MOZ_ASSERT(!IsInternalFunctionObject(obj)); + MOZ_ASSERT(!IsInternalFunctionObject(*obj)); RootedValue v(cx); diff --git a/js/src/jsobjinlines.h b/js/src/jsobjinlines.h index 7a16c5d43a84..7b0b24a2866b 100644 --- a/js/src/jsobjinlines.h +++ b/js/src/jsobjinlines.h @@ -593,12 +593,12 @@ ToPrimitive(JSContext* cx, JSType preferredType, MutableHandleValue vp) * or embedding code. */ inline bool -IsInternalFunctionObject(JSObject* funobj) +IsInternalFunctionObject(JSObject& funobj) { - JSFunction* fun = &funobj->as(); - MOZ_ASSERT_IF(fun->isLambda(), - fun->isInterpreted() || fun->isAsmJSNative()); - return fun->isLambda() && fun->isInterpreted() && !fun->environment(); + JSFunction& fun = funobj.as(); + MOZ_ASSERT_IF(fun.isLambda(), + fun.isInterpreted() || fun.isAsmJSNative()); + return fun.isLambda() && fun.isInterpreted() && !fun.environment(); } typedef AutoVectorRooter AutoPropertyDescriptorVector; diff --git a/js/src/vm/UbiNode.cpp b/js/src/vm/UbiNode.cpp index 3af1a76bb37b..c8023fbc4b98 100644 --- a/js/src/vm/UbiNode.cpp +++ b/js/src/vm/UbiNode.cpp @@ -85,7 +85,7 @@ Node::exposeToJS() const JSObject& obj = *as(); if (obj.is()) { v.setUndefined(); - } else if (obj.is() && js::IsInternalFunctionObject(&obj)) { + } else if (obj.is() && js::IsInternalFunctionObject(obj)) { v.setUndefined(); } else { v.setObject(obj);