| 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 3018 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3029 isolate->heap()->ExternalInWords(Heap::kOld) * kWordSize); | 3029 isolate->heap()->ExternalInWords(Heap::kOld) * kWordSize); |
| 3030 // Large enough to trigger GC in old space. Not actually allocated. | 3030 // Large enough to trigger GC in old space. Not actually allocated. |
| 3031 const intptr_t kHugeExternalSize = (kWordSize == 4) ? 513 * MB : 1025 * MB; | 3031 const intptr_t kHugeExternalSize = (kWordSize == 4) ? 513 * MB : 1025 * MB; |
| 3032 Dart_NewWeakPersistentHandle(live, | 3032 Dart_NewWeakPersistentHandle(live, |
| 3033 NULL, | 3033 NULL, |
| 3034 kHugeExternalSize, | 3034 kHugeExternalSize, |
| 3035 NopCallback); | 3035 NopCallback); |
| 3036 // Expect small garbage to be collected. | 3036 // Expect small garbage to be collected. |
| 3037 EXPECT_EQ(kHugeExternalSize, | 3037 EXPECT_EQ(kHugeExternalSize, |
| 3038 isolate->heap()->ExternalInWords(Heap::kOld) * kWordSize); | 3038 isolate->heap()->ExternalInWords(Heap::kOld) * kWordSize); |
| 3039 Dart_DeleteWeakPersistentHandle(reinterpret_cast<Dart_Isolate>(isolate), | |
| 3040 weak); | |
| 3041 Dart_ExitScope(); | 3039 Dart_ExitScope(); |
| 3042 } | 3040 } |
| 3043 | 3041 |
| 3044 | 3042 |
| 3045 TEST_CASE(WeakPersistentHandleExternalAllocationSizeOddReferents) { | 3043 TEST_CASE(WeakPersistentHandleExternalAllocationSizeOddReferents) { |
| 3046 Heap* heap = Isolate::Current()->heap(); | 3044 Heap* heap = Isolate::Current()->heap(); |
| 3047 Dart_WeakPersistentHandle weak1 = NULL; | 3045 Dart_WeakPersistentHandle weak1 = NULL; |
| 3048 static const intptr_t kWeak1ExternalSize = 1 * KB; | 3046 static const intptr_t kWeak1ExternalSize = 1 * KB; |
| 3049 Dart_WeakPersistentHandle weak2 = NULL; | 3047 Dart_WeakPersistentHandle weak2 = NULL; |
| 3050 static const intptr_t kWeak2ExternalSize = 2 * KB; | 3048 static const intptr_t kWeak2ExternalSize = 2 * KB; |
| (...skipping 7108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10159 result = Dart_Invoke(lib, | 10157 result = Dart_Invoke(lib, |
| 10160 NewString("foozoo"), | 10158 NewString("foozoo"), |
| 10161 0, | 10159 0, |
| 10162 NULL); | 10160 NULL); |
| 10163 EXPECT(Dart_IsError(result)); | 10161 EXPECT(Dart_IsError(result)); |
| 10164 } | 10162 } |
| 10165 | 10163 |
| 10166 #endif // !PRODUCT | 10164 #endif // !PRODUCT |
| 10167 | 10165 |
| 10168 } // namespace dart | 10166 } // namespace dart |
| OLD | NEW |