| 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 "include/dart_api.h" | 5 #include "include/dart_api.h" |
| 6 #include "platform/assert.h" | 6 #include "platform/assert.h" |
| 7 #include "platform/utils.h" | 7 #include "platform/utils.h" |
| 8 #include "vm/class_finalizer.h" | 8 #include "vm/class_finalizer.h" |
| 9 #include "vm/dart_api_impl.h" | 9 #include "vm/dart_api_impl.h" |
| 10 #include "vm/dart_api_state.h" | 10 #include "vm/dart_api_state.h" |
| (...skipping 1319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1330 Isolate::Current()->heap()->CollectGarbage(Heap::kOld); | 1330 Isolate::Current()->heap()->CollectGarbage(Heap::kOld); |
| 1331 | 1331 |
| 1332 // weak ref to old space object should now be cleared | 1332 // weak ref to old space object should now be cleared |
| 1333 EXPECT_VALID(weak_new_ref); | 1333 EXPECT_VALID(weak_new_ref); |
| 1334 EXPECT(Dart_IsNull(weak_new_ref)); | 1334 EXPECT(Dart_IsNull(weak_new_ref)); |
| 1335 EXPECT_VALID(weak_old_ref); | 1335 EXPECT_VALID(weak_old_ref); |
| 1336 EXPECT(Dart_IsNull(weak_old_ref)); | 1336 EXPECT(Dart_IsNull(weak_old_ref)); |
| 1337 | 1337 |
| 1338 Dart_DeletePersistentHandle(weak_new_ref); | 1338 Dart_DeletePersistentHandle(weak_new_ref); |
| 1339 Dart_DeletePersistentHandle(weak_old_ref); | 1339 Dart_DeletePersistentHandle(weak_old_ref); |
| 1340 |
| 1341 // garbage collect one last time to revisit deleted handles |
| 1342 Isolate::Current()->heap()->CollectGarbage(Heap::kNew); |
| 1343 Isolate::Current()->heap()->CollectGarbage(Heap::kOld); |
| 1340 } | 1344 } |
| 1341 | 1345 |
| 1342 | 1346 |
| 1343 static void WeakPersistentHandlePeerFinalizer(Dart_Handle handle, void* peer) { | 1347 static void WeakPersistentHandlePeerFinalizer(Dart_Handle handle, void* peer) { |
| 1344 *static_cast<int*>(peer) = 42; | 1348 *static_cast<int*>(peer) = 42; |
| 1345 } | 1349 } |
| 1346 | 1350 |
| 1347 | 1351 |
| 1348 TEST_CASE(WeakPersistentHandleCallback) { | 1352 TEST_CASE(WeakPersistentHandleCallback) { |
| 1349 Dart_Handle weak_ref = Dart_Null(); | 1353 Dart_Handle weak_ref = Dart_Null(); |
| (...skipping 2377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3727 // We should have received the expected number of interrupts. | 3731 // We should have received the expected number of interrupts. |
| 3728 EXPECT_EQ(kInterruptCount, interrupt_count); | 3732 EXPECT_EQ(kInterruptCount, interrupt_count); |
| 3729 | 3733 |
| 3730 // Give the spawned thread enough time to properly exit. | 3734 // Give the spawned thread enough time to properly exit. |
| 3731 Isolate::SetInterruptCallback(saved); | 3735 Isolate::SetInterruptCallback(saved); |
| 3732 } | 3736 } |
| 3733 | 3737 |
| 3734 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). | 3738 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). |
| 3735 | 3739 |
| 3736 } // namespace dart | 3740 } // namespace dart |
| OLD | NEW |