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

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

Issue 187113003: Track external allocated memory for weak persistent handles. (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
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 <map> 7 #include <map>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 } 291 }
292 if (!raw_obj->IsOldObject()) { 292 if (!raw_obj->IsOldObject()) {
293 return false; 293 return false;
294 } 294 }
295 return !raw_obj->IsMarked(); 295 return !raw_obj->IsMarked();
296 } 296 }
297 297
298 298
299 class MarkingWeakVisitor : public HandleVisitor { 299 class MarkingWeakVisitor : public HandleVisitor {
300 public: 300 public:
301 MarkingWeakVisitor() { 301 explicit MarkingWeakVisitor(Heap* heap) : heap_(heap) {
302 } 302 }
303 303
304 void VisitHandle(uword addr) { 304 void VisitHandle(uword addr) {
305 FinalizablePersistentHandle* handle = 305 FinalizablePersistentHandle* handle =
306 reinterpret_cast<FinalizablePersistentHandle*>(addr); 306 reinterpret_cast<FinalizablePersistentHandle*>(addr);
307 RawObject* raw_obj = handle->raw(); 307 RawObject* raw_obj = handle->raw();
308 if (IsUnreachable(raw_obj)) { 308 if (IsUnreachable(raw_obj)) {
309 FinalizablePersistentHandle::Finalize(handle); 309 handle->UpdateUnreachable(heap_);
310 } 310 }
311 } 311 }
312 312
313 private: 313 private:
314 Heap* heap_;
315
314 DISALLOW_COPY_AND_ASSIGN(MarkingWeakVisitor); 316 DISALLOW_COPY_AND_ASSIGN(MarkingWeakVisitor);
315 }; 317 };
316 318
317 319
318 void GCMarker::Prologue(Isolate* isolate, bool invoke_api_callbacks) { 320 void GCMarker::Prologue(Isolate* isolate, bool invoke_api_callbacks) {
319 if (invoke_api_callbacks) { 321 if (invoke_api_callbacks) {
320 isolate->gc_prologue_callbacks().Invoke(); 322 isolate->gc_prologue_callbacks().Invoke();
321 } 323 }
322 // The store buffers will be rebuilt as part of marking, reset them now. 324 // The store buffers will be rebuilt as part of marking, reset them now.
323 isolate->store_buffer()->Reset(); 325 isolate->store_buffer()->Reset();
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 bool invoke_api_callbacks, 489 bool invoke_api_callbacks,
488 bool collect_code) { 490 bool collect_code) {
489 const bool visit_function_code = !collect_code; 491 const bool visit_function_code = !collect_code;
490 MarkingStack marking_stack; 492 MarkingStack marking_stack;
491 Prologue(isolate, invoke_api_callbacks); 493 Prologue(isolate, invoke_api_callbacks);
492 MarkingVisitor mark( 494 MarkingVisitor mark(
493 isolate, heap_, page_space, &marking_stack, visit_function_code); 495 isolate, heap_, page_space, &marking_stack, visit_function_code);
494 IterateRoots(isolate, &mark, !invoke_api_callbacks); 496 IterateRoots(isolate, &mark, !invoke_api_callbacks);
495 DrainMarkingStack(isolate, &mark); 497 DrainMarkingStack(isolate, &mark);
496 IterateWeakReferences(isolate, &mark); 498 IterateWeakReferences(isolate, &mark);
497 MarkingWeakVisitor mark_weak; 499 MarkingWeakVisitor mark_weak(heap_);
498 IterateWeakRoots(isolate, &mark_weak, invoke_api_callbacks); 500 IterateWeakRoots(isolate, &mark_weak, invoke_api_callbacks);
499 mark.Finalize(); 501 mark.Finalize();
500 ProcessWeakTables(page_space); 502 ProcessWeakTables(page_space);
501 ProcessObjectIdTable(isolate); 503 ProcessObjectIdTable(isolate);
502 504
503 Epilogue(isolate, invoke_api_callbacks); 505 Epilogue(isolate, invoke_api_callbacks);
504 } 506 }
505 507
506 } // namespace dart 508 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698