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

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

Issue 2908353002: Nonvirtual pointer visitor in GCs (Closed)
Patch Set: Separated user-defined classes case so it can be inlined Created 3 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
« no previous file with comments | « no previous file | runtime/vm/raw_object.h » ('j') | runtime/vm/raw_object.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/log.h" 10 #include "vm/log.h"
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 RawObject* raw_key = cur_weak->ptr()->key_; 185 RawObject* raw_key = cur_weak->ptr()->key_;
186 // Reset the next pointer in the weak property. 186 // Reset the next pointer in the weak property.
187 cur_weak->ptr()->next_ = 0; 187 cur_weak->ptr()->next_ = 0;
188 if (raw_key->IsMarked()) { 188 if (raw_key->IsMarked()) {
189 RawObject* raw_val = cur_weak->ptr()->value_; 189 RawObject* raw_val = cur_weak->ptr()->value_;
190 marked = marked || (raw_val->IsHeapObject() && !raw_val->IsMarked()); 190 marked = marked || (raw_val->IsHeapObject() && !raw_val->IsMarked());
191 191
192 // The key is marked so we make sure to properly visit all pointers 192 // The key is marked so we make sure to properly visit all pointers
193 // originating from this weak property. 193 // originating from this weak property.
194 VisitingOldObject(cur_weak); 194 VisitingOldObject(cur_weak);
195 cur_weak->VisitPointers(this); 195 cur_weak->VisitPointersNonvirtual(this);
196 } else { 196 } else {
197 // Requeue this weak property to be handled later. 197 // Requeue this weak property to be handled later.
198 EnqueueWeakProperty(cur_weak); 198 EnqueueWeakProperty(cur_weak);
199 } 199 }
200 // Advance to next weak property in the queue. 200 // Advance to next weak property in the queue.
201 cur_weak = reinterpret_cast<RawWeakProperty*>(next_weak); 201 cur_weak = reinterpret_cast<RawWeakProperty*>(next_weak);
202 } 202 }
203 VisitingOldObject(NULL); 203 VisitingOldObject(NULL);
204 return marked; 204 return marked;
205 } 205 }
206 206
207 void DrainMarkingStack() { 207 void DrainMarkingStack() {
208 RawObject* raw_obj = work_list_.Pop(); 208 RawObject* raw_obj = work_list_.Pop();
209 if ((raw_obj == NULL) && ProcessPendingWeakProperties()) { 209 if ((raw_obj == NULL) && ProcessPendingWeakProperties()) {
210 raw_obj = work_list_.Pop(); 210 raw_obj = work_list_.Pop();
211 } 211 }
212 212
213 if (raw_obj == NULL) { 213 if (raw_obj == NULL) {
214 ASSERT(visiting_old_object_ == NULL); 214 ASSERT(visiting_old_object_ == NULL);
215 return; 215 return;
216 } 216 }
217 do { 217 do {
218 do { 218 do {
219 // First drain the marking stacks. 219 // First drain the marking stacks.
220 VisitingOldObject(raw_obj); 220 VisitingOldObject(raw_obj);
221 const intptr_t class_id = raw_obj->GetClassId(); 221 const intptr_t class_id = raw_obj->GetClassId();
222 if (class_id != kWeakPropertyCid) { 222 if (class_id != kWeakPropertyCid) {
223 marked_bytes_ += raw_obj->VisitPointers(this); 223 marked_bytes_ += raw_obj->VisitPointersNonvirtual(this);
224 } else { 224 } else {
225 RawWeakProperty* raw_weak = 225 RawWeakProperty* raw_weak =
226 reinterpret_cast<RawWeakProperty*>(raw_obj); 226 reinterpret_cast<RawWeakProperty*>(raw_obj);
227 marked_bytes_ += ProcessWeakProperty(raw_weak); 227 marked_bytes_ += ProcessWeakProperty(raw_weak);
228 } 228 }
229 raw_obj = work_list_.Pop(); 229 raw_obj = work_list_.Pop();
230 } while (raw_obj != NULL); 230 } while (raw_obj != NULL);
231 231
232 // Marking stack is empty. 232 // Marking stack is empty.
233 ProcessPendingWeakProperties(); 233 ProcessPendingWeakProperties();
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 intptr_t ProcessWeakProperty(RawWeakProperty* raw_weak) { 265 intptr_t ProcessWeakProperty(RawWeakProperty* raw_weak) {
266 // The fate of the weak property is determined by its key. 266 // The fate of the weak property is determined by its key.
267 RawObject* raw_key = raw_weak->ptr()->key_; 267 RawObject* raw_key = raw_weak->ptr()->key_;
268 if (raw_key->IsHeapObject() && raw_key->IsOldObject() && 268 if (raw_key->IsHeapObject() && raw_key->IsOldObject() &&
269 !raw_key->IsMarked()) { 269 !raw_key->IsMarked()) {
270 // Key was white. Enqueue the weak property. 270 // Key was white. Enqueue the weak property.
271 EnqueueWeakProperty(raw_weak); 271 EnqueueWeakProperty(raw_weak);
272 return raw_weak->Size(); 272 return raw_weak->Size();
273 } 273 }
274 // Key is gray or black. Make the weak property black. 274 // Key is gray or black. Make the weak property black.
275 return raw_weak->VisitPointers(this); 275 return raw_weak->VisitPointersNonvirtual(this);
erikcorry 2017/05/31 10:40:42 I don't think this is worth it. Normally there ar
276 } 276 }
277 277
278 // Called when all marking is complete. 278 // Called when all marking is complete.
279 void Finalize() { 279 void Finalize() {
280 work_list_.Finalize(); 280 work_list_.Finalize();
281 // Detach code from functions. 281 // Detach code from functions.
282 if (skipped_code_functions_ != NULL) { 282 if (skipped_code_functions_ != NULL) {
283 skipped_code_functions_->DetachCode(); 283 skipped_code_functions_->DetachCode();
284 } 284 }
285 // Clear pending weak properties. 285 // Clear pending weak properties.
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after
758 // Phase 3: Finalize results from all markers (detach code, etc.). 758 // Phase 3: Finalize results from all markers (detach code, etc.).
759 barrier.Exit(); 759 barrier.Exit();
760 } 760 }
761 ProcessWeakTables(page_space); 761 ProcessWeakTables(page_space);
762 ProcessObjectIdTable(isolate); 762 ProcessObjectIdTable(isolate);
763 } 763 }
764 Epilogue(isolate, invoke_api_callbacks); 764 Epilogue(isolate, invoke_api_callbacks);
765 } 765 }
766 766
767 } // namespace dart 767 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/raw_object.h » ('j') | runtime/vm/raw_object.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698