Bug 839376 (part 4) - Fix four or five more rooting hazards. r=sfink.
authorNicholas Nethercote <nnethercote@mozilla.com>
Mon, 11 Feb 2013 19:35:22 -0800
changeset 131460 9a0846d180af483fb4328413bd8b8c8c9325b1bb
parent 131459 7b379cdbf9007b9cfda436be1cf8b6e5c666c628
child 131461 328742b12ef546892628fd33327eaa63c22ecc15
push id2323
push userbbajaj@mozilla.com
push dateMon, 01 Apr 2013 19:47:02 +0000
treeherdermozilla-beta@7712be144d91 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssfink
bugs839376
milestone21.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 839376 (part 4) - Fix four or five more rooting hazards. r=sfink.
js/src/builtin/Module.cpp
js/src/builtin/Module.h
js/src/frontend/BytecodeEmitter.cpp
js/src/frontend/ParseNode.h
js/src/methodjit/StubCalls.cpp
js/src/shell/jsheaptools.cpp
js/src/vm/GlobalObject.cpp
--- a/js/src/builtin/Module.cpp
+++ b/js/src/builtin/Module.cpp
@@ -11,17 +11,17 @@ Class js::ModuleClass = {
     JS_PropertyStub,        /* getProperty */
     JS_StrictPropertyStub,  /* setProperty */
     JS_EnumerateStub,
     JS_ResolveStub,
     JS_ConvertStub
 };
 
 Module *
-js_NewModule(JSContext *cx, JSAtom *atom)
+js_NewModule(JSContext *cx, HandleAtom atom)
 {
     RootedObject object(cx, NewBuiltinClassInstance(cx, &ModuleClass));
     if (!object)
         return NULL;
     RootedModule module(cx, &object->asModule());
     module->setAtom(atom);
     module->setScript(NULL);
     return module;
--- a/js/src/builtin/Module.h
+++ b/js/src/builtin/Module.h
@@ -26,17 +26,17 @@ class Module : public JSObject {
   private:
     static const uint32_t ATOM_SLOT = 0;
     static const uint32_t SCRIPT_SLOT = 1;
 };
 
 } // namespace js
 
 js::Module *
-js_NewModule(JSContext *cx, JSAtom *atom);
+js_NewModule(JSContext *cx, js::HandleAtom atom);
 
 inline js::Module &
 JSObject::asModule()
 {
     JS_ASSERT(isModule());
     return *static_cast<js::Module *>(this);
 }
 
--- a/js/src/frontend/BytecodeEmitter.cpp
+++ b/js/src/frontend/BytecodeEmitter.cpp
@@ -3446,70 +3446,70 @@ EmitNewInit(JSContext *cx, BytecodeEmitt
     next[4] = 0;
     bce->current->next = next + len;
     UpdateDepth(cx, bce, offset);
     CheckTypeSet(cx, bce, JSOP_NEWINIT);
     return true;
 }
 
 bool
-ParseNode::getConstantValue(JSContext *cx, bool strictChecks, Value *vp)
+ParseNode::getConstantValue(JSContext *cx, bool strictChecks, MutableHandleValue vp)
 {
     switch (getKind()) {
       case PNK_NUMBER:
-        vp->setNumber(pn_dval);
+        vp.setNumber(pn_dval);
         return true;
       case PNK_STRING:
-        vp->setString(pn_atom);
+        vp.setString(pn_atom);
         return true;
       case PNK_TRUE:
-        vp->setBoolean(true);
+        vp.setBoolean(true);
         return true;
       case PNK_FALSE:
-        vp->setBoolean(false);
+        vp.setBoolean(false);
         return true;
       case PNK_NULL:
-        vp->setNull();
+        vp.setNull();
         return true;
       case PNK_SPREAD:
         return false;
       case PNK_ARRAY: {
         JS_ASSERT(isOp(JSOP_NEWINIT) && !(pn_xflags & PNX_NONCONST));
 
         RootedObject obj(cx, NewDenseAllocatedArray(cx, pn_count));
         if (!obj)
             return false;
 
         unsigned idx = 0;
         RootedId id(cx);
         RootedValue value(cx);
         for (ParseNode *pn = pn_head; pn; idx++, pn = pn->pn_next) {
-            if (!pn->getConstantValue(cx, strictChecks, value.address()))
+            if (!pn->getConstantValue(cx, strictChecks, &value))
                 return false;
             id = INT_TO_JSID(idx);
             if (!JSObject::defineGeneric(cx, obj, id, value, NULL, NULL, JSPROP_ENUMERATE))
                 return false;
         }
         JS_ASSERT(idx == pn_count);
 
         types::FixArrayType(cx, obj);
-        vp->setObject(*obj);
+        vp.setObject(*obj);
         return true;
       }
       case PNK_OBJECT: {
         JS_ASSERT(isOp(JSOP_NEWINIT) && !(pn_xflags & PNX_NONCONST));
 
         gc::AllocKind kind = GuessObjectGCKind(pn_count);
         RootedObject obj(cx, NewBuiltinClassInstance(cx, &ObjectClass, kind));
         if (!obj)
             return false;
 
         for (ParseNode *pn = pn_head; pn; pn = pn->pn_next) {
             RootedValue value(cx);
-            if (!pn->pn_right->getConstantValue(cx, strictChecks, value.address()))
+            if (!pn->pn_right->getConstantValue(cx, strictChecks, &value))
                 return false;
 
             ParseNode *pnid = pn->pn_left;
             if (pnid->isKind(PNK_NUMBER)) {
                 Value idvalue = NumberValue(pnid->pn_dval);
                 RootedId id(cx);
                 if (idvalue.isInt32() && INT_FITS_IN_JSID(idvalue.toInt32()))
                     id = INT_TO_JSID(idvalue.toInt32());
@@ -3524,29 +3524,29 @@ ParseNode::getConstantValue(JSContext *c
                 if (!DefineNativeProperty(cx, obj, id, value, NULL, NULL,
                                           JSPROP_ENUMERATE, 0, 0)) {
                     return false;
                 }
             }
         }
 
         types::FixObjectType(cx, obj);
-        vp->setObject(*obj);
+        vp.setObject(*obj);
         return true;
       }
       default:
         JS_NOT_REACHED("Unexpected node");
     }
     return false;
 }
 
 static bool
 EmitSingletonInitialiser(JSContext *cx, BytecodeEmitter *bce, ParseNode *pn)
 {
-    Value value;
+    RootedValue value(cx);
     if (!pn->getConstantValue(cx, bce->sc->needStrictChecks(), &value))
         return false;
 
     JS_ASSERT(value.isObject());
     ObjectBox *objbox = bce->parser->newObjectBox(&value.toObject());
     if (!objbox)
         return false;
 
--- a/js/src/frontend/ParseNode.h
+++ b/js/src/frontend/ParseNode.h
@@ -798,17 +798,17 @@ struct ParseNode {
     }
 
     void checkListConsistency()
 #ifndef DEBUG
     {}
 #endif
     ;
 
-    bool getConstantValue(JSContext *cx, bool strictChecks, Value *vp);
+    bool getConstantValue(JSContext *cx, bool strictChecks, MutableHandleValue vp);
     inline bool isConstant();
 
     /* Casting operations. */
     template <class NodeType>
     inline NodeType &as() {
         JS_ASSERT(NodeType::test(*this));
         return *static_cast<NodeType *>(this);
     }
--- a/js/src/methodjit/StubCalls.cpp
+++ b/js/src/methodjit/StubCalls.cpp
@@ -1001,17 +1001,17 @@ stubs::InitElem(VMFrame &f)
 
 void JS_FASTCALL
 stubs::RegExp(VMFrame &f, JSObject *regex)
 {
     /*
      * Push a regexp object cloned from the regexp literal object mapped by the
      * bytecode at pc.
      */
-    JSObject *proto = f.fp()->global().getOrCreateRegExpPrototype(f.cx);
+    RootedObject proto(f.cx, f.fp()->global().getOrCreateRegExpPrototype(f.cx));
     if (!proto)
         THROW();
     JS_ASSERT(proto);
     JSObject *obj = CloneRegExpObject(f.cx, regex, proto);
     if (!obj)
         THROW();
     f.regs.sp[0].setObject(*obj);
 }
--- a/js/src/shell/jsheaptools.cpp
+++ b/js/src/shell/jsheaptools.cpp
@@ -534,17 +534,17 @@ JSBool
 FindReferences(JSContext *cx, unsigned argc, jsval *vp)
 {
     if (argc < 1) {
         JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_MORE_ARGS_NEEDED,
                              "findReferences", "0", "s");
         return false;
     }
 
-    JS::Value target = JS_ARGV(cx, vp)[0];
+    RootedValue target(cx, JS_ARGV(cx, vp)[0]);
     if (!target.isObject()) {
         JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_UNEXPECTED_TYPE,
                              "argument", "not an object");
         return false;
     }
 
     /* Walk the JSRuntime, producing a reversed map of the heap. */
     HeapReverser reverser(cx);
--- a/js/src/vm/GlobalObject.cpp
+++ b/js/src/vm/GlobalObject.cpp
@@ -486,17 +486,18 @@ GlobalObject::isRuntimeCodeGenEnabled(JS
 {
     HeapSlot &v = global->getSlotRef(RUNTIME_CODEGEN_ENABLED);
     if (v.isUndefined()) {
         /*
          * If there are callbacks, make sure that the CSP callback is installed
          * and that it permits runtime code generation, then cache the result.
          */
         JSCSPEvalChecker allows = cx->runtime->securityCallbacks->contentSecurityPolicyAllows;
-        v.set(global, HeapSlot::Slot, RUNTIME_CODEGEN_ENABLED, BooleanValue(!allows || allows(cx)));
+        Value boolValue = BooleanValue(!allows || allows(cx));
+        v.set(global, HeapSlot::Slot, RUNTIME_CODEGEN_ENABLED, boolValue);
     }
     return !v.isFalse();
 }
 
 JSFunction *
 GlobalObject::createConstructor(JSContext *cx, Native ctor, JSAtom *nameArg, unsigned length,
                                 gc::AllocKind kind)
 {