Chromium Code Reviews| Index: runtime/vm/dart_api_impl_test.cc |
| =================================================================== |
| --- runtime/vm/dart_api_impl_test.cc (revision 35145) |
| +++ runtime/vm/dart_api_impl_test.cc (working copy) |
| @@ -2311,7 +2311,7 @@ |
| } |
| -TEST_CASE(WeakPersistentHandleExternalAllocationSizeOversized) { |
| +TEST_CASE(WeakPersistentHandleExternalAllocationSizeNewspaceGC) { |
| Dart_Isolate isolate = reinterpret_cast<Dart_Isolate>(Isolate::Current()); |
| Heap* heap = Isolate::Current()->heap(); |
| Dart_WeakPersistentHandle weak1 = NULL; |
| @@ -2352,6 +2352,42 @@ |
| } |
| +TEST_CASE(WeakPersistentHandleExternalAllocationSizeOldspaceGC) { |
| + // Check that external allocation in old space can trigger GC. |
| + Isolate* isolate = Isolate::Current(); |
| + Dart_EnterScope(); |
| + Dart_Handle live = Api::NewHandle(isolate, String::New("live", Heap::kOld)); |
| + EXPECT_VALID(live); |
| + Dart_WeakPersistentHandle weak = NULL; |
| + const intptr_t kSmallExternalSize = 1 * KB; |
| + { |
| + Dart_EnterScope(); |
| + Dart_Handle dead = Api::NewHandle(isolate, String::New("dead", Heap::kOld)); |
| + EXPECT_VALID(dead); |
| + weak = Dart_NewWeakPersistentHandle(dead, |
| + NULL, |
| + kSmallExternalSize, |
| + NopCallback); |
| + EXPECT_VALID(AsHandle(weak)); |
| + Dart_ExitScope(); |
| + } |
| + EXPECT_EQ(kSmallExternalSize, |
|
Ivan Posva
2014/04/18 16:11:26
You might want to verify how much external size th
koda
2014/04/18 16:38:18
Done.
|
| + isolate->heap()->ExternalInWords(Heap::kOld) * kWordSize); |
| + // Large enough to trigger GC in old space. Not actually allocated. |
| + const intptr_t kHugeExternalSize = 1000 * MB; |
| + Dart_NewWeakPersistentHandle(live, |
| + NULL, |
| + kHugeExternalSize, |
| + NopCallback); |
| + // Expect small garbage to be collected. |
| + EXPECT_EQ(kHugeExternalSize, |
| + isolate->heap()->ExternalInWords(Heap::kOld) * kWordSize); |
| + Dart_DeleteWeakPersistentHandle(reinterpret_cast<Dart_Isolate>(isolate), |
| + weak); |
| + Dart_ExitScope(); |
| +} |
| + |
| + |
| TEST_CASE(WeakPersistentHandleExternalAllocationSizeOddReferents) { |
| Heap* heap = Isolate::Current()->heap(); |
| Dart_WeakPersistentHandle weak1 = NULL; |
| @@ -2360,7 +2396,7 @@ |
| static const intptr_t kWeak2ExternalSize = 2 * KB; |
| { |
| Dart_EnterScope(); |
| - Dart_Handle dart_null = Dart_Null(); // VM heap object. |
| + Dart_Handle dart_null = Dart_True(); // VM heap object. |
|
Ivan Posva
2014/04/18 16:11:26
Why?
koda
2014/04/18 16:38:18
I assume you mean "Why the change from 'null' to '
|
| EXPECT_VALID(dart_null); |
| weak1 = Dart_NewWeakPersistentHandle( |
| dart_null, NULL, kWeak1ExternalSize, NopCallback); |
| @@ -2379,7 +2415,7 @@ |
| Dart_DeleteWeakPersistentHandle(isolate, weak1); |
| Dart_DeleteWeakPersistentHandle(isolate, weak2); |
| Isolate::Current()->heap()->CollectGarbage(Heap::kOld); |
| - EXPECT(heap->ExternalInWords(Heap::kOld) == 0); |
| + EXPECT_EQ(0, heap->ExternalInWords(Heap::kOld)); |
| } |
| @@ -2692,7 +2728,8 @@ |
| // Garbage collect old space without invoking API callbacks. |
| Isolate::Current()->heap()->CollectGarbage(Heap::kOld, |
| - Heap::kIgnoreApiCallbacks); |
| + Heap::kIgnoreApiCallbacks, |
| + Heap::kGCTestCase); |
| { |
| Dart_EnterScope(); |
| @@ -2715,7 +2752,8 @@ |
| } |
| Isolate::Current()->heap()->CollectGarbage(Heap::kOld, |
| - Heap::kInvokeApiCallbacks); |
| + Heap::kInvokeApiCallbacks, |
| + Heap::kGCTestCase); |
| { |
| Dart_EnterScope(); |
| @@ -3022,7 +3060,8 @@ |
| global_prologue_callback_status = 3; |
| global_epilogue_callback_status = 7; |
| Isolate::Current()->heap()->CollectGarbage(Heap::kOld, |
| - Heap::kIgnoreApiCallbacks); |
| + Heap::kIgnoreApiCallbacks, |
| + Heap::kGCTestCase); |
| EXPECT_EQ(3, global_prologue_callback_status); |
| EXPECT_EQ(7, global_epilogue_callback_status); |
| @@ -3072,7 +3111,8 @@ |
| // Garbage collect old space again without invoking callbacks. |
| // Nothing should change. |
| Isolate::Current()->heap()->CollectGarbage(Heap::kOld, |
| - Heap::kIgnoreApiCallbacks); |
| + Heap::kIgnoreApiCallbacks, |
| + Heap::kGCTestCase); |
| EXPECT_EQ(6, global_prologue_callback_status); |
| EXPECT_EQ(28, global_epilogue_callback_status); |