Add regression test for r10451.
authormstarzinger@chromium.org <mstarzinger@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Fri, 20 Jan 2012 12:44:04 +0000 (12:44 +0000)
committermstarzinger@chromium.org <mstarzinger@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Fri, 20 Jan 2012 12:44:04 +0000 (12:44 +0000)
R=vegorov@chromium.org
TEST=cctest/test-heap/PrototypeTransitionClearing

Review URL: https://chromiumcodereview.appspot.com/9138016

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@10455 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

test/cctest/test-heap.cc

index 7015a1e..eb5f3c6 100644 (file)
@@ -1606,4 +1606,23 @@ TEST(PrototypeTransitionClearing) {
     CHECK(trans->get(j + Map::kProtoTransitionMapOffset)->IsMap());
     CHECK(trans->get(j + Map::kProtoTransitionPrototypeOffset)->IsJSObject());
   }
+
+  // Make sure next prototype is placed on an old-space evacuation candidate.
+  Handle<JSObject> prototype;
+  PagedSpace* space = HEAP->old_pointer_space();
+  do {
+    prototype = FACTORY->NewJSArray(32 * KB, TENURED);
+  } while (space->FirstPage() == space->LastPage() ||
+      !space->LastPage()->Contains(prototype->address()));
+
+  // Add a prototype on an evacuation candidate and verify that transition
+  // clearing correctly records slots in prototype transition array.
+  i::FLAG_always_compact = true;
+  Handle<Map> map(baseObject->map());
+  CHECK(!space->LastPage()->Contains(map->prototype_transitions()->address()));
+  CHECK(space->LastPage()->Contains(prototype->address()));
+  baseObject->SetPrototype(*prototype, false)->ToObjectChecked();
+  CHECK(map->GetPrototypeTransition(*prototype)->IsMap());
+  HEAP->CollectAllGarbage(Heap::kNoGCFlags);
+  CHECK(map->GetPrototypeTransition(*prototype)->IsMap());
 }