bug 594138 - account for potential shape and dslots change after the GC in conservative GC tests. r=anygregor
authorIgor Bukanov <igor@mir2.org>
Fri, 10 Sep 2010 08:55:33 +0200
changeset 53635 a1f43f4ef565ecf8a01037f8db6de1284ebd66ad
parent 53634 c70c6d647f239b316d938995add5bc820cfa099b
child 53636 e892ea04158179ad911c496c8119d815d20d66a8
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersanygregor
bugs594138
milestone2.0b6pre
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 594138 - account for potential shape and dslots change after the GC in conservative GC tests. r=anygregor
js/src/jsapi-tests/testConservativeGC.cpp
js/src/jsapi-tests/testIsAboutToBeFinalized.cpp
--- a/js/src/jsapi-tests/testConservativeGC.cpp
+++ b/js/src/jsapi-tests/testConservativeGC.cpp
@@ -26,22 +26,35 @@ BEGIN_TEST(testConservativeGC)
     JSString str2Copy = *str2;
 
     tmp = JSVAL_NULL;
 
     JS_GC(cx);
 
     EVAL("var a = [];\n"
          "for (var i = 0; i != 10000; ++i) {\n"
-         "a.push(i + 0.1, [1, 2], String(Math.sqrt(i)));\n"
+         "a.push(i + 0.1, [1, 2], String(Math.sqrt(i)), {a: i});\n"
          "}", &tmp);
 
     JS_GC(cx);
 
-    CHECK(!memcmp(&objCopy,  JSVAL_TO_OBJECT(v2), sizeof(objCopy)));
-    CHECK(!memcmp(&strCopy,  JSVAL_TO_STRING(v3), sizeof(strCopy)));
+    checkObjectFields(&objCopy, JSVAL_TO_OBJECT(v2));
+    CHECK(!memcmp(&strCopy, JSVAL_TO_STRING(v3), sizeof(strCopy)));
 
-    CHECK(!memcmp(&obj2Copy,  obj2, sizeof(obj2Copy)));
-    CHECK(!memcmp(&str2Copy,  str2, sizeof(str2Copy)));
+    checkObjectFields(&obj2Copy, obj2);
+    CHECK(!memcmp(&str2Copy, str2, sizeof(str2Copy)));
 
     return true;
 }
+
+bool checkObjectFields(JSObject *savedCopy, JSObject *obj)
+{
+    /*
+     * The GC can change the shape and shrink dslots so we update them before
+     * doing memcmp.
+     */
+    savedCopy->objShape = obj->objShape;
+    savedCopy->dslots = obj->dslots;
+    CHECK(!memcmp(savedCopy, obj, sizeof(*obj)));
+    return true;
+}
+
 END_TEST(testConservativeGC)
--- a/js/src/jsapi-tests/testIsAboutToBeFinalized.cpp
+++ b/js/src/jsapi-tests/testIsAboutToBeFinalized.cpp
@@ -32,17 +32,17 @@ TestAboutToBeFinalizedCallback(JSContext
  */
 volatile void *ptrSink;
 
 static JS_NEVER_INLINE void
 NativeFrameCleaner()
 {
     char buffer[1 << 16];
     memset(buffer, 0, sizeof buffer);
-    ptrSink = buffer; 
+    ptrSink = buffer;
 }
 
 BEGIN_TEST(testIsAboutToBeFinalized_bug528645)
 {
     /*
      * Due to the conservative GC we use separated never-inline function to
      * test rooted elements.
      */
@@ -78,17 +78,17 @@ cls_testIsAboutToBeFinalized_bug528645::
 {
     jsvalRoot root(cx);
 
     /*
      * Check various types of GC things against JS_IsAboutToBeFinalized.
      * Make sure to include unit and numeric strings to the set.
      */
     EVAL("var x = 1.1; "
-         "[''+x, 'a', '42', 'something'.substring(1), "
+         "[''+x, 'a', '123456789', 'something'.substring(1), "
          "{}, [], new Function('return 10;'), <xml/>];",
          root.addr());
 
     JSObject *array = JSVAL_TO_OBJECT(root.value());
     JS_ASSERT(JS_IsArrayObject(cx, array));
 
     JSBool ok = JS_GetArrayLength(cx, array, &checkPointersLength);
     CHECK(ok);
@@ -112,11 +112,25 @@ cls_testIsAboutToBeFinalized_bug528645::
     JS_GC(cx);
 
     /*
      * All GC things are rooted via the root holding the array containing them
      * and TestAboutToBeFinalizedCallback must keep them as is.
      */
     for (jsuint i = 0; i != checkPointersLength; ++i)
         CHECK(checkPointers[i]);
+
+    /*
+     * Overwrite the registers and stack with new GC things to avoid false
+     * positives with the finalization test.
+     */
+    EVAL("[]", root.addr());
+
+    array = JSVAL_TO_OBJECT(root.value());
+    JS_ASSERT(JS_IsArrayObject(cx, array));
+
+    jsuint tmp;
+    CHECK(JS_GetArrayLength(cx, array, &tmp));
+    CHECK(ok);
+
     return true;
 }