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