Chromium Code Reviews| 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/gc_marker.h" | 5 #include "vm/gc_marker.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <utility> | 8 #include <utility> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 151 return &skipped_code_functions_; | 151 return &skipped_code_functions_; |
| 152 } | 152 } |
| 153 | 153 |
| 154 void DelayWeakProperty(RawWeakProperty* raw_weak) { | 154 void DelayWeakProperty(RawWeakProperty* raw_weak) { |
| 155 RawObject* raw_key = raw_weak->ptr()->key_; | 155 RawObject* raw_key = raw_weak->ptr()->key_; |
| 156 DelaySet::iterator it = delay_set_.find(raw_key); | 156 DelaySet::iterator it = delay_set_.find(raw_key); |
| 157 if (it != delay_set_.end()) { | 157 if (it != delay_set_.end()) { |
| 158 ASSERT(raw_key->IsWatched()); | 158 ASSERT(raw_key->IsWatched()); |
| 159 } else { | 159 } else { |
| 160 ASSERT(!raw_key->IsWatched()); | 160 ASSERT(!raw_key->IsWatched()); |
| 161 raw_key->SetWatchedBit(); | 161 raw_key->SetWatchedBitUnsynchronized(); |
| 162 } | 162 } |
| 163 delay_set_.insert(std::make_pair(raw_key, raw_weak)); | 163 delay_set_.insert(std::make_pair(raw_key, raw_weak)); |
| 164 } | 164 } |
| 165 | 165 |
| 166 void Finalize() { | 166 void Finalize() { |
| 167 DelaySet::iterator it = delay_set_.begin(); | 167 DelaySet::iterator it = delay_set_.begin(); |
| 168 for (; it != delay_set_.end(); ++it) { | 168 for (; it != delay_set_.end(); ++it) { |
| 169 WeakProperty::Clear(it->second); | 169 WeakProperty::Clear(it->second); |
| 170 } | 170 } |
| 171 if (!visit_function_code_) { | 171 if (!visit_function_code_) { |
| 172 DetachCode(); | 172 DetachCode(); |
| 173 } | 173 } |
| 174 } | 174 } |
| 175 | 175 |
| 176 void VisitingOldObject(RawObject* obj) { | 176 void VisitingOldObject(RawObject* obj) { |
| 177 ASSERT((obj == NULL) || obj->IsOldObject()); | 177 ASSERT((obj == NULL) || obj->IsOldObject()); |
| 178 visiting_old_object_ = obj; | 178 visiting_old_object_ = obj; |
| 179 } | 179 } |
| 180 | 180 |
| 181 private: | 181 private: |
| 182 void MarkAndPush(RawObject* raw_obj) { | 182 void MarkAndPush(RawObject* raw_obj) { |
| 183 ASSERT(raw_obj->IsHeapObject()); | 183 ASSERT(raw_obj->IsHeapObject()); |
| 184 ASSERT((FLAG_verify_before_gc || FLAG_verify_before_gc) ? | 184 ASSERT((FLAG_verify_before_gc || FLAG_verify_before_gc) ? |
| 185 page_space_->Contains(RawObject::ToAddr(raw_obj)) : | 185 page_space_->Contains(RawObject::ToAddr(raw_obj)) : |
| 186 true); | 186 true); |
| 187 | 187 |
| 188 // Mark the object and push it on the marking stack. | 188 // Mark the object and push it on the marking stack. |
| 189 ASSERT(!raw_obj->IsMarked()); | 189 ASSERT(!raw_obj->IsMarked()); |
| 190 raw_obj->SetMarkBit(); | 190 raw_obj->SetMarkBitUnsynchronized(); |
| 191 raw_obj->ClearRememberedBit(); | 191 raw_obj->ClearRememberedBitUnsynchronized(); |
| 192 if (raw_obj->IsWatched()) { | 192 if (raw_obj->IsWatched()) { |
|
Ivan Posva
2014/12/16 20:33:23
How about:
bool is_watched = raw_obj->IsWatched()
koda
2014/12/16 20:49:19
Done (after removing ASSERT from ClearWatched...).
| |
| 193 std::pair<DelaySet::iterator, DelaySet::iterator> ret; | 193 std::pair<DelaySet::iterator, DelaySet::iterator> ret; |
| 194 // Visit all elements with a key equal to raw_obj. | 194 // Visit all elements with a key equal to raw_obj. |
| 195 ret = delay_set_.equal_range(raw_obj); | 195 ret = delay_set_.equal_range(raw_obj); |
| 196 // Create a copy of the range in a temporary vector to iterate over it | 196 // Create a copy of the range in a temporary vector to iterate over it |
| 197 // while delay_set_ may be modified. | 197 // while delay_set_ may be modified. |
| 198 std::vector<DelaySetEntry> temp_copy(ret.first, ret.second); | 198 std::vector<DelaySetEntry> temp_copy(ret.first, ret.second); |
| 199 delay_set_.erase(ret.first, ret.second); | 199 delay_set_.erase(ret.first, ret.second); |
| 200 for (std::vector<DelaySetEntry>::iterator it = temp_copy.begin(); | 200 for (std::vector<DelaySetEntry>::iterator it = temp_copy.begin(); |
| 201 it != temp_copy.end(); ++it) { | 201 it != temp_copy.end(); ++it) { |
| 202 it->second->VisitPointers(this); | 202 it->second->VisitPointers(this); |
| 203 } | 203 } |
| 204 raw_obj->ClearWatchedBit(); | 204 raw_obj->ClearWatchedBitUnsynchronized(); |
|
Ivan Posva
2014/12/16 20:33:23
Can we at least move this up to immediately clear
koda
2014/12/16 20:49:19
Acknowledged.
| |
| 205 } | 205 } |
| 206 marking_stack_->Push(raw_obj); | 206 marking_stack_->Push(raw_obj); |
| 207 } | 207 } |
| 208 | 208 |
| 209 void MarkObject(RawObject* raw_obj, RawObject** p) { | 209 void MarkObject(RawObject* raw_obj, RawObject** p) { |
| 210 // Fast exit if the raw object is a Smi. | 210 // Fast exit if the raw object is a Smi. |
| 211 if (!raw_obj->IsHeapObject()) { | 211 if (!raw_obj->IsHeapObject()) { |
| 212 return; | 212 return; |
| 213 } | 213 } |
| 214 | 214 |
| 215 // Fast exit if the raw object is marked. | 215 // Fast exit if the raw object is marked. |
| 216 if (raw_obj->IsMarked()) { | 216 if (raw_obj->IsMarked()) { |
| 217 return; | 217 return; |
| 218 } | 218 } |
| 219 | 219 |
| 220 // Skip over new objects, but verify consistency of heap while at it. | 220 // Skip over new objects, but verify consistency of heap while at it. |
| 221 if (raw_obj->IsNewObject()) { | 221 if (raw_obj->IsNewObject()) { |
| 222 // TODO(iposva): Add consistency check. | 222 // TODO(iposva): Add consistency check. |
| 223 if ((visiting_old_object_ != NULL) && | 223 if ((visiting_old_object_ != NULL) && |
| 224 !visiting_old_object_->IsRemembered()) { | 224 !visiting_old_object_->IsRemembered()) { |
| 225 ASSERT(p != NULL); | 225 ASSERT(p != NULL); |
| 226 visiting_old_object_->SetRememberedBit(); | 226 visiting_old_object_->SetRememberedBitUnsynchronized(); |
| 227 isolate()->store_buffer()->AddObjectGC(visiting_old_object_); | 227 isolate()->store_buffer()->AddObjectGC(visiting_old_object_); |
| 228 } | 228 } |
| 229 return; | 229 return; |
| 230 } | 230 } |
| 231 if (RawObject::IsVariableSizeClassId(raw_obj->GetClassId())) { | 231 if (RawObject::IsVariableSizeClassId(raw_obj->GetClassId())) { |
| 232 class_table_->UpdateLiveOld(raw_obj->GetClassId(), raw_obj->Size()); | 232 class_table_->UpdateLiveOld(raw_obj->GetClassId(), raw_obj->Size()); |
| 233 } else { | 233 } else { |
| 234 class_table_->UpdateLiveOld(raw_obj->GetClassId(), 0); | 234 class_table_->UpdateLiveOld(raw_obj->GetClassId(), 0); |
| 235 } | 235 } |
| 236 | 236 |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 510 MarkingWeakVisitor mark_weak; | 510 MarkingWeakVisitor mark_weak; |
| 511 IterateWeakRoots(isolate, &mark_weak, invoke_api_callbacks); | 511 IterateWeakRoots(isolate, &mark_weak, invoke_api_callbacks); |
| 512 mark.Finalize(); | 512 mark.Finalize(); |
| 513 ProcessWeakTables(page_space); | 513 ProcessWeakTables(page_space); |
| 514 ProcessObjectIdTable(isolate); | 514 ProcessObjectIdTable(isolate); |
| 515 | 515 |
| 516 Epilogue(isolate, invoke_api_callbacks); | 516 Epilogue(isolate, invoke_api_callbacks); |
| 517 } | 517 } |
| 518 | 518 |
| 519 } // namespace dart | 519 } // namespace dart |
| OLD | NEW |