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

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

Issue 761343004: After moving unreachable weak global handles only process harmony collections (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: updates Created 6 years 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 | « src/heap/mark-compact.cc ('k') | test/cctest/test-weakmaps.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 a70cdbb71522873e80b9043f766650fa131b2927..97f740f1233e48cef3b8b277c27c23623236e15d 100644
--- a/test/cctest/test-api.cc
+++ b/test/cctest/test-api.cc
@@ -4430,6 +4430,45 @@ THREADED_TEST(ApiObjectGroupsCycle) {
}
+THREADED_TEST(WeakRootsSurviveTwoRoundsOfGC) {
+ LocalContext env;
+ v8::Isolate* iso = env->GetIsolate();
+ HandleScope scope(iso);
+
+ WeakCallCounter counter(1234);
+
+ WeakCallCounterAndPersistent<Value> weak_obj(&counter);
+
+ // Create a weak object that references a internalized string.
+ {
+ HandleScope scope(iso);
+ weak_obj.handle.Reset(iso, Object::New(iso));
+ weak_obj.handle.SetWeak(&weak_obj, &WeakPointerCallback);
+ CHECK(weak_obj.handle.IsWeak());
+ Local<Object>::New(iso, weak_obj.handle.As<Object>())->Set(
+ v8_str("x"),
+ String::NewFromUtf8(iso, "magic cookie", String::kInternalizedString));
+ }
+ // Do a single full GC
+ i::Isolate* i_iso = reinterpret_cast<v8::internal::Isolate*>(iso);
+ i::Heap* heap = i_iso->heap();
+ heap->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask);
+
+ // We should have received the weak callback.
+ CHECK_EQ(1, counter.NumberOfWeakCalls());
+
+ // Check that the string is still alive.
+ {
+ HandleScope scope(iso);
+ i::MaybeHandle<i::String> magic_string =
+ i::StringTable::LookupStringIfExists(
+ i_iso,
+ v8::Utils::OpenHandle(*String::NewFromUtf8(iso, "magic cookie")));
+ magic_string.Check();
+ }
+}
+
+
// TODO(mstarzinger): This should be a THREADED_TEST but causes failures
// on the buildbots, so was made non-threaded for the time being.
TEST(ApiObjectGroupsCycleForScavenger) {
« no previous file with comments | « src/heap/mark-compact.cc ('k') | test/cctest/test-weakmaps.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698