Readd ctypes, xpconnect, plugin, xpinstall, canvas, and typed array changes from bug 548702.
authorJeff Walden <jwalden@mit.edu>
Mon, 29 Mar 2010 19:47:40 -0700
changeset 40402 797f224e76ccc6ed35b1099ac0daf7bd32b955f3
parent 40401 f3bb6aa1a412084e95621b59a476c407395768de
child 40403 cca4fef59a309f7c7d32a535c2de1b799478c867
push id12610
push userrsayre@mozilla.com
push dateMon, 05 Apr 2010 17:26:41 +0000
treeherdermozilla-central@1942c0b4e101 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs548702
milestone1.9.3a3pre
Readd ctypes, xpconnect, plugin, xpinstall, canvas, and typed array changes from bug 548702.
content/canvas/src/CustomQS_WebGL.h
js/ctypes/Function.cpp
js/src/jstypedarray.cpp
js/src/xpconnect/src/XPCChromeObjectWrapper.cpp
js/src/xpconnect/src/XPCCrossOriginWrapper.cpp
js/src/xpconnect/src/XPCNativeWrapper.cpp
js/src/xpconnect/src/XPCSystemOnlyWrapper.cpp
js/src/xpconnect/src/XPCWrapper.cpp
js/src/xpconnect/src/qsgen.py
js/src/xpconnect/src/xpcconvert.cpp
js/src/xpconnect/src/xpcquickstubs.cpp
js/src/xpconnect/src/xpcquickstubs.h
js/src/xpconnect/src/xpcwrappednativejsops.cpp
js/src/xpconnect/tests/TestXPC.cpp
modules/plugin/base/src/nsJSNPRuntime.cpp
modules/plugin/base/src/nsNPAPIPlugin.cpp
xpinstall/src/nsXPITriggerInfo.cpp
--- a/content/canvas/src/CustomQS_WebGL.h
+++ b/content/canvas/src/CustomQS_WebGL.h
@@ -63,17 +63,17 @@ nsICanvasRenderingContextWebGL_BufferDat
 {
     XPC_QS_ASSERT_CONTEXT_OK(cx);
     JSObject *obj = JS_THIS_OBJECT(cx, vp);
     if (!obj)
         return JS_FALSE;
 
     nsICanvasRenderingContextWebGL *self;
     xpc_qsSelfRef selfref;
-    JSAutoTempValueRooter tvr(cx);
+    js::AutoValueRooter tvr(cx);
     if (!xpc_qsUnwrapThis(cx, obj, nsnull, &self, &selfref.ptr, tvr.addr(), nsnull))
         return JS_FALSE;
 
     if (argc < 3)
         return xpc_qsThrow(cx, NS_ERROR_XPC_NOT_ENOUGH_ARGS);
 
     jsval *argv = JS_ARGV(cx, vp);
 
@@ -129,17 +129,17 @@ nsICanvasRenderingContextWebGL_BufferSub
 {
     XPC_QS_ASSERT_CONTEXT_OK(cx);
     JSObject *obj = JS_THIS_OBJECT(cx, vp);
     if (!obj)
         return JS_FALSE;
 
     nsICanvasRenderingContextWebGL *self;
     xpc_qsSelfRef selfref;
-    JSAutoTempValueRooter tvr(cx);
+    js::AutoValueRooter tvr(cx);
     if (!xpc_qsUnwrapThis(cx, obj, nsnull, &self, &selfref.ptr, tvr.addr(), nsnull))
         return JS_FALSE;
 
     if (argc < 3)
         return xpc_qsThrow(cx, NS_ERROR_XPC_NOT_ENOUGH_ARGS);
 
     jsval *argv = JS_ARGV(cx, vp);
 
@@ -199,17 +199,17 @@ nsICanvasRenderingContextWebGL_TexImage2
     JSObject *obj = JS_THIS_OBJECT(cx, vp);
     if (!obj)
         return JS_FALSE;
 
     nsresult rv;
 
     nsICanvasRenderingContextWebGL *self;
     xpc_qsSelfRef selfref;
-    JSAutoTempValueRooter tvr(cx);
+    js::AutoValueRooter tvr(cx);
     if (!xpc_qsUnwrapThis(cx, obj, nsnull, &self, &selfref.ptr, tvr.addr(), nsnull))
         return JS_FALSE;
 
     if (argc < 3)
         return xpc_qsThrow(cx, NS_ERROR_XPC_NOT_ENOUGH_ARGS);
 
     jsval *argv = JS_ARGV(cx, vp);
 
@@ -301,17 +301,17 @@ nsICanvasRenderingContextWebGL_TexSubIma
     JSObject *obj = JS_THIS_OBJECT(cx, vp);
     if (!obj)
         return JS_FALSE;
 
     nsresult rv;
 
     nsICanvasRenderingContextWebGL *self;
     xpc_qsSelfRef selfref;
-    JSAutoTempValueRooter tvr(cx);
+    js::AutoValueRooter tvr(cx);
     if (!xpc_qsUnwrapThis(cx, obj, nsnull, &self, &selfref.ptr, tvr.addr(), nsnull))
         return JS_FALSE;
 
     if (argc < 7 || (argc > 7 && argc < 9))
         return xpc_qsThrow(cx, NS_ERROR_XPC_NOT_ENOUGH_ARGS);
 
     jsval *argv = JS_ARGV(cx, vp);
 
@@ -402,17 +402,17 @@ helper_nsICanvasRenderingContextWebGL_Un
     JSObject *obj = JS_THIS_OBJECT(cx, vp);
     if (!obj)
         return JS_FALSE;
 
     nsresult rv;
 
     nsICanvasRenderingContextWebGL *self;
     xpc_qsSelfRef selfref;
-    JSAutoTempValueRooter tvr(cx);
+    js::AutoValueRooter tvr(cx);
     if (!xpc_qsUnwrapThis(cx, obj, nsnull, &self, &selfref.ptr, tvr.addr(), nsnull))
         return JS_FALSE;
 
     if (argc < 2)
         return xpc_qsThrow(cx, NS_ERROR_XPC_NOT_ENOUGH_ARGS);
 
     jsval *argv = JS_ARGV(cx, vp);
 
@@ -422,17 +422,17 @@ helper_nsICanvasRenderingContextWebGL_Un
 
     if (!JSVAL_IS_OBJECT(argv[1])) {
         xpc_qsThrowBadArg(cx, NS_ERROR_FAILURE, vp, 1);
         return JS_FALSE;
     }
 
     JSObject *arg1 = JSVAL_TO_OBJECT(argv[1]);
 
-    JSAutoTempValueRooter obj_tvr(cx);
+    js::AutoValueRooter obj_tvr(cx);
 
     js::TypedArray *wa = 0;
 
     if (helper_isInt32Array(arg1)) {
         wa = js::TypedArray::fromJSObject(arg1);
     }  else if (JS_IsArrayObject(cx, arg1)) {
         JSObject *nobj = js_CreateTypedArrayWithArray(cx, js::TypedArray::TYPE_INT32, arg1);
         if (!nobj) {
@@ -472,17 +472,17 @@ helper_nsICanvasRenderingContextWebGL_Un
     JSObject *obj = JS_THIS_OBJECT(cx, vp);
     if (!obj)
         return JS_FALSE;
 
     nsresult rv;
 
     nsICanvasRenderingContextWebGL *self;
     xpc_qsSelfRef selfref;
-    JSAutoTempValueRooter tvr(cx);
+    js::AutoValueRooter tvr(cx);
     if (!xpc_qsUnwrapThis(cx, obj, nsnull, &self, &selfref.ptr, tvr.addr(), nsnull))
         return JS_FALSE;
 
     if (argc < 2)
         return xpc_qsThrow(cx, NS_ERROR_XPC_NOT_ENOUGH_ARGS);
 
     jsval *argv = JS_ARGV(cx, vp);
 
@@ -492,17 +492,17 @@ helper_nsICanvasRenderingContextWebGL_Un
 
     if (!JSVAL_IS_OBJECT(argv[1])) {
         xpc_qsThrowBadArg(cx, NS_ERROR_FAILURE, vp, 1);
         return JS_FALSE;
     }
 
     JSObject *arg1 = JSVAL_TO_OBJECT(argv[1]);
 
-    JSAutoTempValueRooter obj_tvr(cx);
+    js::AutoValueRooter obj_tvr(cx);
 
     js::TypedArray *wa = 0;
 
     if (helper_isFloat32Array(arg1)) {
         wa = js::TypedArray::fromJSObject(arg1);
     }  else if (JS_IsArrayObject(cx, arg1)) {
         JSObject *nobj = js_CreateTypedArrayWithArray(cx, js::TypedArray::TYPE_FLOAT32, arg1);
         if (!nobj) {
@@ -542,17 +542,17 @@ helper_nsICanvasRenderingContextWebGL_Un
     JSObject *obj = JS_THIS_OBJECT(cx, vp);
     if (!obj)
         return JS_FALSE;
 
     nsresult rv;
 
     nsICanvasRenderingContextWebGL *self;
     xpc_qsSelfRef selfref;
-    JSAutoTempValueRooter tvr(cx);
+    js::AutoValueRooter tvr(cx);
     if (!xpc_qsUnwrapThis(cx, obj, nsnull, &self, &selfref.ptr, tvr.addr(), nsnull))
         return JS_FALSE;
 
     if (argc < 3)
         return xpc_qsThrow(cx, NS_ERROR_XPC_NOT_ENOUGH_ARGS);
 
     jsval *argv = JS_ARGV(cx, vp);
 
@@ -566,17 +566,17 @@ helper_nsICanvasRenderingContextWebGL_Un
 
     if (!JSVAL_IS_OBJECT(argv[2])) {
         xpc_qsThrowBadArg(cx, NS_ERROR_FAILURE, vp, 2);
         return JS_FALSE;
     }
 
     JSObject *arg2 = JSVAL_TO_OBJECT(argv[2]);
 
-    JSAutoTempValueRooter obj_tvr(cx);
+    js::AutoValueRooter obj_tvr(cx);
 
     js::TypedArray *wa = 0;
 
     if (helper_isFloat32Array(arg2)) {
         wa = js::TypedArray::fromJSObject(arg2);
     }  else if (JS_IsArrayObject(cx, arg2)) {
         JSObject *nobj = js_CreateTypedArrayWithArray(cx, js::TypedArray::TYPE_FLOAT32, arg2);
         if (!nobj) {
@@ -613,17 +613,17 @@ helper_nsICanvasRenderingContextWebGL_Ve
     JSObject *obj = JS_THIS_OBJECT(cx, vp);
     if (!obj)
         return JS_FALSE;
 
     nsresult rv;
 
     nsICanvasRenderingContextWebGL *self;
     xpc_qsSelfRef selfref;
-    JSAutoTempValueRooter tvr(cx);
+    js::AutoValueRooter tvr(cx);
     if (!xpc_qsUnwrapThis(cx, obj, nsnull, &self, &selfref.ptr, tvr.addr(), nsnull))
         return JS_FALSE;
 
     if (argc < 2)
         return xpc_qsThrow(cx, NS_ERROR_XPC_NOT_ENOUGH_ARGS);
 
     jsval *argv = JS_ARGV(cx, vp);
 
@@ -633,17 +633,17 @@ helper_nsICanvasRenderingContextWebGL_Ve
 
     if (!JSVAL_IS_OBJECT(argv[1])) {
         xpc_qsThrowBadArg(cx, NS_ERROR_FAILURE, vp, 1);
         return JS_FALSE;
     }
 
     JSObject *arg1 = JSVAL_TO_OBJECT(argv[1]);
 
-    JSAutoTempValueRooter obj_tvr(cx);
+    js::AutoValueRooter obj_tvr(cx);
 
     js::TypedArray *wa = 0;
 
     if (helper_isFloat32Array(arg1)) {
         wa = js::TypedArray::fromJSObject(arg1);
     }  else if (JS_IsArrayObject(cx, arg1)) {
         JSObject *nobj = js_CreateTypedArrayWithArray(cx, js::TypedArray::TYPE_FLOAT32, arg1);
         if (!nobj) {
@@ -775,17 +775,17 @@ helper_nsICanvasRenderingContextWebGL_Un
     nsICanvasRenderingContextWebGL *self;
     xpc_qsSelfRef selfref;
     xpc_qsArgValArray<3> vp(cx);
     if (!xpc_qsUnwrapThis(cx, obj, nsnull, &self, &selfref.ptr, &vp.array[0], nsnull)) {
         js_SetTraceableNativeFailed(cx);
         return JSVAL_VOID;
     }
 
-    JSAutoTempValueRooter obj_tvr(cx);
+    js::AutoValueRooter obj_tvr(cx);
 
     js::TypedArray *wa = 0;
 
     if (helper_isInt32Array(arg)) {
         wa = js::TypedArray::fromJSObject(arg);
     }  else if (JS_IsArrayObject(cx, arg)) {
         JSObject *nobj = js_CreateTypedArrayWithArray(cx, js::TypedArray::TYPE_INT32, arg);
         if (!nobj) {
@@ -830,17 +830,17 @@ helper_nsICanvasRenderingContextWebGL_Un
     nsICanvasRenderingContextWebGL *self;
     xpc_qsSelfRef selfref;
     xpc_qsArgValArray<3> vp(cx);
     if (!xpc_qsUnwrapThis(cx, obj, nsnull, &self, &selfref.ptr, &vp.array[0], nsnull)) {
         js_SetTraceableNativeFailed(cx);
         return JSVAL_VOID;
     }
 
-    JSAutoTempValueRooter obj_tvr(cx);
+    js::AutoValueRooter obj_tvr(cx);
 
     js::TypedArray *wa = 0;
 
     if (helper_isFloat32Array(arg)) {
         wa = js::TypedArray::fromJSObject(arg);
     }  else if (JS_IsArrayObject(cx, arg)) {
         JSObject *nobj = js_CreateTypedArrayWithArray(cx, js::TypedArray::TYPE_FLOAT32, arg);
         if (!nobj) {
@@ -885,17 +885,17 @@ helper_nsICanvasRenderingContextWebGL_Un
     nsICanvasRenderingContextWebGL *self;
     xpc_qsSelfRef selfref;
     xpc_qsArgValArray<4> vp(cx);
     if (!xpc_qsUnwrapThis(cx, obj, nsnull, &self, &selfref.ptr, &vp.array[0], nsnull)) {
         js_SetTraceableNativeFailed(cx);
         return JSVAL_VOID;
     }
 
-    JSAutoTempValueRooter obj_tvr(cx);
+    js::AutoValueRooter obj_tvr(cx);
 
     js::TypedArray *wa = 0;
 
     if (helper_isFloat32Array(arg)) {
         wa = js::TypedArray::fromJSObject(arg);
     }  else if (JS_IsArrayObject(cx, arg)) {
         JSObject *nobj = js_CreateTypedArrayWithArray(cx, js::TypedArray::TYPE_FLOAT32, arg);
         if (!nobj) {
--- a/js/ctypes/Function.cpp
+++ b/js/ctypes/Function.cpp
@@ -288,17 +288,17 @@ Function::Create(JSContext* aContext,
 
   // create and root the new JS function object
   JSFunction* fn = JS_NewFunction(aContext, JSNative(Function::Call),
                      aArgLength, JSFUN_FAST_NATIVE, NULL, aName);
   if (!fn)
     return NULL;
 
   JSObject* fnObj = JS_GetFunctionObject(fn);
-  JSAutoTempValueRooter fnRoot(aContext, fnObj);
+  js::AutoObjectRooter fnRoot(aContext, fnObj);
 
   // stash a pointer to self, which Function::Call will need at call time
   if (!JS_SetReservedSlot(aContext, fnObj, SLOT_FUNCTION, PRIVATE_TO_JSVAL(self.get())))
     return NULL;
 
   // make a strong reference to the library for GC-safety
   if (!JS_SetReservedSlot(aContext, fnObj, SLOT_LIBRARYOBJ, OBJECT_TO_JSVAL(aLibrary)))
     return NULL;
--- a/js/src/jstypedarray.cpp
+++ b/js/src/jstypedarray.cpp
@@ -1377,20 +1377,20 @@ js_IsTypedArray(JSObject *obj)
     return obj &&
            obj->getClass() >= &TypedArray::fastClasses[0] &&
            obj->getClass() <  &TypedArray::fastClasses[TypedArray::TYPE_MAX];
 }
 
 JS_FRIEND_API(JSObject *)
 js_CreateArrayBuffer(JSContext *cx, jsuint nbytes)
 {
-    JSAutoTempValueRooter tvr(cx);
+    AutoValueRooter tvr(cx);
     js_NewNumberInRootedValue(cx, jsdouble(nbytes), tvr.addr());
 
-    JSAutoTempValueRooter rval(cx);
+    AutoValueRooter rval(cx);
     if (!ArrayBuffer::class_constructor(cx, cx->globalObject,
                                         1, tvr.addr(), 
                                         rval.addr()))
         return NULL;
 
     return JSVAL_TO_OBJECT(rval.value());
 }
 
@@ -1432,34 +1432,34 @@ TypedArrayConstruct(JSContext *cx, jsint
 }
 
 JS_FRIEND_API(JSObject *)
 js_CreateTypedArray(JSContext *cx, jsint atype, jsuint nelements)
 {
     JS_ASSERT(atype >= 0 && atype < TypedArray::TYPE_MAX);
 
     jsval vals[2];
-    JSAutoTempValueRooter tvr(cx, 2, vals);
+    AutoArrayRooter tvr(cx, JS_ARRAY_LENGTH(vals), vals);
 
     if (!js_NewNumberInRootedValue(cx, jsdouble(nelements), &vals[0]))
         return NULL;
 
     if (!TypedArrayConstruct(cx, atype, 1, &vals[0], &vals[1]))
         return NULL;
 
     return JSVAL_TO_OBJECT(vals[1]);
 }
 
 JS_FRIEND_API(JSObject *)
 js_CreateTypedArrayWithArray(JSContext *cx, jsint atype, JSObject *arrayArg)
 {
     JS_ASSERT(atype >= 0 && atype < TypedArray::TYPE_MAX);
 
     jsval vals[2];
-    JSAutoTempValueRooter tvr(cx, 2, vals);
+    AutoArrayRooter tvr(cx, JS_ARRAY_LENGTH(vals), vals);
 
     vals[0] = OBJECT_TO_JSVAL(arrayArg);
 
     if (!TypedArrayConstruct(cx, atype, 1, &vals[0], &vals[1]))
         return NULL;
 
     return JSVAL_TO_OBJECT(vals[1]);
 }
@@ -1469,17 +1469,17 @@ js_CreateTypedArrayWithBuffer(JSContext 
                               jsint byteoffset, jsint length)
 {
     JS_ASSERT(atype >= 0 && atype < TypedArray::TYPE_MAX);
     JS_ASSERT(bufArg && ArrayBuffer::fromJSObject(bufArg));
     /* if byteoffset is -1, length must be -1 */
     JS_ASSERT(length < 0 || byteoffset >= 0);
 
     jsval vals[4];
-    JSAutoTempValueRooter tvr(cx, 4, vals);
+    AutoArrayRooter tvr(cx, JS_ARRAY_LENGTH(vals), vals);
 
     int argc = 1;
     vals[0] = OBJECT_TO_JSVAL(bufArg);
 
     if (byteoffset >= 0) {
         js_NewNumberInRootedValue(cx, jsdouble(byteoffset), &vals[1]);
         argc++;
     }
--- a/js/src/xpconnect/src/XPCChromeObjectWrapper.cpp
+++ b/js/src/xpconnect/src/XPCChromeObjectWrapper.cpp
@@ -35,17 +35,17 @@
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "xpcprivate.h"
 #include "nsDOMError.h"
 #include "jsdbgapi.h"
-#include "jscntxt.h"  // For JSAutoTempValueRooter.
+#include "jscntxt.h"  // For js::AutoValueRooter.
 #include "jsobj.h"
 #include "XPCNativeWrapper.h"
 #include "XPCWrapper.h"
 
 // This file implements a wrapper around trusted objects that allows them to
 // be safely injected into untrusted code.
 
 namespace {
@@ -278,27 +278,26 @@ WrapObject(JSContext *cx, JSObject *pare
   JSObject *wrapperObj =
     JS_NewObjectWithGivenProto(cx, &COWClass.base, NULL, parent);
   if (!wrapperObj) {
     return JS_FALSE;
   }
 
   *vp = OBJECT_TO_JSVAL(wrapperObj);
 
-  jsval exposedProps = JSVAL_VOID;
-  JSAutoTempValueRooter tvr(cx, 1, &exposedProps);
+  js::AutoValueRooter exposedProps(cx, JSVAL_VOID);
 
-  if (!GetExposedProperties(cx, JSVAL_TO_OBJECT(v), &exposedProps)) {
+  if (!GetExposedProperties(cx, JSVAL_TO_OBJECT(v), exposedProps.addr())) {
     return JS_FALSE;
   }
 
   if (!JS_SetReservedSlot(cx, wrapperObj, XPCWrapper::sWrappedObjSlot, v) ||
-      !JS_SetReservedSlot(cx, wrapperObj, XPCWrapper::sFlagsSlot,
-                          JSVAL_ZERO) ||
-      !JS_SetReservedSlot(cx, wrapperObj, sExposedPropsSlot, exposedProps)) {
+      !JS_SetReservedSlot(cx, wrapperObj, XPCWrapper::sFlagsSlot, JSVAL_ZERO) ||
+      !JS_SetReservedSlot(cx, wrapperObj, sExposedPropsSlot,
+                          exposedProps.value())) {
     return JS_FALSE;
   }
 
   return JS_TRUE;
 }
 
 } // namespace ChromeObjectWrapper
 
@@ -773,17 +772,17 @@ XPC_COW_Iterator(JSContext *cx, JSObject
   }
 
   JSObject *wrapperIter = JS_NewObject(cx, &COWClass.base, nsnull,
                                        JS_GetGlobalForObject(cx, obj));
   if (!wrapperIter) {
     return nsnull;
   }
 
-  JSAutoTempValueRooter tvr(cx, OBJECT_TO_JSVAL(wrapperIter));
+  js::AutoObjectRooter tvr(cx, wrapperIter);
 
   // Initialize our COW.
   jsval v = OBJECT_TO_JSVAL(wrappedObj);
   if (!JS_SetReservedSlot(cx, wrapperIter, XPCWrapper::sWrappedObjSlot, v) ||
       !JS_SetReservedSlot(cx, wrapperIter, XPCWrapper::sFlagsSlot,
                           JSVAL_ZERO)) {
     return nsnull;
   }
--- a/js/src/xpconnect/src/XPCCrossOriginWrapper.cpp
+++ b/js/src/xpconnect/src/XPCCrossOriginWrapper.cpp
@@ -35,17 +35,17 @@
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "xpcprivate.h"
 #include "nsDOMError.h"
 #include "jsdbgapi.h"
-#include "jscntxt.h"  // For JSAutoTempValueRooter.
+#include "jscntxt.h"  // For js::AutoValueRooter.
 #include "XPCWrapper.h"
 #include "nsIDOMWindow.h"
 #include "nsIDOMWindowCollection.h"
 
 // This file implements a wrapper around objects that allows them to be
 // accessed safely from across origins.
 
 static JSBool
@@ -825,17 +825,17 @@ GetUXPCObject(JSContext *cx, JSObject *o
   }
 
   JSObject *uxpco =
     JS_NewObjectWithGivenProto(cx, &XOWClass.base, nsnull, obj->getParent());
   if (!uxpco) {
     return nsnull;
   }
 
-  JSAutoTempValueRooter tvr(cx, uxpco);
+  js::AutoValueRooter tvr(cx, uxpco);
 
   jsval wrappedObj, parentScope;
   if (!JS_GetReservedSlot(cx, obj, sWrappedObjSlot, &wrappedObj) ||
       !JS_GetReservedSlot(cx, obj, XPC_XOW_ScopeSlot, &parentScope)) {
     return nsnull;
   }
 
   if (!JS_SetReservedSlot(cx, uxpco, sWrappedObjSlot, wrappedObj) ||
@@ -1201,17 +1201,17 @@ XPC_XOW_Iterator(JSContext *cx, JSObject
   }
 
   JSObject *wrapperIter = JS_NewObject(cx, &XOWClass.base, nsnull,
                                        JS_GetGlobalForObject(cx, obj));
   if (!wrapperIter) {
     return nsnull;
   }
 
-  JSAutoTempValueRooter tvr(cx, OBJECT_TO_JSVAL(wrapperIter));
+  js::AutoObjectRooter tvr(cx, wrapperIter);
 
   // Initialize our XOW.
   jsval v = OBJECT_TO_JSVAL(wrappedObj);
   if (!JS_SetReservedSlot(cx, wrapperIter, sWrappedObjSlot, v) ||
       !JS_SetReservedSlot(cx, wrapperIter, sFlagsSlot, JSVAL_ZERO) ||
       !JS_SetReservedSlot(cx, wrapperIter, XPC_XOW_ScopeSlot,
                           PRIVATE_TO_JSVAL(nsnull))) {
     return nsnull;
--- a/js/src/xpconnect/src/XPCNativeWrapper.cpp
+++ b/js/src/xpconnect/src/XPCNativeWrapper.cpp
@@ -1139,17 +1139,17 @@ XPC_NW_Iterator(JSContext *cx, JSObject 
 
   JSObject *wrapperIter =
     JS_NewObjectWithGivenProto(cx, XPCNativeWrapper::GetJSClass(false), nsnull,
                                obj->getParent());
   if (!wrapperIter) {
     return nsnull;
   }
 
-  JSAutoTempValueRooter tvr(cx, OBJECT_TO_JSVAL(wrapperIter));
+  js::AutoObjectRooter tvr(cx, wrapperIter);
 
   // Initialize our native wrapper.
   XPCWrappedNative *wn = static_cast<XPCWrappedNative *>(JS_GetPrivate(cx, obj));
   JS_SetPrivate(cx, wrapperIter, wn);
   if (!JS_SetReservedSlot(cx, wrapperIter, 0,
                           INT_TO_JSVAL(FLAG_DEEP | FLAG_EXPLICIT))) {
     return nsnull;
   }
--- a/js/src/xpconnect/src/XPCSystemOnlyWrapper.cpp
+++ b/js/src/xpconnect/src/XPCSystemOnlyWrapper.cpp
@@ -35,17 +35,17 @@
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "xpcprivate.h"
 #include "nsDOMError.h"
 #include "jsdbgapi.h"
-#include "jscntxt.h"  // For JSAutoTempValueRooter.
+#include "jscntxt.h"  // For js::AutoValueRooter.
 #include "XPCNativeWrapper.h"
 #include "XPCWrapper.h"
 
 // This file implements a wrapper around trusted objects that allows them to
 // be safely injected into untrusted code.
 
 static JSBool
 XPC_SOW_AddProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp);
@@ -132,17 +132,17 @@ WrapObject(JSContext *cx, JSObject *pare
 
   JSObject *wrapperObj =
     JS_NewObjectWithGivenProto(cx, &SOWClass.base, NULL, parent);
   if (!wrapperObj) {
     return JS_FALSE;
   }
 
   *vp = OBJECT_TO_JSVAL(wrapperObj);
-  JSAutoTempValueRooter tvr(cx, *vp);
+  js::AutoValueRooter tvr(cx, *vp);
 
   if (!JS_SetReservedSlot(cx, wrapperObj, sWrappedObjSlot, v) ||
       !JS_SetReservedSlot(cx, wrapperObj, sFlagsSlot, JSVAL_ZERO)) {
     return JS_FALSE;
   }
 
   return JS_TRUE;
 }
@@ -432,17 +432,17 @@ XPC_SOW_GetOrSetProperty(JSContext *cx, 
   if (!obj) {
     return ThrowException(NS_ERROR_ILLEGAL_VALUE, cx);
   }
 
   if (!AllowedToAct(cx, id)) {
     return JS_FALSE;
   }
 
-  JSAutoTempValueRooter tvr(cx, 1, vp);
+  js::AutoArrayRooter tvr(cx, 1, vp);
 
   JSObject *wrappedObj = GetWrappedObject(cx, obj);
   if (!wrappedObj) {
     return ThrowException(NS_ERROR_ILLEGAL_VALUE, cx);
   }
 
   if (isSet && id == GetRTStringByIndex(cx, XPCJSRuntime::IDX_PROTO)) {
     // No setting __proto__ on my object.
@@ -644,17 +644,17 @@ XPC_SOW_Iterator(JSContext *cx, JSObject
   }
 
   JSObject *wrapperIter = JS_NewObject(cx, &SOWClass.base, nsnull,
                                        JS_GetGlobalForObject(cx, obj));
   if (!wrapperIter) {
     return nsnull;
   }
 
-  JSAutoTempValueRooter tvr(cx, OBJECT_TO_JSVAL(wrapperIter));
+  js::AutoValueRooter tvr(cx, OBJECT_TO_JSVAL(wrapperIter));
 
   // Initialize our SOW.
   jsval v = OBJECT_TO_JSVAL(wrappedObj);
   if (!JS_SetReservedSlot(cx, wrapperIter, sWrappedObjSlot, v) ||
       !JS_SetReservedSlot(cx, wrapperIter, sFlagsSlot, JSVAL_ZERO)) {
     return nsnull;
   }
 
--- a/js/src/xpconnect/src/XPCWrapper.cpp
+++ b/js/src/xpconnect/src/XPCWrapper.cpp
@@ -148,18 +148,18 @@ IteratorNext(JSContext *cx, uintN argc, 
     jsval name;
     JSString *str;
     if (!JS_IdToValue(cx, id, &name) ||
         !(str = JS_ValueToString(cx, name))) {
       return JS_FALSE;
     }
 
     jsval vec[2] = { STRING_TO_JSVAL(str), v };
-    JSAutoTempValueRooter tvr(cx, 2, vec);
-    JSObject *array = JS_NewArrayObject(cx, 2, vec);
+    js::AutoArrayRooter tvr(cx, JS_ARRAY_LENGTH(vec), vec);
+    JSObject *array = JS_NewArrayObject(cx, JS_ARRAY_LENGTH(vec), vec);
     if (!array) {
       return JS_FALSE;
     }
 
     *vp = OBJECT_TO_JSVAL(array);
   }
 
   JS_SetReservedSlot(cx, obj, 1, INT_TO_JSVAL(idx));
@@ -187,17 +187,17 @@ CreateIteratorObj(JSContext *cx, JSObjec
   // identifiers with a next method, so we create an object that
   // delegates (via the __proto__ link) to the wrapper.
 
   JSObject *iterObj = JS_NewObject(cx, &IteratorClass, tempWrapper, wrapperObj);
   if (!iterObj) {
     return nsnull;
   }
 
-  JSAutoTempValueRooter tvr(cx, OBJECT_TO_JSVAL(iterObj));
+  js::AutoObjectRooter tvr(cx, iterObj);
 
   // Do this sooner rather than later to avoid complications in
   // IteratorFinalize.
   if (!JS_SetReservedSlot(cx, iterObj, 0, PRIVATE_TO_JSVAL(nsnull))) {
     return nsnull;
   }
 
   // Initialize iterObj.
@@ -208,17 +208,17 @@ CreateIteratorObj(JSContext *cx, JSObjec
 
   if (XPCNativeWrapper::IsNativeWrapper(wrapperObj)) {
     // For native wrappers, expandos on the wrapper itself aren't propagated
     // to the wrapped object, so we have to actually iterate the wrapper here.
     // In order to do so, we set the prototype of the iter to the wrapper,
     // call enumerate, and then re-set the prototype. As we do this, we have
     // to protec the temporary wrapper from garbage collection.
 
-    JSAutoTempValueRooter tvr(cx, tempWrapper);
+    js::AutoValueRooter tvr(cx, tempWrapper);
     if (!JS_SetPrototype(cx, iterObj, wrapperObj) ||
         !XPCWrapper::Enumerate(cx, iterObj, wrapperObj) ||
         !JS_SetPrototype(cx, iterObj, tempWrapper)) {
       return nsnull;
     }
   }
 
   // Start enumerating over all of our properties.
--- a/js/src/xpconnect/src/qsgen.py
+++ b/js/src/xpconnect/src/qsgen.py
@@ -830,17 +830,17 @@ def writeQuickStub(f, customMethodCalls,
         # which is vp[1]; and it's ok to overwrite it.
         f.write("    if (!xpc_qsUnwrapThisFromCcx(ccx, &self, &selfref.ptr, "
                 "&vp[1]))\n")
         f.write("        return JS_FALSE;\n")
     else:
         if isGetter:
             pthisval = 'vp'
         elif isSetter:
-            f.write("    JSAutoTempValueRooter tvr(cx);\n")
+            f.write("    js::AutoValueRooter tvr(cx);\n")
             pthisval = 'tvr.addr()'
         else:
             pthisval = '&vp[1]' # as above, ok to overwrite vp[1]
 
         if not isSetter and isInterfaceType(member.realtype):
             f.write("    XPCLazyCallContext lccx(JS_CALLER, cx, obj);\n")
             f.write("    if (!xpc_qsUnwrapThis(cx, obj, callee, &self, "
                     "&selfref.ptr, %s, &lccx))\n" % pthisval)
--- a/js/src/xpconnect/src/xpcconvert.cpp
+++ b/js/src/xpconnect/src/xpcconvert.cpp
@@ -1577,33 +1577,33 @@ XPCConvert::ConstructException(nsresult 
 
     if(sz)
         JS_smprintf_free(sz);
     return res;
 }
 
 /********************************/
 
-class AutoExceptionRestorer : public JSAutoTempValueRooter
+class AutoExceptionRestorer
 {
 public:
     AutoExceptionRestorer(JSContext *cx, jsval v)
-        : JSAutoTempValueRooter(cx, v),
-          mVal(v)
+        : mContext(cx), tvr(cx, v)
     {
         JS_ClearPendingException(mContext);
     }
 
     ~AutoExceptionRestorer()
     {
-        JS_SetPendingException(mContext, mVal);
+        JS_SetPendingException(mContext, tvr.value());
     }
 
 private:
-    jsval mVal;
+    JSContext * const mContext;
+    js::AutoValueRooter tvr;
 };
 
 // static
 nsresult
 XPCConvert::JSValToXPCException(XPCCallContext& ccx,
                                 jsval s,
                                 const char* ifaceName,
                                 const char* methodName,
--- a/js/src/xpconnect/src/xpcquickstubs.cpp
+++ b/js/src/xpconnect/src/xpcquickstubs.cpp
@@ -168,17 +168,17 @@ GeneratePropertyOp(JSContext *cx, JSObje
     JSFunction *fun =
         JS_NewFunction(cx, reinterpret_cast<JSNative>(PropertyOpForwarder),
                        argc, JSFUN_FAST_NATIVE, obj, name);
     if(!fun)
         return JS_FALSE;
 
     JSObject *funobj = JS_GetFunctionObject(fun);
 
-    JSAutoTempValueRooter tvr(cx, OBJECT_TO_JSVAL(funobj));
+    js::AutoObjectRooter tvr(cx, funobj);
 
     // Unfortunately, we cannot guarantee that JSPropertyOp is aligned. Use a
     // second object to work around this.
     JSObject *ptrobj = JS_NewObject(cx, &PointerHolderClass, nsnull, funobj);
     if(!ptrobj)
         return JS_FALSE;
     JSPropertyOp *popp = new JSPropertyOp;
     if(!popp)
@@ -193,17 +193,17 @@ GeneratePropertyOp(JSContext *cx, JSObje
 
 static JSBool
 ReifyPropertyOps(JSContext *cx, JSObject *obj, jsval idval, jsid interned_id,
                  const char *name, JSPropertyOp getter, JSPropertyOp setter,
                  JSObject **getterobjp, JSObject **setterobjp)
 {
     // Generate both getter and setter and stash them in the prototype.
     jsval roots[2] = { JSVAL_NULL, JSVAL_NULL };
-    JSAutoTempValueRooter tvr(cx, 2, roots);
+    js::AutoArrayRooter tvr(cx, JS_ARRAY_LENGTH(roots), roots);
 
     uintN attrs = JSPROP_SHARED;
     JSObject *getterobj;
     if(getter)
     {
         getterobj = GeneratePropertyOp(cx, obj, idval, 0, name, getter);
         if(!getterobj)
             return JS_FALSE;
--- a/js/src/xpconnect/src/xpcquickstubs.h
+++ b/js/src/xpconnect/src/xpcquickstubs.h
@@ -316,17 +316,17 @@ struct xpc_qsSelfRef
 template<size_t N>
 struct xpc_qsArgValArray
 {
     xpc_qsArgValArray(JSContext *cx) : tvr(cx, N, array)
     {
         memset(array, 0, N * sizeof(jsval));
     }
 
-    JSAutoTempValueRooter tvr;
+    js::AutoArrayRooter tvr;
     jsval array[N];
 };
 
 /**
  * Convert a jsval to char*, returning JS_TRUE on success.
  *
  * @param cx
  *      A context.
--- a/js/src/xpconnect/src/xpcwrappednativejsops.cpp
+++ b/js/src/xpconnect/src/xpcwrappednativejsops.cpp
@@ -1512,43 +1512,42 @@ XPC_WN_JSOp_ThisObject(JSContext *cx, JS
     {
         XPCThrower::Throw(NS_ERROR_FAILURE, cx);
         return nsnull;
     }
 
     JSStackFrame *fp;
     nsIPrincipal *principal = secMan->GetCxSubjectPrincipalAndFrame(cx, &fp);
 
-    jsval retval = OBJECT_TO_JSVAL(obj);
-    JSAutoTempValueRooter atvr(cx, 1, &retval);
+    js::AutoValueRooter retval(cx, obj);
 
     if(principal && fp)
     {
         JSScript* script = JS_GetFrameScript(cx, fp);
 
         PRUint32 flags = script ? JS_GetScriptFilenameFlags(script) : 0;
         NS_ASSERTION(flags != JSFILENAME_NULL, "Null filename!");
 
         nsXPConnect *xpc = nsXPConnect::GetXPConnect();
         if(!xpc)
         {
             XPCThrower::Throw(NS_ERROR_FAILURE, cx);
             return nsnull;
         }
 
         nsresult rv = xpc->GetWrapperForObject(cx, obj, scope, principal, flags,
-                                               &retval);
+                                               retval.addr());
         if(NS_FAILED(rv))
         {
             XPCThrower::Throw(rv, cx);
             return nsnull;
         }
     }
 
-    return JSVAL_TO_OBJECT(retval);
+    return JSVAL_TO_OBJECT(retval.value());
 }
 
 JSObjectOps *
 XPC_WN_GetObjectOpsNoCall(JSContext *cx, JSClass *clazz)
 {
     return &XPC_WN_NoCall_JSOps;
 }
 
--- a/js/src/xpconnect/tests/TestXPC.cpp
+++ b/js/src/xpconnect/tests/TestXPC.cpp
@@ -557,17 +557,17 @@ TestArgFormatter(JSContext* jscontext, J
         return;
     }
 
     do {
         JSAutoRequest ar(jscontext);
 
         // Prepare an array of arguments for JS_ConvertArguments
         jsval argv[5];
-        JSAutoTempValueRooter tvr(jscontext, 5, argv);
+        js::AutoArrayRooter tvr(jscontext, JS_ARRAY_LENGTH(argv), argv);
 
         if (!PushArguments(jscontext, 5, argv,
                            "s %ip %iv %is s",
                            a_in,
                            &NS_GET_IID(nsITestXPCFoo2), b_in.get(),
                            c_in.get(),
                            static_cast<const nsAString*>(&d_in),
                            e_in))
--- a/modules/plugin/base/src/nsJSNPRuntime.cpp
+++ b/modules/plugin/base/src/nsJSNPRuntime.cpp
@@ -668,46 +668,46 @@ doInvoke(NPObject *npobj, NPIdentifier m
     jsargs = (jsval *)PR_Malloc(argCount * sizeof(jsval));
     if (!jsargs) {
       ::JS_ReportOutOfMemory(cx);
 
       return PR_FALSE;
     }
   }
 
-  JSTempValueRooter tvr;
-  JS_PUSH_TEMP_ROOT(cx, 0, jsargs, &tvr);
-
-  // Convert args
-  for (PRUint32 i = 0; i < argCount; ++i) {
-    jsargs[i] = NPVariantToJSVal(npp, cx, args + i);
-    ++tvr.count;
-  }
-
   jsval v;
   JSBool ok;
 
-  if (ctorCall) {
-    JSObject *global = ::JS_GetGlobalForObject(cx, npjsobj->mJSObj);
-    JSObject *newObj =
-      ::JS_ConstructObjectWithArguments(cx, JS_GET_CLASS(cx, npjsobj->mJSObj),
-                                        nsnull, global, argCount, jsargs);
-
-    if (newObj) {
-      v = OBJECT_TO_JSVAL(newObj);
-      ok = JS_TRUE;
+  {
+    js::AutoArrayRooter tvr(cx, 0, jsargs);
+
+    // Convert args
+    for (PRUint32 i = 0; i < argCount; ++i) {
+      jsargs[i] = NPVariantToJSVal(npp, cx, args + i);
+      tvr.changeLength(i + 1);
+    }
+
+    if (ctorCall) {
+      JSObject *global = ::JS_GetGlobalForObject(cx, npjsobj->mJSObj);
+      JSObject *newObj =
+        ::JS_ConstructObjectWithArguments(cx, JS_GET_CLASS(cx, npjsobj->mJSObj),
+                                          nsnull, global, argCount, jsargs);
+
+      if (newObj) {
+        v = OBJECT_TO_JSVAL(newObj);
+        ok = JS_TRUE;
+      } else {
+        ok = JS_FALSE;
+      }
     } else {
-      ok = JS_FALSE;
+      ok = ::JS_CallFunctionValue(cx, npjsobj->mJSObj, fv, argCount, jsargs, &v);
     }
-  } else {
-    ok = ::JS_CallFunctionValue(cx, npjsobj->mJSObj, fv, argCount, jsargs, &v);
+
   }
 
-  JS_POP_TEMP_ROOT(cx, &tvr);
-
   if (jsargs != jsargs_buf)
     PR_Free(jsargs);
 
   if (ok)
     ok = JSValToNPVariant(npp, cx, v, result);
 
   // return ok == JS_TRUE to quiet down compiler warning, even if
   // return ok is what we really want.
@@ -832,17 +832,17 @@ nsJSObjWrapper::NP_SetProperty(NPObject 
   jsval id = (jsval)identifier;
   JSBool ok = JS_FALSE;
 
   AutoCXPusher pusher(cx);
   JSAutoRequest ar(cx);
   AutoJSExceptionReporter reporter(cx);
 
   jsval v = NPVariantToJSVal(npp, cx, value);
-  JSAutoTempValueRooter tvr(cx, v);
+  js::AutoValueRooter tvr(cx, v);
 
   if (JSVAL_IS_STRING(id)) {
     JSString *str = JSVAL_TO_STRING(id);
 
     ok = ::JS_SetUCProperty(cx, npjsobj->mJSObj, ::JS_GetStringChars(str),
                             ::JS_GetStringLength(str), &v);
   } else {
     NS_ASSERTION(JSVAL_IS_INT(id), "id must be either string or int!\n");
--- a/modules/plugin/base/src/nsNPAPIPlugin.cpp
+++ b/modules/plugin/base/src/nsNPAPIPlugin.cpp
@@ -1693,17 +1693,17 @@ bool NP_CALLBACK
     nsNPObjWrapper::GetNewOrUsed(npp, cx, npobj);
 
   if (!obj) {
     return false;
   }
 
   // Root obj and the rval (below).
   jsval vec[] = { OBJECT_TO_JSVAL(obj), JSVAL_NULL };
-  JSAutoTempValueRooter tvr(cx, NS_ARRAY_LENGTH(vec), vec);
+  js::AutoArrayRooter tvr(cx, NS_ARRAY_LENGTH(vec), vec);
   jsval *rval = &vec[1];
 
   if (result) {
     // Initialize the out param to void
     VOID_TO_NPVARIANT(*result);
   }
 
   if (!script || !script->UTF8Length || !script->UTF8Characters) {
--- a/xpinstall/src/nsXPITriggerInfo.cpp
+++ b/xpinstall/src/nsXPITriggerInfo.cpp
@@ -242,17 +242,17 @@ XPITriggerEvent::Run()
     JSObject* innerGlobal = JS_GetGlobalForObject(cx, JSVAL_TO_OBJECT(cbval));
     jsval components;
     if (!JS_LookupProperty(cx, innerGlobal, "Components", &components) ||
         !JSVAL_IS_OBJECT(components))
         return 0;
 
     // Build arguments into rooted jsval array
     jsval args[2] = { JSVAL_NULL, JSVAL_NULL };
-    JSAutoTempValueRooter tvr(cx, JS_ARRAY_LENGTH(args), args);
+    js::AutoArrayRooter tvr(cx, JS_ARRAY_LENGTH(args), args);
 
     // args[0] is the URL
     JSString *str = JS_NewUCStringCopyZ(cx, reinterpret_cast<const jschar*>(URL.get()));
     if (!str)
         return 0;
     args[0] = STRING_TO_JSVAL(str);
 
     // args[1] is the status