| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "bin/builtin.h" | 5 #include "bin/builtin.h" |
| 6 #include "vm/compiler.h" | 6 #include "vm/compiler.h" |
| 7 #include "include/dart_api.h" | 7 #include "include/dart_api.h" |
| 8 #include "include/dart_mirrors_api.h" | 8 #include "include/dart_mirrors_api.h" |
| 9 #include "include/dart_native_api.h" | 9 #include "include/dart_native_api.h" |
| 10 #include "include/dart_tools_api.h" | 10 #include "include/dart_tools_api.h" |
| (...skipping 1188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1199 &utf8_encoded_reversed, &utf8_length_reversed); | 1199 &utf8_encoded_reversed, &utf8_length_reversed); |
| 1200 EXPECT_VALID(result); | 1200 EXPECT_VALID(result); |
| 1201 EXPECT_EQ(6, utf8_length_reversed); | 1201 EXPECT_EQ(6, utf8_length_reversed); |
| 1202 uint8_t expected[6] = {237, 180, 158, 237, 160, 180}; | 1202 uint8_t expected[6] = {237, 180, 158, 237, 160, 180}; |
| 1203 for (int i = 0; i < 6; i++) { | 1203 for (int i = 0; i < 6; i++) { |
| 1204 EXPECT_EQ(expected[i], utf8_encoded_reversed[i]); | 1204 EXPECT_EQ(expected[i], utf8_encoded_reversed[i]); |
| 1205 } | 1205 } |
| 1206 } | 1206 } |
| 1207 | 1207 |
| 1208 | 1208 |
| 1209 // Helper class to ensure new gen GC is triggered without any side effects. | |
| 1210 // The normal call to CollectGarbage(Heap::kNew) could potentially trigger | |
| 1211 // an old gen collection if there is a promotion failure and this could | |
| 1212 // perturb the test. | |
| 1213 class GCTestHelper : public AllStatic { | |
| 1214 public: | |
| 1215 static void CollectNewSpace(Heap::ApiCallbacks api_callbacks) { | |
| 1216 bool invoke_api_callbacks = (api_callbacks == Heap::kInvokeApiCallbacks); | |
| 1217 Isolate::Current()->heap()->new_space()->Scavenge(invoke_api_callbacks); | |
| 1218 } | |
| 1219 | |
| 1220 static void WaitForFinalizationTasks() { | |
| 1221 Thread* thread = Thread::Current(); | |
| 1222 Heap* heap = thread->isolate()->heap(); | |
| 1223 MonitorLocker ml(heap->finalization_tasks_lock()); | |
| 1224 while (heap->finalization_tasks() > 0) { | |
| 1225 ml.WaitWithSafepointCheck(thread); | |
| 1226 } | |
| 1227 } | |
| 1228 }; | |
| 1229 | |
| 1230 | |
| 1231 static void ExternalStringCallbackFinalizer(void* peer) { | 1209 static void ExternalStringCallbackFinalizer(void* peer) { |
| 1232 *static_cast<int*>(peer) *= 2; | 1210 *static_cast<int*>(peer) *= 2; |
| 1233 } | 1211 } |
| 1234 | 1212 |
| 1235 | 1213 |
| 1236 TEST_CASE(ExternalStringCallback) { | 1214 TEST_CASE(ExternalStringCallback) { |
| 1237 int peer8 = 40; | 1215 int peer8 = 40; |
| 1238 int peer16 = 41; | 1216 int peer16 = 41; |
| 1239 | 1217 |
| 1240 { | 1218 { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1257 EXPECT_VALID(obj16); | 1235 EXPECT_VALID(obj16); |
| 1258 | 1236 |
| 1259 Dart_ExitScope(); | 1237 Dart_ExitScope(); |
| 1260 } | 1238 } |
| 1261 | 1239 |
| 1262 { | 1240 { |
| 1263 TransitionNativeToVM transition(thread); | 1241 TransitionNativeToVM transition(thread); |
| 1264 EXPECT_EQ(40, peer8); | 1242 EXPECT_EQ(40, peer8); |
| 1265 EXPECT_EQ(41, peer16); | 1243 EXPECT_EQ(41, peer16); |
| 1266 Isolate::Current()->heap()->CollectGarbage(Heap::kOld); | 1244 Isolate::Current()->heap()->CollectGarbage(Heap::kOld); |
| 1267 GCTestHelper::WaitForFinalizationTasks(); | |
| 1268 EXPECT_EQ(40, peer8); | 1245 EXPECT_EQ(40, peer8); |
| 1269 EXPECT_EQ(41, peer16); | 1246 EXPECT_EQ(41, peer16); |
| 1270 Isolate::Current()->heap()->CollectGarbage(Heap::kNew); | 1247 Isolate::Current()->heap()->CollectGarbage(Heap::kNew); |
| 1271 GCTestHelper::WaitForFinalizationTasks(); | |
| 1272 EXPECT_EQ(80, peer8); | 1248 EXPECT_EQ(80, peer8); |
| 1273 EXPECT_EQ(82, peer16); | 1249 EXPECT_EQ(82, peer16); |
| 1274 } | 1250 } |
| 1275 } | 1251 } |
| 1276 | 1252 |
| 1277 | 1253 |
| 1278 TEST_CASE(ExternalStringPretenure) { | 1254 TEST_CASE(ExternalStringPretenure) { |
| 1279 { | 1255 { |
| 1280 Dart_EnterScope(); | 1256 Dart_EnterScope(); |
| 1281 static const uint8_t big_data8[16*MB] = {0, }; | 1257 static const uint8_t big_data8[16*MB] = {0, }; |
| (...skipping 1116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2398 ARRAY_SIZE(data)); | 2374 ARRAY_SIZE(data)); |
| 2399 Dart_NewWeakPersistentHandle( | 2375 Dart_NewWeakPersistentHandle( |
| 2400 obj, &peer, sizeof(data), ExternalTypedDataFinalizer); | 2376 obj, &peer, sizeof(data), ExternalTypedDataFinalizer); |
| 2401 EXPECT_VALID(obj); | 2377 EXPECT_VALID(obj); |
| 2402 Dart_ExitScope(); | 2378 Dart_ExitScope(); |
| 2403 } | 2379 } |
| 2404 { | 2380 { |
| 2405 TransitionNativeToVM transition(thread); | 2381 TransitionNativeToVM transition(thread); |
| 2406 EXPECT(peer == 0); | 2382 EXPECT(peer == 0); |
| 2407 Isolate::Current()->heap()->CollectGarbage(Heap::kOld); | 2383 Isolate::Current()->heap()->CollectGarbage(Heap::kOld); |
| 2408 GCTestHelper::WaitForFinalizationTasks(); | |
| 2409 EXPECT(peer == 0); | 2384 EXPECT(peer == 0); |
| 2410 Isolate::Current()->heap()->CollectGarbage(Heap::kNew); | 2385 Isolate::Current()->heap()->CollectGarbage(Heap::kNew); |
| 2411 GCTestHelper::WaitForFinalizationTasks(); | |
| 2412 EXPECT(peer == 42); | 2386 EXPECT(peer == 42); |
| 2413 } | 2387 } |
| 2414 } | 2388 } |
| 2415 | 2389 |
| 2416 | 2390 |
| 2417 static void CheckFloat32x4Data(Dart_Handle obj) { | 2391 static void CheckFloat32x4Data(Dart_Handle obj) { |
| 2418 void* raw_data = NULL; | 2392 void* raw_data = NULL; |
| 2419 intptr_t len; | 2393 intptr_t len; |
| 2420 Dart_TypedData_Type type; | 2394 Dart_TypedData_Type type; |
| 2421 EXPECT_VALID(Dart_TypedDataAcquireData(obj, &type, &raw_data, &len)); | 2395 EXPECT_VALID(Dart_TypedDataAcquireData(obj, &type, &raw_data, &len)); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2458 Dart_Handle lcl = Dart_NewExternalTypedData( | 2432 Dart_Handle lcl = Dart_NewExternalTypedData( |
| 2459 Dart_TypedData_kFloat32x4, data, 10); | 2433 Dart_TypedData_kFloat32x4, data, 10); |
| 2460 Dart_NewWeakPersistentHandle( | 2434 Dart_NewWeakPersistentHandle( |
| 2461 lcl, &peer, sizeof(data), ExternalTypedDataFinalizer); | 2435 lcl, &peer, sizeof(data), ExternalTypedDataFinalizer); |
| 2462 CheckFloat32x4Data(lcl); | 2436 CheckFloat32x4Data(lcl); |
| 2463 } | 2437 } |
| 2464 Dart_ExitScope(); | 2438 Dart_ExitScope(); |
| 2465 { | 2439 { |
| 2466 TransitionNativeToVM transition(thread); | 2440 TransitionNativeToVM transition(thread); |
| 2467 Isolate::Current()->heap()->CollectGarbage(Heap::kNew); | 2441 Isolate::Current()->heap()->CollectGarbage(Heap::kNew); |
| 2468 GCTestHelper::WaitForFinalizationTasks(); | |
| 2469 EXPECT(peer == 42); | 2442 EXPECT(peer == 42); |
| 2470 } | 2443 } |
| 2471 } | 2444 } |
| 2472 | 2445 |
| 2473 | 2446 |
| 2474 // Unit test for entering a scope, creating a local handle and exiting | 2447 // Unit test for entering a scope, creating a local handle and exiting |
| 2475 // the scope. | 2448 // the scope. |
| 2476 UNIT_TEST_CASE(EnterExitScope) { | 2449 UNIT_TEST_CASE(EnterExitScope) { |
| 2477 TestIsolateScope __test_isolate__; | 2450 TestIsolateScope __test_isolate__; |
| 2478 | 2451 |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2621 Dart_SetPersistentHandle(obj, ref2); | 2594 Dart_SetPersistentHandle(obj, ref2); |
| 2622 str ^= PersistentHandle::Cast(obj)->raw(); | 2595 str ^= PersistentHandle::Cast(obj)->raw(); |
| 2623 EXPECT(str.Equals(kTestString2)); | 2596 EXPECT(str.Equals(kTestString2)); |
| 2624 | 2597 |
| 2625 // Now assign Null to the persistent handle and check. | 2598 // Now assign Null to the persistent handle and check. |
| 2626 Dart_SetPersistentHandle(obj, Dart_Null()); | 2599 Dart_SetPersistentHandle(obj, Dart_Null()); |
| 2627 EXPECT(Dart_IsNull(obj)); | 2600 EXPECT(Dart_IsNull(obj)); |
| 2628 } | 2601 } |
| 2629 | 2602 |
| 2630 | 2603 |
| 2604 // Helper class to ensure new gen GC is triggered without any side effects. |
| 2605 // The normal call to CollectGarbage(Heap::kNew) could potentially trigger |
| 2606 // an old gen collection if there is a promotion failure and this could |
| 2607 // perturb the test. |
| 2608 class GCTestHelper : public AllStatic { |
| 2609 public: |
| 2610 static void CollectNewSpace(Heap::ApiCallbacks api_callbacks) { |
| 2611 bool invoke_api_callbacks = (api_callbacks == Heap::kInvokeApiCallbacks); |
| 2612 Isolate::Current()->heap()->new_space()->Scavenge(invoke_api_callbacks); |
| 2613 } |
| 2614 }; |
| 2615 |
| 2616 |
| 2631 static Dart_Handle AsHandle(Dart_PersistentHandle weak) { | 2617 static Dart_Handle AsHandle(Dart_PersistentHandle weak) { |
| 2632 return Dart_HandleFromPersistent(weak); | 2618 return Dart_HandleFromPersistent(weak); |
| 2633 } | 2619 } |
| 2634 | 2620 |
| 2635 | 2621 |
| 2636 static Dart_Handle AsHandle(Dart_WeakPersistentHandle weak) { | 2622 static Dart_Handle AsHandle(Dart_WeakPersistentHandle weak) { |
| 2637 return Dart_HandleFromWeakPersistent(weak); | 2623 return Dart_HandleFromWeakPersistent(weak); |
| 2638 } | 2624 } |
| 2639 | 2625 |
| 2640 | 2626 |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2735 EXPECT(Dart_IdentityEquals(old_ref, AsHandle(weak_old_ref))); | 2721 EXPECT(Dart_IdentityEquals(old_ref, AsHandle(weak_old_ref))); |
| 2736 | 2722 |
| 2737 // Delete local (strong) references. | 2723 // Delete local (strong) references. |
| 2738 Dart_ExitScope(); | 2724 Dart_ExitScope(); |
| 2739 } | 2725 } |
| 2740 | 2726 |
| 2741 { | 2727 { |
| 2742 TransitionNativeToVM transition(thread); | 2728 TransitionNativeToVM transition(thread); |
| 2743 // Garbage collect new space again. | 2729 // Garbage collect new space again. |
| 2744 GCTestHelper::CollectNewSpace(Heap::kIgnoreApiCallbacks); | 2730 GCTestHelper::CollectNewSpace(Heap::kIgnoreApiCallbacks); |
| 2745 GCTestHelper::WaitForFinalizationTasks(); | |
| 2746 } | 2731 } |
| 2747 | 2732 |
| 2748 { | 2733 { |
| 2749 Dart_EnterScope(); | 2734 Dart_EnterScope(); |
| 2750 // Weak ref to new space object should now be cleared. | 2735 // Weak ref to new space object should now be cleared. |
| 2751 EXPECT(weak_new_ref == NULL); | 2736 EXPECT(weak_new_ref == NULL); |
| 2752 EXPECT_VALID(AsHandle(weak_old_ref)); | 2737 EXPECT_VALID(AsHandle(weak_old_ref)); |
| 2753 EXPECT(!Dart_IsNull(AsHandle(weak_old_ref))); | 2738 EXPECT(!Dart_IsNull(AsHandle(weak_old_ref))); |
| 2754 Dart_ExitScope(); | 2739 Dart_ExitScope(); |
| 2755 } | 2740 } |
| 2756 | 2741 |
| 2757 { | 2742 { |
| 2758 TransitionNativeToVM transition(thread); | 2743 TransitionNativeToVM transition(thread); |
| 2759 // Garbage collect old space again. | 2744 // Garbage collect old space again. |
| 2760 Isolate::Current()->heap()->CollectGarbage(Heap::kOld); | 2745 Isolate::Current()->heap()->CollectGarbage(Heap::kOld); |
| 2761 GCTestHelper::WaitForFinalizationTasks(); | |
| 2762 } | 2746 } |
| 2763 | 2747 |
| 2764 { | 2748 { |
| 2765 Dart_EnterScope(); | 2749 Dart_EnterScope(); |
| 2766 // Weak ref to old space object should now be cleared. | 2750 // Weak ref to old space object should now be cleared. |
| 2767 EXPECT(weak_new_ref == NULL); | 2751 EXPECT(weak_new_ref == NULL); |
| 2768 EXPECT(weak_old_ref == NULL); | 2752 EXPECT(weak_old_ref == NULL); |
| 2769 Dart_ExitScope(); | 2753 Dart_ExitScope(); |
| 2770 } | 2754 } |
| 2771 | 2755 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 2796 WeakPersistentHandlePeerFinalizer); | 2780 WeakPersistentHandlePeerFinalizer); |
| 2797 EXPECT_VALID(AsHandle(weak_ref)); | 2781 EXPECT_VALID(AsHandle(weak_ref)); |
| 2798 EXPECT(peer == 0); | 2782 EXPECT(peer == 0); |
| 2799 Dart_ExitScope(); | 2783 Dart_ExitScope(); |
| 2800 } | 2784 } |
| 2801 { | 2785 { |
| 2802 TransitionNativeToVM transition(thread); | 2786 TransitionNativeToVM transition(thread); |
| 2803 Isolate::Current()->heap()->CollectGarbage(Heap::kOld); | 2787 Isolate::Current()->heap()->CollectGarbage(Heap::kOld); |
| 2804 EXPECT(peer == 0); | 2788 EXPECT(peer == 0); |
| 2805 GCTestHelper::CollectNewSpace(Heap::kIgnoreApiCallbacks); | 2789 GCTestHelper::CollectNewSpace(Heap::kIgnoreApiCallbacks); |
| 2806 GCTestHelper::WaitForFinalizationTasks(); | |
| 2807 EXPECT(peer == 42); | 2790 EXPECT(peer == 42); |
| 2808 } | 2791 } |
| 2809 } | 2792 } |
| 2810 | 2793 |
| 2811 | 2794 |
| 2812 TEST_CASE(WeakPersistentHandleNoCallback) { | 2795 TEST_CASE(WeakPersistentHandleNoCallback) { |
| 2813 Dart_WeakPersistentHandle weak_ref = NULL; | 2796 Dart_WeakPersistentHandle weak_ref = NULL; |
| 2814 int peer = 0; | 2797 int peer = 0; |
| 2815 { | 2798 { |
| 2816 Dart_EnterScope(); | 2799 Dart_EnterScope(); |
| 2817 Dart_Handle obj = NewString("new string"); | 2800 Dart_Handle obj = NewString("new string"); |
| 2818 EXPECT_VALID(obj); | 2801 EXPECT_VALID(obj); |
| 2819 weak_ref = Dart_NewWeakPersistentHandle(obj, &peer, 0, | 2802 weak_ref = Dart_NewWeakPersistentHandle(obj, &peer, 0, |
| 2820 WeakPersistentHandlePeerFinalizer); | 2803 WeakPersistentHandlePeerFinalizer); |
| 2821 Dart_ExitScope(); | 2804 Dart_ExitScope(); |
| 2822 } | 2805 } |
| 2823 // A finalizer is not invoked on a deleted handle. Therefore, the | 2806 // A finalizer is not invoked on a deleted handle. Therefore, the |
| 2824 // peer value should not change after the referent is collected. | 2807 // peer value should not change after the referent is collected. |
| 2825 Dart_Isolate isolate = reinterpret_cast<Dart_Isolate>(Isolate::Current()); | 2808 Dart_Isolate isolate = reinterpret_cast<Dart_Isolate>(Isolate::Current()); |
| 2826 Dart_DeleteWeakPersistentHandle(isolate, weak_ref); | 2809 Dart_DeleteWeakPersistentHandle(isolate, weak_ref); |
| 2827 EXPECT(peer == 0); | 2810 EXPECT(peer == 0); |
| 2828 { | 2811 { |
| 2829 TransitionNativeToVM transition(thread); | 2812 TransitionNativeToVM transition(thread); |
| 2830 Isolate::Current()->heap()->CollectGarbage(Heap::kOld); | 2813 Isolate::Current()->heap()->CollectGarbage(Heap::kOld); |
| 2831 EXPECT(peer == 0); | 2814 EXPECT(peer == 0); |
| 2832 GCTestHelper::CollectNewSpace(Heap::kIgnoreApiCallbacks); | 2815 GCTestHelper::CollectNewSpace(Heap::kIgnoreApiCallbacks); |
| 2833 GCTestHelper::WaitForFinalizationTasks(); | |
| 2834 EXPECT(peer == 0); | 2816 EXPECT(peer == 0); |
| 2835 } | 2817 } |
| 2836 } | 2818 } |
| 2837 | 2819 |
| 2838 | 2820 |
| 2839 UNIT_TEST_CASE(WeakPersistentHandlesCallbackShutdown) { | 2821 UNIT_TEST_CASE(WeakPersistentHandlesCallbackShutdown) { |
| 2840 TestCase::CreateTestIsolate(); | 2822 TestCase::CreateTestIsolate(); |
| 2841 Dart_EnterScope(); | 2823 Dart_EnterScope(); |
| 2842 Dart_Handle ref = Dart_True(); | 2824 Dart_Handle ref = Dart_True(); |
| 2843 int peer = 1234; | 2825 int peer = 1234; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2884 Dart_ExitScope(); | 2866 Dart_ExitScope(); |
| 2885 } | 2867 } |
| 2886 { | 2868 { |
| 2887 TransitionNativeToVM transition(thread); | 2869 TransitionNativeToVM transition(thread); |
| 2888 Isolate::Current()->heap()->CollectGarbage(Heap::kOld); | 2870 Isolate::Current()->heap()->CollectGarbage(Heap::kOld); |
| 2889 EXPECT(heap->ExternalInWords(Heap::kNew) == | 2871 EXPECT(heap->ExternalInWords(Heap::kNew) == |
| 2890 (kWeak1ExternalSize + kWeak2ExternalSize) / kWordSize); | 2872 (kWeak1ExternalSize + kWeak2ExternalSize) / kWordSize); |
| 2891 // Collect weakly referenced string, and promote strongly referenced string. | 2873 // Collect weakly referenced string, and promote strongly referenced string. |
| 2892 GCTestHelper::CollectNewSpace(Heap::kIgnoreApiCallbacks); | 2874 GCTestHelper::CollectNewSpace(Heap::kIgnoreApiCallbacks); |
| 2893 GCTestHelper::CollectNewSpace(Heap::kIgnoreApiCallbacks); | 2875 GCTestHelper::CollectNewSpace(Heap::kIgnoreApiCallbacks); |
| 2894 GCTestHelper::WaitForFinalizationTasks(); | |
| 2895 EXPECT(heap->ExternalInWords(Heap::kNew) == 0); | 2876 EXPECT(heap->ExternalInWords(Heap::kNew) == 0); |
| 2896 EXPECT(heap->ExternalInWords(Heap::kOld) == kWeak2ExternalSize / kWordSize); | 2877 EXPECT(heap->ExternalInWords(Heap::kOld) == kWeak2ExternalSize / kWordSize); |
| 2897 } | 2878 } |
| 2898 Dart_Isolate isolate = reinterpret_cast<Dart_Isolate>(Isolate::Current()); | 2879 Dart_Isolate isolate = reinterpret_cast<Dart_Isolate>(Isolate::Current()); |
| 2899 Dart_DeleteWeakPersistentHandle(isolate, weak1); | 2880 Dart_DeleteWeakPersistentHandle(isolate, weak1); |
| 2900 Dart_DeleteWeakPersistentHandle(isolate, weak2); | 2881 Dart_DeleteWeakPersistentHandle(isolate, weak2); |
| 2901 Dart_DeletePersistentHandle(strong_ref); | 2882 Dart_DeletePersistentHandle(strong_ref); |
| 2902 { | 2883 { |
| 2903 TransitionNativeToVM transition(thread); | 2884 TransitionNativeToVM transition(thread); |
| 2904 Isolate::Current()->heap()->CollectGarbage(Heap::kOld); | 2885 Isolate::Current()->heap()->CollectGarbage(Heap::kOld); |
| 2905 GCTestHelper::WaitForFinalizationTasks(); | |
| 2906 EXPECT(heap->ExternalInWords(Heap::kOld) == 0); | 2886 EXPECT(heap->ExternalInWords(Heap::kOld) == 0); |
| 2907 } | 2887 } |
| 2908 } | 2888 } |
| 2909 | 2889 |
| 2910 | 2890 |
| 2911 TEST_CASE(WeakPersistentHandleExternalAllocationSizeNewspaceGC) { | 2891 TEST_CASE(WeakPersistentHandleExternalAllocationSizeNewspaceGC) { |
| 2912 Dart_Isolate isolate = reinterpret_cast<Dart_Isolate>(Isolate::Current()); | 2892 Dart_Isolate isolate = reinterpret_cast<Dart_Isolate>(Isolate::Current()); |
| 2913 Heap* heap = Isolate::Current()->heap(); | 2893 Heap* heap = Isolate::Current()->heap(); |
| 2914 Dart_WeakPersistentHandle weak1 = NULL; | 2894 Dart_WeakPersistentHandle weak1 = NULL; |
| 2915 // Large enough to exceed any new space limit. Not actually allocated. | 2895 // Large enough to exceed any new space limit. Not actually allocated. |
| (...skipping 25 matching lines...) Expand all Loading... |
| 2941 EXPECT(handle.IsOld()); | 2921 EXPECT(handle.IsOld()); |
| 2942 } | 2922 } |
| 2943 EXPECT(heap->ExternalInWords(Heap::kNew) == 0); | 2923 EXPECT(heap->ExternalInWords(Heap::kNew) == 0); |
| 2944 EXPECT(heap->ExternalInWords(Heap::kOld) == kWeak1ExternalSize / kWordSize); | 2924 EXPECT(heap->ExternalInWords(Heap::kOld) == kWeak1ExternalSize / kWordSize); |
| 2945 Dart_ExitScope(); | 2925 Dart_ExitScope(); |
| 2946 } | 2926 } |
| 2947 Dart_DeleteWeakPersistentHandle(isolate, weak1); | 2927 Dart_DeleteWeakPersistentHandle(isolate, weak1); |
| 2948 { | 2928 { |
| 2949 TransitionNativeToVM transition(thread); | 2929 TransitionNativeToVM transition(thread); |
| 2950 Isolate::Current()->heap()->CollectGarbage(Heap::kOld); | 2930 Isolate::Current()->heap()->CollectGarbage(Heap::kOld); |
| 2951 GCTestHelper::WaitForFinalizationTasks(); | |
| 2952 EXPECT(heap->ExternalInWords(Heap::kOld) == 0); | 2931 EXPECT(heap->ExternalInWords(Heap::kOld) == 0); |
| 2953 } | 2932 } |
| 2954 } | 2933 } |
| 2955 | 2934 |
| 2956 | 2935 |
| 2957 TEST_CASE(WeakPersistentHandleExternalAllocationSizeOldspaceGC) { | 2936 TEST_CASE(WeakPersistentHandleExternalAllocationSizeOldspaceGC) { |
| 2958 // Check that external allocation in old space can trigger GC. | 2937 // Check that external allocation in old space can trigger GC. |
| 2959 Isolate* isolate = Isolate::Current(); | 2938 Isolate* isolate = Isolate::Current(); |
| 2960 Dart_EnterScope(); | 2939 Dart_EnterScope(); |
| 2961 Dart_Handle live = Api::NewHandle(thread, String::New("live", Heap::kOld)); | 2940 Dart_Handle live = Api::NewHandle(thread, String::New("live", Heap::kOld)); |
| (...skipping 7140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10102 result = Dart_Invoke(lib, | 10081 result = Dart_Invoke(lib, |
| 10103 NewString("foozoo"), | 10082 NewString("foozoo"), |
| 10104 0, | 10083 0, |
| 10105 NULL); | 10084 NULL); |
| 10106 EXPECT(Dart_IsError(result)); | 10085 EXPECT(Dart_IsError(result)); |
| 10107 } | 10086 } |
| 10108 | 10087 |
| 10109 #endif // !PRODUCT | 10088 #endif // !PRODUCT |
| 10110 | 10089 |
| 10111 } // namespace dart | 10090 } // namespace dart |
| OLD | NEW |