| 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 "vm/heap.h" | 5 #include "vm/heap.h" |
| 6 | 6 |
| 7 #include "platform/assert.h" | 7 #include "platform/assert.h" |
| 8 #include "platform/utils.h" | 8 #include "platform/utils.h" |
| 9 #include "vm/flags.h" | 9 #include "vm/flags.h" |
| 10 #include "vm/isolate.h" | 10 #include "vm/isolate.h" |
| (...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 437 CollectOldSpaceGarbage(thread, kInvokeApiCallbacks, kOldSpace); | 437 CollectOldSpaceGarbage(thread, kInvokeApiCallbacks, kOldSpace); |
| 438 } else { | 438 } else { |
| 439 ASSERT(space == kNew); | 439 ASSERT(space == kNew); |
| 440 CollectNewSpaceGarbage(thread, kInvokeApiCallbacks, kNewSpace); | 440 CollectNewSpaceGarbage(thread, kInvokeApiCallbacks, kNewSpace); |
| 441 } | 441 } |
| 442 } | 442 } |
| 443 | 443 |
| 444 | 444 |
| 445 void Heap::CollectAllGarbage() { | 445 void Heap::CollectAllGarbage() { |
| 446 Thread* thread = Thread::Current(); | 446 Thread* thread = Thread::Current(); |
| 447 | 447 CollectNewSpaceGarbage(thread, kInvokeApiCallbacks, kFull); |
| 448 // New space is evacuated so this GC will collect all dead objects | |
| 449 // kept alive by a cross-generational pointer. | |
| 450 new_space_.Evacuate(); | |
| 451 CollectOldSpaceGarbage(thread, kInvokeApiCallbacks, kFull); | 448 CollectOldSpaceGarbage(thread, kInvokeApiCallbacks, kFull); |
| 452 } | 449 } |
| 453 | 450 |
| 454 | 451 |
| 455 void Heap::WaitForSweeperTasks(Thread* thread) { | 452 void Heap::WaitForSweeperTasks(Thread* thread) { |
| 456 MonitorLocker ml(old_space_.tasks_lock()); | 453 MonitorLocker ml(old_space_.tasks_lock()); |
| 457 while (old_space_.tasks() > 0) { | 454 while (old_space_.tasks() > 0) { |
| 458 ml.WaitWithSafepointCheck(thread); | 455 ml.WaitWithSafepointCheck(thread); |
| 459 } | 456 } |
| 460 } | 457 } |
| (...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 880 Dart::vm_isolate()->heap()->WriteProtect(false); | 877 Dart::vm_isolate()->heap()->WriteProtect(false); |
| 881 } | 878 } |
| 882 | 879 |
| 883 | 880 |
| 884 WritableVMIsolateScope::~WritableVMIsolateScope() { | 881 WritableVMIsolateScope::~WritableVMIsolateScope() { |
| 885 ASSERT(Dart::vm_isolate()->heap()->UsedInWords(Heap::kNew) == 0); | 882 ASSERT(Dart::vm_isolate()->heap()->UsedInWords(Heap::kNew) == 0); |
| 886 Dart::vm_isolate()->heap()->WriteProtect(true); | 883 Dart::vm_isolate()->heap()->WriteProtect(true); |
| 887 } | 884 } |
| 888 | 885 |
| 889 } // namespace dart | 886 } // namespace dart |
| OLD | NEW |