| 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 25 matching lines...) Expand all Loading... |
| 36 DEFINE_FLAG(int, verbose_gc_hdr, 40, "Print verbose GC header interval."); | 36 DEFINE_FLAG(int, verbose_gc_hdr, 40, "Print verbose GC header interval."); |
| 37 DEFINE_FLAG(bool, verify_after_gc, false, | 37 DEFINE_FLAG(bool, verify_after_gc, false, |
| 38 "Enables heap verification after GC."); | 38 "Enables heap verification after GC."); |
| 39 DEFINE_FLAG(bool, verify_before_gc, false, | 39 DEFINE_FLAG(bool, verify_before_gc, false, |
| 40 "Enables heap verification before GC."); | 40 "Enables heap verification before GC."); |
| 41 DEFINE_FLAG(bool, pretenure_all, false, "Global pretenuring (for testing)."); | 41 DEFINE_FLAG(bool, pretenure_all, false, "Global pretenuring (for testing)."); |
| 42 | 42 |
| 43 | 43 |
| 44 Heap::Heap(Isolate* isolate, | 44 Heap::Heap(Isolate* isolate, |
| 45 intptr_t max_new_gen_semi_words, | 45 intptr_t max_new_gen_semi_words, |
| 46 intptr_t max_old_gen_words) | 46 intptr_t max_old_gen_words, |
| 47 intptr_t max_external_words) |
| 47 : isolate_(isolate), | 48 : isolate_(isolate), |
| 48 read_only_(false), | 49 read_only_(false), |
| 49 gc_in_progress_(false), | 50 gc_in_progress_(false), |
| 50 pretenure_policy_(0) { | 51 pretenure_policy_(0) { |
| 51 for (int sel = 0; | 52 for (int sel = 0; |
| 52 sel < kNumWeakSelectors; | 53 sel < kNumWeakSelectors; |
| 53 sel++) { | 54 sel++) { |
| 54 new_weak_tables_[sel] = new WeakTable(); | 55 new_weak_tables_[sel] = new WeakTable(); |
| 55 old_weak_tables_[sel] = new WeakTable(); | 56 old_weak_tables_[sel] = new WeakTable(); |
| 56 } | 57 } |
| 57 new_space_ = new Scavenger(this, | 58 new_space_ = new Scavenger(this, |
| 58 max_new_gen_semi_words, | 59 max_new_gen_semi_words, |
| 59 kNewObjectAlignmentOffset); | 60 kNewObjectAlignmentOffset); |
| 60 old_space_ = new PageSpace(this, max_old_gen_words); | 61 old_space_ = new PageSpace(this, max_old_gen_words, max_external_words); |
| 61 stats_.num_ = 0; | 62 stats_.num_ = 0; |
| 62 } | 63 } |
| 63 | 64 |
| 64 | 65 |
| 65 Heap::~Heap() { | 66 Heap::~Heap() { |
| 66 delete new_space_; | 67 delete new_space_; |
| 67 delete old_space_; | 68 delete old_space_; |
| 68 for (int sel = 0; | 69 for (int sel = 0; |
| 69 sel < kNumWeakSelectors; | 70 sel < kNumWeakSelectors; |
| 70 sel++) { | 71 sel++) { |
| (...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 427 } | 428 } |
| 428 | 429 |
| 429 | 430 |
| 430 Heap::Space Heap::SpaceForAllocation(intptr_t cid) const { | 431 Heap::Space Heap::SpaceForAllocation(intptr_t cid) const { |
| 431 return FLAG_pretenure_all ? kPretenured : kNew; | 432 return FLAG_pretenure_all ? kPretenured : kNew; |
| 432 } | 433 } |
| 433 | 434 |
| 434 | 435 |
| 435 void Heap::Init(Isolate* isolate, | 436 void Heap::Init(Isolate* isolate, |
| 436 intptr_t max_new_gen_words, | 437 intptr_t max_new_gen_words, |
| 437 intptr_t max_old_gen_words) { | 438 intptr_t max_old_gen_words, |
| 439 intptr_t max_external_words) { |
| 438 ASSERT(isolate->heap() == NULL); | 440 ASSERT(isolate->heap() == NULL); |
| 439 Heap* heap = new Heap(isolate, max_new_gen_words, max_old_gen_words); | 441 Heap* heap = new Heap(isolate, |
| 442 max_new_gen_words, |
| 443 max_old_gen_words, |
| 444 max_external_words); |
| 440 isolate->set_heap(heap); | 445 isolate->set_heap(heap); |
| 441 } | 446 } |
| 442 | 447 |
| 443 | 448 |
| 444 void Heap::GetMergedAddressRange(uword* start, uword* end) const { | 449 void Heap::GetMergedAddressRange(uword* start, uword* end) const { |
| 445 if (new_space_->CapacityInWords() != 0) { | 450 if (new_space_->CapacityInWords() != 0) { |
| 446 uword new_start; | 451 uword new_start; |
| 447 uword new_end; | 452 uword new_end; |
| 448 new_space_->StartEndAddress(&new_start, &new_end); | 453 new_space_->StartEndAddress(&new_start, &new_end); |
| 449 *start = Utils::Minimum(new_start, *start); | 454 *start = Utils::Minimum(new_start, *start); |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 724 heap->DisableGrowthControl(); | 729 heap->DisableGrowthControl(); |
| 725 } | 730 } |
| 726 | 731 |
| 727 | 732 |
| 728 NoHeapGrowthControlScope::~NoHeapGrowthControlScope() { | 733 NoHeapGrowthControlScope::~NoHeapGrowthControlScope() { |
| 729 Heap* heap = reinterpret_cast<Isolate*>(isolate())->heap(); | 734 Heap* heap = reinterpret_cast<Isolate*>(isolate())->heap(); |
| 730 heap->SetGrowthControlState(current_growth_controller_state_); | 735 heap->SetGrowthControlState(current_growth_controller_state_); |
| 731 } | 736 } |
| 732 | 737 |
| 733 } // namespace dart | 738 } // namespace dart |
| OLD | NEW |