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

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

Issue 1287333007: - Avoid scavenging the same location twice. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 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
« no previous file with comments | « runtime/vm/dart_api_impl_test.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 <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 BoolScope bs(&in_scavenge_pointer_, true); 151 BoolScope bs(&in_scavenge_pointer_, true);
152 #endif 152 #endif
153 153
154 RawObject* raw_obj = *p; 154 RawObject* raw_obj = *p;
155 155
156 if (raw_obj->IsSmiOrOldObject()) { 156 if (raw_obj->IsSmiOrOldObject()) {
157 return; 157 return;
158 } 158 }
159 159
160 uword raw_addr = RawObject::ToAddr(raw_obj); 160 uword raw_addr = RawObject::ToAddr(raw_obj);
161 // The scavenger is only interested in objects located in the from space. 161 // The scavenger is only expects objects located in the from space.
162 if (scavenger_->to_->Contains(raw_addr)) {
163 return;
164 }
165 ASSERT(from_->Contains(raw_addr)); 162 ASSERT(from_->Contains(raw_addr));
166 // Read the header word of the object and determine if the object has 163 // Read the header word of the object and determine if the object has
167 // already been copied. 164 // already been copied.
168 uword header = *reinterpret_cast<uword*>(raw_addr); 165 uword header = *reinterpret_cast<uword*>(raw_addr);
169 uword new_addr = 0; 166 uword new_addr = 0;
170 if (IsForwarding(header)) { 167 if (IsForwarding(header)) {
171 // Get the new location of the object. 168 // Get the new location of the object.
172 new_addr = ForwardedAddr(header); 169 new_addr = ForwardedAddr(header);
173 } else { 170 } else {
174 if (raw_obj->IsWatched()) { 171 if (raw_obj->IsWatched()) {
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after
611 // We do not have to process sets that have just one key/value pair 608 // We do not have to process sets that have just one key/value pair
612 // and the key and value are identical. 609 // and the key and value are identical.
613 continue; 610 continue;
614 } 611 }
615 bool is_unreachable = true; 612 bool is_unreachable = true;
616 // Test each key object for reachability. If a key object is 613 // Test each key object for reachability. If a key object is
617 // reachable, all value objects should be scavenged. 614 // reachable, all value objects should be scavenged.
618 for (intptr_t k = 0; k < num_keys; ++k) { 615 for (intptr_t k = 0; k < num_keys; ++k) {
619 if (!IsUnreachable(reference_set->get_key(k))) { 616 if (!IsUnreachable(reference_set->get_key(k))) {
620 for (intptr_t v = 0; v < num_values; ++v) { 617 for (intptr_t v = 0; v < num_values; ++v) {
621 visitor->VisitPointer(reference_set->get_value(v)); 618 RawObject** raw_obj_addr = reference_set->get_value(v);
619 RawObject* raw_obj = *raw_obj_addr;
620 // Only visit heap objects which are in from space, aka new objects
621 // not in to space. This avoids visiting a value multiple times
622 // during a scavenge.
623 if (raw_obj->IsHeapObject() &&
624 raw_obj->IsNewObject() &&
625 !to_->Contains(RawObject::ToAddr(raw_obj))) {
626 visitor->VisitPointer(raw_obj_addr);
627 }
622 } 628 }
623 is_unreachable = false; 629 is_unreachable = false;
624 // Since we have found a key object that is reachable and all 630 // Since we have found a key object that is reachable and all
625 // value objects have been marked we can break out of iterating 631 // value objects have been marked we can break out of iterating
626 // this set and move on to the next set. 632 // this set and move on to the next set.
627 break; 633 break;
628 } 634 }
629 } 635 }
630 // If all key objects are unreachable put the reference on a 636 // If all key objects are unreachable put the reference on a
631 // delay queue. This reference will be revisited if another 637 // delay queue. This reference will be revisited if another
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
896 } 902 }
897 903
898 904
899 void Scavenger::FreeExternal(intptr_t size) { 905 void Scavenger::FreeExternal(intptr_t size) {
900 ASSERT(size >= 0); 906 ASSERT(size >= 0);
901 external_size_ -= size; 907 external_size_ -= size;
902 ASSERT(external_size_ >= 0); 908 ASSERT(external_size_ >= 0);
903 } 909 }
904 910
905 } // namespace dart 911 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/dart_api_impl_test.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698