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

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

Issue 6686053: Introduce one way dependencies into object grouping. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Renaming Created 9 years, 9 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') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..f86aa16a27fa726a78efcb6c6c173cdc04cc38c4 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,15 @@ 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::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);
@@ -352,17 +369,38 @@ 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::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') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698