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

Unified Diff: runtime/vm/dart_api_impl_test.cc

Issue 193473002: Fix external size accounting for prologue weak persistent handles. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 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 | « no previous file | 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
===================================================================
--- runtime/vm/dart_api_impl_test.cc (revision 33550)
+++ runtime/vm/dart_api_impl_test.cc (working copy)
@@ -2255,6 +2255,33 @@
}
+TEST_CASE(PrologueWeakPersistentHandleExternalAllocationSize) {
+ Heap* heap = Isolate::Current()->heap();
+ EXPECT(heap->ExternalInWords(Heap::kNew) == 0);
+ EXPECT(heap->ExternalInWords(Heap::kOld) == 0);
+ Dart_WeakPersistentHandle pwph = NULL;
+ static const intptr_t kWeakExternalSize = 1 * KB;
+ {
+ Dart_EnterScope();
+ Dart_Handle obj = NewString("a string");
+ EXPECT_VALID(obj);
+ pwph = Dart_NewPrologueWeakPersistentHandle(
+ obj, NULL, kWeakExternalSize, NULL);
+ EXPECT_VALID(AsHandle(pwph));
+ Dart_ExitScope();
+ }
+ EXPECT(heap->ExternalInWords(Heap::kNew) == kWeakExternalSize / kWordSize);
+ EXPECT(heap->ExternalInWords(Heap::kOld) == 0);
+ // Promoting the string should transfer the external size to old.
+ GCTestHelper::CollectNewSpace(Heap::kIgnoreApiCallbacks);
+ GCTestHelper::CollectNewSpace(Heap::kIgnoreApiCallbacks);
+ EXPECT(heap->ExternalInWords(Heap::kNew) == 0);
+ EXPECT(heap->ExternalInWords(Heap::kOld) == kWeakExternalSize / kWordSize);
+ Isolate::Current()->heap()->CollectGarbage(Heap::kOld);
+ EXPECT(heap->ExternalInWords(Heap::kOld) == 0);
+}
+
+
TEST_CASE(WeakPersistentHandleExternalAllocationSizeOversized) {
Heap* heap = Isolate::Current()->heap();
Dart_WeakPersistentHandle weak1 = NULL;
« no previous file with comments | « no previous file | runtime/vm/dart_api_state.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698