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

Unified Diff: runtime/vm/dart_api_impl_test.cc

Issue 9655011: Implement prologue weak persistent handles. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: final revision Created 8 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 | « runtime/vm/dart_api_impl.cc ('k') | runtime/vm/dart_api_state.h » ('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 d9776de592b9d28759cbef523f06020df4fb707b..f976eaa1721434442578db1142e81c3aadc3a919 100644
--- a/runtime/vm/dart_api_impl_test.cc
+++ b/runtime/vm/dart_api_impl_test.cc
@@ -1561,6 +1561,64 @@ TEST_CASE(ObjectGroups) {
}
+TEST_CASE(PrologueWeakPersistentHandles) {
+ Dart_Handle old_pwph = Dart_Null();
+ EXPECT(Dart_IsNull(old_pwph));
+ Dart_Handle new_pwph = Dart_Null();
+ EXPECT(Dart_IsNull(new_pwph));
+ Dart_EnterScope();
+ {
+ DARTSCOPE(Isolate::Current());
+ String& str = String::Handle();
+ str ^= String::New("new space prologue weak", Heap::kNew);
+ new_pwph = Dart_NewPrologueWeakPersistentHandle(Api::NewLocalHandle(str),
+ NULL,
+ NULL);
+ EXPECT_VALID(new_pwph);
+ EXPECT(!Dart_IsNull(new_pwph));
+ str ^= String::New("old space prologue weak", Heap::kOld);
+ old_pwph = Dart_NewPrologueWeakPersistentHandle(Api::NewLocalHandle(str),
+ NULL,
+ NULL);
+ EXPECT_VALID(old_pwph);
+ EXPECT(!Dart_IsNull(old_pwph));
+ str ^= String::null();
+ }
+ Dart_ExitScope();
+ EXPECT_VALID(new_pwph);
+ EXPECT(!Dart_IsNull(new_pwph));
+ EXPECT(Dart_IsPrologueWeakPersistentHandle(new_pwph));
+ EXPECT_VALID(old_pwph);
+ EXPECT(!Dart_IsNull(old_pwph));
+ EXPECT(Dart_IsPrologueWeakPersistentHandle(old_pwph));
+ // Garbage collect new space without invoking API callbacks.
+ Isolate::Current()->heap()->CollectGarbage(Heap::kNew,
+ Heap::kIgnoreApiCallbacks);
+ // Both prologue weak handles should be preserved.
+ EXPECT(!Dart_IsNull(new_pwph));
+ EXPECT(!Dart_IsNull(old_pwph));
+ // Garbage collect old space without invoking API callbacks.
+ Isolate::Current()->heap()->CollectGarbage(Heap::kOld,
+ Heap::kIgnoreApiCallbacks);
+ // Both prologue weak handles should be preserved.
+ EXPECT(!Dart_IsNull(new_pwph));
+ EXPECT(!Dart_IsNull(old_pwph));
+ // Garbage collect new space invoking API callbacks.
+ Isolate::Current()->heap()->CollectGarbage(Heap::kNew,
+ Heap::kInvokeApiCallbacks);
+ // The prologue weak handle with a new space referent should now be
+ // cleared. The old space referent should be preserved.
+ EXPECT(Dart_IsNull(new_pwph));
+ EXPECT(!Dart_IsNull(old_pwph));
+ Isolate::Current()->heap()->CollectGarbage(Heap::kOld,
+ Heap::kInvokeApiCallbacks);
+ // The prologue weak handle with an old space referent should now be
+ // cleared. The new space referent should remain cleared.
+ EXPECT(Dart_IsNull(new_pwph));
+ EXPECT(Dart_IsNull(old_pwph));
+}
+
+
TEST_CASE(ImplicitReferences) {
Dart_Handle strong = Dart_Null();
EXPECT(Dart_IsNull(strong));
« no previous file with comments | « runtime/vm/dart_api_impl.cc ('k') | runtime/vm/dart_api_state.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698