Bug 831386 - GC: ChromeBuffer jsapi test fails under rooting analysis r=terrence
authorJon Coppeard <jcoppeard@mozilla.com>
Wed, 16 Jan 2013 18:42:04 +0000
changeset 119261 2c517fcf3c690a9088a3a778701fab3a0c52abeb
parent 119260 7d5fdfc2b165cd6ab6b0d7c60d017d4114ec2b5b
child 119262 e5f0630bccc324e4976acb25578b66a1769c7f6d
push id24195
push userMs2ger@gmail.com
push dateSat, 19 Jan 2013 16:10:11 +0000
treeherdermozilla-central@02e12a80aef9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersterrence
bugs831386
milestone21.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 831386 - GC: ChromeBuffer jsapi test fails under rooting analysis r=terrence
js/src/jsapi-tests/testChromeBuffer.cpp
--- a/js/src/jsapi-tests/testChromeBuffer.cpp
+++ b/js/src/jsapi-tests/testChromeBuffer.cpp
@@ -27,17 +27,17 @@ JSBool
 CallTrusted(JSContext *cx, unsigned argc, jsval *vp)
 {
     if (!JS_SaveFrameChain(cx))
         return JS_FALSE;
 
     JSBool ok = JS_FALSE;
     {
         JSAutoCompartment ac(cx, trusted_glob);
-        ok = JS_CallFunctionValue(cx, NULL, OBJECT_TO_JSVAL(trusted_fun),
+        ok = JS_CallFunctionValue(cx, NULL, JS::ObjectValue(*trusted_fun),
                                   0, NULL, vp);
     }
     JS_RestoreFrameChain(cx);
     return ok;
 }
 
 BEGIN_TEST(testChromeBuffer)
 {
@@ -65,30 +65,30 @@ BEGIN_TEST(testChromeBuffer)
             const char *bytes = "return x ? 1 + trusted(x-1) : 0";
             JS::HandleObject global = JS::HandleObject::fromMarkedLocation(&trusted_glob);
             CHECK(fun = JS_CompileFunctionForPrincipals(cx, global, &system_principals,
                                                         "trusted", 1, &paramName, bytes, strlen(bytes),
                                                         "", 0));
             trusted_fun = JS_GetFunctionObject(fun);
         }
 
-        jsval v = OBJECT_TO_JSVAL(trusted_fun);
-        CHECK(JS_WrapValue(cx, &v));
+        js::RootedValue v(cx, JS::ObjectValue(*trusted_fun));
+        CHECK(JS_WrapValue(cx, v.address()));
 
         const char *paramName = "trusted";
         const char *bytes = "try {                                      "
                             "  return untrusted(trusted);               "
                             "} catch (e) {                              "
                             "  return trusted(100);                     "
                             "}                                          ";
         CHECK(fun = JS_CompileFunction(cx, global, "untrusted", 1, &paramName,
                                        bytes, strlen(bytes), "", 0));
 
         jsval rval;
-        CHECK(JS_CallFunction(cx, NULL, fun, 1, &v, &rval));
+        CHECK(JS_CallFunction(cx, NULL, fun, 1, v.address(), &rval));
         CHECK(JSVAL_TO_INT(rval) == 100);
     }
 
     /*
      * Check that content called from chrome in the reserved-buffer space
      * immediately ooms.
      */
     {
@@ -102,30 +102,30 @@ BEGIN_TEST(testChromeBuffer)
                                 "}                                      ";
             JS::HandleObject global = JS::HandleObject::fromMarkedLocation(&trusted_glob);
             CHECK(fun = JS_CompileFunctionForPrincipals(cx, global, &system_principals,
                                                         "trusted", 1, &paramName, bytes, strlen(bytes),
                                                         "", 0));
             trusted_fun = JS_GetFunctionObject(fun);
         }
 
-        jsval v = OBJECT_TO_JSVAL(trusted_fun);
-        CHECK(JS_WrapValue(cx, &v));
+        js::RootedValue v(cx, JS::ObjectValue(*trusted_fun));
+        CHECK(JS_WrapValue(cx, v.address()));
 
         const char *paramName = "trusted";
         const char *bytes = "try {                                      "
                             "  return untrusted(trusted);               "
                             "} catch (e) {                              "
                             "  return trusted(untrusted);               "
                             "}                                          ";
         CHECK(fun = JS_CompileFunction(cx, global, "untrusted", 1, &paramName,
                                        bytes, strlen(bytes), "", 0));
 
         jsval rval;
-        CHECK(JS_CallFunction(cx, NULL, fun, 1, &v, &rval));
+        CHECK(JS_CallFunction(cx, NULL, fun, 1, v.address(), &rval));
         JSBool match;
         CHECK(JS_StringEqualsAscii(cx, JSVAL_TO_STRING(rval), "From trusted: InternalError: too much recursion", &match));
         CHECK(match);
     }
 
     /*
      * Check that JS_SaveFrameChain called on the way from content to chrome
      * (say, as done by XPCJSContextSTack::Push) works.
@@ -137,30 +137,30 @@ BEGIN_TEST(testChromeBuffer)
             JS::HandleObject global = JS::HandleObject::fromMarkedLocation(&trusted_glob);
             CHECK(fun = JS_CompileFunctionForPrincipals(cx, global, &system_principals,
                                                         "trusted", 0, NULL, bytes, strlen(bytes),
                                                         "", 0));
             trusted_fun = JS_GetFunctionObject(fun);
         }
 
         JSFunction *fun = JS_NewFunction(cx, CallTrusted, 0, 0, global, "callTrusted");
-        JS::Anchor<JSObject *> callTrusted(JS_GetFunctionObject(fun));
+        js::RootedObject callTrusted(cx, JS_GetFunctionObject(fun));
 
         const char *paramName = "f";
         const char *bytes = "try {                                      "
                             "  return untrusted(trusted);               "
                             "} catch (e) {                              "
                             "  return f();                              "
                             "}                                          ";
         CHECK(fun = JS_CompileFunction(cx, global, "untrusted", 1, &paramName,
                                        bytes, strlen(bytes), "", 0));
 
-        jsval arg = OBJECT_TO_JSVAL(callTrusted.get());
+        js::RootedValue arg(cx, JS::ObjectValue(*callTrusted));
         jsval rval;
-        CHECK(JS_CallFunction(cx, NULL, fun, 1, &arg, &rval));
+        CHECK(JS_CallFunction(cx, NULL, fun, 1, arg.address(), &rval));
         CHECK(JSVAL_TO_INT(rval) == 42);
     }
 
     return true;
 }
 virtual void uninit() {
     JS_RemoveObjectRoot(cx, &trusted_glob);
     JS_RemoveObjectRoot(cx, &trusted_fun);