| 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 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 IterateOldObjects(visitor); | 253 IterateOldObjects(visitor); |
| 254 } | 254 } |
| 255 | 255 |
| 256 | 256 |
| 257 void Heap::IterateOldObjects(ObjectVisitor* visitor) const { | 257 void Heap::IterateOldObjects(ObjectVisitor* visitor) const { |
| 258 HeapIterationScope heap_iteration_scope; | 258 HeapIterationScope heap_iteration_scope; |
| 259 old_space_.VisitObjects(visitor); | 259 old_space_.VisitObjects(visitor); |
| 260 } | 260 } |
| 261 | 261 |
| 262 | 262 |
| 263 void Heap::IterateOldObjectsNoEmbedderPages(ObjectVisitor* visitor) const { |
| 264 HeapIterationScope heap_iteration_scope; |
| 265 old_space_.VisitObjectsNoEmbedderPages(visitor); |
| 266 } |
| 267 |
| 268 |
| 263 void Heap::VisitObjectPointers(ObjectPointerVisitor* visitor) const { | 269 void Heap::VisitObjectPointers(ObjectPointerVisitor* visitor) const { |
| 264 new_space_.VisitObjectPointers(visitor); | 270 new_space_.VisitObjectPointers(visitor); |
| 265 old_space_.VisitObjectPointers(visitor); | 271 old_space_.VisitObjectPointers(visitor); |
| 266 } | 272 } |
| 267 | 273 |
| 268 | 274 |
| 269 RawInstructions* Heap::FindObjectInCodeSpace(FindObjectVisitor* visitor) const { | 275 RawInstructions* Heap::FindObjectInCodeSpace(FindObjectVisitor* visitor) const { |
| 270 // Only executable pages can have RawInstructions objects. | 276 // Only executable pages can have RawInstructions objects. |
| 271 RawObject* raw_obj = old_space_.FindObject(visitor, HeapPage::kExecutable); | 277 RawObject* raw_obj = old_space_.FindObject(visitor, HeapPage::kExecutable); |
| 272 ASSERT((raw_obj == Object::null()) || | 278 ASSERT((raw_obj == Object::null()) || |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 504 void Heap::SetGrowthControlState(bool state) { | 510 void Heap::SetGrowthControlState(bool state) { |
| 505 old_space_.SetGrowthControlState(state); | 511 old_space_.SetGrowthControlState(state); |
| 506 } | 512 } |
| 507 | 513 |
| 508 | 514 |
| 509 bool Heap::GrowthControlState() { | 515 bool Heap::GrowthControlState() { |
| 510 return old_space_.GrowthControlState(); | 516 return old_space_.GrowthControlState(); |
| 511 } | 517 } |
| 512 | 518 |
| 513 | 519 |
| 514 void Heap::WriteProtect(bool read_only, bool include_code_pages) { | 520 void Heap::WriteProtect(bool read_only) { |
| 515 read_only_ = read_only; | 521 read_only_ = read_only; |
| 516 new_space_.WriteProtect(read_only); | 522 new_space_.WriteProtect(read_only); |
| 517 old_space_.WriteProtect(read_only, include_code_pages); | 523 old_space_.WriteProtect(read_only); |
| 518 } | 524 } |
| 519 | 525 |
| 520 | 526 |
| 521 Heap::Space Heap::SpaceForAllocation(intptr_t cid) { | 527 Heap::Space Heap::SpaceForAllocation(intptr_t cid) { |
| 522 return FLAG_pretenure_all ? kPretenured : kNew; | 528 return FLAG_pretenure_all ? kPretenured : kNew; |
| 523 } | 529 } |
| 524 | 530 |
| 525 | 531 |
| 526 intptr_t Heap::TopOffset(Heap::Space space) { | 532 intptr_t Heap::TopOffset(Heap::Space space) { |
| 527 if (space == kNew) { | 533 if (space == kNew) { |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 833 heap->DisableGrowthControl(); | 839 heap->DisableGrowthControl(); |
| 834 } | 840 } |
| 835 | 841 |
| 836 | 842 |
| 837 NoHeapGrowthControlScope::~NoHeapGrowthControlScope() { | 843 NoHeapGrowthControlScope::~NoHeapGrowthControlScope() { |
| 838 Heap* heap = reinterpret_cast<Isolate*>(isolate())->heap(); | 844 Heap* heap = reinterpret_cast<Isolate*>(isolate())->heap(); |
| 839 heap->SetGrowthControlState(current_growth_controller_state_); | 845 heap->SetGrowthControlState(current_growth_controller_state_); |
| 840 } | 846 } |
| 841 | 847 |
| 842 | 848 |
| 843 WritableVMIsolateScope::WritableVMIsolateScope(Thread* thread, | 849 WritableVMIsolateScope::WritableVMIsolateScope(Thread* thread) |
| 844 bool include_code_pages) | 850 : StackResource(thread) { |
| 845 : StackResource(thread), include_code_pages_(include_code_pages) { | 851 Dart::vm_isolate()->heap()->WriteProtect(false); |
| 846 Dart::vm_isolate()->heap()->WriteProtect(false, include_code_pages_); | |
| 847 } | 852 } |
| 848 | 853 |
| 849 | 854 |
| 850 WritableVMIsolateScope::~WritableVMIsolateScope() { | 855 WritableVMIsolateScope::~WritableVMIsolateScope() { |
| 851 ASSERT(Dart::vm_isolate()->heap()->UsedInWords(Heap::kNew) == 0); | 856 ASSERT(Dart::vm_isolate()->heap()->UsedInWords(Heap::kNew) == 0); |
| 852 Dart::vm_isolate()->heap()->WriteProtect(true, include_code_pages_); | 857 Dart::vm_isolate()->heap()->WriteProtect(true); |
| 853 } | 858 } |
| 854 | 859 |
| 855 } // namespace dart | 860 } // namespace dart |
| OLD | NEW |