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

Unified Diff: runtime/vm/dart_api_impl_test.cc

Issue 1287333007: - Avoid scavenging the same location twice. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 4 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 | « no previous file | runtime/vm/scavenger.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/dart_api_impl_test.cc
diff --git a/runtime/vm/dart_api_impl_test.cc b/runtime/vm/dart_api_impl_test.cc
index 3d0b9b848eb3bb1829525c1308918aff0672b967..668e6553d93e2a2fc13c31cf36f157107bf77d8a 100644
--- a/runtime/vm/dart_api_impl_test.cc
+++ b/runtime/vm/dart_api_impl_test.cc
@@ -3167,6 +3167,47 @@ TEST_CASE(ObjectGroups) {
}
+TEST_CASE(DuplicateWeakReferenceSetEntries) {
+ Isolate* isolate = Isolate::Current();
+ Dart_PersistentHandle strong = NULL;
+ Dart_WeakPersistentHandle weak = NULL; // A weak handle to strong.
+
+ Dart_EnterScope();
+ {
+ DARTSCOPE(isolate);
+
+ // Strong handle to keep the reference set alive.
+ Dart_Handle local = Api::NewHandle(isolate, String::New("string"));
+ strong = Dart_NewPersistentHandle(local);
+ EXPECT_VALID(AsHandle(strong));
+ EXPECT(!Dart_IsNull(AsHandle(strong)));
+ // Corresponding weak handle to use as key and duplicated value.
+ weak = Dart_NewWeakPersistentHandle(local, NULL, 0, NopCallback);
+ EXPECT_VALID(AsHandle(weak));
+ EXPECT(!Dart_IsNull(AsHandle(weak)));
+ }
+ Dart_ExitScope();
+
+ {
+ Dart_EnterScope();
+ // Create the weak reference set.
+ Dart_WeakReferenceSetBuilder builder = Dart_NewWeakReferenceSetBuilder();
+ EXPECT_NOTNULL(builder);
+ // Register the key and the first copy of the value.
+ Dart_WeakReferenceSet set = Dart_NewWeakReferenceSet(builder, weak, weak);
+ EXPECT_NOTNULL(set);
+ // Add the second copy of the value.
+ Dart_Handle result = Dart_AppendValueToWeakReferenceSet(set, weak);
+ EXPECT_VALID(result);
+
+ // Trigger GC to ensure that we can visit duplicate entries in weak
+ // reference sets.
+ isolate->heap()->CollectGarbage(Heap::kNew);
+ Dart_ExitScope();
+ }
+}
+
+
static Dart_WeakPersistentHandle old_pwph = NULL;
static Dart_WeakPersistentHandle new_pwph = NULL;
« no previous file with comments | « no previous file | runtime/vm/scavenger.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698