| OLD | NEW |
| 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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 visiting_old_object_ = obj; | 106 visiting_old_object_ = obj; |
| 107 } | 107 } |
| 108 | 108 |
| 109 void DelayWeakProperty(RawWeakProperty* raw_weak) { | 109 void DelayWeakProperty(RawWeakProperty* raw_weak) { |
| 110 RawObject* raw_key = raw_weak->ptr()->key_; | 110 RawObject* raw_key = raw_weak->ptr()->key_; |
| 111 DelaySet::iterator it = delay_set_.find(raw_key); | 111 DelaySet::iterator it = delay_set_.find(raw_key); |
| 112 if (it != delay_set_.end()) { | 112 if (it != delay_set_.end()) { |
| 113 ASSERT(raw_key->IsWatched()); | 113 ASSERT(raw_key->IsWatched()); |
| 114 } else { | 114 } else { |
| 115 ASSERT(!raw_key->IsWatched()); | 115 ASSERT(!raw_key->IsWatched()); |
| 116 raw_key->SetWatchedBit(); | 116 raw_key->SetWatchedBitUnsynchronized(); |
| 117 } | 117 } |
| 118 delay_set_.insert(std::make_pair(raw_key, raw_weak)); | 118 delay_set_.insert(std::make_pair(raw_key, raw_weak)); |
| 119 } | 119 } |
| 120 | 120 |
| 121 void Finalize() { | 121 void Finalize() { |
| 122 DelaySet::iterator it = delay_set_.begin(); | 122 DelaySet::iterator it = delay_set_.begin(); |
| 123 for (; it != delay_set_.end(); ++it) { | 123 for (; it != delay_set_.end(); ++it) { |
| 124 WeakProperty::Clear(it->second); | 124 WeakProperty::Clear(it->second); |
| 125 } | 125 } |
| 126 } | 126 } |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 uword raw_addr = RawObject::ToAddr(raw_obj); | 171 uword raw_addr = RawObject::ToAddr(raw_obj); |
| 172 // Read the header word of the object and determine if the object has | 172 // Read the header word of the object and determine if the object has |
| 173 // already been copied. | 173 // already been copied. |
| 174 uword header = *reinterpret_cast<uword*>(raw_addr); | 174 uword header = *reinterpret_cast<uword*>(raw_addr); |
| 175 uword new_addr = 0; | 175 uword new_addr = 0; |
| 176 if (IsForwarding(header)) { | 176 if (IsForwarding(header)) { |
| 177 // Get the new location of the object. | 177 // Get the new location of the object. |
| 178 new_addr = ForwardedAddr(header); | 178 new_addr = ForwardedAddr(header); |
| 179 } else { | 179 } else { |
| 180 if (raw_obj->IsWatched()) { | 180 if (raw_obj->IsWatched()) { |
| 181 raw_obj->ClearWatchedBit(); | 181 raw_obj->ClearWatchedBitUnsynchronized(); |
| 182 std::pair<DelaySet::iterator, DelaySet::iterator> ret; | 182 std::pair<DelaySet::iterator, DelaySet::iterator> ret; |
| 183 // Visit all elements with a key equal to this raw_obj. | 183 // Visit all elements with a key equal to this raw_obj. |
| 184 ret = delay_set_.equal_range(raw_obj); | 184 ret = delay_set_.equal_range(raw_obj); |
| 185 for (DelaySet::iterator it = ret.first; it != ret.second; ++it) { | 185 for (DelaySet::iterator it = ret.first; it != ret.second; ++it) { |
| 186 // Remember the delayed WeakProperty. These objects have been | 186 // Remember the delayed WeakProperty. These objects have been |
| 187 // forwarded, but have not been scavenged because their key was not | 187 // forwarded, but have not been scavenged because their key was not |
| 188 // known to be reachable. Now that the key object is known to be | 188 // known to be reachable. Now that the key object is known to be |
| 189 // reachable, we need to visit its key and value pointers. | 189 // reachable, we need to visit its key and value pointers. |
| 190 delayed_weak_stack_.Add(it->second); | 190 delayed_weak_stack_.Add(it->second); |
| 191 } | 191 } |
| (...skipping 704 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 896 } | 896 } |
| 897 | 897 |
| 898 | 898 |
| 899 void Scavenger::FreeExternal(intptr_t size) { | 899 void Scavenger::FreeExternal(intptr_t size) { |
| 900 ASSERT(size >= 0); | 900 ASSERT(size >= 0); |
| 901 external_size_ -= size; | 901 external_size_ -= size; |
| 902 ASSERT(external_size_ >= 0); | 902 ASSERT(external_size_ >= 0); |
| 903 } | 903 } |
| 904 | 904 |
| 905 } // namespace dart | 905 } // namespace dart |
| OLD | NEW |