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

Unified Diff: test/cctest/test-api.cc

Side-by-side diff isn't available for this file because of its large size.
Issue 2628893003: [api] Mark functions related to object grouping as DEPRECATE_SOON (Closed)
Patch Set: Remove object grouping tests Created 3 years, 11 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:
Download patch
« no previous file with comments | « test/cctest/heap/test-heap.cc ('k') | test/cctest/test-heap-profiler.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-api.cc
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc
index 927f74c135ba0afe1504c20877dd66ae2d3fdaf9..8f4a947a7d0e95c13aa2807706d35e05573a2696 100644
--- a/test/cctest/test-api.cc
+++ b/test/cctest/test-api.cc
@@ -4483,335 +4483,6 @@ static void WeakPointerCallback(
data.GetParameter()->handle.Reset();
}
-
-template <typename T>
-static UniqueId MakeUniqueId(const Persistent<T>& p) {
- return UniqueId(reinterpret_cast<uintptr_t>(*v8::Utils::OpenPersistent(p)));
-}
-
-
-THREADED_TEST(ApiObjectGroups) {
- LocalContext env;
- v8::Isolate* iso = env->GetIsolate();
- HandleScope scope(iso);
-
- WeakCallCounter counter(1234);
-
- WeakCallCounterAndPersistent<Value> g1s1(&counter);
- WeakCallCounterAndPersistent<Value> g1s2(&counter);
- WeakCallCounterAndPersistent<Value> g1c1(&counter);
- WeakCallCounterAndPersistent<Value> g2s1(&counter);
- WeakCallCounterAndPersistent<Value> g2s2(&counter);
- WeakCallCounterAndPersistent<Value> g2c1(&counter);
-
- {
- HandleScope scope(iso);
- g1s1.handle.Reset(iso, Object::New(iso));
- g1s2.handle.Reset(iso, Object::New(iso));
- g1c1.handle.Reset(iso, Object::New(iso));
- g1s1.handle.SetWeak(&g1s1, &WeakPointerCallback,
- v8::WeakCallbackType::kParameter);
- g1s2.handle.SetWeak(&g1s2, &WeakPointerCallback,
- v8::WeakCallbackType::kParameter);
- g1c1.handle.SetWeak(&g1c1, &WeakPointerCallback,
- v8::WeakCallbackType::kParameter);
-
- g2s1.handle.Reset(iso, Object::New(iso));
- g2s2.handle.Reset(iso, Object::New(iso));
- g2c1.handle.Reset(iso, Object::New(iso));
- g2s1.handle.SetWeak(&g2s1, &WeakPointerCallback,
- v8::WeakCallbackType::kParameter);
- g2s2.handle.SetWeak(&g2s2, &WeakPointerCallback,
- v8::WeakCallbackType::kParameter);
- g2c1.handle.SetWeak(&g2c1, &WeakPointerCallback,
- v8::WeakCallbackType::kParameter);
- }
-
- WeakCallCounterAndPersistent<Value> root(&counter);
- root.handle.Reset(iso, g1s1.handle); // make a root.
-
- // Connect group 1 and 2, make a cycle.
- {
- HandleScope scope(iso);
- CHECK(Local<Object>::New(iso, g1s2.handle.As<Object>())
- ->Set(env.local(), 0, Local<Value>::New(iso, g2s2.handle))
- .FromJust());
- CHECK(Local<Object>::New(iso, g2s1.handle.As<Object>())
- ->Set(env.local(), 0, Local<Value>::New(iso, g1s1.handle))
- .FromJust());
- }
-
- {
- UniqueId id1 = MakeUniqueId(g1s1.handle);
- UniqueId id2 = MakeUniqueId(g2s2.handle);
- iso->SetObjectGroupId(g1s1.handle, id1);
- iso->SetObjectGroupId(g1s2.handle, id1);
- iso->SetReferenceFromGroup(id1, g1c1.handle);
- iso->SetObjectGroupId(g2s1.handle, id2);
- iso->SetObjectGroupId(g2s2.handle, id2);
- iso->SetReferenceFromGroup(id2, g2c1.handle);
- }
- // Do a single full GC, ensure incremental marking is stopped.
- CcTest::CollectAllGarbage(i::Heap::kFinalizeIncrementalMarkingMask);
-
- // All object should be alive.
- CHECK_EQ(0, counter.NumberOfWeakCalls());
-
- // Weaken the root.
- root.handle.SetWeak(&root, &WeakPointerCallback,
- v8::WeakCallbackType::kParameter);
- // But make children strong roots---all the objects (except for children)
- // should be collectable now.
- g1c1.handle.ClearWeak();
- g2c1.handle.ClearWeak();
-
- // Groups are deleted, rebuild groups.
- {
- UniqueId id1 = MakeUniqueId(g1s1.handle);
- UniqueId id2 = MakeUniqueId(g2s2.handle);
- iso->SetObjectGroupId(g1s1.handle, id1);
- iso->SetObjectGroupId(g1s2.handle, id1);
- iso->SetReferenceFromGroup(id1, g1c1.handle);
- iso->SetObjectGroupId(g2s1.handle, id2);
- iso->SetObjectGroupId(g2s2.handle, id2);
- iso->SetReferenceFromGroup(id2, g2c1.handle);
- }
-
- CcTest::CollectAllGarbage(i::Heap::kFinalizeIncrementalMarkingMask);
-
- // All objects should be gone. 5 global handles in total.
- CHECK_EQ(5, counter.NumberOfWeakCalls());
-
- // And now make children weak again and collect them.
- g1c1.handle.SetWeak(&g1c1, &WeakPointerCallback,
- v8::WeakCallbackType::kParameter);
- g2c1.handle.SetWeak(&g2c1, &WeakPointerCallback,
- v8::WeakCallbackType::kParameter);
-
- CcTest::CollectAllGarbage(i::Heap::kFinalizeIncrementalMarkingMask);
- CHECK_EQ(7, counter.NumberOfWeakCalls());
-}
-
-
-THREADED_TEST(ApiObjectGroupsForSubtypes) {
- LocalContext env;
- v8::Isolate* iso = env->GetIsolate();
- HandleScope scope(iso);
-
- WeakCallCounter counter(1234);
-
- WeakCallCounterAndPersistent<Object> g1s1(&counter);
- WeakCallCounterAndPersistent<String> g1s2(&counter);
- WeakCallCounterAndPersistent<String> g1c1(&counter);
- WeakCallCounterAndPersistent<Object> g2s1(&counter);
- WeakCallCounterAndPersistent<String> g2s2(&counter);
- WeakCallCounterAndPersistent<String> g2c1(&counter);
-
- {
- HandleScope scope(iso);
- g1s1.handle.Reset(iso, Object::New(iso));
- g1s2.handle.Reset(iso, v8_str("foo1"));
- g1c1.handle.Reset(iso, v8_str("foo2"));
- g1s1.handle.SetWeak(&g1s1, &WeakPointerCallback,
- v8::WeakCallbackType::kParameter);
- g1s2.handle.SetWeak(&g1s2, &WeakPointerCallback,
- v8::WeakCallbackType::kParameter);
- g1c1.handle.SetWeak(&g1c1, &WeakPointerCallback,
- v8::WeakCallbackType::kParameter);
-
- g2s1.handle.Reset(iso, Object::New(iso));
- g2s2.handle.Reset(iso, v8_str("foo3"));
- g2c1.handle.Reset(iso, v8_str("foo4"));
- g2s1.handle.SetWeak(&g2s1, &WeakPointerCallback,
- v8::WeakCallbackType::kParameter);
- g2s2.handle.SetWeak(&g2s2, &WeakPointerCallback,
- v8::WeakCallbackType::kParameter);
- g2c1.handle.SetWeak(&g2c1, &WeakPointerCallback,
- v8::WeakCallbackType::kParameter);
- }
-
- WeakCallCounterAndPersistent<Value> root(&counter);
- root.handle.Reset(iso, g1s1.handle); // make a root.
-
- // Connect group 1 and 2, make a cycle.
- {
- HandleScope scope(iso);
- CHECK(Local<Object>::New(iso, g1s1.handle)
- ->Set(env.local(), 0, Local<Object>::New(iso, g2s1.handle))
- .FromJust());
- CHECK(Local<Object>::New(iso, g2s1.handle)
- ->Set(env.local(), 0, Local<Object>::New(iso, g1s1.handle))
- .FromJust());
- }
-
- {
- UniqueId id1 = MakeUniqueId(g1s1.handle);
- UniqueId id2 = MakeUniqueId(g2s2.handle);
- iso->SetObjectGroupId(g1s1.handle, id1);
- iso->SetObjectGroupId(g1s2.handle, id1);
- iso->SetReference(g1s1.handle, g1c1.handle);
- iso->SetObjectGroupId(g2s1.handle, id2);
- iso->SetObjectGroupId(g2s2.handle, id2);
- iso->SetReferenceFromGroup(id2, g2c1.handle);
- }
- // Do a single full GC, ensure incremental marking is stopped.
- CcTest::CollectAllGarbage(i::Heap::kFinalizeIncrementalMarkingMask);
-
- // All object should be alive.
- CHECK_EQ(0, counter.NumberOfWeakCalls());
-
- // Weaken the root.
- root.handle.SetWeak(&root, &WeakPointerCallback,
- v8::WeakCallbackType::kParameter);
- // But make children strong roots---all the objects (except for children)
- // should be collectable now.
- g1c1.handle.ClearWeak();
- g2c1.handle.ClearWeak();
-
- // Groups are deleted, rebuild groups.
- {
- UniqueId id1 = MakeUniqueId(g1s1.handle);
- UniqueId id2 = MakeUniqueId(g2s2.handle);
- iso->SetObjectGroupId(g1s1.handle, id1);
- iso->SetObjectGroupId(g1s2.handle, id1);
- iso->SetReference(g1s1.handle, g1c1.handle);
- iso->SetObjectGroupId(g2s1.handle, id2);
- iso->SetObjectGroupId(g2s2.handle, id2);
- iso->SetReferenceFromGroup(id2, g2c1.handle);
- }
-
- CcTest::CollectAllGarbage(i::Heap::kFinalizeIncrementalMarkingMask);
-
- // All objects should be gone. 5 global handles in total.
- CHECK_EQ(5, counter.NumberOfWeakCalls());
-
- // And now make children weak again and collect them.
- g1c1.handle.SetWeak(&g1c1, &WeakPointerCallback,
- v8::WeakCallbackType::kParameter);
- g2c1.handle.SetWeak(&g2c1, &WeakPointerCallback,
- v8::WeakCallbackType::kParameter);
-
- CcTest::CollectAllGarbage(i::Heap::kFinalizeIncrementalMarkingMask);
- CHECK_EQ(7, counter.NumberOfWeakCalls());
-}
-
-
-THREADED_TEST(ApiObjectGroupsCycle) {
- LocalContext env;
- v8::Isolate* iso = env->GetIsolate();
- HandleScope scope(iso);
-
- WeakCallCounter counter(1234);
-
- WeakCallCounterAndPersistent<Value> g1s1(&counter);
- WeakCallCounterAndPersistent<Value> g1s2(&counter);
- WeakCallCounterAndPersistent<Value> g2s1(&counter);
- WeakCallCounterAndPersistent<Value> g2s2(&counter);
- WeakCallCounterAndPersistent<Value> g3s1(&counter);
- WeakCallCounterAndPersistent<Value> g3s2(&counter);
- WeakCallCounterAndPersistent<Value> g4s1(&counter);
- WeakCallCounterAndPersistent<Value> g4s2(&counter);
-
- {
- HandleScope scope(iso);
- g1s1.handle.Reset(iso, Object::New(iso));
- g1s2.handle.Reset(iso, Object::New(iso));
- g1s1.handle.SetWeak(&g1s1, &WeakPointerCallback,
- v8::WeakCallbackType::kParameter);
- g1s2.handle.SetWeak(&g1s2, &WeakPointerCallback,
- v8::WeakCallbackType::kParameter);
- CHECK(g1s1.handle.IsWeak());
- CHECK(g1s2.handle.IsWeak());
-
- g2s1.handle.Reset(iso, Object::New(iso));
- g2s2.handle.Reset(iso, Object::New(iso));
- g2s1.handle.SetWeak(&g2s1, &WeakPointerCallback,
- v8::WeakCallbackType::kParameter);
- g2s2.handle.SetWeak(&g2s2, &WeakPointerCallback,
- v8::WeakCallbackType::kParameter);
- CHECK(g2s1.handle.IsWeak());
- CHECK(g2s2.handle.IsWeak());
-
- g3s1.handle.Reset(iso, Object::New(iso));
- g3s2.handle.Reset(iso, Object::New(iso));
- g3s1.handle.SetWeak(&g3s1, &WeakPointerCallback,
- v8::WeakCallbackType::kParameter);
- g3s2.handle.SetWeak(&g3s2, &WeakPointerCallback,
- v8::WeakCallbackType::kParameter);
- CHECK(g3s1.handle.IsWeak());
- CHECK(g3s2.handle.IsWeak());
-
- g4s1.handle.Reset(iso, Object::New(iso));
- g4s2.handle.Reset(iso, Object::New(iso));
- g4s1.handle.SetWeak(&g4s1, &WeakPointerCallback,
- v8::WeakCallbackType::kParameter);
- g4s2.handle.SetWeak(&g4s2, &WeakPointerCallback,
- v8::WeakCallbackType::kParameter);
- CHECK(g4s1.handle.IsWeak());
- CHECK(g4s2.handle.IsWeak());
- }
-
- WeakCallCounterAndPersistent<Value> root(&counter);
- root.handle.Reset(iso, g1s1.handle); // make a root.
-
- // Connect groups. We're building the following cycle:
- // G1: { g1s1, g2s1 }, g1s1 implicitly references g2s1, ditto for other
- // groups.
- {
- UniqueId id1 = MakeUniqueId(g1s1.handle);
- UniqueId id2 = MakeUniqueId(g2s1.handle);
- UniqueId id3 = MakeUniqueId(g3s1.handle);
- UniqueId id4 = MakeUniqueId(g4s1.handle);
- iso->SetObjectGroupId(g1s1.handle, id1);
- iso->SetObjectGroupId(g1s2.handle, id1);
- iso->SetReferenceFromGroup(id1, g2s1.handle);
- iso->SetObjectGroupId(g2s1.handle, id2);
- iso->SetObjectGroupId(g2s2.handle, id2);
- iso->SetReferenceFromGroup(id2, g3s1.handle);
- iso->SetObjectGroupId(g3s1.handle, id3);
- iso->SetObjectGroupId(g3s2.handle, id3);
- iso->SetReferenceFromGroup(id3, g4s1.handle);
- iso->SetObjectGroupId(g4s1.handle, id4);
- iso->SetObjectGroupId(g4s2.handle, id4);
- iso->SetReferenceFromGroup(id4, g1s1.handle);
- }
- // Do a single full GC
- CcTest::CollectAllGarbage(i::Heap::kFinalizeIncrementalMarkingMask);
-
- // All object should be alive.
- CHECK_EQ(0, counter.NumberOfWeakCalls());
-
- // Weaken the root.
- root.handle.SetWeak(&root, &WeakPointerCallback,
- v8::WeakCallbackType::kParameter);
-
- // Groups are deleted, rebuild groups.
- {
- UniqueId id1 = MakeUniqueId(g1s1.handle);
- UniqueId id2 = MakeUniqueId(g2s1.handle);
- UniqueId id3 = MakeUniqueId(g3s1.handle);
- UniqueId id4 = MakeUniqueId(g4s1.handle);
- iso->SetObjectGroupId(g1s1.handle, id1);
- iso->SetObjectGroupId(g1s2.handle, id1);
- iso->SetReferenceFromGroup(id1, g2s1.handle);
- iso->SetObjectGroupId(g2s1.handle, id2);
- iso->SetObjectGroupId(g2s2.handle, id2);
- iso->SetReferenceFromGroup(id2, g3s1.handle);
- iso->SetObjectGroupId(g3s1.handle, id3);
- iso->SetObjectGroupId(g3s2.handle, id3);
- iso->SetReferenceFromGroup(id3, g4s1.handle);
- iso->SetObjectGroupId(g4s1.handle, id4);
- iso->SetObjectGroupId(g4s2.handle, id4);
- iso->SetReferenceFromGroup(id4, g1s1.handle);
- }
-
- CcTest::CollectAllGarbage(i::Heap::kFinalizeIncrementalMarkingMask);
-
- // All objects should be gone. 9 global handles in total.
- CHECK_EQ(9, counter.NumberOfWeakCalls());
-}
-
-
THREADED_TEST(ScriptException) {
LocalContext env;
v8::HandleScope scope(env->GetIsolate());
« no previous file with comments | « test/cctest/heap/test-heap.cc ('k') | test/cctest/test-heap-profiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698