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

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

Issue 18051007: - Revert r24564 and r24563 due to unexplained malloc corruption. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 5 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/gc_marker.h ('k') | runtime/vm/heap.h » ('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) 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 9
10 #include "vm/allocation.h" 10 #include "vm/allocation.h"
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 !raw_key->IsMarked()) { 372 !raw_key->IsMarked()) {
373 // Key is white. Delay the weak property. 373 // Key is white. Delay the weak property.
374 visitor->DelayWeakProperty(raw_weak); 374 visitor->DelayWeakProperty(raw_weak);
375 } else { 375 } else {
376 // Key is gray or black. Make the weak property black. 376 // Key is gray or black. Make the weak property black.
377 raw_weak->VisitPointers(visitor); 377 raw_weak->VisitPointers(visitor);
378 } 378 }
379 } 379 }
380 380
381 381
382 void GCMarker::ProcessWeakTables(PageSpace* page_space) { 382 void GCMarker::ProcessPeerReferents(PageSpace* page_space) {
383 for (int sel = 0; 383 PageSpace::PeerTable* peer_table = page_space->GetPeerTable();
384 sel < Heap::kNumWeakSelectors; 384 PageSpace::PeerTable::iterator it = peer_table->begin();
385 sel++) { 385 while (it != peer_table->end()) {
386 WeakTable* table = heap_->GetWeakTable( 386 RawObject* raw_obj = it->first;
387 Heap::kOld, static_cast<Heap::WeakSelector>(sel)); 387 ASSERT(raw_obj->IsHeapObject());
388 intptr_t size = table->size(); 388 if (raw_obj->IsMarked()) {
389 for (intptr_t i = 0; i < size; i++) { 389 // The object has survived. Do nothing.
390 if (table->IsValidEntryAt(i)) { 390 ++it;
391 RawObject* raw_obj = table->ObjectAt(i); 391 } else {
392 ASSERT(raw_obj->IsHeapObject()); 392 // The object has become garbage. Remove its record.
393 if (!raw_obj->IsMarked()) { 393 peer_table->erase(it++);
394 table->InvalidateAt(i);
395 }
396 }
397 } 394 }
398 } 395 }
399 } 396 }
400 397
401 398
402 void GCMarker::MarkObjects(Isolate* isolate, 399 void GCMarker::MarkObjects(Isolate* isolate,
403 PageSpace* page_space, 400 PageSpace* page_space,
404 bool invoke_api_callbacks) { 401 bool invoke_api_callbacks) {
405 MarkingStack marking_stack; 402 MarkingStack marking_stack;
406 Prologue(isolate, invoke_api_callbacks); 403 Prologue(isolate, invoke_api_callbacks);
407 MarkingVisitor mark(isolate, heap_, page_space, &marking_stack); 404 MarkingVisitor mark(isolate, heap_, page_space, &marking_stack);
408 IterateRoots(isolate, &mark, !invoke_api_callbacks); 405 IterateRoots(isolate, &mark, !invoke_api_callbacks);
409 DrainMarkingStack(isolate, &mark); 406 DrainMarkingStack(isolate, &mark);
410 IterateWeakReferences(isolate, &mark); 407 IterateWeakReferences(isolate, &mark);
411 MarkingWeakVisitor mark_weak; 408 MarkingWeakVisitor mark_weak;
412 IterateWeakRoots(isolate, &mark_weak, invoke_api_callbacks); 409 IterateWeakRoots(isolate, &mark_weak, invoke_api_callbacks);
413 mark.Finalize(); 410 mark.Finalize();
414 ProcessWeakTables(page_space); 411 ProcessPeerReferents(page_space);
415 Epilogue(isolate, invoke_api_callbacks); 412 Epilogue(isolate, invoke_api_callbacks);
416 } 413 }
417 414
418 } // namespace dart 415 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/gc_marker.h ('k') | runtime/vm/heap.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698