Bug 831216 - GC: jsapi test GCFinalizeCallback fails under rooting analysis r=billm
authorJon Coppeard <jcoppeard@mozilla.com>
Wed, 16 Jan 2013 18:42:04 +0000
changeset 119131 4959e4692993ebb0d5645da8d47337de9f8f32d7
parent 119130 15db83a182f50f40fe4333d6354e1015edb1d95d
child 119132 935b891ba3988d9c6949e09dc404bb4a0f0e4df2
push id21479
push userjcoppeard@mozilla.com
push dateThu, 17 Jan 2013 12:25:13 +0000
treeherdermozilla-inbound@935b891ba398 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbillm
bugs831216
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 831216 - GC: jsapi test GCFinalizeCallback fails under rooting analysis r=billm
js/src/jsapi-tests/testGCFinalizeCallback.cpp
--- a/js/src/jsapi-tests/testGCFinalizeCallback.cpp
+++ b/js/src/jsapi-tests/testGCFinalizeCallback.cpp
@@ -42,58 +42,58 @@ BEGIN_TEST(testGCFinalizeCallback)
     js::PrepareForFullGC(rt);
     js::IncrementalGC(rt, js::gcreason::API, 1000000);
     CHECK(rt->gcIncrementalState == js::gc::NO_INCREMENTAL);
     CHECK(rt->gcIsFull);
     CHECK(checkMultipleGroups());
     CHECK(checkFinalizeStatus());
     CHECK(checkFinalizeIsCompartmentGC(false));
 
-    js::AutoObjectRooter global1(cx, createGlobal());
-    js::AutoObjectRooter global2(cx, createGlobal());
-    js::AutoObjectRooter global3(cx, createGlobal());
-    CHECK(global1.object());
-    CHECK(global2.object());
-    CHECK(global3.object());
+    js::RootedObject global1(cx, createGlobal());
+    js::RootedObject global2(cx, createGlobal());
+    js::RootedObject global3(cx, createGlobal());
+    CHECK(global1);
+    CHECK(global2);
+    CHECK(global3);
 
     /* Compartment GC, non-incremental, single compartment. */
     FinalizeCalls = 0;
-    js::PrepareCompartmentForGC(global1.object()->compartment());
+    js::PrepareCompartmentForGC(global1->compartment());
     js::GCForReason(rt, js::gcreason::API);
     CHECK(!rt->gcIsFull);
     CHECK(checkSingleGroup());
     CHECK(checkFinalizeStatus());
     CHECK(checkFinalizeIsCompartmentGC(true));
 
     /* Compartment GC, non-incremental, multiple compartments. */
     FinalizeCalls = 0;
-    js::PrepareCompartmentForGC(global1.object()->compartment());
-    js::PrepareCompartmentForGC(global2.object()->compartment());
-    js::PrepareCompartmentForGC(global3.object()->compartment());
+    js::PrepareCompartmentForGC(global1->compartment());
+    js::PrepareCompartmentForGC(global2->compartment());
+    js::PrepareCompartmentForGC(global3->compartment());
     js::GCForReason(rt, js::gcreason::API);
     CHECK(!rt->gcIsFull);
     CHECK(checkSingleGroup());
     CHECK(checkFinalizeStatus());
     CHECK(checkFinalizeIsCompartmentGC(true));
 
     /* Compartment GC, incremental, single compartment. */
     FinalizeCalls = 0;
-    js::PrepareCompartmentForGC(global1.object()->compartment());
+    js::PrepareCompartmentForGC(global1->compartment());
     js::IncrementalGC(rt, js::gcreason::API, 1000000);
     CHECK(rt->gcIncrementalState == js::gc::NO_INCREMENTAL);
     CHECK(!rt->gcIsFull);
     CHECK(checkSingleGroup());
     CHECK(checkFinalizeStatus());
     CHECK(checkFinalizeIsCompartmentGC(true));
 
     /* Compartment GC, incremental, multiple compartments. */
     FinalizeCalls = 0;
-    js::PrepareCompartmentForGC(global1.object()->compartment());
-    js::PrepareCompartmentForGC(global2.object()->compartment());
-    js::PrepareCompartmentForGC(global3.object()->compartment());
+    js::PrepareCompartmentForGC(global1->compartment());
+    js::PrepareCompartmentForGC(global2->compartment());
+    js::PrepareCompartmentForGC(global3->compartment());
     js::IncrementalGC(rt, js::gcreason::API, 1000000);
     CHECK(rt->gcIncrementalState == js::gc::NO_INCREMENTAL);
     CHECK(!rt->gcIsFull);
     CHECK(checkMultipleGroups());
     CHECK(checkFinalizeStatus());
     CHECK(checkFinalizeIsCompartmentGC(true));
 
 #ifdef JS_GC_ZEAL
@@ -102,31 +102,40 @@ BEGIN_TEST(testGCFinalizeCallback)
 
     FinalizeCalls = 0;
     JS_SetGCZeal(cx, 9, 1000000);
     js::PrepareForFullGC(rt);
     js::GCDebugSlice(rt, true, 1);
     CHECK(rt->gcIncrementalState == js::gc::MARK);
     CHECK(rt->gcIsFull);
 
-    js::AutoObjectRooter global4(cx, createGlobal());
+    js::RootedObject global4(cx, createGlobal());
     js::GCDebugSlice(rt, true, 1);
     CHECK(rt->gcIncrementalState == js::gc::NO_INCREMENTAL);
     CHECK(!rt->gcIsFull);
     CHECK(checkMultipleGroups());
     CHECK(checkFinalizeStatus());
 
     for (unsigned i = 0; i < FinalizeCalls - 1; ++i)
         CHECK(!IsCompartmentGCBuffer[i]);
     CHECK(IsCompartmentGCBuffer[FinalizeCalls - 1]);
 
     JS_SetGCZeal(cx, 0, 0);
 
 #endif
 
+    /*
+     * Make some use of the globals here to ensure the compiler doesn't optimize
+     * them away in release builds, causing the compartments to be collected and
+     * the test to fail.
+     */
+    CHECK(JS_IsGlobalObject(global1));
+    CHECK(JS_IsGlobalObject(global2));
+    CHECK(JS_IsGlobalObject(global3));
+
     JS_SetFinalizeCallback(rt, NULL);
     return true;
 }
 
 bool checkSingleGroup()
 {
     CHECK(FinalizeCalls < BufferSize);
     CHECK(FinalizeCalls == 3);