Bug 847579 - Re-enable testGCOutOfMemory, r=terrence
authorSteve Fink <sfink@mozilla.com>
Fri, 16 Jan 2015 12:50:16 -0800
changeset 224327 fc089bc9d516ec410b3fc87266d54a42b1ff1dc4
parent 224326 cde7eff18b1a8cdcafd30624f320045733a56ef7
child 224328 fd38183fccea02e62b3bc15b33b77cdcf48dcba4
push id28122
push userkwierso@gmail.com
push dateSat, 17 Jan 2015 01:33:15 +0000
treeherdermozilla-central@369a8f14ccf8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersterrence
bugs847579
milestone38.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 847579 - Re-enable testGCOutOfMemory, r=terrence
js/src/jsapi-tests/testGCOutOfMemory.cpp
--- a/js/src/jsapi-tests/testGCOutOfMemory.cpp
+++ b/js/src/jsapi-tests/testGCOutOfMemory.cpp
@@ -17,48 +17,55 @@ ErrorCounter(JSContext *cx, const char *
 }
 
 BEGIN_TEST(testGCOutOfMemory)
 {
     JS_SetErrorReporter(rt, ErrorCounter);
 
     JS::RootedValue root(cx);
 
+    // Count the number of allocations until we hit OOM, and store it in 'max'.
     static const char source[] =
         "var max = 0; (function() {"
         "    var array = [];"
         "    for (; ; ++max)"
         "        array.push({});"
         "    array = []; array.push(0);"
         "})();";
     JS::CompileOptions opts(cx);
     bool ok = JS::Evaluate(cx, global, opts, source, strlen(source), &root);
 
     /* Check that we get OOM. */
     CHECK(!ok);
     CHECK(!JS_IsExceptionPending(cx));
     CHECK_EQUAL(errorCount, 1u);
     JS_GC(rt);
 
-    // Temporarily disabled to reopen the tree. Bug 847579.
-    return true;
-
+    // The above GC should have discarded everything. Verify that we can now
+    // allocate half as many objects without OOMing.
     EVAL("(function() {"
          "    var array = [];"
          "    for (var i = max >> 2; i != 0;) {"
          "        --i;"
          "        array.push({});"
          "    }"
          "})();", &root);
     CHECK_EQUAL(errorCount, 1u);
     return true;
 }
 
 virtual JSRuntime * createRuntime() MOZ_OVERRIDE {
-    JSRuntime *rt = JS_NewRuntime(768 * 1024);
+    // Note that the max nursery size must be less than the whole heap size, or
+    // the test will fail because 'max' (the number of allocations required for
+    // OOM) will be based on the nursery size, and that will overflow the
+    // tenured heap, which will cause the second pass with max/4 allocations to
+    // OOM. (Actually, this only happens with nursery zeal, because normally
+    // the nursery will start out with only a single chunk before triggering a
+    // major GC.)
+    JSRuntime *rt = JS_NewRuntime(768 * 1024, 128 * 1024);
     if (!rt)
         return nullptr;
     setNativeStackQuota(rt);
     return rt;
 }
 
 virtual void destroyRuntime() MOZ_OVERRIDE {
     JS_DestroyRuntime(rt);