| Index: test/cctest/test-mark-compact.cc
|
| diff --git a/test/cctest/test-mark-compact.cc b/test/cctest/test-mark-compact.cc
|
| index 54c12eb83aa3cfbb56a8827db9c6eff0ff62d544..be433621634a539a6dbef8809ee174628b0e2693 100644
|
| --- a/test/cctest/test-mark-compact.cc
|
| +++ b/test/cctest/test-mark-compact.cc
|
| @@ -298,6 +298,7 @@ TEST(GCCallback) {
|
|
|
| static int NumberOfWeakCalls = 0;
|
| static void WeakPointerCallback(v8::Persistent<v8::Value> handle, void* id) {
|
| + ASSERT(id == reinterpret_cast<void*>(1234));
|
| NumberOfWeakCalls++;
|
| handle.Dispose();
|
| }
|
| @@ -312,23 +313,33 @@ TEST(ObjectGroups) {
|
| GlobalHandles::Create(Heap::AllocateFixedArray(1)->ToObjectChecked());
|
| Handle<Object> g1s2 =
|
| GlobalHandles::Create(Heap::AllocateFixedArray(1)->ToObjectChecked());
|
| + Handle<Object> g1c1 =
|
| + GlobalHandles::Create(Heap::AllocateFixedArray(1)->ToObjectChecked());
|
| GlobalHandles::MakeWeak(g1s1.location(),
|
| reinterpret_cast<void*>(1234),
|
| &WeakPointerCallback);
|
| GlobalHandles::MakeWeak(g1s2.location(),
|
| reinterpret_cast<void*>(1234),
|
| &WeakPointerCallback);
|
| + GlobalHandles::MakeWeak(g1c1.location(),
|
| + reinterpret_cast<void*>(1234),
|
| + &WeakPointerCallback);
|
|
|
| Handle<Object> g2s1 =
|
| GlobalHandles::Create(Heap::AllocateFixedArray(1)->ToObjectChecked());
|
| Handle<Object> g2s2 =
|
| GlobalHandles::Create(Heap::AllocateFixedArray(1)->ToObjectChecked());
|
| + Handle<Object> g2c1 =
|
| + GlobalHandles::Create(Heap::AllocateFixedArray(1)->ToObjectChecked());
|
| GlobalHandles::MakeWeak(g2s1.location(),
|
| reinterpret_cast<void*>(1234),
|
| &WeakPointerCallback);
|
| GlobalHandles::MakeWeak(g2s2.location(),
|
| reinterpret_cast<void*>(1234),
|
| &WeakPointerCallback);
|
| + GlobalHandles::MakeWeak(g2c1.location(),
|
| + reinterpret_cast<void*>(1234),
|
| + &WeakPointerCallback);
|
|
|
| Handle<Object> root = GlobalHandles::Create(*g1s1); // make a root.
|
|
|
| @@ -338,9 +349,13 @@ TEST(ObjectGroups) {
|
|
|
| {
|
| Object** g1_objects[] = { g1s1.location(), g1s2.location() };
|
| + Object** g1_children[] = { g1c1.location() };
|
| Object** g2_objects[] = { g2s1.location(), g2s2.location() };
|
| - GlobalHandles::AddGroup(g1_objects, 2, NULL);
|
| - GlobalHandles::AddGroup(g2_objects, 2, NULL);
|
| + Object** g2_children[] = { g2c1.location() };
|
| + GlobalHandles::AddObjectGroup(g1_objects, 2, NULL);
|
| + GlobalHandles::AddImplicitRefGroup(HeapObject::cast(*g1s1), g1_children, 1);
|
| + GlobalHandles::AddObjectGroup(g2_objects, 2, NULL);
|
| + GlobalHandles::AddImplicitRefGroup(HeapObject::cast(*g2s2), g2_children, 1);
|
| }
|
| // Do a full GC
|
| Heap::CollectGarbage(OLD_POINTER_SPACE);
|
| @@ -352,17 +367,36 @@ TEST(ObjectGroups) {
|
| GlobalHandles::MakeWeak(root.location(),
|
| reinterpret_cast<void*>(1234),
|
| &WeakPointerCallback);
|
| + // But make children strong roots---all the objects (except for children)
|
| + // should be collectable now.
|
| + GlobalHandles::ClearWeakness(g1c1.location());
|
| + GlobalHandles::ClearWeakness(g2c1.location());
|
|
|
| // Groups are deleted, rebuild groups.
|
| {
|
| Object** g1_objects[] = { g1s1.location(), g1s2.location() };
|
| + Object** g1_children[] = { g1c1.location() };
|
| Object** g2_objects[] = { g2s1.location(), g2s2.location() };
|
| - GlobalHandles::AddGroup(g1_objects, 2, NULL);
|
| - GlobalHandles::AddGroup(g2_objects, 2, NULL);
|
| + Object** g2_children[] = { g2c1.location() };
|
| + GlobalHandles::AddObjectGroup(g1_objects, 2, NULL);
|
| + GlobalHandles::AddImplicitRefGroup(HeapObject::cast(*g1s1), g1_children, 1);
|
| + GlobalHandles::AddObjectGroup(g2_objects, 2, NULL);
|
| + GlobalHandles::AddImplicitRefGroup(HeapObject::cast(*g2s2), g2_children, 1);
|
| }
|
|
|
| Heap::CollectGarbage(OLD_POINTER_SPACE);
|
|
|
| // All objects should be gone. 5 global handles in total.
|
| CHECK_EQ(5, NumberOfWeakCalls);
|
| +
|
| + // And now make children weak again and collect them.
|
| + GlobalHandles::MakeWeak(g1c1.location(),
|
| + reinterpret_cast<void*>(1234),
|
| + &WeakPointerCallback);
|
| + GlobalHandles::MakeWeak(g2c1.location(),
|
| + reinterpret_cast<void*>(1234),
|
| + &WeakPointerCallback);
|
| +
|
| + Heap::CollectGarbage(OLD_POINTER_SPACE);
|
| + CHECK_EQ(7, NumberOfWeakCalls);
|
| }
|
|
|