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

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

Issue 206583003: Add 'address' vm service message that finds heap objects. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 9 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/heap_test.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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 void Heap::IterateNewObjects(ObjectVisitor* visitor) { 155 void Heap::IterateNewObjects(ObjectVisitor* visitor) {
156 new_space_->VisitObjects(visitor); 156 new_space_->VisitObjects(visitor);
157 } 157 }
158 158
159 159
160 void Heap::IterateOldObjects(ObjectVisitor* visitor) { 160 void Heap::IterateOldObjects(ObjectVisitor* visitor) {
161 old_space_->VisitObjects(visitor); 161 old_space_->VisitObjects(visitor);
162 } 162 }
163 163
164 164
165 RawInstructions* Heap::FindObjectInCodeSpace(FindObjectVisitor* visitor) { 165 RawInstructions* Heap::FindObjectInCodeSpace(FindObjectVisitor* visitor) const {
166 // Only executable pages can have RawInstructions objects. 166 // Only executable pages can have RawInstructions objects.
167 RawObject* raw_obj = old_space_->FindObject(visitor, HeapPage::kExecutable); 167 RawObject* raw_obj = old_space_->FindObject(visitor, HeapPage::kExecutable);
168 ASSERT((raw_obj == Object::null()) || 168 ASSERT((raw_obj == Object::null()) ||
169 (raw_obj->GetClassId() == kInstructionsCid)); 169 (raw_obj->GetClassId() == kInstructionsCid));
170 return reinterpret_cast<RawInstructions*>(raw_obj); 170 return reinterpret_cast<RawInstructions*>(raw_obj);
171 } 171 }
172 172
173 173
174 RawObject* Heap::FindOldObject(FindObjectVisitor* visitor) const { 174 RawObject* Heap::FindOldObject(FindObjectVisitor* visitor) const {
175 return old_space_->FindObject(visitor, HeapPage::kData); 175 return old_space_->FindObject(visitor, HeapPage::kData);
176 } 176 }
177 177
178 178
179 RawObject* Heap::FindNewObject(FindObjectVisitor* visitor) const {
180 return new_space_->FindObject(visitor);
181 }
182
183
184 RawObject* Heap::FindObject(FindObjectVisitor* visitor) const {
185 ASSERT(Isolate::Current()->no_gc_scope_depth() != 0);
186 RawObject* raw_obj = FindNewObject(visitor);
187 if (raw_obj != Object::null()) {
188 return raw_obj;
189 }
190 raw_obj = FindOldObject(visitor);
191 if (raw_obj != Object::null()) {
192 return raw_obj;
193 }
194 raw_obj = FindObjectInCodeSpace(visitor);
195 return raw_obj;
196 }
197
198
179 void Heap::CollectGarbage(Space space, ApiCallbacks api_callbacks) { 199 void Heap::CollectGarbage(Space space, ApiCallbacks api_callbacks) {
180 Isolate* isolate = Isolate::Current(); 200 Isolate* isolate = Isolate::Current();
181 bool invoke_api_callbacks = (api_callbacks == kInvokeApiCallbacks); 201 bool invoke_api_callbacks = (api_callbacks == kInvokeApiCallbacks);
182 switch (space) { 202 switch (space) {
183 case kNew: { 203 case kNew: {
184 VMTagScope tagScope(isolate, VMTag::kGCNewSpaceTagId); 204 VMTagScope tagScope(isolate, VMTag::kGCNewSpaceTagId);
185 RecordBeforeGC(kNew, kNewSpace); 205 RecordBeforeGC(kNew, kNewSpace);
186 UpdateClassHeapStatsBeforeGC(kNew); 206 UpdateClassHeapStatsBeforeGC(kNew);
187 new_space_->Scavenge(invoke_api_callbacks); 207 new_space_->Scavenge(invoke_api_callbacks);
188 RecordAfterGC(); 208 RecordAfterGC();
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 heap->DisableGrowthControl(); 572 heap->DisableGrowthControl();
553 } 573 }
554 574
555 575
556 NoHeapGrowthControlScope::~NoHeapGrowthControlScope() { 576 NoHeapGrowthControlScope::~NoHeapGrowthControlScope() {
557 Heap* heap = reinterpret_cast<Isolate*>(isolate())->heap(); 577 Heap* heap = reinterpret_cast<Isolate*>(isolate())->heap();
558 heap->SetGrowthControlState(current_growth_controller_state_); 578 heap->SetGrowthControlState(current_growth_controller_state_);
559 } 579 }
560 580
561 } // namespace dart 581 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/heap.h ('k') | runtime/vm/heap_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698