OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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/heap.h" | 5 #include "vm/heap.h" |
6 | 6 |
7 #include "platform/assert.h" | 7 #include "platform/assert.h" |
8 #include "platform/utils.h" | 8 #include "platform/utils.h" |
9 #include "vm/flags.h" | 9 #include "vm/flags.h" |
10 #include "vm/isolate.h" | 10 #include "vm/isolate.h" |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 return old_space_.DataContains(addr); | 182 return old_space_.DataContains(addr); |
183 } | 183 } |
184 | 184 |
185 | 185 |
186 void Heap::VisitObjects(ObjectVisitor* visitor) const { | 186 void Heap::VisitObjects(ObjectVisitor* visitor) const { |
187 new_space_.VisitObjects(visitor); | 187 new_space_.VisitObjects(visitor); |
188 old_space_.VisitObjects(visitor); | 188 old_space_.VisitObjects(visitor); |
189 } | 189 } |
190 | 190 |
191 | 191 |
| 192 void Heap::VisitObjectsNoExternalPages(ObjectVisitor* visitor) const { |
| 193 new_space_.VisitObjects(visitor); |
| 194 old_space_.VisitObjectsNoExternalPages(visitor); |
| 195 } |
| 196 |
| 197 |
| 198 void Heap::VisitObjectsExternalPages(ObjectVisitor* visitor) const { |
| 199 old_space_.VisitObjectsExternalPages(visitor); |
| 200 } |
| 201 |
| 202 |
192 HeapIterationScope::HeapIterationScope(bool writable) | 203 HeapIterationScope::HeapIterationScope(bool writable) |
193 : StackResource(Thread::Current()), | 204 : StackResource(Thread::Current()), |
194 old_space_(isolate()->heap()->old_space()), | 205 old_space_(isolate()->heap()->old_space()), |
195 writable_(writable) { | 206 writable_(writable) { |
196 { | 207 { |
197 // It's not yet safe to iterate over a paged space while it's concurrently | 208 // It's not yet safe to iterate over a paged space while it's concurrently |
198 // sweeping, so wait for any such task to complete first. | 209 // sweeping, so wait for any such task to complete first. |
199 MonitorLocker ml(old_space_->tasks_lock()); | 210 MonitorLocker ml(old_space_->tasks_lock()); |
200 #if defined(DEBUG) | 211 #if defined(DEBUG) |
201 // We currently don't support nesting of HeapIterationScopes. | 212 // We currently don't support nesting of HeapIterationScopes. |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 IterateOldObjects(visitor); | 251 IterateOldObjects(visitor); |
241 } | 252 } |
242 | 253 |
243 | 254 |
244 void Heap::IterateOldObjects(ObjectVisitor* visitor) const { | 255 void Heap::IterateOldObjects(ObjectVisitor* visitor) const { |
245 HeapIterationScope heap_iteration_scope; | 256 HeapIterationScope heap_iteration_scope; |
246 old_space_.VisitObjects(visitor); | 257 old_space_.VisitObjects(visitor); |
247 } | 258 } |
248 | 259 |
249 | 260 |
250 void Heap::IterateOldObjectsNoEmbedderPages(ObjectVisitor* visitor) const { | 261 void Heap::IterateOldObjectsNoExternalPages(ObjectVisitor* visitor) const { |
251 HeapIterationScope heap_iteration_scope; | 262 HeapIterationScope heap_iteration_scope; |
252 old_space_.VisitObjectsNoEmbedderPages(visitor); | 263 old_space_.VisitObjectsNoExternalPages(visitor); |
253 } | 264 } |
254 | 265 |
255 | 266 |
256 void Heap::VisitObjectPointers(ObjectPointerVisitor* visitor) const { | 267 void Heap::VisitObjectPointers(ObjectPointerVisitor* visitor) const { |
257 new_space_.VisitObjectPointers(visitor); | 268 new_space_.VisitObjectPointers(visitor); |
258 old_space_.VisitObjectPointers(visitor); | 269 old_space_.VisitObjectPointers(visitor); |
259 } | 270 } |
260 | 271 |
261 | 272 |
262 RawInstructions* Heap::FindObjectInCodeSpace(FindObjectVisitor* visitor) const { | 273 RawInstructions* Heap::FindObjectInCodeSpace(FindObjectVisitor* visitor) const { |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
513 | 524 |
514 ObjectSet* Heap::CreateAllocatedObjectSet( | 525 ObjectSet* Heap::CreateAllocatedObjectSet( |
515 Zone* zone, | 526 Zone* zone, |
516 MarkExpectation mark_expectation) const { | 527 MarkExpectation mark_expectation) const { |
517 ObjectSet* allocated_set = new (zone) ObjectSet(zone); | 528 ObjectSet* allocated_set = new (zone) ObjectSet(zone); |
518 | 529 |
519 this->AddRegionsToObjectSet(allocated_set); | 530 this->AddRegionsToObjectSet(allocated_set); |
520 { | 531 { |
521 VerifyObjectVisitor object_visitor(isolate(), allocated_set, | 532 VerifyObjectVisitor object_visitor(isolate(), allocated_set, |
522 mark_expectation); | 533 mark_expectation); |
523 this->VisitObjects(&object_visitor); | 534 this->VisitObjectsNoExternalPages(&object_visitor); |
| 535 } |
| 536 { |
| 537 VerifyObjectVisitor object_visitor(isolate(), allocated_set, |
| 538 kRequireMarked); |
| 539 this->VisitObjectsExternalPages(&object_visitor); |
524 } | 540 } |
525 | 541 |
526 Isolate* vm_isolate = Dart::vm_isolate(); | 542 Isolate* vm_isolate = Dart::vm_isolate(); |
527 vm_isolate->heap()->AddRegionsToObjectSet(allocated_set); | 543 vm_isolate->heap()->AddRegionsToObjectSet(allocated_set); |
528 { | 544 { |
529 // VM isolate heap is premarked. | 545 // VM isolate heap is premarked. |
530 VerifyObjectVisitor vm_object_visitor(isolate(), allocated_set, | 546 VerifyObjectVisitor vm_object_visitor(isolate(), allocated_set, |
531 kRequireMarked); | 547 kRequireMarked); |
532 vm_isolate->heap()->VisitObjects(&vm_object_visitor); | 548 vm_isolate->heap()->VisitObjects(&vm_object_visitor); |
533 } | 549 } |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
827 Dart::vm_isolate()->heap()->WriteProtect(false); | 843 Dart::vm_isolate()->heap()->WriteProtect(false); |
828 } | 844 } |
829 | 845 |
830 | 846 |
831 WritableVMIsolateScope::~WritableVMIsolateScope() { | 847 WritableVMIsolateScope::~WritableVMIsolateScope() { |
832 ASSERT(Dart::vm_isolate()->heap()->UsedInWords(Heap::kNew) == 0); | 848 ASSERT(Dart::vm_isolate()->heap()->UsedInWords(Heap::kNew) == 0); |
833 Dart::vm_isolate()->heap()->WriteProtect(true); | 849 Dart::vm_isolate()->heap()->WriteProtect(true); |
834 } | 850 } |
835 | 851 |
836 } // namespace dart | 852 } // namespace dart |
OLD | NEW |