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 | 9 |
10 #include "vm/allocation.h" | 10 #include "vm/allocation.h" |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 void MarkAndPush(RawObject* raw_obj) { | 168 void MarkAndPush(RawObject* raw_obj) { |
169 ASSERT(raw_obj->IsHeapObject()); | 169 ASSERT(raw_obj->IsHeapObject()); |
170 ASSERT((FLAG_verify_before_gc || FLAG_verify_before_gc) ? | 170 ASSERT((FLAG_verify_before_gc || FLAG_verify_before_gc) ? |
171 page_space_->Contains(RawObject::ToAddr(raw_obj)) : | 171 page_space_->Contains(RawObject::ToAddr(raw_obj)) : |
172 true); | 172 true); |
173 | 173 |
174 // Mark the object and push it on the marking stack. | 174 // Mark the object and push it on the marking stack. |
175 ASSERT(!raw_obj->IsMarked()); | 175 ASSERT(!raw_obj->IsMarked()); |
176 RawClass* raw_class = isolate()->class_table()->At(raw_obj->GetClassId()); | 176 RawClass* raw_class = isolate()->class_table()->At(raw_obj->GetClassId()); |
177 raw_obj->SetMarkBit(); | 177 raw_obj->SetMarkBit(); |
| 178 raw_obj->ClearRememberedBit(); |
178 if (raw_obj->IsWatched()) { | 179 if (raw_obj->IsWatched()) { |
179 std::pair<DelaySet::iterator, DelaySet::iterator> ret; | 180 std::pair<DelaySet::iterator, DelaySet::iterator> ret; |
180 // Visit all elements with a key equal to raw_obj. | 181 // Visit all elements with a key equal to raw_obj. |
181 ret = delay_set_.equal_range(raw_obj); | 182 ret = delay_set_.equal_range(raw_obj); |
182 for (DelaySet::iterator it = ret.first; it != ret.second; ++it) { | 183 for (DelaySet::iterator it = ret.first; it != ret.second; ++it) { |
183 it->second->VisitPointers(this); | 184 it->second->VisitPointers(this); |
184 } | 185 } |
185 delay_set_.erase(ret.first, ret.second); | 186 delay_set_.erase(ret.first, ret.second); |
186 raw_obj->ClearWatchedBit(); | 187 raw_obj->ClearWatchedBit(); |
187 } | 188 } |
188 marking_stack_->Push(raw_obj); | 189 marking_stack_->Push(raw_obj); |
189 | 190 |
190 // TODO(iposva): Should we mark the classes early? | 191 // TODO(iposva): Should we mark the classes early? |
191 MarkObject(raw_class, NULL); | 192 MarkObject(raw_class, NULL); |
192 } | 193 } |
193 | 194 |
194 void MarkObject(RawObject* raw_obj, RawObject** p) { | 195 void MarkObject(RawObject* raw_obj, RawObject** p) { |
195 // Fast exit if the raw object is a Smi. | 196 // Fast exit if the raw object is a Smi. |
196 if (!raw_obj->IsHeapObject()) return; | 197 if (!raw_obj->IsHeapObject()) return; |
197 | 198 |
198 // Fast exit if the raw object is marked. | 199 // Fast exit if the raw object is marked. |
199 if (raw_obj->IsMarked()) return; | 200 if (raw_obj->IsMarked()) return; |
200 | 201 |
201 // Skip over new objects, but verify consistency of heap while at it. | 202 // Skip over new objects, but verify consistency of heap while at it. |
202 if (raw_obj->IsNewObject()) { | 203 if (raw_obj->IsNewObject()) { |
203 // TODO(iposva): Add consistency check. | 204 // TODO(iposva): Add consistency check. |
204 if (visiting_old_object_ != NULL) { | 205 if ((visiting_old_object_ != NULL) && |
| 206 !visiting_old_object_->IsRemembered()) { |
205 ASSERT(p != NULL); | 207 ASSERT(p != NULL); |
| 208 visiting_old_object_->SetRememberedBit(); |
206 isolate()->store_buffer()->AddPointer( | 209 isolate()->store_buffer()->AddPointer( |
207 reinterpret_cast<uword>(visiting_old_object_)); | 210 reinterpret_cast<uword>(visiting_old_object_)); |
208 } | 211 } |
209 return; | 212 return; |
210 } | 213 } |
211 | 214 |
212 MarkAndPush(raw_obj); | 215 MarkAndPush(raw_obj); |
213 } | 216 } |
214 | 217 |
215 Heap* heap_; | 218 Heap* heap_; |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
405 DrainMarkingStack(isolate, &mark); | 408 DrainMarkingStack(isolate, &mark); |
406 IterateWeakReferences(isolate, &mark); | 409 IterateWeakReferences(isolate, &mark); |
407 MarkingWeakVisitor mark_weak; | 410 MarkingWeakVisitor mark_weak; |
408 IterateWeakRoots(isolate, &mark_weak, invoke_api_callbacks); | 411 IterateWeakRoots(isolate, &mark_weak, invoke_api_callbacks); |
409 mark.Finalize(); | 412 mark.Finalize(); |
410 ProcessPeerReferents(page_space); | 413 ProcessPeerReferents(page_space); |
411 Epilogue(isolate, invoke_api_callbacks); | 414 Epilogue(isolate, invoke_api_callbacks); |
412 } | 415 } |
413 | 416 |
414 } // namespace dart | 417 } // namespace dart |
OLD | NEW |