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

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

Issue 10450014: Request for comments on overall approach. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: fix scavenger and freelist handling Created 8 years, 6 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
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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/gc_marker.h" 5 #include "vm/gc_marker.h"
6 6
7 #include "vm/allocation.h" 7 #include "vm/allocation.h"
8 #include "vm/dart_api_state.h" 8 #include "vm/dart_api_state.h"
9 #include "vm/isolate.h" 9 #include "vm/isolate.h"
10 #include "vm/pages.h" 10 #include "vm/pages.h"
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 } 132 }
133 } 133 }
134 134
135 private: 135 private:
136 void MarkAndPush(RawObject* raw_obj) { 136 void MarkAndPush(RawObject* raw_obj) {
137 ASSERT(raw_obj->IsHeapObject()); 137 ASSERT(raw_obj->IsHeapObject());
138 ASSERT(page_space_->Contains(RawObject::ToAddr(raw_obj))); 138 ASSERT(page_space_->Contains(RawObject::ToAddr(raw_obj)));
139 139
140 // Mark the object and push it on the marking stack. 140 // Mark the object and push it on the marking stack.
141 ASSERT(!raw_obj->IsMarked()); 141 ASSERT(!raw_obj->IsMarked());
142 RawClass* raw_class = raw_obj->ptr()->class_; 142 // TODO(vegorov): consider moving it to a separate helper method.
143 RawClass* raw_class = raw_obj->GetClass();
Ivan Posva 2012/05/26 04:34:46 This does not need to be done early anymore as the
143 raw_obj->SetMarkBit(); 144 raw_obj->SetMarkBit();
144 marking_stack_->Push(raw_obj); 145 marking_stack_->Push(raw_obj);
145 146
146 // Update the number of used bytes on this page for fast accounting. 147 // Update the number of used bytes on this page for fast accounting.
147 HeapPage* page = PageSpace::PageFor(raw_obj); 148 HeapPage* page = PageSpace::PageFor(raw_obj);
148 page->AddUsed(raw_obj->Size()); 149 page->AddUsed(raw_obj->Size());
149 150
150 // TODO(iposva): Should we mark the classes early? 151 // TODO(iposva): Should we mark the classes early?
151 MarkObject(raw_class); 152 MarkObject(raw_class);
Ivan Posva 2012/05/26 04:34:46 How about MarkClass(raw_obj->ClassId()); or someth
Vyacheslav Egorov (Google) 2012/05/26 16:48:22 Nice idea. Will do.
152 } 153 }
153 154
154 void MarkObject(RawObject* raw_obj) { 155 void MarkObject(RawObject* raw_obj) {
155 // Fast exit if the raw object is a Smi. 156 // Fast exit if the raw object is a Smi.
156 if (!raw_obj->IsHeapObject()) return; 157 if (!raw_obj->IsHeapObject()) return;
157 158
158 // Fast exit if the raw object is marked. 159 // Fast exit if the raw object is marked.
159 if (raw_obj->IsMarked()) return; 160 if (raw_obj->IsMarked()) return;
160 161
161 // Skip over new objects, but verify consistency of heap while at it. 162 // Skip over new objects, but verify consistency of heap while at it.
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 MarkingVisitor mark(heap_, page_space, &marking_stack); 318 MarkingVisitor mark(heap_, page_space, &marking_stack);
318 IterateRoots(isolate, &mark, !invoke_api_callbacks); 319 IterateRoots(isolate, &mark, !invoke_api_callbacks);
319 DrainMarkingStack(isolate, &mark); 320 DrainMarkingStack(isolate, &mark);
320 IterateWeakReferences(isolate, &mark); 321 IterateWeakReferences(isolate, &mark);
321 MarkingWeakVisitor mark_weak; 322 MarkingWeakVisitor mark_weak;
322 IterateWeakRoots(isolate, &mark_weak, invoke_api_callbacks); 323 IterateWeakRoots(isolate, &mark_weak, invoke_api_callbacks);
323 Epilogue(isolate, invoke_api_callbacks); 324 Epilogue(isolate, invoke_api_callbacks);
324 } 325 }
325 326
326 } // namespace dart 327 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698