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

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: address review comments 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 | « runtime/tests/vm/vm.status ('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 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.
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 // Scavenge the delayed WeakProperty. These objects have been
133 // forwarded but have not been scavenged because their key
134 // object was not known to be reachable. Now that the key
135 // object is known to be reachable we can scavenge the key and
136 // value pointers.
137 it->second->VisitPointers(this);
138 }
139 delay_set_.erase(ret.first, ret.second);
140 // Reread the header word to get the new location of the object.
141 header = *reinterpret_cast<uword*>(raw_addr);
142 ASSERT(IsForwarding(header));
143 new_addr = ForwardedAddr(header);
125 } else { 144 } 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(); 145 intptr_t size = raw_obj->Size();
138 // Check whether object should be promoted. 146 // Check whether object should be promoted.
139 if (scavenger_->survivor_end_ <= raw_addr) { 147 if (scavenger_->survivor_end_ <= raw_addr) {
140 // Not a survivor of a previous scavenge. Just copy the object into the 148 // Not a survivor of a previous scavenge. Just copy the object into the
141 // to space. 149 // to space.
142 new_addr = scavenger_->TryAllocate(size); 150 new_addr = scavenger_->TryAllocate(size);
143 } else { 151 } else {
144 // TODO(iposva): Experiment with less aggressive promotion. For example 152 // TODO(iposva): Experiment with less aggressive promotion. For example
145 // a coin toss determines if an object is promoted or whether it should 153 // a coin toss determines if an object is promoted or whether it should
146 // survive in this generation. 154 // 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); 635 PeerTable::iterator it = peer_table_.find(raw_obj);
628 return (it == peer_table_.end()) ? NULL : it->second; 636 return (it == peer_table_.end()) ? NULL : it->second;
629 } 637 }
630 638
631 639
632 int64_t Scavenger::PeerCount() const { 640 int64_t Scavenger::PeerCount() const {
633 return static_cast<int64_t>(peer_table_.size()); 641 return static_cast<int64_t>(peer_table_.size());
634 } 642 }
635 643
636 } // namespace dart 644 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/tests/vm/vm.status ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698