| 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 20 matching lines...) Expand all Loading... |
| 31 intptr_t max_new_gen_semi_words, | 31 intptr_t max_new_gen_semi_words, |
| 32 intptr_t max_old_gen_words, | 32 intptr_t max_old_gen_words, |
| 33 intptr_t max_external_words) | 33 intptr_t max_external_words) |
| 34 : isolate_(isolate), | 34 : isolate_(isolate), |
| 35 new_space_(this, max_new_gen_semi_words, kNewObjectAlignmentOffset), | 35 new_space_(this, max_new_gen_semi_words, kNewObjectAlignmentOffset), |
| 36 old_space_(this, max_old_gen_words, max_external_words), | 36 old_space_(this, max_old_gen_words, max_external_words), |
| 37 barrier_(new Monitor()), | 37 barrier_(new Monitor()), |
| 38 barrier_done_(new Monitor()), | 38 barrier_done_(new Monitor()), |
| 39 read_only_(false), | 39 read_only_(false), |
| 40 gc_new_space_in_progress_(false), | 40 gc_new_space_in_progress_(false), |
| 41 gc_old_space_in_progress_(false) { | 41 gc_old_space_in_progress_(false), |
| 42 debug_gc_in_progress_(false) { |
| 42 UpdateGlobalMaxUsed(); | 43 UpdateGlobalMaxUsed(); |
| 43 for (int sel = 0; sel < kNumWeakSelectors; sel++) { | 44 for (int sel = 0; sel < kNumWeakSelectors; sel++) { |
| 44 new_weak_tables_[sel] = new WeakTable(); | 45 new_weak_tables_[sel] = new WeakTable(); |
| 45 old_weak_tables_[sel] = new WeakTable(); | 46 old_weak_tables_[sel] = new WeakTable(); |
| 46 } | 47 } |
| 47 stats_.num_ = 0; | 48 stats_.num_ = 0; |
| 48 } | 49 } |
| 49 | 50 |
| 50 | 51 |
| 51 Heap::~Heap() { | 52 Heap::~Heap() { |
| (...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 437 CollectOldSpaceGarbage(thread, kInvokeApiCallbacks, kOldSpace); | 438 CollectOldSpaceGarbage(thread, kInvokeApiCallbacks, kOldSpace); |
| 438 } else { | 439 } else { |
| 439 ASSERT(space == kNew); | 440 ASSERT(space == kNew); |
| 440 CollectNewSpaceGarbage(thread, kInvokeApiCallbacks, kNewSpace); | 441 CollectNewSpaceGarbage(thread, kInvokeApiCallbacks, kNewSpace); |
| 441 } | 442 } |
| 442 } | 443 } |
| 443 | 444 |
| 444 | 445 |
| 445 void Heap::CollectAllGarbage() { | 446 void Heap::CollectAllGarbage() { |
| 446 Thread* thread = Thread::Current(); | 447 Thread* thread = Thread::Current(); |
| 448 debug_gc_in_progress_ = true; |
| 449 CollectOldSpaceGarbage(thread, kInvokeApiCallbacks, kFull); |
| 447 CollectNewSpaceGarbage(thread, kInvokeApiCallbacks, kFull); | 450 CollectNewSpaceGarbage(thread, kInvokeApiCallbacks, kFull); |
| 448 CollectOldSpaceGarbage(thread, kInvokeApiCallbacks, kFull); | 451 debug_gc_in_progress_ = false; |
| 449 } | 452 } |
| 450 | 453 |
| 451 | 454 |
| 452 void Heap::WaitForSweeperTasks(Thread* thread) { | 455 void Heap::WaitForSweeperTasks(Thread* thread) { |
| 453 MonitorLocker ml(old_space_.tasks_lock()); | 456 MonitorLocker ml(old_space_.tasks_lock()); |
| 454 while (old_space_.tasks() > 0) { | 457 while (old_space_.tasks() > 0) { |
| 455 ml.WaitWithSafepointCheck(thread); | 458 ml.WaitWithSafepointCheck(thread); |
| 456 } | 459 } |
| 457 } | 460 } |
| 458 | 461 |
| (...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 854 Dart::vm_isolate()->heap()->WriteProtect(false); | 857 Dart::vm_isolate()->heap()->WriteProtect(false); |
| 855 } | 858 } |
| 856 | 859 |
| 857 | 860 |
| 858 WritableVMIsolateScope::~WritableVMIsolateScope() { | 861 WritableVMIsolateScope::~WritableVMIsolateScope() { |
| 859 ASSERT(Dart::vm_isolate()->heap()->UsedInWords(Heap::kNew) == 0); | 862 ASSERT(Dart::vm_isolate()->heap()->UsedInWords(Heap::kNew) == 0); |
| 860 Dart::vm_isolate()->heap()->WriteProtect(true); | 863 Dart::vm_isolate()->heap()->WriteProtect(true); |
| 861 } | 864 } |
| 862 | 865 |
| 863 } // namespace dart | 866 } // namespace dart |
| OLD | NEW |