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

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

Issue 10824053: Rename WeakReference to WeakReferenceSet. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 4 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.cc ('k') | no next file » | 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/scavenger.h" 5 #include "vm/scavenger.h"
6 6
7 #include "vm/dart.h" 7 #include "vm/dart.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/object.h" 10 #include "vm/object.h"
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 } 372 }
373 return true; 373 return true;
374 } 374 }
375 375
376 376
377 void Scavenger::IterateWeakReferences(Isolate* isolate, 377 void Scavenger::IterateWeakReferences(Isolate* isolate,
378 ScavengerVisitor* visitor) { 378 ScavengerVisitor* visitor) {
379 ApiState* state = isolate->api_state(); 379 ApiState* state = isolate->api_state();
380 ASSERT(state != NULL); 380 ASSERT(state != NULL);
381 while (true) { 381 while (true) {
382 WeakReference* queue = state->delayed_weak_references(); 382 WeakReferenceSet* queue = state->delayed_weak_reference_sets();
383 if (queue == NULL) { 383 if (queue == NULL) {
384 // The delay queue is empty therefore no clean-up is required. 384 // The delay queue is empty therefore no clean-up is required.
385 return; 385 return;
386 } 386 }
387 state->set_delayed_weak_references(NULL); 387 state->set_delayed_weak_reference_sets(NULL);
388 while (queue != NULL) { 388 while (queue != NULL) {
389 WeakReference* reference = WeakReference::Pop(&queue); 389 WeakReferenceSet* reference_set = WeakReferenceSet::Pop(&queue);
390 ASSERT(reference != NULL); 390 ASSERT(reference_set != NULL);
391 bool is_unreachable = true; 391 bool is_unreachable = true;
392 // Test each key object for reachability. If a key object is 392 // Test each key object for reachability. If a key object is
393 // reachable, all value objects should be scavenged. 393 // reachable, all value objects should be scavenged.
394 for (intptr_t k = 0; k < reference->num_keys(); ++k) { 394 for (intptr_t k = 0; k < reference_set->num_keys(); ++k) {
395 if (!IsUnreachable(reference->get_key(k))) { 395 if (!IsUnreachable(reference_set->get_key(k))) {
396 for (intptr_t v = 0; v < reference->num_values(); ++v) { 396 for (intptr_t v = 0; v < reference_set->num_values(); ++v) {
397 visitor->VisitPointer(reference->get_value(v)); 397 visitor->VisitPointer(reference_set->get_value(v));
398 } 398 }
399 is_unreachable = false; 399 is_unreachable = false;
400 delete reference; 400 delete reference_set;
401 break; 401 break;
402 } 402 }
403 } 403 }
404 // If all key objects are unreachable put the reference on a 404 // If all key objects are unreachable put the reference on a
405 // delay queue. This reference will be revisited if another 405 // delay queue. This reference will be revisited if another
406 // reference is scavenged. 406 // reference is scavenged.
407 if (is_unreachable) { 407 if (is_unreachable) {
408 state->DelayWeakReference(reference); 408 state->DelayWeakReferenceSet(reference_set);
409 } 409 }
410 } 410 }
411 if ((resolved_top_ < top_) || PromotedStackHasMore()) { 411 if ((resolved_top_ < top_) || PromotedStackHasMore()) {
412 ProcessToSpace(visitor); 412 ProcessToSpace(visitor);
413 } else { 413 } else {
414 // Break out of the loop if there has been no forward process. 414 // Break out of the loop if there has been no forward process.
415 break; 415 break;
416 } 416 }
417 } 417 }
418 // Deallocate any unreachable references on the delay queue. 418 // Deallocate any unreachable references on the delay queue.
419 if (state->delayed_weak_references() != NULL) { 419 if (state->delayed_weak_reference_sets() != NULL) {
420 WeakReference* queue = state->delayed_weak_references(); 420 WeakReferenceSet* queue = state->delayed_weak_reference_sets();
421 state->set_delayed_weak_references(NULL); 421 state->set_delayed_weak_reference_sets(NULL);
422 while (queue != NULL) { 422 while (queue != NULL) {
423 delete WeakReference::Pop(&queue); 423 delete WeakReferenceSet::Pop(&queue);
424 } 424 }
425 } 425 }
426 } 426 }
427 427
428 428
429 void Scavenger::IterateWeakRoots(Isolate* isolate, 429 void Scavenger::IterateWeakRoots(Isolate* isolate,
430 HandleVisitor* visitor, 430 HandleVisitor* visitor,
431 bool visit_prologue_weak_persistent_handles) { 431 bool visit_prologue_weak_persistent_handles) {
432 isolate->VisitWeakPersistentHandles(visitor, 432 isolate->VisitWeakPersistentHandles(visitor,
433 visit_prologue_weak_persistent_handles); 433 visit_prologue_weak_persistent_handles);
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 OS::PrintErr(" done.\n"); 519 OS::PrintErr(" done.\n");
520 } 520 }
521 521
522 count_++; 522 count_++;
523 // Done scavenging. Reset the marker. 523 // Done scavenging. Reset the marker.
524 ASSERT(scavenging_); 524 ASSERT(scavenging_);
525 scavenging_ = false; 525 scavenging_ = false;
526 } 526 }
527 527
528 } // namespace dart 528 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/gc_marker.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698