Make JSHasInstanceOp and JSEqualityOp take jsval. Get a lot of xpconnect compiling
authorLuke Wagner <lw@mozilla.com>
Fri, 04 Jun 2010 16:55:08 -0700
changeset 52698 a49a04a4de0b7ab60b002f2123b9b8ce71e1cec1
parent 52683 e4c9a1ef9c8633d6939d2f6dd0982ddb13bd894a
child 52699 7eaa67f17657e2dc5f0b6e830e3bcc0a9bb68631
child 52701 215ec672df104c419b38e2b16f69e16cbcff9cd3
child 52748 780169bc95cc32798e500c1d4333f040186ad30c
push idunknown
push userunknown
push dateunknown
milestone1.9.3a5pre
Make JSHasInstanceOp and JSEqualityOp take jsval. Get a lot of xpconnect compiling
content/base/public/nsContentUtils.h
content/base/src/nsContentUtils.cpp
content/canvas/src/NativeJSContext.cpp
content/canvas/src/NativeJSContext.h
js/jsd/jsd_val.c
js/src/jsapi-tests/testExtendedEq.cpp
js/src/jsapi.cpp
js/src/jsapi.h
js/src/jsdbgapi.h
js/src/jsfun.cpp
js/src/jsgc.cpp
js/src/jsgc.h
js/src/jsiter.cpp
js/src/jsobj.cpp
js/src/jsobj.h
js/src/jsops.cpp
js/src/jsprvtd.h
js/src/jspubtd.h
js/src/jsxml.cpp
js/src/shell/js.cpp
js/src/xpconnect/loader/mozJSComponentLoader.cpp
js/src/xpconnect/loader/mozJSComponentLoader.h
js/src/xpconnect/public/nsAutoJSValHolder.h
js/src/xpconnect/src/XPCNativeWrapper.h
js/src/xpconnect/src/XPCWrapper.h
js/src/xpconnect/src/nsXPConnect.cpp
js/src/xpconnect/src/xpccomponents.cpp
js/src/xpconnect/src/xpcconvert.cpp
js/src/xpconnect/src/xpcinlines.h
js/src/xpconnect/src/xpcprivate.h
js/src/xpconnect/src/xpcstring.cpp
js/src/xpconnect/src/xpcvariant.cpp
js/src/xpconnect/src/xpcwrappedjsclass.cpp
js/src/xpconnect/src/xpcwrappednative.cpp
js/src/xpconnect/src/xpcwrappednativejsops.cpp
modules/plugin/base/src/nsJSNPRuntime.cpp
security/manager/ssl/src/nsCrypto.cpp
xpinstall/src/nsXPITriggerInfo.cpp
--- a/content/base/public/nsContentUtils.h
+++ b/content/base/public/nsContentUtils.h
@@ -1731,56 +1731,49 @@ private:
 #endif
 };
 
 class NS_STACK_CLASS nsAutoGCRoot {
 public:
   // aPtr should be the pointer to the jsval we want to protect
   nsAutoGCRoot(jsval* aPtr, nsresult* aResult
                MOZILLA_GUARD_OBJECT_NOTIFIER_PARAM) :
-    mPtr(aPtr)
+    mPtr(aPtr), mRootType(RootType_JSVal)
   {
     MOZILLA_GUARD_OBJECT_NOTIFIER_INIT;
-    mResult = *aResult = AddJSGCRoot(aPtr, "nsAutoGCRoot");
+    mResult = *aResult = AddJSGCRoot(aPtr, RootType_JSVal, "nsAutoGCRoot");
   }
 
   // aPtr should be the pointer to the JSObject* we want to protect
   nsAutoGCRoot(JSObject** aPtr, nsresult* aResult
                MOZILLA_GUARD_OBJECT_NOTIFIER_PARAM) :
-    mPtr(aPtr)
+    mPtr(aPtr), mRootType(RootType_Object)
   {
     MOZILLA_GUARD_OBJECT_NOTIFIER_INIT;
-    mResult = *aResult = AddJSGCRoot(aPtr, "nsAutoGCRoot");
-  }
-
-  // aPtr should be the pointer to the thing we want to protect
-  nsAutoGCRoot(void* aPtr, nsresult* aResult
-               MOZILLA_GUARD_OBJECT_NOTIFIER_PARAM) :
-    mPtr(aPtr)
-  {
-    MOZILLA_GUARD_OBJECT_NOTIFIER_INIT;
-    mResult = *aResult = AddJSGCRoot(aPtr, "nsAutoGCRoot");
+    mResult = *aResult = AddJSGCRoot(aPtr, RootType_Object, "nsAutoGCRoot");
   }
 
   ~nsAutoGCRoot() {
     if (NS_SUCCEEDED(mResult)) {
-      RemoveJSGCRoot(mPtr);
+      RemoveJSGCRoot((jsval *)mPtr, mRootType);
     }
   }
 
   static void Shutdown();
 
 private:
-  static nsresult AddJSGCRoot(void *aPtr, const char* aName);
-  static nsresult RemoveJSGCRoot(void *aPtr);
+  enum RootType { RootType_JSVal, RootType_Object };
+  static nsresult AddJSGCRoot(void *aPtr, RootType aRootType, const char* aName);
+  static nsresult RemoveJSGCRoot(void *aPtr, RootType aRootType);
 
   static nsIJSRuntimeService* sJSRuntimeService;
   static JSRuntime* sJSScriptRuntime;
 
   void* mPtr;
+  RootType mRootType;
   nsresult mResult;
   MOZILLA_DECL_USE_GUARD_OBJECT_NOTIFIER
 };
 
 class NS_STACK_CLASS nsAutoScriptBlocker {
 public:
   nsAutoScriptBlocker(MOZILLA_GUARD_OBJECT_NOTIFIER_ONLY_PARAM) {
     MOZILLA_GUARD_OBJECT_NOTIFIER_INIT;
--- a/content/base/src/nsContentUtils.cpp
+++ b/content/base/src/nsContentUtils.cpp
@@ -3194,51 +3194,57 @@ nsContentUtils::GetContentPolicy()
     sTriedToGetContentPolicy = PR_TRUE;
   }
 
   return sContentPolicyService;
 }
 
 // static
 nsresult
-nsAutoGCRoot::AddJSGCRoot(void* aPtr, const char* aName)
+nsAutoGCRoot::AddJSGCRoot(void* aPtr, RootType aRootType, const char* aName)
 {
   if (!sJSScriptRuntime) {
     nsresult rv = CallGetService("@mozilla.org/js/xpc/RuntimeService;1",
                                  &sJSRuntimeService);
     NS_ENSURE_TRUE(sJSRuntimeService, rv);
 
     sJSRuntimeService->GetRuntime(&sJSScriptRuntime);
     if (!sJSScriptRuntime) {
       NS_RELEASE(sJSRuntimeService);
       NS_WARNING("Unable to get JS runtime from JS runtime service");
       return NS_ERROR_FAILURE;
     }
   }
 
   PRBool ok;
-  ok = ::JS_AddNamedRootRT(sJSScriptRuntime, aPtr, aName);
+  if (aRootType == RootType_JSVal)
+    ok = ::js_AddRootRT(sJSScriptRuntime, (jsval *)aPtr, aName);
+  else
+    ok = ::js_AddGCThingRootRT(sJSScriptRuntime, (void **)aPtr, aName);
   if (!ok) {
     NS_WARNING("JS_AddNamedRootRT failed");
     return NS_ERROR_OUT_OF_MEMORY;
   }
 
   return NS_OK;
 }
 
 /* static */
 nsresult
-nsAutoGCRoot::RemoveJSGCRoot(void* aPtr)
+nsAutoGCRoot::RemoveJSGCRoot(void* aPtr, RootType aRootType)
 {
   if (!sJSScriptRuntime) {
     NS_NOTREACHED("Trying to remove a JS GC root when none were added");
     return NS_ERROR_UNEXPECTED;
   }
 
-  ::JS_RemoveRootRT(sJSScriptRuntime, aPtr);
+  if (aRootType == RootType_JSVal)
+    ::js_RemoveRoot(sJSScriptRuntime, (jsval *)aPtr);
+  else
+    ::js_RemoveRoot(sJSScriptRuntime, (JSObject **)aPtr);
 
   return NS_OK;
 }
 
 // static
 PRBool
 nsContentUtils::IsEventAttributeName(nsIAtom* aName, PRInt32 aType)
 {
--- a/content/canvas/src/NativeJSContext.cpp
+++ b/content/canvas/src/NativeJSContext.cpp
@@ -1,38 +1,19 @@
 #include "NativeJSContext.h"
 #include "nsServiceManagerUtils.h"
 #include "nsIJSRuntimeService.h"
 
-nsIJSRuntimeService* NativeJSContext::sJSRuntimeService = 0;
-JSRuntime* NativeJSContext::sJSScriptRuntime = 0;
-
 PRBool
 NativeJSContext::AddGCRoot(void *aPtr, const char *aName)
 {
-  if (!sJSScriptRuntime) {
-    nsresult rv = CallGetService("@mozilla.org/js/xpc/RuntimeService;1",
-                                 &sJSRuntimeService);
-    NS_ENSURE_SUCCESS(rv, PR_FALSE);
-    NS_ABORT_IF_FALSE(sJSRuntimeService, "CallGetService succeeded but returned a null pointer?");
-
-    sJSRuntimeService->GetRuntime(&sJSScriptRuntime);
-    if (!sJSScriptRuntime) {
-      NS_RELEASE(sJSRuntimeService);
-      NS_WARNING("Unable to get JS runtime from JS runtime service");
-      return PR_FALSE;
-    }
-  }
+  NS_ASSERTION(NS_SUCCEEDED(error), "class failed to initialize and caller used class without checking!");
 
   PRBool ok;
-  return ok = ::JS_AddNamedRootRT(sJSScriptRuntime, aPtr, aName);
+  return ok = ::JS_AddNamedObjectRoot(ctx, aPtr, aName);
 }
 
 void
-NativeJSContext::ReleaseGCRoot(void *aPtr)
+NativeJSContext::ReleaseGCRoot(JSObject **aPtr)
 {
-  if (!sJSScriptRuntime) {
-    NS_NOTREACHED("Trying to remove a JS GC root when none were added");
-    return;
-  }
-
-  ::JS_RemoveRootRT(sJSScriptRuntime, aPtr);
+  NS_ASSERTION(NS_SUCCEEDED(error), "class failed to initialize and caller used class without checking!");
+  ::JS_RemoveObjectRoot(ctx, aPtr);
 }
--- a/content/canvas/src/NativeJSContext.h
+++ b/content/canvas/src/NativeJSContext.h
@@ -168,19 +168,16 @@ public:
     void SetRetVal (JSObjectHelper& objh);
 
     nsAXPCNativeCallContext *ncc;
     nsresult error;
     JSContext *ctx;
     PRUint32 argc;
     jsval *argv;
 
-    static nsIJSRuntimeService* sJSRuntimeService;
-    static JSRuntime* sJSScriptRuntime;
-
 public:
     // static JS helpers
 
     static inline PRBool JSValToFloatArray (JSContext *ctx, jsval val,
                                             jsuint cnt, float *array)
     {
         JSObject *arrayObj;
         jsuint arrayLen;
--- a/js/jsd/jsd_val.c
+++ b/js/jsd/jsd_val.c
@@ -225,17 +225,17 @@ jsd_GetValueString(JSDContext* jsdc, JSD
         else
         {
             JS_BeginRequest(cx);
             exceptionState = JS_SaveExceptionState(cx);
             jsdval->string = JS_ValueToString(cx, jsdval->val);
             JS_RestoreExceptionState(cx, exceptionState);
             if(jsdval->string)
             {
-                if(!JS_AddNamedRoot(cx, &jsdval->string, "ValueString"))
+                if(!JS_AddNamedStringRoot(cx, &jsdval->string, "ValueString"))
                     jsdval->string = NULL;
             }
             JS_EndRequest(cx);
         }
     }
     return jsdval->string;
 }
 
@@ -269,17 +269,17 @@ jsd_NewValue(JSDContext* jsdc, jsval val
 
     if(!(jsdval = (JSDValue*) calloc(1, sizeof(JSDValue))))
         return NULL;
 
     if(JSVAL_IS_GCTHING(val))
     {
         JSBool ok = JS_FALSE;
         JS_BeginRequest(jsdc->dumbContext);
-        ok = JS_AddNamedRoot(jsdc->dumbContext, &jsdval->val, "JSDValue");
+        ok = JS_AddNamedValueRoot(jsdc->dumbContext, &jsdval->val, "JSDValue");
         JS_EndRequest(jsdc->dumbContext);
         if(!ok)
         {
             free(jsdval);
             return NULL;
         }
     }
     jsdval->val  = val;
@@ -294,17 +294,17 @@ jsd_DropValue(JSDContext* jsdc, JSDValue
 {
     JS_ASSERT(jsdval->nref > 0);
     if(0 == --jsdval->nref)
     {
         jsd_RefreshValue(jsdc, jsdval);
         if(JSVAL_IS_GCTHING(jsdval->val))
         {
             JS_BeginRequest(jsdc->dumbContext);
-            JS_RemoveRoot(jsdc->dumbContext, &jsdval->val);
+            JS_RemoveValueRoot(jsdc->dumbContext, &jsdval->val);
             JS_EndRequest(jsdc->dumbContext);
         }
         free(jsdval);
     }
 }
 
 jsval
 jsd_GetValueWrappedJSVal(JSDContext* jsdc, JSDValue* jsdval)
@@ -416,17 +416,17 @@ jsd_RefreshValue(JSDContext* jsdc, JSDVa
     JSContext* cx = jsdc->dumbContext;
 
     if(jsdval->string)
     {
         /* if the jsval is a string, then we didn't need to root the string */
         if(!JSVAL_IS_STRING(jsdval->val))
         {
             JS_BeginRequest(cx);
-            JS_RemoveRoot(cx, &jsdval->string);
+            JS_RemoveStringRoot(cx, &jsdval->string);
             JS_EndRequest(cx);
         }
         jsdval->string = NULL;
     }
 
     jsdval->funName = NULL;
     jsdval->className = NULL;
     DROP_CLEAR_VALUE(jsdc, jsdval->proto);
--- a/js/src/jsapi-tests/testExtendedEq.cpp
+++ b/js/src/jsapi-tests/testExtendedEq.cpp
@@ -3,17 +3,17 @@
  *
  * This tests user-specified (via JSExtendedClass) equality operations on
  * trace.
  */
 
 #include "tests.h"
 
 static JSBool
-my_Equality(JSContext *cx, JSObject *obj, const jsval *vp, JSBool *bp)
+my_Equality(JSContext *cx, JSObject *obj, jsval, JSBool *bp)
 {
     *bp = JS_TRUE;
     return JS_TRUE;
 }
 
 JSExtendedClass TestExtendedEq_JSClass = {
     { "TestExtendedEq",
         JSCLASS_IS_EXTENDED,
--- a/js/src/jsapi.cpp
+++ b/js/src/jsapi.cpp
@@ -1708,16 +1708,23 @@ JS_AddStringRoot(JSContext *cx, JSString
 JS_PUBLIC_API(JSBool)
 JS_AddObjectRoot(JSContext *cx, JSObject **rp)
 {
     CHECK_REQUEST(cx);
     return js_AddGCThingRoot(cx, (void **)rp, NULL);
 }
 
 JS_PUBLIC_API(JSBool)
+JS_AddGCThingRoot(JSContext *cx, void **rp)
+{
+    CHECK_REQUEST(cx);
+    return js_AddGCThingRoot(cx, (void **)rp, NULL);
+}
+
+JS_PUBLIC_API(JSBool)
 JS_AddNamedValueRoot(JSContext *cx, jsval *vp, const char *name)
 {
     CHECK_REQUEST(cx);
     return js_AddRoot(cx, Valueify(vp), name);
 }
 
 JS_PUBLIC_API(JSBool)
 JS_AddNamedStringRoot(JSContext *cx, JSString **rp, const char *name)
@@ -1729,31 +1736,20 @@ JS_AddNamedStringRoot(JSContext *cx, JSS
 JS_PUBLIC_API(JSBool)
 JS_AddNamedObjectRoot(JSContext *cx, JSObject **rp, const char *name)
 {
     CHECK_REQUEST(cx);
     return js_AddGCThingRoot(cx, (void **)rp, name);
 }
 
 JS_PUBLIC_API(JSBool)
-JS_AddNamedValueRootRT(JSRuntime *rt, jsval *vp, const char *name)
-{
-    return js_AddRootRT(rt, Valueify(vp), name);
-}
-
-JS_PUBLIC_API(JSBool)
-JS_AddNamedStringRootRT(JSRuntime *rt, JSString **rp, const char *name)
-{
-    return js_AddGCThingRootRT(rt, (void **)rp, name);
-}
-
-JS_PUBLIC_API(JSBool)
-JS_AddNamedObjectRootRT(JSRuntime *rt, JSObject **rp, const char *name)
-{
-    return js_AddGCThingRootRT(rt, (void **)rp, name);
+JS_AddNamedGCThingRoot(JSContext *cx, void **rp, const char *name)
+{
+    CHECK_REQUEST(cx);
+    return js_AddGCThingRoot(cx, (void **)rp, name);
 }
 
 JS_PUBLIC_API(JSBool)
 JS_RemoveValueRoot(JSContext *cx, jsval *vp)
 {
     CHECK_REQUEST(cx);
     return js_RemoveRoot(cx->runtime, (void *)vp);
 }
@@ -1768,31 +1764,20 @@ JS_RemoveStringRoot(JSContext *cx, JSStr
 JS_PUBLIC_API(JSBool)
 JS_RemoveObjectRoot(JSContext *cx, JSObject **rp)
 {
     CHECK_REQUEST(cx);
     return js_RemoveRoot(cx->runtime, (void *)rp);
 }
 
 JS_PUBLIC_API(JSBool)
-JS_RemoveValueRootRT(JSRuntime *rt, jsval *vp)
-{
-    return js_RemoveRoot(rt, (void *)vp);
-}
-
-JS_PUBLIC_API(JSBool)
-JS_RemoveStringRootRT(JSRuntime *rt, JSString **rp)
-{
-    return js_RemoveRoot(rt, (void *)rp);
-}
-
-JS_PUBLIC_API(JSBool)
-JS_RemoveObjectRootRT(JSRuntime *rt, JSObject **rp)
-{
-    return js_RemoveRoot(rt, (void *)rp);
+JS_RemoveGCThingRoot(JSContext *cx, void **rp)
+{
+    CHECK_REQUEST(cx);
+    return js_RemoveRoot(cx->runtime, (void *)rp);
 }
 
 JS_PUBLIC_API(void)
 JS_ClearNewbornRoots(JSContext *cx)
 {
     JS_CLEAR_WEAK_ROOTS(&cx->weakRoots);
 }
 
@@ -1933,20 +1918,16 @@ JS_PrintTraceThingInfo(char *buf, size_t
       }
 
       case JSTRACE_STRING:
         name = ((JSString *)thing)->isDependent()
                ? "substring"
                : "string";
         break;
 
-      case JSTRACE_DOUBLE:
-        name = "double";
-        break;
-
 #if JS_HAS_XML_SUPPORT
       case JSTRACE_XML:
         name = "xml";
         break;
 #endif
       default:
         JS_ASSERT(0);
         return;
@@ -1987,20 +1968,16 @@ JS_PrintTraceThingInfo(char *buf, size_t
             }
             break;
           }
 
           case JSTRACE_STRING:
             js_PutEscapedString(buf, bufsize, (JSString *)thing, 0);
             break;
 
-          case JSTRACE_DOUBLE:
-            JS_snprintf(buf, bufsize, "%g", *(jsdouble *)thing);
-            break;
-
 #if JS_HAS_XML_SUPPORT
           case JSTRACE_XML:
           {
             extern const char *js_xml_class_str[];
             JSXML *xml = (JSXML *)thing;
 
             JS_snprintf(buf, bufsize, "%s", js_xml_class_str[xml->xml_class]);
             break;
@@ -2535,21 +2512,22 @@ JS_DestroyIdArray(JSContext *cx, JSIdArr
 
 JS_PUBLIC_API(JSBool)
 JS_ValueToId(JSContext *cx, jsval v, jsid *idp)
 {
     CHECK_REQUEST(cx);
     return ValueToId(cx, Valueify(v), idp);
 }
 
-JS_PUBLIC_API(void)
+JS_PUBLIC_API(JSBool)
 JS_IdToValue(JSContext *cx, jsid id, jsval *vp)
 {
     CHECK_REQUEST(cx);
     *vp = ID_TO_JSVAL(id);
+    return JS_TRUE;
 }
 
 JS_PUBLIC_API(JSBool)
 JS_PropertyStub(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
 {
     return JS_TRUE;
 }
 
@@ -2607,17 +2585,17 @@ JS_InstanceOf(JSContext *cx, JSObject *o
 {
     CHECK_REQUEST(cx);
     return InstanceOf(cx, obj, Valueify(clasp), Valueify(argv));
 }
 
 JS_PUBLIC_API(JSBool)
 JS_HasInstance(JSContext *cx, JSObject *obj, jsval v, JSBool *bp)
 {
-    return js_HasInstance(cx, obj, Valueify(&v), bp);
+    return js_HasInstance(cx, obj, Valueify(v), bp);
 }
 
 JS_PUBLIC_API(void *)
 JS_GetPrivate(JSContext *cx, JSObject *obj)
 {
     return obj->getPrivate();
 }
 
--- a/js/src/jsapi.h
+++ b/js/src/jsapi.h
@@ -165,17 +165,18 @@ JSVAL_IS_OBJECT(jsval v)
 static JS_ALWAYS_INLINE JSObject *
 JSVAL_TO_OBJECT(jsval v)
 {
     JS_ASSERT(JSVAL_IS_OBJECT(v));
     jsval_layout l = { v };
     return JSVAL_TO_OBJECT_IMPL(l);
 }
 
-/* N.B. Not cheap; uses public API instead of obj->isFunction()! */
+/* TODO: This is unnecessarily expensive. If this gets hot, do something dirty
+ * to achieve obj->isFunction(). */
 static JS_ALWAYS_INLINE jsval
 OBJECT_TO_JSVAL(JSObject *obj)
 {
     extern JS_PUBLIC_API(JSBool)
     JS_ObjectIsFunction(JSContext *cx, JSObject *obj);
 
     if (!obj)
         return JSVAL_NULL;
@@ -894,16 +895,19 @@ extern JS_PUBLIC_API(JSBool)
 JS_AddValueRoot(JSContext *cx, jsval *vp);
 
 extern JS_PUBLIC_API(JSBool)
 JS_AddStringRoot(JSContext *cx, JSString **rp);
 
 extern JS_PUBLIC_API(JSBool)
 JS_AddObjectRoot(JSContext *cx, JSObject **rp);
 
+extern JS_PUBLIC_API(JSBool)
+JS_AddGCThingRoot(JSContext *cx, void **rp);
+
 #ifdef NAME_ALL_GC_ROOTS
 #define JS_DEFINE_TO_TOKEN(def) #def
 #define JS_DEFINE_TO_STRING(def) JS_DEFINE_TO_TOKEN(def)
 #define JS_AddValueRoot(cx,vp) JS_AddNamedValueRoot((cx), (vp), (__FILE__ ":" JS_TOKEN_TO_STRING(__LINE__))
 #define JS_AddStringRoot(cx,rp) JS_AddNamedStringRoot((cx), (rp), (__FILE__ ":" JS_TOKEN_TO_STRING(__LINE__))
 #define JS_AddObjectRoot(cx,rp) JS_AddNamedObjectRoot((cx), (rp), (__FILE__ ":" JS_TOKEN_TO_STRING(__LINE__))
 #endif
 
@@ -912,41 +916,40 @@ JS_AddNamedValueRoot(JSContext *cx, jsva
 
 extern JS_PUBLIC_API(JSBool)
 JS_AddNamedStringRoot(JSContext *cx, JSString **rp, const char *name);
 
 extern JS_PUBLIC_API(JSBool)
 JS_AddNamedObjectRoot(JSContext *cx, JSObject **rp, const char *name);
 
 extern JS_PUBLIC_API(JSBool)
-JS_AddNamedValueRootRT(JSRuntime *rt, jsval *vp, const char *name);
-
-extern JS_PUBLIC_API(JSBool)
-JS_AddNamedStringRootRT(JSRuntime *rt, JSString **rp, const char *name);
-
-extern JS_PUBLIC_API(JSBool)
-JS_AddNamedObjectRootRT(JSRuntime *rt, JSObject **rp, const char *name);
+JS_AddNamedGCThingRoot(JSContext *cx, void **rp, const char *name);
 
 extern JS_PUBLIC_API(JSBool)
 JS_RemoveValueRoot(JSContext *cx, jsval *vp);
 
 extern JS_PUBLIC_API(JSBool)
 JS_RemoveStringRoot(JSContext *cx, JSString **rp);
 
 extern JS_PUBLIC_API(JSBool)
 JS_RemoveObjectRoot(JSContext *cx, JSObject **rp);
 
 extern JS_PUBLIC_API(JSBool)
-JS_RemoveValueRootRT(JSRuntime *rt, jsval *vp);
-
-extern JS_PUBLIC_API(JSBool)
-JS_RemoveStringRootRT(JSRuntime *rt, JSString **rp);
-
-extern JS_PUBLIC_API(JSBool)
-JS_RemoveObjectRootRT(JSRuntime *rt, JSObject **rp);
+JS_RemoveGCThingRoot(JSContext *cx, void **rp);
+
+/* TODO: remove these APIs */
+
+extern JS_FRIEND_API(JSBool)
+js_AddRootRT(JSRuntime *rt, jsval *vp, const char *name);
+
+extern JS_FRIEND_API(JSBool)
+js_AddGCThingRootRT(JSRuntime *rt, void **rp, const char *name);
+
+extern JS_FRIEND_API(JSBool)
+js_RemoveRoot(JSRuntime *rt, void *rp);
 
 /*
  * The last GC thing of each type (object, string, double, external string
  * types) created on a given context is kept alive until another thing of the
  * same type is created, using a newborn root in the context.  These newborn
  * roots help native code protect newly-created GC-things from GC invocations
  * activated before those things can be rooted using local or global roots.
  *
@@ -1138,19 +1141,16 @@ JS_MarkGCThing(JSContext *cx, jsval v, c
  *
  * See the JSTraceOp typedef in jspubtd.h.
  */
 
 /* Trace kinds to pass to JS_Tracing. */
 #define JSTRACE_OBJECT  0
 #define JSTRACE_STRING  1
 
-/* Engine private; not the trace kind of any jsval. */
-#define JSTRACE_DOUBLE  2
-
 /*
  * Use the following macros to check if a particular jsval is a traceable
  * thing and to extract the thing and its kind to pass to JS_CallTracer.
  */
 static JS_ALWAYS_INLINE JSBool
 JSVAL_IS_TRACEABLE(jsval v)
 {
     return JSVAL_IS_GCTHING(v);
@@ -1572,17 +1572,17 @@ struct JSIdArray {
 };
 
 extern JS_PUBLIC_API(void)
 JS_DestroyIdArray(JSContext *cx, JSIdArray *ida);
 
 extern JS_PUBLIC_API(JSBool)
 JS_ValueToId(JSContext *cx, jsval v, jsid *idp);
 
-extern JS_PUBLIC_API(void)
+extern JS_PUBLIC_API(JSBool)
 JS_IdToValue(JSContext *cx, jsid id, jsval *vp);
 
 /*
  * The magic XML namespace id is int-tagged, but not a valid integer jsval.
  * Global object classes in embeddings that enable JS_HAS_XML_SUPPORT (E4X)
  * should handle this id specially before converting id via JSVAL_TO_INT.
  */
 #define JS_DEFAULT_XML_NAMESPACE_ID ((jsid) JSVAL_VOID)
--- a/js/src/jsdbgapi.h
+++ b/js/src/jsdbgapi.h
@@ -168,20 +168,18 @@ extern JS_PUBLIC_API(void)
 JS_ReleaseFunctionLocalNameArray(JSContext *cx, void *mark);
 
 extern JS_PUBLIC_API(JSScript *)
 JS_GetFunctionScript(JSContext *cx, JSFunction *fun);
 
 extern JS_PUBLIC_API(JSNative)
 JS_GetFunctionNative(JSContext *cx, JSFunction *fun);
 
-#ifdef __cpluscplus
 extern JS_PUBLIC_API(JSFastNative)
 JS_GetFunctionFastNative(JSContext *cx, JSFunction *fun);
-#endif
 
 extern JS_PUBLIC_API(JSPrincipals *)
 JS_GetScriptPrincipals(JSContext *cx, JSScript *script);
 
 /*
  * Stack Frame Iterator
  *
  * Used to iterate through the JS stack frames to extract
--- a/js/src/jsfun.cpp
+++ b/js/src/jsfun.cpp
@@ -1710,33 +1710,33 @@ js_XDRFunctionObject(JSXDRState *xdr, JS
 #endif /* !JS_HAS_XDR */
 
 /*
  * [[HasInstance]] internal method for Function objects: fetch the .prototype
  * property of its 'this' parameter, and walks the prototype chain of v (only
  * if v is an object) returning true if .prototype is found.
  */
 static JSBool
-fun_hasInstance(JSContext *cx, JSObject *obj, const Value *v, JSBool *bp)
+fun_hasInstance(JSContext *cx, JSObject *obj, Value v, JSBool *bp)
 {
     jsid id = ATOM_TO_JSID(cx->runtime->atomState.classPrototypeAtom);
     Value pval;
     if (!obj->getProperty(cx, id, &pval))
         return JS_FALSE;
 
     if (pval.isPrimitive()) {
         /*
          * Throw a runtime error if instanceof is called on a function that
          * has a non-object as its .prototype value.
          */
         js_ReportValueError(cx, JSMSG_BAD_PROTOTYPE, -1, ObjectTag(*obj), NULL);
         return JS_FALSE;
     }
 
-    *bp = js_IsDelegate(cx, &pval.asObject(), *v);
+    *bp = js_IsDelegate(cx, &pval.asObject(), v);
     return JS_TRUE;
 }
 
 static void
 TraceLocalNames(JSTracer *trc, JSFunction *fun);
 
 static void
 DestroyLocalNames(JSContext *cx, JSFunction *fun);
--- a/js/src/jsgc.cpp
+++ b/js/src/jsgc.cpp
@@ -106,29 +106,27 @@
 #endif
 #if !defined(MAP_ANONYMOUS)
 # define MAP_ANONYMOUS 0
 #endif
 
 using namespace js;
 
 /*
- * Check that JSTRACE_XML follows JSTRACE_OBJECT, JSTRACE_DOUBLE and
- * JSTRACE_STRING.
+ * Check that JSTRACE_XML follows JSTRACE_OBJECT and JSTRACE_STRING.
  */
 JS_STATIC_ASSERT(JSTRACE_OBJECT == 0);
 JS_STATIC_ASSERT(JSTRACE_STRING == 1);
-JS_STATIC_ASSERT(JSTRACE_DOUBLE == 2);
-JS_STATIC_ASSERT(JSTRACE_XML    == 3);
+JS_STATIC_ASSERT(JSTRACE_XML    == 2);
 
 /*
  * JS_IS_VALID_TRACE_KIND assumes that JSTRACE_STRING is the last non-xml
  * trace kind when JS_HAS_XML_SUPPORT is false.
  */
-JS_STATIC_ASSERT(JSTRACE_DOUBLE + 1 == JSTRACE_XML);
+JS_STATIC_ASSERT(JSTRACE_STRING + 1 == JSTRACE_XML);
 
 /*
  * Check consistency of external string constants from JSFinalizeGCThingKind.
  */
 JS_STATIC_ASSERT(FINALIZE_EXTERNAL_STRING_LAST - FINALIZE_EXTERNAL_STRING0 ==
                  JS_EXTERNAL_STRING_LIMIT - 1);
 
 /*
@@ -856,18 +854,17 @@ js_GetExternalStringGCType(JSString *str
 
 JS_FRIEND_API(uint32)
 js_GetGCThingTraceKind(void *thing)
 {
     if (JSString::isStatic(thing))
         return JSTRACE_STRING;
 
     JSGCArenaInfo *ainfo = JSGCArenaInfo::fromGCThing(thing);
-    if (!ainfo->list)
-        return JSTRACE_DOUBLE;
+    JS_ASSERT(ainfo);
     return GetFinalizableArenaTraceKind(ainfo);
 }
 
 JSRuntime *
 js_GetGCThingRuntime(void *thing)
 {
     jsuword chunk = JSGCArena::fromGCThing(thing)->getChunk();
     return JSGCChunkInfo::fromChunk(chunk)->runtime;
@@ -1140,66 +1137,66 @@ js_FinishGC(JSRuntime *rt)
         JS_DHashTableFinish(&rt->gcLocksHash);
         rt->gcLocksHash.ops = NULL;
     }
 }
 
 JSBool
 js_AddRoot(JSContext *cx, Value *vp, const char *name)
 {
-    JSBool ok = js_AddRootRT(cx->runtime, vp, name);
+    JSBool ok = js_AddRootRT(cx->runtime, Jsvalify(vp), name);
     if (!ok)
         JS_ReportOutOfMemory(cx);
     return ok;
 }
 
 JSBool
 js_AddGCThingRoot(JSContext *cx, void **rp, const char *name)
 {
     JSBool ok = js_AddGCThingRootRT(cx->runtime, rp, name);
     if (!ok)
         JS_ReportOutOfMemory(cx);
     return ok;
 }
 
-JSBool
-js_AddRootRT(JSRuntime *rt, Value *vp, const char *name)
+JS_FRIEND_API(JSBool)
+js_AddRootRT(JSRuntime *rt, jsval *vp, const char *name)
 {
     /*
      * Due to the long-standing, but now removed, use of rt->gcLock across the
      * bulk of js_GC, API users have come to depend on JS_AddRoot etc. locking
      * properly with a racing GC, without calling JS_AddRoot from a request.
      * We have to preserve API compatibility here, now that we avoid holding
      * rt->gcLock across the mark phase (including the root hashtable mark).
      */
     AutoLockGC lock(rt);
     js_WaitForGC(rt);
 
     void *key = vp;
     return !!rt->gcRootsHash.put(key, RootInfo(name, JS_GC_ROOT_VALUE_PTR));
 }
 
-JSBool
+JS_FRIEND_API(JSBool)
 js_AddGCThingRootRT(JSRuntime *rt, void **rp, const char *name)
 {
     /*
      * Due to the long-standing, but now removed, use of rt->gcLock across the
      * bulk of js_GC, API users have come to depend on JS_AddRoot etc. locking
      * properly with a racing GC, without calling JS_AddRoot from a request.
      * We have to preserve API compatibility here, now that we avoid holding
      * rt->gcLock across the mark phase (including the root hashtable mark).
      */
     AutoLockGC lock(rt);
     js_WaitForGC(rt);
 
     void *key = rp;
     return !!rt->gcRootsHash.put(key, RootInfo(name, JS_GC_ROOT_GCTHING_PTR));
 }
 
-JSBool
+JS_FRIEND_API(JSBool)
 js_RemoveRoot(JSRuntime *rt, void *rp)
 {
     /*
      * Due to the JS_RemoveRootRT API, we may be called outside of a request.
      * Same synchronization drill as above in js_AddRoot.
      */
     AutoLockGC lock(rt);
     js_WaitForGC(rt);
@@ -1817,29 +1814,17 @@ MarkRaw(JSTracer *trc, void *thing, uint
     rt = cx->runtime;
     JS_ASSERT(rt->gcMarkingTracer == trc);
     JS_ASSERT(rt->gcLevel > 0);
 
     /*
      * Optimize for string and double as their size is known and their tracing
      * is not recursive.
      */
-    switch (kind) {
-      case JSTRACE_DOUBLE: {
-        JSGCArenaInfo *ainfo = JSGCArenaInfo::fromGCThing(thing);
-        JS_ASSERT(!ainfo->list);
-        if (!ainfo->hasMarkedDoubles) {
-            ainfo->hasMarkedDoubles = true;
-            JSGCArena::fromGCThing(thing)->clearMarkBitmap();
-        }
-        MarkIfUnmarkedGCThing(thing);
-        goto out;
-      }
-
-      case JSTRACE_STRING:
+    if (kind == JSTRACE_STRING) {
         for (;;) {
             if (JSString::isStatic(thing))
                 goto out;
             JS_ASSERT(kind == GetFinalizableThingTraceKind(thing));
             if (!MarkIfUnmarkedGCThing(thing))
                 goto out;
             if (!((JSString *) thing)->isDependent())
                 goto out;
--- a/js/src/jsgc.h
+++ b/js/src/jsgc.h
@@ -46,22 +46,22 @@
 #include "jspubtd.h"
 #include "jsdhash.h"
 #include "jsbit.h"
 #include "jsutil.h"
 #include "jstask.h"
 #include "jsvector.h"
 #include "jsversion.h"
 
-#define JSTRACE_XML         3
+#define JSTRACE_XML         2
 
 /*
  * One past the maximum trace kind.
  */
-#define JSTRACE_LIMIT       4
+#define JSTRACE_LIMIT       3
 
 const uintN JS_EXTERNAL_STRING_LIMIT = 8;
 
 /*
  * Get the type of the external string or -1 if the string was not created
  * with JS_NewExternalString.
  */
 extern intN
@@ -97,27 +97,18 @@ js_FinishGC(JSRuntime *rt);
 extern intN
 js_ChangeExternalStringFinalizer(JSStringFinalizeOp oldop,
                                  JSStringFinalizeOp newop);
 
 extern JSBool
 js_AddRoot(JSContext *cx, js::Value *vp, const char *name);
 
 extern JSBool
-js_AddRootRT(JSRuntime *rt, js::Value *vp, const char *name);
-
-extern JSBool
 js_AddGCThingRoot(JSContext *cx, void **rp, const char *name);
 
-extern JSBool
-js_AddGCThingRootRT(JSRuntime *rt, void **rp, const char *name);
-
-extern JSBool
-js_RemoveRoot(JSRuntime *rt, void *rp);
-
 #ifdef DEBUG
 extern void
 js_DumpNamedRoots(JSRuntime *rt,
                   void (*dump)(const char *name, void *rp, JSGCRootType type, void *data),
                   void *data);
 #endif
 
 extern uint32
@@ -150,17 +141,17 @@ js_IsAboutToBeFinalized(void *thing);
  * Macro to test if a traversal is the marking phase of GC to avoid exposing
  * ScriptFilenameEntry to traversal implementations.
  */
 #define IS_GC_MARKING_TRACER(trc) ((trc)->callback == NULL)
 
 #if JS_HAS_XML_SUPPORT
 # define JS_IS_VALID_TRACE_KIND(kind) ((uint32)(kind) < JSTRACE_LIMIT)
 #else
-# define JS_IS_VALID_TRACE_KIND(kind) ((uint32)(kind) <= JSTRACE_DOUBLE)
+# define JS_IS_VALID_TRACE_KIND(kind) ((uint32)(kind) <= JSTRACE_STRING)
 #endif
 
 extern void
 js_TraceStackFrame(JSTracer *trc, JSStackFrame *fp);
 
 extern JS_REQUIRES_STACK void
 js_TraceRuntime(JSTracer *trc);
 
--- a/js/src/jsiter.cpp
+++ b/js/src/jsiter.cpp
@@ -661,19 +661,19 @@ js_IteratorNext(JSContext *cx, JSObject 
     JS_ASSERT(!cx->iterValue.isMagic(JS_NO_ITER_VALUE));
     *rval = cx->iterValue;
     cx->iterValue.setMagic(JS_NO_ITER_VALUE);
 
     return true;
 }
 
 static JSBool
-stopiter_hasInstance(JSContext *cx, JSObject *obj, const Value *v, JSBool *bp)
+stopiter_hasInstance(JSContext *cx, JSObject *obj, Value v, JSBool *bp)
 {
-    *bp = js_ValueIsStopIteration(*v);
+    *bp = js_ValueIsStopIteration(v);
     return JS_TRUE;
 }
 
 Class js_StopIterationClass = {
     js_StopIteration_str,
     JSCLASS_HAS_CACHED_PROTO(JSProto_StopIteration),
     PropertyStub,     PropertyStub,
     PropertyStub,     PropertyStub,
--- a/js/src/jsobj.cpp
+++ b/js/src/jsobj.cpp
@@ -5529,17 +5529,17 @@ js_Construct(JSContext *cx, JSObject *ob
 #endif
         js_ReportIsNotFunction(cx, &argv[-2], JSV2F_CONSTRUCT);
         return JS_FALSE;
     }
     return clasp->construct(cx, obj, argc, argv, rval);
 }
 
 JSBool
-js_HasInstance(JSContext *cx, JSObject *obj, const Value *v, JSBool *bp)
+js_HasInstance(JSContext *cx, JSObject *obj, Value v, JSBool *bp)
 {
     Class *clasp = obj->getClass();
     if (clasp->hasInstance)
         return clasp->hasInstance(cx, obj, v, bp);
 #ifdef NARCISSUS
     {
         jsval fval, rval;
 
--- a/js/src/jsobj.h
+++ b/js/src/jsobj.h
@@ -269,16 +269,20 @@ struct JSObject {
     js::Value   fslots[JS_INITIAL_NSLOTS];  /* small number of fixed slots */
 
     bool isNative() const { return map->ops->isNative(); }
 
     js::Class *getClass() const {
         return clasp;
     }
 
+    JSClass *getJSClass() const {
+        return Jsvalify(clasp);
+    }
+
     bool hasClass(const js::Class *c) const {
         return c == clasp;
     }
 
     inline JSScope *scope() const;
     inline uint32 shape() const;
 
     bool isDelegate() const {
@@ -1154,17 +1158,17 @@ extern JSBool
 js_Call(JSContext *cx, JSObject *obj, uintN argc, js::Value *argv,
         js::Value *rval);
 
 extern JSBool
 js_Construct(JSContext *cx, JSObject *obj, uintN argc, js::Value *argv,
              js::Value *rval);
 
 extern JSBool
-js_HasInstance(JSContext *cx, JSObject *obj, const js::Value *v, JSBool *bp);
+js_HasInstance(JSContext *cx, JSObject *obj, js::Value v, JSBool *bp);
 
 extern JSBool
 js_SetProtoOrParent(JSContext *cx, JSObject *obj, uint32 slot, JSObject *pobj,
                     JSBool checkForCycles);
 
 extern bool
 js_IsDelegate(JSContext *cx, JSObject *obj, const js::Value &v);
 
--- a/js/src/jsops.cpp
+++ b/js/src/jsops.cpp
@@ -821,17 +821,17 @@ END_CASE(JSOP_BITAND)
         if (!js_TestXMLEquality(cx, lval, rval, &cond))                       \
             goto error;                                                       \
         cond = cond OP JS_TRUE;                                               \
     } else
 
 #define EXTENDED_EQUALITY_OP(OP)                                              \
     if (((clasp = l->getClass())->flags & JSCLASS_IS_EXTENDED) &&             \
         ((ExtendedClass *)clasp)->equality) {                                 \
-        if (!((ExtendedClass *)clasp)->equality(cx, l, &rval, &cond))         \
+        if (!((ExtendedClass *)clasp)->equality(cx, l, rval, &cond))          \
             goto error;                                                       \
         cond = cond OP JS_TRUE;                                               \
     } else
 #else
 #define XML_EQUALITY_OP(OP)             /* nothing */
 #define EXTENDED_EQUALITY_OP(OP)        /* nothing */
 #endif
 
@@ -3921,17 +3921,17 @@ BEGIN_CASE(JSOP_INSTANCEOF)
     if (rref.isPrimitive() ||
         !(obj = &rref.asObject())->map->ops->hasInstance) {
         js_ReportValueError(cx, JSMSG_BAD_INSTANCEOF_RHS,
                             -1, rref, NULL);
         goto error;
     }
     const Value &lref = regs.sp[-2];
     JSBool cond = JS_FALSE;
-    if (!obj->map->ops->hasInstance(cx, obj, &lref, &cond))
+    if (!obj->map->ops->hasInstance(cx, obj, lref, &cond))
         goto error;
     regs.sp--;
     regs.sp[-1].setBoolean(cond);
 }
 END_CASE(JSOP_INSTANCEOF)
 
 #if JS_HAS_DEBUGGER_KEYWORD
 BEGIN_CASE(JSOP_DEBUGGER)
--- a/js/src/jsprvtd.h
+++ b/js/src/jsprvtd.h
@@ -63,24 +63,25 @@
 #define JSID_TO_ATOM(id)            ((JSAtom *)JSVAL_TO_STRING((jsval)(id)))
 #define JSID_TO_STRING(id)          ATOM_TO_STRING(JSID_TO_ATOM(id))
 #define ATOM_TO_JSID(atom)          ((jsid)STRING_TO_JSVAL((JSString *)atom))
 
 #define JSID_IS_INT(id)             JSVAL_IS_INT((jsval)(id))
 #define JSID_TO_INT(id)             JSVAL_TO_INT((jsval)(id))
 #define INT_TO_JSID(i)              ((jsid)INT_TO_JSVAL(i))
 #define INT_JSVAL_TO_JSID(v)        ((jsid)(v))
+#define INT_JSID_TO_VALUE(id)       (js::Valueify((jsval)(id)))
 #define INT_JSID_TO_JSVAL(id)       ((jsval)(id))
 
 #define JSID_IS_OBJECT(id)          JSVAL_IS_OBJECT((jsval)(id))
 #define JSID_TO_OBJECT(id)          JSVAL_TO_OBJECT((jsval)(id))
 #define OBJECT_TO_JSID(obj)         ((jsid)OBJECT_TO_JSVAL(obj))
 #define OBJECT_JSVAL_TO_JSID(v)     ((jsid)v)
 
-#define ID_TO_VALUE(id)             (Valueify(id))
+#define ID_TO_VALUE(id)             (js::Valueify(id))
 #define ID_TO_JSVAL(id)             ((jsval)(id))
 
 /*
  * Convenience constants.
  */
 #define JS_BITS_PER_UINT32_LOG2 5
 #define JS_BITS_PER_UINT32      32
 
--- a/js/src/jspubtd.h
+++ b/js/src/jspubtd.h
@@ -783,17 +783,17 @@ typedef JSBool
 (* JSXDRObjectOp)(JSXDRState *xdr, JSObject **objp);
 
 /*
  * Check whether v is an instance of obj.  Return false on error or exception,
  * true on success with JS_TRUE in *bp if v is an instance of obj, JS_FALSE in
  * *bp otherwise.
  */
 typedef JSBool
-(* JSHasInstanceOp)(JSContext *cx, JSObject *obj, const jsval *v, JSBool *bp);
+(* JSHasInstanceOp)(JSContext *cx, JSObject *obj, jsval v, JSBool *bp);
 
 /*
  * Deprecated function type for JSClass.mark. All new code should define
  * JSTraceOp instead to ensure the traversal of traceable things stored in
  * the native structures.
  */
 typedef uint32
 (* JSMarkOp)(JSContext *cx, JSObject *obj, void *arg);
@@ -837,20 +837,20 @@ extern JSMarkOp js_WrongTypeForClassTrac
 
 /*
  * Tracer callback, called for each traceable thing directly refrenced by a
  * particular object or runtime structure. It is the callback responsibility
  * to ensure the traversal of the full object graph via calling eventually
  * JS_TraceChildren on the passed thing. In this case the callback must be
  * prepared to deal with cycles in the traversal graph.
  *
- * kind argument is one of JSTRACE_OBJECT, JSTRACE_DOUBLE, JSTRACE_STRING or
- * a tag denoting internal implementation-specific traversal kind. In the
- * latter case the only operations on thing that the callback can do is to call
- * JS_TraceChildren or DEBUG-only JS_PrintTraceThingInfo.
+ * kind argument is one of JSTRACE_OBJECT, JSTRACE_STRING or a tag denoting
+ * internal implementation-specific traversal kind. In the latter case the only
+ * operations on thing that the callback can do is to call JS_TraceChildren or
+ * DEBUG-only JS_PrintTraceThingInfo.
  */
 typedef void
 (* JSTraceCallback)(JSTracer *trc, void *thing, uint32 kind);
 
 /*
  * DEBUG only callback that JSTraceOp implementation can provide to return
  * a string describing the reference traced with JS_CallTracer.
  */
@@ -873,17 +873,17 @@ typedef uint32
 (* JSReserveSlotsOp)(JSContext *cx, JSObject *obj);
 
 /* JSExtendedClass function pointer typedefs. */
 
 /*
  *
  */
 typedef JSBool
-(* JSEqualityOp)(JSContext *cx, JSObject *obj, const jsval *v, JSBool *bp);
+(* JSEqualityOp)(JSContext *cx, JSObject *obj, jsval v, JSBool *bp);
 
 /*
  * A generic type for functions mapping an object to another object, or null
  * if an error or exception was thrown on cx.  Used by JSObjectOps.thisObject
  * at present.
  */
 typedef JSObject *
 (* JSObjectOp)(JSContext *cx, JSObject *obj);
@@ -1063,24 +1063,24 @@ typedef JSBool
 typedef JSBool
 (* PropertyOp)(JSContext *cx, JSObject *obj, jsval id, Value *vp);
 typedef JSBool
 (* ConvertOp)(JSContext *cx, JSObject *obj, JSType type, Value *vp);
 typedef JSBool
 (* NewEnumerateOp)(JSContext *cx, JSObject *obj, JSIterateOp enum_op,
                    Value *statep, jsval *idp);
 typedef JSBool
-(* HasInstanceOp)(JSContext *cx, JSObject *obj, const Value *v, JSBool *bp);
+(* HasInstanceOp)(JSContext *cx, JSObject *obj, Value v, JSBool *bp);
 typedef JSBool
 (* CheckAccessOp)(JSContext *cx, JSObject *obj, jsval id, JSAccessMode mode,
                   Value *vp);
 typedef JSObjectOps *
 (* GetObjectOps)(JSContext *cx, Class *clasp);
 typedef JSBool
-(* EqualityOp)(JSContext *cx, JSObject *obj, const Value *v, JSBool *bp);
+(* EqualityOp)(JSContext *cx, JSObject *obj, Value v, JSBool *bp);
 
 /*
  * Since jsval and Value are layout-compatible, pointers to otherwise-identical
  * functions can be cast back and forth. To avoid widespread casting, the
  * following safe casts are provided.
  *
  * See also Valueify and Jsvalify overloads in jsprvtd.h.
  */
--- a/js/src/jsxml.cpp
+++ b/js/src/jsxml.cpp
@@ -247,22 +247,22 @@ namespace_getProperty(JSContext *cx, JSO
 static void
 namespace_finalize(JSContext *cx, JSObject *obj)
 {
     if (cx->runtime->functionNamespaceObject == obj)
         cx->runtime->functionNamespaceObject = NULL;
 }
 
 static JSBool
-namespace_equality(JSContext *cx, JSObject *obj, const jsval *v, JSBool *bp)
+namespace_equality(JSContext *cx, JSObject *obj, jsval v, JSBool *bp)
 {
     JSObject *obj2;
 
-    JS_ASSERT(JSVAL_IS_OBJECT(*v));
-    obj2 = JSVAL_TO_OBJECT(*v);
+    JS_ASSERT(JSVAL_IS_OBJECT(v));
+    obj2 = JSVAL_TO_OBJECT(v);
     *bp = (!obj2 || obj2->getClass() != &js_NamespaceClass.base)
           ? JS_FALSE
           : js_EqualStrings(GetURI(obj), GetURI(obj2));
     return JS_TRUE;
 }
 
 JS_FRIEND_DATA(ExtendedClass) js_NamespaceClass = {
   { "Namespace",
@@ -371,21 +371,21 @@ qname_identity(JSObject *qna, JSObject *
     if (!uri1 ^ !uri2)
         return JS_FALSE;
     if (uri1 && !js_EqualStrings(uri1, uri2))
         return JS_FALSE;
     return js_EqualStrings(GetLocalName(qna), GetLocalName(qnb));
 }
 
 static JSBool
-qname_equality(JSContext *cx, JSObject *qn, const Value *v, JSBool *bp)
+qname_equality(JSContext *cx, JSObject *qn, Value v, JSBool *bp)
 {
     JSObject *obj2;
 
-    obj2 = v->asObjectOrNull();
+    obj2 = v.asObjectOrNull();
     *bp = (!obj2 || obj2->getClass() != &js_QNameClass.base)
           ? JS_FALSE
           : qname_identity(qn, obj2);
     return JS_TRUE;
 }
 
 JS_FRIEND_DATA(ExtendedClass) js_QNameClass = {
   { "QName",
@@ -5006,17 +5006,17 @@ xml_enumerate(JSContext *cx, JSObject *o
 
 static JSType
 xml_typeOf(JSContext *cx, JSObject *obj)
 {
     return JSTYPE_XML;
 }
 
 static JSBool
-xml_hasInstance(JSContext *cx, JSObject *obj, const Value *, JSBool *bp)
+xml_hasInstance(JSContext *cx, JSObject *obj, Value, JSBool *bp)
 {
     return JS_TRUE;
 }
 
 static void
 xml_trace(JSTracer *trc, JSObject *obj)
 {
     JSXML *xml = (JSXML *) obj->getPrivate();
--- a/js/src/shell/js.cpp
+++ b/js/src/shell/js.cpp
@@ -1311,17 +1311,16 @@ CountHeap(JSContext *cx, uintN argc, jsv
     size_t counter;
 
     static const struct {
         const char       *name;
         int32             kind;
     } traceKindNames[] = {
         { "all",        -1                  },
         { "object",     JSTRACE_OBJECT      },
-        { "double",     JSTRACE_DOUBLE      },
         { "string",     JSTRACE_STRING      },
 #if JS_HAS_XML_SUPPORT
         { "xml",        JSTRACE_XML         },
 #endif
     };
 
     startThing = NULL;
     startTraceKind = 0;
@@ -2776,17 +2775,17 @@ split_getObjectOps(JSContext *cx, JSClas
         split_objectops.call = NULL;
         split_objectops.construct = NULL;
     }
 
     return &split_objectops;
 }
 
 static JSBool
-split_equality(JSContext *cx, JSObject *obj, const jsval *v, JSBool *bp);
+split_equality(JSContext *cx, JSObject *obj, jsval v, JSBool *bp);
 
 static JSObject *
 split_innerObject(JSContext *cx, JSObject *obj)
 {
     ComplexObject *cpx;
 
     cpx = (ComplexObject *) JS_GetPrivate(cx, obj);
     if (cpx->frozen) {
@@ -2807,23 +2806,23 @@ static JSExtendedClass split_global_clas
     JS_ConvertStub, split_finalize,
     split_getObjectOps, NULL, NULL, NULL, NULL, NULL,
     split_mark, NULL},
     split_equality, split_outerObject, split_innerObject,
     NULL, NULL, NULL, NULL, NULL
 };
 
 static JSBool
-split_equality(JSContext *cx, JSObject *obj, const jsval *v, JSBool *bp)
+split_equality(JSContext *cx, JSObject *obj, jsval v, JSBool *bp)
 {
     *bp = JS_FALSE;
-    if (JSVAL_IS_PRIMITIVE(*v))
+    if (JSVAL_IS_PRIMITIVE(v))
         return JS_TRUE;
 
-    JSObject *obj2 = JSVAL_TO_OBJECT(*v);
+    JSObject *obj2 = JSVAL_TO_OBJECT(v);
     if (JS_GET_CLASS(cx, obj2) != &split_global_class.base)
         return JS_TRUE;
 
     ComplexObject *cpx = (ComplexObject *) JS_GetPrivate(cx, obj2);
     JS_ASSERT(!cpx->isInner);
 
     ComplexObject *ourCpx = (ComplexObject *) JS_GetPrivate(cx, obj);
     JS_ASSERT(!ourCpx->isInner);
--- a/js/src/xpconnect/loader/mozJSComponentLoader.cpp
+++ b/js/src/xpconnect/loader/mozJSComponentLoader.cpp
@@ -1392,17 +1392,17 @@ mozJSComponentLoader::GlobalForLocation(
     nsCAutoString path;
     aComponent->GetNativePath(path);
     *aLocation = ToNewCString(path);
     if (!*aLocation) {
         *aGlobal = nsnull;
         return NS_ERROR_OUT_OF_MEMORY;
     }
 
-    JS_AddNamedRoot(cx, aGlobal, *aLocation);
+    JS_AddNamedObjectRoot(cx, aGlobal, *aLocation);
     return NS_OK;
 }
 
 void
 mozJSComponentLoader::UnloadModules()
 {
     mInitialized = PR_FALSE;
 
--- a/js/src/xpconnect/loader/mozJSComponentLoader.h
+++ b/js/src/xpconnect/loader/mozJSComponentLoader.h
@@ -146,17 +146,17 @@ class mozJSComponentLoader : public nsIM
         }
 
         ~ModuleEntry() {
             module = nsnull;
 
             if (global) {
                 JSAutoRequest ar(sSelf->mContext);
                 JS_ClearScope(sSelf->mContext, global);
-                JS_RemoveRoot(sSelf->mContext, &global);
+                JS_RemoveObjectRoot(sSelf->mContext, &global);
             }
 
             if (location)
                 NS_Free(location);
         }
 
         nsCOMPtr<nsIModule>  module;
         JSObject            *global;
--- a/js/src/xpconnect/public/nsAutoJSValHolder.h
+++ b/js/src/xpconnect/public/nsAutoJSValHolder.h
@@ -77,17 +77,17 @@ public:
   }
 
   /**
    * Hold by rooting on the runtime.
    * Note that mGCThing may be JSVAL_NULL, which is not a problem.
    */
   JSBool Hold(JSRuntime* aRt) {
     if (!mHeld) {
-      if (JS_AddNamedRootRT(aRt, &mGCThing, "nsAutoJSValHolder")) {
+      if (js_AddGCThingRootRT(aRt, &mGCThing, "nsAutoJSValHolder")) {
         mRt = aRt;
         mHeld = JS_TRUE;
       } else {
         Release(); // out of memory
       }
     }
     return mHeld;
   }
@@ -97,17 +97,17 @@ public:
    * the original jsval.
    */
   jsval Release() {
     NS_ASSERTION(!mHeld || mRt, "Bad!");
 
     jsval oldval = mVal;
 
     if (mHeld) {
-      JS_RemoveRootRT(mRt, &mGCThing); // infallible
+      js_RemoveRoot(mRt, &mGCThing); // infallible
       mHeld = JS_FALSE;
     }
 
     mVal = JSVAL_NULL;
     mGCThing = NULL;
     mRt = NULL;
 
     return oldval;
--- a/js/src/xpconnect/src/XPCNativeWrapper.h
+++ b/js/src/xpconnect/src/XPCNativeWrapper.h
@@ -64,17 +64,17 @@ IsNativeWrapperClass(JSClass *clazz)
 {
   return clazz == &internal::NW_NoCall_Class.base ||
          clazz == &internal::NW_Call_Class.base;
 }
 
 inline PRBool
 IsNativeWrapper(JSObject *obj)
 {
-  return IsNativeWrapperClass(obj->getClass());
+  return IsNativeWrapperClass(obj->getJSClass());
 }
 
 JSBool
 GetWrappedNative(JSContext *cx, JSObject *obj,
                  XPCWrappedNative **aWrappedNative);
 
 // NB: Use the following carefully.
 inline XPCWrappedNative *
--- a/js/src/xpconnect/src/XPCWrapper.h
+++ b/js/src/xpconnect/src/XPCWrapper.h
@@ -287,17 +287,17 @@ MaybePreserveWrapper(JSContext *cx, XPCW
       ci->PreserveWrapper(wn->Native());
     }
   }
 }
 
 inline JSBool
 IsSecurityWrapper(JSObject *wrapper)
 {
-  JSClass *clasp = wrapper->getClass();
+  JSClass *clasp = wrapper->getJSClass();
   return (clasp->flags & JSCLASS_IS_EXTENDED) &&
     ((JSExtendedClass*)clasp)->wrappedObject;
 }
 
 /**
  * Given an arbitrary object, Unwrap will return the wrapped object if the
  * passed-in object is a wrapper that Unwrap knows about *and* the
  * currently running code has permission to access both the wrapper and
@@ -311,17 +311,17 @@ JSObject *
 Unwrap(JSContext *cx, JSObject *wrapper);
 
 /**
  * Unwraps objects whose class is |xclasp|.
  */
 inline JSObject *
 UnwrapGeneric(JSContext *cx, const JSExtendedClass *xclasp, JSObject *wrapper)
 {
-  if (wrapper->getClass() != &xclasp->base) {
+  if (wrapper->getJSClass() != &xclasp->base) {
     return nsnull;
   }
 
   jsval v;
   if (!JS_GetReservedSlot(cx, wrapper, XPCWrapper::sWrappedObjSlot, &v)) {
     JS_ClearPendingException(cx);
     return nsnull;
   }
--- a/js/src/xpconnect/src/nsXPConnect.cpp
+++ b/js/src/xpconnect/src/nsXPConnect.cpp
@@ -687,17 +687,17 @@ NoteJSChild(JSTracer *trc, void *thing, 
             } else {
                 tracer->cb.NoteNextEdgeName(
                   static_cast<const char*>(tracer->debugPrintArg));
             }
         }
 #endif
         tracer->cb.NoteScriptChild(nsIProgrammingLanguage::JAVASCRIPT, thing);
     }
-    else if(kind != JSTRACE_DOUBLE && kind != JSTRACE_STRING)
+    else if(kind != JSTRACE_STRING)
     {
         JS_TraceChildren(trc, thing, kind);
     }
 }
 
 static JSBool
 WrapperIsNotMainThreadOnly(XPCWrappedNative *wrapper)
 {
@@ -730,17 +730,17 @@ nsXPConnect::Traverse(void *p, nsCycleCo
     // do want to explicitly mark them for cycle collection if the wrapper has
     // an external reference, because the wrapper would mark the JS object if
     // we did add the wrapper to the cycle collector.
     JSBool dontTraverse = PR_FALSE;
     JSBool markJSObject = PR_FALSE;
     if(traceKind == JSTRACE_OBJECT)
     {
         obj = static_cast<JSObject*>(p);
-        clazz = obj->getClass();
+        clazz = obj->getJSClass();
 
         if(clazz == &XPC_WN_Tearoff_JSClass)
         {
             XPCWrappedNative *wrapper =
                 (XPCWrappedNative*)xpc_GetJSPrivate(obj->getParent());
             dontTraverse = WrapperIsNotMainThreadOnly(wrapper);
         }
         else if(IS_WRAPPER_CLASS(clazz) && IS_WN_WRAPPER_OBJECT(obj))
@@ -780,17 +780,17 @@ nsXPConnect::Traverse(void *p, nsCycleCo
                                                                  GCMarked;
     }
 
     if (cb.WantDebugInfo()) {
         char name[72];
         if(traceKind == JSTRACE_OBJECT)
         {
             JSObject *obj = static_cast<JSObject*>(p);
-            JSClass *clazz = obj->getClass();
+            JSClass *clazz = obj->getJSClass();
             if(XPCNativeWrapper::IsNativeWrapperClass(clazz))
             {
                 XPCWrappedNative* wn;
                 if(XPCNativeWrapper::GetWrappedNative(cx, obj, &wn) && wn)
                 {
                     XPCNativeScriptableInfo* si = wn->GetScriptableInfo();
                     if(si)
                     {
@@ -840,31 +840,31 @@ nsXPConnect::Traverse(void *p, nsCycleCo
                         (XPCWrappedNativeProto*) xpc_GetJSPrivate(obj);
                     si = p->GetScriptableInfo();
                 }
                 if(si)
                 {
                     JS_snprintf(name, sizeof(name), "JS Object (%s - %s)",
                                 clazz->name, si->GetJSClass()->name);
                 }
-                else if(clazz == &js_ScriptClass)
+                else if(clazz == Jsvalify(&js_ScriptClass))
                 {
                     JSScript* script = (JSScript*) xpc_GetJSPrivate(obj);
                     if(script->filename)
                     {
                         JS_snprintf(name, sizeof(name),
                                     "JS Object (Script - %s)",
                                     script->filename);
                     }
                     else
                     {
                         JS_snprintf(name, sizeof(name), "JS Object (Script)");
                     }
                 }
-                else if(clazz == &js_FunctionClass)
+                else if(clazz == Jsvalify(&js_FunctionClass))
                 {
                     JSFunction* fun = (JSFunction*) xpc_GetJSPrivate(obj);
                     JSString* str = JS_GetFunctionId(fun);
                     if(str)
                     {
                         NS_ConvertUTF16toUTF8
                             fname(reinterpret_cast<const PRUnichar*>(JS_GetStringChars(str)));
                         JS_snprintf(name, sizeof(name),
@@ -881,17 +881,16 @@ nsXPConnect::Traverse(void *p, nsCycleCo
                                 clazz->name);
                 }
             }
         }
         else
         {
             static const char trace_types[JSTRACE_LIMIT][7] = {
                 "Object",
-                "Double",
                 "String",
                 "Xml"
             };
             JS_snprintf(name, sizeof(name), "JS %s", trace_types[traceKind]);
         }
 
         if(traceKind == JSTRACE_OBJECT) {
             JSObject *global = static_cast<JSObject*>(p), *parent;
@@ -1953,17 +1952,17 @@ nsXPConnect::RestoreWrappedNativePrototy
     if(!aClassInfo || !aPrototype)
         return UnexpectedFailure(NS_ERROR_INVALID_ARG);
 
     JSObject *protoJSObject;
     nsresult rv = aPrototype->GetJSObject(&protoJSObject);
     if(NS_FAILED(rv))
         return UnexpectedFailure(rv);
 
-    if(!IS_PROTO_CLASS(protoJSObject->getClass()))
+    if(!IS_PROTO_CLASS(protoJSObject->getJSClass()))
         return UnexpectedFailure(NS_ERROR_INVALID_ARG);
 
     XPCWrappedNativeScope* scope =
         XPCWrappedNativeScope::FindInJSObjectScope(ccx, aScope);
     if(!scope)
         return UnexpectedFailure(NS_ERROR_FAILURE);
 
     XPCWrappedNativeProto *proto =
@@ -2527,17 +2526,17 @@ nsXPConnect::GetWrapperForObject(JSConte
         JSObject *toInnerize = scopeobj;
         OBJ_TO_INNER_OBJECT(aJSContext, toInnerize);
         NS_ASSERTION(toInnerize == scopeobj, "Scope chain ending in outer object?");
     }
 #endif
 
     {
         JSObject *possibleOuter = objectscope->GetGlobalJSObject();
-        OBJ_TO_INNER_OBJECT(aJSContext, possibleOuter);
+        Innerize(aJSContext, &possibleOuter);
         if(!possibleOuter)
             return NS_ERROR_FAILURE;
 
         if(objectscope->GetGlobalJSObject() != possibleOuter)
         {
             objectscope =
                 XPCWrappedNativeScope::FindInJSObjectScope(aJSContext,
                                                            possibleOuter);
@@ -2839,43 +2838,12 @@ JS_EXPORT_API(void) DumpJSEval(PRUint32 
 
 JS_EXPORT_API(void) DumpJSObject(JSObject* obj)
 {
     xpc_DumpJSObject(obj);
 }
 
 JS_EXPORT_API(void) DumpJSValue(jsval val)
 {
-    printf("Dumping 0x%p. Value tag is %u.\n", (void *) val, (PRUint32) JSVAL_TAG(val));
-    if(JSVAL_IS_NULL(val)) {
-        printf("Value is null\n");
-    }
-    else if(JSVAL_IS_OBJECT(val)) {
-        printf("Value is an object\n");
-        JSObject* obj = JSVAL_TO_OBJECT(val);
-        DumpJSObject(obj);
-    }
-    else if(JSVAL_IS_NUMBER(val)) {
-        printf("Value is a number: ");
-        if(JSVAL_IS_INT(val))
-          printf("Integer %i\n", JSVAL_TO_INT(val));
-        else if(JSVAL_IS_DOUBLE(val))
-          printf("Floating-point value %f\n", *JSVAL_TO_DOUBLE(val));
-    }
-    else if(JSVAL_IS_STRING(val)) {
-        printf("Value is a string: ");
-        JSString* string = JSVAL_TO_STRING(val);
-        char* bytes = JS_GetStringBytes(string);
-        printf("<%s>\n", bytes);
-    }
-    else if(JSVAL_IS_BOOLEAN(val)) {
-        printf("Value is boolean: ");
-        printf(JSVAL_TO_BOOLEAN(val) ? "true" : "false");
-    }
-    else if(JSVAL_IS_VOID(val)) {
-        printf("Value is undefined\n");
-    }
-    else {
-        printf("No idea what this value is.\n");
-    }
+    js::DumpValue(js::Valueify(val));
 }
 JS_END_EXTERN_C
 
--- a/js/src/xpconnect/src/xpccomponents.cpp
+++ b/js/src/xpconnect/src/xpccomponents.cpp
@@ -2807,17 +2807,17 @@ nsXPCComponents_Utils::LookupMethod()
     if(JSVAL_IS_PRIMITIVE(argv[0]))
         return NS_ERROR_XPC_BAD_CONVERT_JS;
 
     JSObject* obj = JSVAL_TO_OBJECT(argv[0]);
     rv = nsXPConnect::GetXPConnect()->GetJSObjectOfWrapper(cx, obj, &obj);
     if(NS_FAILED(rv))
         return rv;
 
-    OBJ_TO_INNER_OBJECT(cx, obj);
+    Innerize(cx, &obj);
     if(!obj)
         return NS_ERROR_XPC_BAD_CONVERT_JS;
 
     // second param must be a string
     if(!JSVAL_IS_STRING(argv[1]))
         return NS_ERROR_XPC_BAD_CONVERT_JS;
 
     // Make sure the name (argv[1]) that we use for looking up the
@@ -3108,17 +3108,17 @@ static JSBool
 sandbox_setProto(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
 {
     if (!JSVAL_IS_OBJECT(*vp)) {
         return JS_TRUE;
     }
 
     JSObject *pobj = JSVAL_TO_OBJECT(*vp);
     if (pobj) {
-        if (pobj->getClass() == &XPCCrossOriginWrapper::XOWClass.base &&
+        if (pobj->getJSClass() == &XPCCrossOriginWrapper::XOWClass.base &&
             !XPCWrapper::RewrapObject(cx, obj, pobj,
                                       XPCWrapper::XPCNW_EXPLICIT, vp)) {
             return JS_FALSE;
         }
     }
 
     return JS_SetPrototype(cx, obj, JSVAL_TO_OBJECT(*vp));
 }
@@ -3218,17 +3218,17 @@ xpc_CreateSandboxObject(JSContext * cx, 
     nsCOMPtr<nsIXPConnect> xpc(do_GetService(nsIXPConnect::GetCID(), &rv));
     if(NS_FAILED(rv))
         return NS_ERROR_XPC_UNEXPECTED;
 
     JSObject *sandbox = JS_NewObjectWithGivenProto(cx, &SandboxClass,
                                                    nsnull, nsnull);
     if (!sandbox)
         return NS_ERROR_XPC_UNEXPECTED;
-    js::AutoValueRooter tvr(cx, sandbox);
+    js::AutoObjectRooter tvr(cx, sandbox);
 
     nsCOMPtr<nsIScriptObjectPrincipal> sop(do_QueryInterface(prinOrSop));
 
     if (!sop) {
         nsCOMPtr<nsIPrincipal> principal(do_QueryInterface(prinOrSop));
 
         if (!principal) {
             principal = do_CreateInstance("@mozilla.org/nullprincipal;1", &rv);
@@ -3562,17 +3562,17 @@ xpc_EvalInSandbox(JSContext *cx, JSObjec
             PRBool system;
             ssm->IsSystemPrincipal(subjectPrincipal, &system);
             NS_ASSERTION(!fp || system, "Bad caller!");
         }
     }
 #endif
 
     sandbox = XPCWrapper::UnsafeUnwrapSecurityWrapper(cx, sandbox);
-    if (!sandbox || sandbox->getClass() != &SandboxClass) {
+    if (!sandbox || sandbox->getJSClass() != &SandboxClass) {
         return NS_ERROR_INVALID_ARG;
     }
 
     nsIScriptObjectPrincipal *sop =
         (nsIScriptObjectPrincipal*)xpc_GetJSPrivate(sandbox);
     NS_ASSERTION(sop, "Invalid sandbox passed");
     nsCOMPtr<nsIPrincipal> prin = sop->GetPrincipal();
 
--- a/js/src/xpconnect/src/xpcconvert.cpp
+++ b/js/src/xpconnect/src/xpcconvert.cpp
@@ -148,17 +148,17 @@ XPCConvert::IsMethodReflectable(const XP
 }
 
 /***************************************************************************/
 
 // static
 JSBool
 XPCConvert::GetISupportsFromJSObject(JSObject* obj, nsISupports** iface)
 {
-    JSClass* jsclass = obj->getClass();
+    JSClass* jsclass = obj->getJSClass();
     NS_ASSERTION(jsclass, "obj has no class");
     if(jsclass &&
        (jsclass->flags & JSCLASS_HAS_PRIVATE) &&
        (jsclass->flags & JSCLASS_PRIVATE_IS_NSISUPPORTS))
     {
         *iface = (nsISupports*) xpc_GetJSPrivate(obj);
         return JS_TRUE;
     }
@@ -197,23 +197,19 @@ AddXPCOMUCStringFinalizer()
 void
 XPCConvert::RemoveXPCOMUCStringFinalizer()
 {
     JS_RemoveExternalStringFinalizer(FinalizeXPCOMUCString);
     sXPCOMUCStringFinalizerIndex = -1;
 }
 
 
-#define FIT_32(cx,i,d)      (INT_FITS_IN_JSVAL(i) \
-                             ? *d = INT_TO_JSVAL(i), JS_TRUE    \
-                             : JS_NewDoubleValue(cx, i, d))
-
-#define FIT_U32(cx,i,d)     ((i) <= JSVAL_INT_MAX \
-                             ? *d = INT_TO_JSVAL(i), JS_TRUE    \
-                             : JS_NewDoubleValue(cx, i, d))
+#define FIT_U32(i)     ((i) <= JSVAL_INT_MAX      \
+                        ? INT_TO_JSVAL(i)         \
+                        : DOUBLE_TO_JSVAL(i))
 
 /*
  * Support for 64 bit conversions where 'long long' not supported.
  * (from John Fairhurst <mjf35@cam.ac.uk>)
  */
 
 #ifdef HAVE_LONG_LONG
 
@@ -247,29 +243,27 @@ XPCConvert::NativeData2JS(XPCLazyCallCon
 
     JSContext* cx = lccx.GetJSContext();
 
     if(pErr)
         *pErr = NS_ERROR_XPC_BAD_CONVERT_NATIVE;
 
     switch(type.TagPart())
     {
-    case nsXPTType::T_I8    : *d = INT_TO_JSVAL((int32)*((int8*)s));     break;
-    case nsXPTType::T_I16   : *d = INT_TO_JSVAL((int32)*((int16*)s));    break;
-    case nsXPTType::T_I32   : return FIT_32(cx,*((int32*)s),d);
-    case nsXPTType::T_I64   :
-        return JS_NewNumberValue(cx, INT64_TO_DOUBLE(*((int64*)s)), d);
-    case nsXPTType::T_U8    : *d = INT_TO_JSVAL((int32)*((uint8*)s));    break;
-    case nsXPTType::T_U16   : *d = INT_TO_JSVAL((int32)*((uint16*)s));   break;
-    case nsXPTType::T_U32   : return FIT_U32(cx,*((uint32*)s),d);
-    case nsXPTType::T_U64   :
-        return JS_NewNumberValue(cx, UINT64_TO_DOUBLE(*((uint64*)s)), d);
-    case nsXPTType::T_FLOAT : return JS_NewNumberValue(cx, *((float*)s), d);
-    case nsXPTType::T_DOUBLE: return JS_NewNumberValue(cx, *((double*)s), d);
-    case nsXPTType::T_BOOL  : *d = *((PRBool*)s)?JSVAL_TRUE:JSVAL_FALSE; break;
+    case nsXPTType::T_I8    : *d = INT_TO_JSVAL((int32)*((int8*)s));                 break;
+    case nsXPTType::T_I16   : *d = INT_TO_JSVAL((int32)*((int16*)s));                break;
+    case nsXPTType::T_I32   : *d = INT_TO_JSVAL(*((int32*)s));                       break;
+    case nsXPTType::T_I64   : *d = DOUBLE_TO_JSVAL(INT64_TO_DOUBLE(*((int64*)s)));   break;
+    case nsXPTType::T_U8    : *d = INT_TO_JSVAL((int32)*((uint8*)s));                break;
+    case nsXPTType::T_U16   : *d = INT_TO_JSVAL((int32)*((uint16*)s));               break;
+    case nsXPTType::T_U32   : *d = FIT_U32(*((uint32*)s));                           break;
+    case nsXPTType::T_U64   : *d = DOUBLE_TO_JSVAL(UINT64_TO_DOUBLE(*((uint64*)s))); break;
+    case nsXPTType::T_FLOAT : *d = DOUBLE_TO_JSVAL(*((float*)s));                    break;
+    case nsXPTType::T_DOUBLE: *d = DOUBLE_TO_JSVAL(*((double*)s));                   break;
+    case nsXPTType::T_BOOL  : *d = BOOLEAN_TO_JSVAL(*((PRBool*)s));                  break;
     case nsXPTType::T_CHAR  :
         {
             char* p = (char*)s;
             if(!p)
                 return JS_FALSE;
 
 #ifdef STRICT_CHECK_OF_UNICODE
             NS_ASSERTION(! ILLEGAL_CHAR_RANGE(p) , "passing non ASCII data");
@@ -1581,24 +1575,24 @@ XPCConvert::ConstructException(nsresult 
 }
 
 /********************************/
 
 class AutoExceptionRestorer
 {
 public:
     AutoExceptionRestorer(JSContext *cx, jsval v)
-        : mContext(cx), tvr(cx, v)
+        : mContext(cx), tvr(cx, js::Valueify(v))
     {
         JS_ClearPendingException(mContext);
     }
 
     ~AutoExceptionRestorer()
     {
-        JS_SetPendingException(mContext, tvr.value());
+        JS_SetPendingException(mContext, js::Jsvalify(tvr.value()));
     }
 
 private:
     JSContext * const mContext;
     js::AutoValueRooter tvr;
 };
 
 // static
@@ -1724,17 +1718,17 @@ XPCConvert::JSValToXPCException(XPCCallC
             rv = (nsresult) JSVAL_TO_INT(s);
             if(NS_FAILED(rv))
                 isResult = JS_TRUE;
             else
                 number = (double) JSVAL_TO_INT(s);
         }
         else
         {
-            number = *(JSVAL_TO_DOUBLE(s));
+            number = JSVAL_TO_DOUBLE(s);
             if(number > 0.0 &&
                number < (double)0xffffffff &&
                0.0 == fmod(number,1))
             {
                 rv = (nsresult) number;
                 if(NS_FAILED(rv))
                     isResult = JS_TRUE;
             }
--- a/js/src/xpconnect/src/xpcinlines.h
+++ b/js/src/xpconnect/src/xpcinlines.h
@@ -762,17 +762,17 @@ GetRTIdByIndex(JSContext *cx, uintN inde
 {
   XPCJSRuntime *rt = nsXPConnect::GetRuntimeInstance();
   return rt->GetStringID(index);
 }
 
 inline jsval
 GetRTStringByIndex(JSContext *cx, uintN index)
 {
-  return ID_TO_VALUE(GetRTIdByIndex(cx, index));
+  return ID_TO_JSVAL(GetRTIdByIndex(cx, index));
 }
 
 inline
 JSBool ThrowBadParam(nsresult rv, uintN paramNum, XPCCallContext& ccx)
 {
     XPCThrower::ThrowBadParam(rv, paramNum, ccx);
     return JS_FALSE;
 }
--- a/js/src/xpconnect/src/xpcprivate.h
+++ b/js/src/xpconnect/src/xpcprivate.h
@@ -1341,20 +1341,20 @@ DebugCheckWrapperClass(JSObject* obj)
 // a slim wrapper, holding a native in its private slot, or a wrappednative
 // wrapper, holding the XPCWrappedNative in its private slot. A slim wrapper
 // also holds a pointer to its XPCWrappedNativeProto in a reserved slot, we can
 // check that slot for a non-void value to distinguish between the two.
 
 // Only use these macros if IS_WRAPPER_CLASS(obj->getClass()) is true.
 #define IS_WN_WRAPPER_OBJECT(obj)                                             \
     (DebugCheckWrapperClass(obj) &&                                           \
-     JSVAL_IS_VOID(obj->getSlot(JSSLOT_START(obj->getClass()))))
+     obj->getSlot(JSSLOT_START(obj->getClass())).isUndefined())
 #define IS_SLIM_WRAPPER_OBJECT(obj)                                           \
     (DebugCheckWrapperClass(obj) &&                                           \
-     !JSVAL_IS_VOID(obj->getSlot(JSSLOT_START(obj->getClass()))))
+     !obj->getSlot(JSSLOT_START(obj->getClass())).isUndefined())
 
 // Use these macros if IS_WRAPPER_CLASS(obj->getClass()) might be false.
 // Avoid calling them if IS_WRAPPER_CLASS(obj->getClass()) can only be
 // true, as we'd do a redundant call to IS_WRAPPER_CLASS.
 #define IS_WN_WRAPPER(obj)                                                    \
     (IS_WRAPPER_CLASS(obj->getClass()) && IS_WN_WRAPPER_OBJECT(obj))
 #define IS_SLIM_WRAPPER(obj)                                                  \
     (IS_WRAPPER_CLASS(obj->getClass()) && IS_SLIM_WRAPPER_OBJECT(obj))
@@ -2260,18 +2260,18 @@ extern JSBool ConstructSlimWrapper(XPCCa
                                    nsWrapperCache *cache,
                                    XPCWrappedNativeScope* xpcScope,
                                    jsval *rval);
 extern JSBool MorphSlimWrapper(JSContext *cx, JSObject *obj);
 
 static inline XPCWrappedNativeProto*
 GetSlimWrapperProto(JSObject *obj)
 {
-  jsval v = obj->getSlot(JSSLOT_START(obj->getClass()));
-  return static_cast<XPCWrappedNativeProto*>(JSVAL_TO_PRIVATE(v));
+  const js::Value &v = obj->getSlot(JSSLOT_START(obj->getClass()));
+  return static_cast<XPCWrappedNativeProto*>(v.asPrivateVoidPtr());
 }
 
 
 /***********************************************/
 // XPCWrappedNativeTearOff represents the info needed to make calls to one
 // interface on the underlying native object of a XPCWrappedNative.
 
 class XPCWrappedNativeTearOff
@@ -2641,17 +2641,17 @@ public:
 
     JSBool NeedsChromeWrapper() { return !!(mWrapperWord & CHROME_ONLY); }
     void SetNeedsChromeWrapper() { mWrapperWord |= CHROME_ONLY; }
     JSBool IsDoubleWrapper() { return !!(mWrapperWord & DOUBLE_WRAPPER); }
     void SetIsDoubleWrapper() { mWrapperWord |= DOUBLE_WRAPPER; }
 
     JSObject* GetWrapper()
     {
-        return (JSObject *) JSVAL_CLRTAG(mWrapperWord);
+        return (JSObject *) (mWrapperWord & FLAG_MASK);
     }
     void SetWrapper(JSObject *obj)
     {
         JSBool needsChrome = NeedsChromeWrapper();
         JSBool doubleWrapper = IsDoubleWrapper();
         mWrapperWord = PRWord(obj) | doubleWrapper | needsChrome;
     }
 
@@ -2683,17 +2683,17 @@ protected:
     // This ctor is used if this object will NOT have a proto.
     XPCWrappedNative(already_AddRefed<nsISupports> aIdentity,
                      XPCWrappedNativeScope* aScope,
                      XPCNativeSet* aSet);
 
     virtual ~XPCWrappedNative();
 
 private:
-    enum { CHROME_ONLY = JS_BIT(0), DOUBLE_WRAPPER = JS_BIT(1) };
+    enum { CHROME_ONLY = JS_BIT(0), DOUBLE_WRAPPER = JS_BIT(1), FLAG_MASK = (PRWord)~(PRWord)0x3 };
 
     void TraceOtherWrapper(JSTracer* trc);
     JSBool Init(XPCCallContext& ccx, JSObject* parent, JSBool isGlobal,
                 const XPCNativeScriptableCreateInfo* sci);
     JSBool Init(XPCCallContext &ccx, JSObject *existingJSObject);
     JSBool FinishInit(XPCCallContext &ccx);
 
     JSBool ExtendSet(XPCCallContext& ccx, XPCNativeInterface* aInterface);
--- a/js/src/xpconnect/src/xpcstring.cpp
+++ b/js/src/xpconnect/src/xpcstring.cpp
@@ -81,18 +81,17 @@ XPCStringConvert::ReadableToJSVal(JSCont
 {
     JSString *str;
 
     PRUint32 length = readable.Length();
 
     JSAtom *atom;
     if (length == 0 && (atom = cx->runtime->atomState.emptyAtom))
     {
-        NS_ASSERTION(ATOM_IS_STRING(atom), "What kind of atom is this?");
-        return ATOM_KEY(atom);
+        return ATOM_TO_JSVAL(atom);
     }
 
     nsStringBuffer *buf = nsStringBuffer::FromString(readable);
     if (buf)
     {
         // yay, we can share the string's buffer!
 
         if (sDOMStringFinalizerIndex == -1)
--- a/js/src/xpconnect/src/xpcvariant.cpp
+++ b/js/src/xpconnect/src/xpcvariant.cpp
@@ -296,17 +296,17 @@ XPCArrayHomogenizer::GetTypeForArray(XPC
 
 JSBool XPCVariant::InitializeData(XPCCallContext& ccx)
 {
     if(JSVAL_IS_INT(mJSVal))
         return NS_SUCCEEDED(nsVariant::SetFromInt32(&mData, 
                                                     JSVAL_TO_INT(mJSVal)));
     if(JSVAL_IS_DOUBLE(mJSVal))
         return NS_SUCCEEDED(nsVariant::SetFromDouble(&mData, 
-                                                     *JSVAL_TO_DOUBLE(mJSVal)));
+                                                     JSVAL_TO_DOUBLE(mJSVal)));
     if(JSVAL_IS_BOOLEAN(mJSVal))
         return NS_SUCCEEDED(nsVariant::SetFromBool(&mData, 
                                                    JSVAL_TO_BOOLEAN(mJSVal)));
     if(JSVAL_IS_VOID(mJSVal))
         return NS_SUCCEEDED(nsVariant::SetToVoid(&mData));
     if(JSVAL_IS_NULL(mJSVal))
         return NS_SUCCEEDED(nsVariant::SetToEmpty(&mData));
     if(JSVAL_IS_STRING(mJSVal))
--- a/js/src/xpconnect/src/xpcwrappedjsclass.cpp
+++ b/js/src/xpconnect/src/xpcwrappedjsclass.cpp
@@ -352,17 +352,17 @@ nsXPCWrappedJSClass::CallQueryInterfaceO
                             JS_ClearPendingException(cx);
                         }
                     }
                 }
                 else if(JSVAL_IS_NUMBER(jsexception))
                 {
                     // JS often throws an nsresult.
                     if(JSVAL_IS_DOUBLE(jsexception))
-                        rv = (nsresult)(*JSVAL_TO_DOUBLE(jsexception));
+                        rv = (nsresult)(JSVAL_TO_DOUBLE(jsexception));
                     else
                         rv = (nsresult)(JSVAL_TO_INT(jsexception));
 
                     if(rv == NS_NOINTERFACE)
                         JS_ClearPendingException(cx);
                 }
             }
 
@@ -1279,17 +1279,16 @@ nsXPCWrappedJSClass::CallMethod(nsXPCWra
     JSObject* obj;
     const char* name = info->name;
     jsval fval;
     JSBool foundDependentParam;
     XPCContext* xpcc;
     JSContext* cx;
     JSObject* thisObj;
     bool invokeCall;
-    bool invokeCall;
 
     // Make sure not to set the callee on ccx until after we've gone through
     // the whole nsIXPCFunctionThisTranslator bit.  That code uses ccx to
     // convert natives to JSObjects, but we do NOT plan to pass those JSObjects
     // to our real callee.
     JSContext *context = GetContextFromObject(wrapper->GetJSObject());
     XPCCallContext ccx(NATIVE_CALLER, context);
     if(ccx.IsValid())
@@ -1466,17 +1465,17 @@ nsXPCWrappedJSClass::CallMethod(nsXPCWra
      */
     JS_ASSERT_IF(!invokeCall, argc < 2);
     if (!cx->stack().pushInvokeArgsFriendAPI(cx, invokeCall ? argc : 0, args))
     {
         retval = NS_ERROR_OUT_OF_MEMORY;
         goto pre_call_clean_up;
     }
 
-    sp = stackbase = args.getvp();
+    sp = stackbase = Jsvalify(args.getvp());
 
     // this is a function call, so push function and 'this'
     if(invokeCall)
     {
         *sp++ = fval;
         *sp++ = OBJECT_TO_JSVAL(thisObj);
     }
 
@@ -1683,17 +1682,17 @@ pre_call_clean_up:
     if(XPT_MD_IS_GETTER(info->flags))
         success = JS_GetProperty(cx, obj, name, stackbase);
     else if(XPT_MD_IS_SETTER(info->flags))
         success = JS_SetProperty(cx, obj, name, stackbase);
     else
     {
         if(!JSVAL_IS_PRIMITIVE(fval))
         {
-            success = js_Invoke(cx, args, 0);
+            success = js::Invoke(cx, args, 0);
         }
         else
         {
             // The property was not an object so can't be a function.
             // Let's build and 'throw' an exception.
 
             static const nsresult code =
                     NS_ERROR_XPC_JSOBJECT_HAS_NO_FUNCTION_NAMED;
--- a/js/src/xpconnect/src/xpcwrappednative.cpp
+++ b/js/src/xpconnect/src/xpcwrappednative.cpp
@@ -1649,17 +1649,17 @@ XPCWrappedNative::GetWrappedNativeOfJSOb
     // If we were passed a function object then we need to find the correct
     // wrapper out of those that might be in the callee obj's proto chain.
 
     if(funobj)
     {
         JSObject* funObjParent = funobj->getParent();
         NS_ASSERTION(funObjParent, "funobj has no parent");
 
-        JSClass* funObjParentClass = funObjParent->getClass();
+        JSClass* funObjParentClass = funObjParent->getJSClass();
 
         if(IS_PROTO_CLASS(funObjParentClass))
         {
             NS_ASSERTION(funObjParent->getParent(), "funobj's parent (proto) is global");
             proto = (XPCWrappedNativeProto*) xpc_GetJSPrivate(funObjParent);
             if(proto)
                 protoClassInfo = proto->GetClassInfo();
         }
@@ -1680,17 +1680,17 @@ XPCWrappedNative::GetWrappedNativeOfJSOb
             return nsnull;
         }
     }
 
     for(cur = obj; cur; cur = cur->getProto())
     {
         // this is on two lines to make the compiler happy given the goto.
         JSClass* clazz;
-        clazz = cur->getClass();
+        clazz = cur->getJSClass();
 
         if(IS_WRAPPER_CLASS(clazz))
         {
 return_wrapper:
             JSBool isWN = IS_WN_WRAPPER_OBJECT(cur);
             XPCWrappedNative* wrapper =
                 isWN ? (XPCWrappedNative*) xpc_GetJSPrivate(cur) : nsnull;
             if(proto)
@@ -1737,26 +1737,26 @@ return_tearoff:
         if((unsafeObj = XPCWrapper::Unwrap(cx, cur)))
             return GetWrappedNativeOfJSObject(cx, unsafeObj, funobj, pobj2,
                                               pTearOff);
     }
 
     // If we didn't find a wrapper using the given funobj and obj, try
     // again with obj's outer object, if it's got one.
 
-    JSClass *clazz = obj->getClass();
+    JSClass *clazz = obj->getJSClass();
 
     if((clazz->flags & JSCLASS_IS_EXTENDED) &&
         ((JSExtendedClass*)clazz)->outerObject)
     {
         JSObject *outer = ((JSExtendedClass*)clazz)->outerObject(cx, obj);
 
         // Protect against infinite recursion through XOWs.
         JSObject *unsafeObj;
-        clazz = outer->getClass();
+        clazz = outer->getJSClass();
         if(clazz == &XPCCrossOriginWrapper::XOWClass.base &&
            (unsafeObj = XPCWrapper::UnwrapXOW(cx, outer)))
         {
             outer = unsafeObj;
         }
 
         if(outer && outer != obj)
             return GetWrappedNativeOfJSObject(cx, outer, funobj, pobj2,
--- a/js/src/xpconnect/src/xpcwrappednativejsops.cpp
+++ b/js/src/xpconnect/src/xpcwrappednativejsops.cpp
@@ -517,17 +517,17 @@ DefinePropertyIfFound(XPCCallContext& cc
     if(member->IsWritableAttribute())
     {
         propFlags |= JSPROP_SETTER;
         propFlags &= ~JSPROP_READONLY;
         setter = getter;
     }
     else
     {
-        setter = js_GetterOnlyPropertyStub;
+        setter = Jsvalify(js_GetterOnlyPropertyStub);
     }
 
     AutoResolveName arn(ccx, idval);
     if(resolved)
         *resolved = JS_TRUE;
 
     return JS_ValueToId(ccx, idval, &id) &&
            JS_DefinePropertyById(ccx, obj, id, JSVAL_VOID, getter, setter,
@@ -848,17 +848,17 @@ XPC_WN_Equality(JSContext *cx, JSObject 
     XPCNativeScriptableInfo* si = wrapper->GetScriptableInfo();
     if(si && si->GetFlags().WantEquality())
     {
         nsresult rv = si->GetCallback()->Equality(wrapper, cx, obj, v, bp);
         if(NS_FAILED(rv))
             return Throw(rv, cx);
 
         if(!*bp && !JSVAL_IS_PRIMITIVE(v) &&
-           JSVAL_TO_OBJECT(v)->getClass() == &XPCSafeJSObjectWrapper::SJOWClass.base)
+           JSVAL_TO_OBJECT(v)->getJSClass() == &XPCSafeJSObjectWrapper::SJOWClass.base)
         {
             v = OBJECT_TO_JSVAL(XPCSafeJSObjectWrapper::GetUnsafeObject(cx, JSVAL_TO_OBJECT(v)));
 
             rv = si->GetCallback()->Equality(wrapper, cx, obj, v, bp);
             if(NS_FAILED(rv))
                 return Throw(rv, cx);
         }
     }
@@ -1278,17 +1278,17 @@ XPC_WN_Helper_NewResolve(JSContext *cx, 
         }
     }
 
     return retval;
 }
 
 /***************************************************************************/
 
-extern "C" JS_IMPORT_DATA(JSObjectOps) js_ObjectOps;
+JS_IMPORT_DATA(JSObjectOps) js_ObjectOps;
 
 static JSObjectOps XPC_WN_WithCall_JSOps;
 static JSObjectOps XPC_WN_NoCall_JSOps;
 
 /*
     Here are the enumerator cases:
 
     set jsclass enumerate to stub (unless noted otherwise)
@@ -1322,17 +1322,17 @@ static JSObjectOps XPC_WN_NoCall_JSOps;
         else
             do shared enumerate - don't use this JSOp thing at all
 */
 
 static JSBool
 XPC_WN_JSOp_Enumerate(JSContext *cx, JSObject *obj, JSIterateOp enum_op,
                       jsval *statep, jsid *idp)
 {
-    JSClass *clazz = obj->getClass();
+    JSClass *clazz = obj->getJSClass();
     if(!IS_WRAPPER_CLASS(clazz) || clazz == &XPC_WN_NoHelper_JSClass.base)
     {
         // obj must be a prototype object or a wrapper w/o a
         // helper. Short circuit this call to
         // js_ObjectOps.enumerate().
 
         return js_ObjectOps.enumerate(cx, obj, enum_op, statep, idp);
     }
--- a/modules/plugin/base/src/nsJSNPRuntime.cpp
+++ b/modules/plugin/base/src/nsJSNPRuntime.cpp
@@ -578,17 +578,17 @@ nsJSObjWrapper::NP_Deallocate(NPObject *
 // static
 void
 nsJSObjWrapper::NP_Invalidate(NPObject *npobj)
 {
   nsJSObjWrapper *jsnpobj = (nsJSObjWrapper *)npobj;
 
   if (jsnpobj && jsnpobj->mJSObj) {
     // Unroot the object's JSObject
-    ::JS_RemoveRootRT(sJSRuntime, &jsnpobj->mJSObj);
+    js_RemoveRoot(sJSRuntime, &jsnpobj->mJSObj);
 
     if (sJSObjWrappers.ops) {
       // Remove the wrapper from the hash
 
       nsJSObjWrapperKey key(jsnpobj->mJSObj, jsnpobj->mNpp);
       PL_DHashTableOperate(&sJSObjWrappers, &key, PL_DHASH_REMOVE);
     }
 
@@ -1152,17 +1152,17 @@ nsJSObjWrapper::GetNewOrUsed(NPP npp, JS
   entry->mJSObjWrapper = wrapper;
 
   NS_ASSERTION(wrapper->mNpp == npp, "nsJSObjWrapper::mNpp not initialized!");
 
   JSAutoRequest ar(cx);
 
   // Root the JSObject, its lifetime is now tied to that of the
   // NPObject.
-  if (!::JS_AddNamedRoot(cx, &wrapper->mJSObj, "nsJSObjWrapper::mJSObject")) {
+  if (!::JS_AddNamedObjectRoot(cx, &wrapper->mJSObj, "nsJSObjWrapper::mJSObject")) {
     NS_ERROR("Failed to root JSObject!");
 
     _releaseobject(wrapper);
 
     PL_DHashTableRawRemove(&sJSObjWrappers, entry);
 
     return nsnull;
   }
@@ -2127,17 +2127,17 @@ CreateNPObjectMember(NPP npp, JSContext 
 
   JSObject *memobj = ::JS_NewObject(cx, &sNPObjectMemberClass, nsnull, nsnull);
   if (!memobj) {
     PR_Free(memberPrivate);
     return JS_FALSE;
   }
 
   *vp = OBJECT_TO_JSVAL(memobj);
-  ::JS_AddRoot(cx, vp);
+  ::JS_AddValueRoot(cx, vp);
 
   ::JS_SetPrivate(cx, memobj, (void *)memberPrivate);
 
   jsval fieldValue;
   NPVariant npv;
   NPBool hasProperty;
 
   if (getPropertyResult) {
@@ -2146,22 +2146,22 @@ CreateNPObjectMember(NPP npp, JSContext 
     hasProperty = true;
   }
   else {
     VOID_TO_NPVARIANT(npv);
 
     NPBool hasProperty = npobj->_class->getProperty(npobj, (NPIdentifier)id,
                                                     &npv);
     if (!ReportExceptionIfPending(cx)) {
-      ::JS_RemoveRoot(cx, vp);
+      ::JS_RemoveValueRoot(cx, vp);
       return JS_FALSE;
     }
 
     if (!hasProperty) {
-      ::JS_RemoveRoot(cx, vp);
+      ::JS_RemoveValueRoot(cx, vp);
       return JS_FALSE;
     }
   }
 
   fieldValue = NPVariantToJSVal(npp, cx, &npv);
 
   // npobjWrapper is the JSObject through which we make sure we don't
   // outlive the underlying NPObject, so make sure it points to the
@@ -2171,17 +2171,17 @@ CreateNPObjectMember(NPP npp, JSContext 
   }
 
   memberPrivate->npobjWrapper = obj;
 
   memberPrivate->fieldValue = fieldValue;
   memberPrivate->methodName = id;
   memberPrivate->npp = npp;
 
-  ::JS_RemoveRoot(cx, vp);
+  ::JS_RemoveValueRoot(cx, vp);
 
   return JS_TRUE;
 }
 
 static JSBool
 NPObjectMember_Convert(JSContext *cx, JSObject *obj, JSType type, jsval *vp)
 {
   NPObjectMemberPrivate *memberPrivate =
--- a/security/manager/ssl/src/nsCrypto.cpp
+++ b/security/manager/ssl/src/nsCrypto.cpp
@@ -2154,26 +2154,26 @@ nsCryptoRunArgs::~nsCryptoRunArgs() {}
 
 
 nsCryptoRunnable::nsCryptoRunnable(nsCryptoRunArgs *args)
 {
   nsNSSShutDownPreventionLock locker;
   NS_ASSERTION(args,"Passed nsnull to nsCryptoRunnable constructor.");
   m_args = args;
   NS_IF_ADDREF(m_args);
-  JS_AddNamedRoot(args->m_cx, &args->m_scope,"nsCryptoRunnable::mScope");
+  JS_AddNamedObjectRoot(args->m_cx, &args->m_scope,"nsCryptoRunnable::mScope");
 }
 
 nsCryptoRunnable::~nsCryptoRunnable()
 {
   nsNSSShutDownPreventionLock locker;
 
   {
     JSAutoRequest ar(m_args->m_cx);
-    JS_RemoveRoot(m_args->m_cx, &m_args->m_scope);
+    JS_RemoveObjectRoot(m_args->m_cx, &m_args->m_scope);
   }
 
   NS_IF_RELEASE(m_args);
 }
 
 //Implementation that runs the callback passed to 
 //crypto.generateCRMFRequest as an event.
 NS_IMETHODIMP
--- a/xpinstall/src/nsXPITriggerInfo.cpp
+++ b/xpinstall/src/nsXPITriggerInfo.cpp
@@ -190,17 +190,17 @@ nsXPITriggerInfo::~nsXPITriggerInfo()
         item = Get(i);
         if (item)
             delete item;
     }
     mItems.Clear();
 
     if ( mCx && !JSVAL_IS_NULL(mCbval) ) {
         JS_BeginRequest(mCx);
-        JS_RemoveRoot( mCx, &mCbval );
+        JS_RemoveValueRoot(mCx, &mCbval );
         JS_EndRequest(mCx);
     }
 
     MOZ_COUNT_DTOR(nsXPITriggerInfo);
 }
 
 void nsXPITriggerInfo::SaveCallback( JSContext *aCx, jsval aVal )
 {
@@ -214,25 +214,25 @@ void nsXPITriggerInfo::SaveCallback( JSC
         return;
 
     mCx = aCx;
     mCbval = aVal;
     mThread = do_GetCurrentThread();
 
     if ( !JSVAL_IS_NULL(mCbval) ) {
         JS_BeginRequest(mCx);
-        JS_AddRoot( mCx, &mCbval );
+        JS_AddValueRoot(mCx, &mCbval );
         JS_EndRequest(mCx);
     }
 }
 
 XPITriggerEvent::~XPITriggerEvent()
 {
     JS_BeginRequest(cx);
-    JS_RemoveRoot(cx, &cbval);
+    JS_RemoveValueRoot(cx, &cbval);
     JS_EndRequest(cx);
 }
 
 NS_IMETHODIMP
 XPITriggerEvent::Run()
 {
     JSAutoRequest ar(cx);
 
@@ -323,17 +323,17 @@ void nsXPITriggerInfo::SendStatus(const 
         {
             event->URL      = URL;
             event->status   = status;
             event->cx       = mCx;
             event->princ    = mPrincipal;
 
             event->cbval    = mCbval;
             JS_BeginRequest(event->cx);
-            JS_AddNamedRoot(event->cx, &event->cbval,
+            JS_AddNamedValueRoot(event->cx, &event->cbval,
                             "XPITriggerEvent::cbval" );
             JS_EndRequest(event->cx);
 
             // Hold a strong reference to keep the underlying
             // JSContext from dying before we handle this event.
             event->ref      = mContextWrapper;
 
             rv = mThread->Dispatch(event, NS_DISPATCH_NORMAL);