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

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

Issue 11055007: Scavenge watched objects by scavenging their watchers. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 2 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 | « no previous file | 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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 return; 115 return;
116 } 116 }
117 117
118 // Read the header word of the object and determine if the object has 118 // Read the header word of the object and determine if the object has
119 // already been copied. 119 // already been copied.
120 uword header = *reinterpret_cast<uword*>(raw_addr); 120 uword header = *reinterpret_cast<uword*>(raw_addr);
121 uword new_addr = 0; 121 uword new_addr = 0;
122 if (IsForwarding(header)) { 122 if (IsForwarding(header)) {
123 // Get the new location of the object. 123 // Get the new location of the object.
124 new_addr = ForwardedAddr(header); 124 new_addr = ForwardedAddr(header);
125 } else if (raw_obj->IsWatched()) {
126 // Forward the object by scavenging its watchers.
Ivan Posva 2012/10/02 23:02:31 Can you add a comment here that we delayed visitin
cshapiro 2012/10/03 01:39:42 Done.
127 raw_obj->ClearWatchedBit();
128 std::pair<DelaySet::iterator, DelaySet::iterator> ret;
129 // Visit all elements with a key equal to raw_obj.
130 ret = delay_set_.equal_range(raw_obj);
131 for (DelaySet::iterator it = ret.first; it != ret.second; ++it) {
132 // Visit through the associated WeakProperty at this time.
133 it->second->VisitPointers(this);
134 }
135 delay_set_.erase(ret.first, ret.second);
136 // Reread the header word to get the new location of the object.
137 header = *reinterpret_cast<uword*>(raw_addr);
138 ASSERT(IsForwarding(header));
139 new_addr = ForwardedAddr(header);
125 } else { 140 } else {
126 if (raw_obj->IsWatched()) {
127 std::pair<DelaySet::iterator, DelaySet::iterator> ret;
128 // Visit all elements with a key equal to raw_obj.
129 ret = delay_set_.equal_range(raw_obj);
130 for (DelaySet::iterator it = ret.first; it != ret.second; ++it) {
131 // Visit through the associated WeakProperty at this time.
132 it->second->VisitPointers(this);
133 }
134 delay_set_.erase(ret.first, ret.second);
135 raw_obj->ClearWatchedBit();
136 }
137 intptr_t size = raw_obj->Size(); 141 intptr_t size = raw_obj->Size();
138 // Check whether object should be promoted. 142 // Check whether object should be promoted.
139 if (scavenger_->survivor_end_ <= raw_addr) { 143 if (scavenger_->survivor_end_ <= raw_addr) {
140 // Not a survivor of a previous scavenge. Just copy the object into the 144 // Not a survivor of a previous scavenge. Just copy the object into the
141 // to space. 145 // to space.
142 new_addr = scavenger_->TryAllocate(size); 146 new_addr = scavenger_->TryAllocate(size);
143 } else { 147 } else {
144 // TODO(iposva): Experiment with less aggressive promotion. For example 148 // TODO(iposva): Experiment with less aggressive promotion. For example
145 // a coin toss determines if an object is promoted or whether it should 149 // a coin toss determines if an object is promoted or whether it should
146 // survive in this generation. 150 // survive in this generation.
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after
627 PeerTable::iterator it = peer_table_.find(raw_obj); 631 PeerTable::iterator it = peer_table_.find(raw_obj);
628 return (it == peer_table_.end()) ? NULL : it->second; 632 return (it == peer_table_.end()) ? NULL : it->second;
629 } 633 }
630 634
631 635
632 int64_t Scavenger::PeerCount() const { 636 int64_t Scavenger::PeerCount() const {
633 return static_cast<int64_t>(peer_table_.size()); 637 return static_cast<int64_t>(peer_table_.size());
634 } 638 }
635 639
636 } // namespace dart 640 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698