Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(801)

Side by Side Diff: runtime/vm/heap.cc

Issue 1090053003: - Avoid inconsistency of for example IterateObjects vs VisitObjects. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/heap.h ('k') | runtime/vm/object.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 bool Heap::OldContains(uword addr) const { 204 bool Heap::OldContains(uword addr) const {
205 return old_space_->Contains(addr); 205 return old_space_->Contains(addr);
206 } 206 }
207 207
208 208
209 bool Heap::CodeContains(uword addr) const { 209 bool Heap::CodeContains(uword addr) const {
210 return old_space_->Contains(addr, HeapPage::kExecutable); 210 return old_space_->Contains(addr, HeapPage::kExecutable);
211 } 211 }
212 212
213 213
214 void Heap::IterateObjects(ObjectVisitor* visitor) const { 214 void Heap::VisitObjects(ObjectVisitor* visitor) const {
215 new_space_->VisitObjects(visitor); 215 new_space_->VisitObjects(visitor);
216 old_space_->VisitObjects(visitor); 216 old_space_->VisitObjects(visitor);
217 } 217 }
218 218
219 219
220 void Heap::IteratePointers(ObjectPointerVisitor* visitor) const { 220 void Heap::VisitObjectPointers(ObjectPointerVisitor* visitor) const {
221 new_space_->VisitObjectPointers(visitor); 221 new_space_->VisitObjectPointers(visitor);
222 old_space_->VisitObjectPointers(visitor); 222 old_space_->VisitObjectPointers(visitor);
223 } 223 }
224 224
225 225
226 void Heap::IterateNewPointers(ObjectPointerVisitor* visitor) const {
227 new_space_->VisitObjectPointers(visitor);
228 }
229
230
231 void Heap::IterateOldPointers(ObjectPointerVisitor* visitor) const {
232 old_space_->VisitObjectPointers(visitor);
233 }
234
235
236 void Heap::IterateNewObjects(ObjectVisitor* visitor) const {
237 new_space_->VisitObjects(visitor);
238 }
239
240
241 void Heap::IterateOldObjects(ObjectVisitor* visitor) const {
242 old_space_->VisitObjects(visitor);
243 }
244
245
246 RawInstructions* Heap::FindObjectInCodeSpace(FindObjectVisitor* visitor) const { 226 RawInstructions* Heap::FindObjectInCodeSpace(FindObjectVisitor* visitor) const {
247 // Only executable pages can have RawInstructions objects. 227 // Only executable pages can have RawInstructions objects.
248 RawObject* raw_obj = old_space_->FindObject(visitor, HeapPage::kExecutable); 228 RawObject* raw_obj = old_space_->FindObject(visitor, HeapPage::kExecutable);
249 ASSERT((raw_obj == Object::null()) || 229 ASSERT((raw_obj == Object::null()) ||
250 (raw_obj->GetClassId() == kInstructionsCid)); 230 (raw_obj->GetClassId() == kInstructionsCid));
251 return reinterpret_cast<RawInstructions*>(raw_obj); 231 return reinterpret_cast<RawInstructions*>(raw_obj);
252 } 232 }
253 233
254 234
255 RawObject* Heap::FindOldObject(FindObjectVisitor* visitor) const { 235 RawObject* Heap::FindOldObject(FindObjectVisitor* visitor) const {
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 uword start = static_cast<uword>(-1); 455 uword start = static_cast<uword>(-1);
476 uword end = 0; 456 uword end = 0;
477 Isolate* vm_isolate = Dart::vm_isolate(); 457 Isolate* vm_isolate = Dart::vm_isolate();
478 vm_isolate->heap()->GetMergedAddressRange(&start, &end); 458 vm_isolate->heap()->GetMergedAddressRange(&start, &end);
479 this->GetMergedAddressRange(&start, &end); 459 this->GetMergedAddressRange(&start, &end);
480 460
481 ObjectSet* allocated_set = new ObjectSet(start, end); 461 ObjectSet* allocated_set = new ObjectSet(start, end);
482 { 462 {
483 VerifyObjectVisitor object_visitor( 463 VerifyObjectVisitor object_visitor(
484 isolate(), allocated_set, mark_expectation); 464 isolate(), allocated_set, mark_expectation);
485 this->IterateObjects(&object_visitor); 465 this->VisitObjects(&object_visitor);
486 } 466 }
487 { 467 {
488 // VM isolate heap is premarked. 468 // VM isolate heap is premarked.
489 VerifyObjectVisitor vm_object_visitor( 469 VerifyObjectVisitor vm_object_visitor(
490 isolate(), allocated_set, kRequireMarked); 470 isolate(), allocated_set, kRequireMarked);
491 vm_isolate->heap()->IterateObjects(&vm_object_visitor); 471 vm_isolate->heap()->VisitObjects(&vm_object_visitor);
492 } 472 }
493 return allocated_set; 473 return allocated_set;
494 } 474 }
495 475
496 476
497 bool Heap::Verify(MarkExpectation mark_expectation) const { 477 bool Heap::Verify(MarkExpectation mark_expectation) const {
498 ObjectSet* allocated_set = CreateAllocatedObjectSet(mark_expectation); 478 ObjectSet* allocated_set = CreateAllocatedObjectSet(mark_expectation);
499 VerifyPointersVisitor visitor(isolate(), allocated_set); 479 VerifyPointersVisitor visitor(isolate(), allocated_set);
500 IteratePointers(&visitor); 480 VisitObjectPointers(&visitor);
501 delete allocated_set; 481 delete allocated_set;
502 // Only returning a value so that Heap::Validate can be called from an ASSERT. 482 // Only returning a value so that Heap::Validate can be called from an ASSERT.
503 return true; 483 return true;
504 } 484 }
505 485
506 486
507 void Heap::PrintSizes() const { 487 void Heap::PrintSizes() const {
508 OS::PrintErr("New space (%" Pd "k of %" Pd "k) " 488 OS::PrintErr("New space (%" Pd "k of %" Pd "k) "
509 "Old space (%" Pd "k of %" Pd "k)\n", 489 "Old space (%" Pd "k of %" Pd "k)\n",
510 (UsedInWords(kNew) / KBInWords), 490 (UsedInWords(kNew) / KBInWords),
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
734 heap->DisableGrowthControl(); 714 heap->DisableGrowthControl();
735 } 715 }
736 716
737 717
738 NoHeapGrowthControlScope::~NoHeapGrowthControlScope() { 718 NoHeapGrowthControlScope::~NoHeapGrowthControlScope() {
739 Heap* heap = reinterpret_cast<Isolate*>(isolate())->heap(); 719 Heap* heap = reinterpret_cast<Isolate*>(isolate())->heap();
740 heap->SetGrowthControlState(current_growth_controller_state_); 720 heap->SetGrowthControlState(current_growth_controller_state_);
741 } 721 }
742 722
743 } // namespace dart 723 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/heap.h ('k') | runtime/vm/object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698