Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1536)

Unified Diff: test/cctest/test-mark-compact.cc

Issue 6815029: Merge (7180:7265] from bleeding_edge to the experimental/gc branch.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/gc/
Patch Set: Created 9 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/cctest/test-api.cc ('k') | test/cctest/testcfg.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-mark-compact.cc
===================================================================
--- test/cctest/test-mark-compact.cc (revision 7557)
+++ test/cctest/test-mark-compact.cc (working copy)
@@ -302,6 +302,7 @@
static int NumberOfWeakCalls = 0;
static void WeakPointerCallback(v8::Persistent<v8::Value> handle, void* id) {
+ ASSERT(id == reinterpret_cast<void*>(1234));
NumberOfWeakCalls++;
handle.Dispose();
}
@@ -316,23 +317,33 @@
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.
@@ -342,9 +353,15 @@
{
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::AddImplicitReferences(HeapObject::cast(*g1s1),
+ g1_children, 1);
+ GlobalHandles::AddObjectGroup(g2_objects, 2, NULL);
+ GlobalHandles::AddImplicitReferences(HeapObject::cast(*g2s2),
+ g2_children, 1);
}
// Do a full GC
Heap::CollectGarbage(OLD_POINTER_SPACE);
@@ -356,17 +373,38 @@
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::AddImplicitReferences(HeapObject::cast(*g1s1),
+ g1_children, 1);
+ GlobalHandles::AddObjectGroup(g2_objects, 2, NULL);
+ GlobalHandles::AddImplicitReferences(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);
}
« no previous file with comments | « test/cctest/test-api.cc ('k') | test/cctest/testcfg.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698