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