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

Unified Diff: runtime/vm/dart_api_impl_test.cc

Issue 211593004: Reduce GC from external allocation. (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/heap.cc » ('j') | runtime/vm/heap.cc » ('J')
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 34384)
+++ runtime/vm/dart_api_impl_test.cc (working copy)
@@ -2306,9 +2306,11 @@
TEST_CASE(WeakPersistentHandleExternalAllocationSizeOversized) {
+ Dart_Isolate isolate = reinterpret_cast<Dart_Isolate>(Isolate::Current());
Heap* heap = Isolate::Current()->heap();
Dart_WeakPersistentHandle weak1 = NULL;
- const intptr_t kWeak1ExternalSize = 100 * MB;
+ // Large enough to exceed any new space limit. Not actually allocated.
+ const intptr_t kWeak1ExternalSize = 500 * MB;
{
Dart_EnterScope();
Dart_Handle obj = NewString("weakly referenced string");
@@ -2318,12 +2320,12 @@
kWeak1ExternalSize,
NopCallback);
EXPECT_VALID(AsHandle(weak1));
- // While new space is "full" of external data, any allocation will
- // trigger GC, so after two of them, obj should be promoted.
- Dart_Handle trigger1 = NewString("trigger1");
- EXPECT_VALID(trigger1);
- Dart_Handle trigger2 = NewString("trigger2");
- EXPECT_VALID(trigger2);
+ // While external size in new space is above limit, any external allocation
+ // in new space will trigger GC, so after one more, obj should be promoted.
+ Dart_WeakPersistentHandle trigger =
+ Dart_NewWeakPersistentHandle(obj, NULL, 1, NopCallback);
+ EXPECT_VALID(AsHandle(trigger));
+ Dart_DeleteWeakPersistentHandle(isolate, trigger);
{
DARTSCOPE(Isolate::Current());
String& handle = String::Handle();
@@ -2334,7 +2336,6 @@
EXPECT(heap->ExternalInWords(Heap::kOld) == kWeak1ExternalSize / kWordSize);
Dart_ExitScope();
}
- Dart_Isolate isolate = reinterpret_cast<Dart_Isolate>(Isolate::Current());
Dart_DeleteWeakPersistentHandle(isolate, weak1);
Isolate::Current()->heap()->CollectGarbage(Heap::kOld);
EXPECT(heap->ExternalInWords(Heap::kOld) == 0);
« no previous file with comments | « no previous file | runtime/vm/heap.cc » ('j') | runtime/vm/heap.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698