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 #ifndef VM_SCAVENGER_H_ | 5 #ifndef VM_SCAVENGER_H_ |
6 #define VM_SCAVENGER_H_ | 6 #define VM_SCAVENGER_H_ |
7 | 7 |
8 #include "vm/globals.h" | 8 #include "vm/globals.h" |
9 #include "vm/object.h" | 9 #include "vm/object.h" |
10 #include "vm/utils.h" | 10 #include "vm/utils.h" |
11 #include "vm/virtual_memory.h" | 11 #include "vm/virtual_memory.h" |
12 | 12 |
13 namespace dart { | 13 namespace dart { |
14 | 14 |
15 // Forward declarations. | 15 // Forward declarations. |
16 class Heap; | 16 class Heap; |
| 17 class Isolate; |
17 | 18 |
18 class Scavenger { | 19 class Scavenger { |
19 public: | 20 public: |
20 Scavenger(Heap* heap, intptr_t max_capacity, uword object_alignment); | 21 Scavenger(Heap* heap, intptr_t max_capacity, uword object_alignment); |
21 ~Scavenger(); | 22 ~Scavenger(); |
22 | 23 |
23 // Check whether this Scavenger contains this address. | 24 // Check whether this Scavenger contains this address. |
24 // During scavenging both the to and from spaces contain "legal" objects. | 25 // During scavenging both the to and from spaces contain "legal" objects. |
25 // During a scavenge this function only returns true for addresses that will | 26 // During a scavenge this function only returns true for addresses that will |
26 // be part of the surviving objects. | 27 // be part of the surviving objects. |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 static intptr_t top_offset() { return OFFSET_OF(Scavenger, top_); } | 62 static intptr_t top_offset() { return OFFSET_OF(Scavenger, top_); } |
62 static intptr_t end_offset() { return OFFSET_OF(Scavenger, end_); } | 63 static intptr_t end_offset() { return OFFSET_OF(Scavenger, end_); } |
63 | 64 |
64 intptr_t in_use() const { return (top_ - FirstObjectStart()); } | 65 intptr_t in_use() const { return (top_ - FirstObjectStart()); } |
65 | 66 |
66 void VisitObjectPointers(ObjectPointerVisitor* visitor) const; | 67 void VisitObjectPointers(ObjectPointerVisitor* visitor) const; |
67 | 68 |
68 private: | 69 private: |
69 uword FirstObjectStart() const { return to_->start() | object_alignment_; } | 70 uword FirstObjectStart() const { return to_->start() | object_alignment_; } |
70 void Prologue(); | 71 void Prologue(); |
71 void IterateRoots(ObjectPointerVisitor* visitor); | 72 void IterateRoots(Isolate* isolate, ObjectPointerVisitor* visitor); |
72 void ProcessToSpace(ObjectPointerVisitor* visitor); | 73 void ProcessToSpace(ObjectPointerVisitor* visitor); |
73 void Epilogue(); | 74 void Epilogue(); |
74 | 75 |
75 VirtualMemory* space_; | 76 VirtualMemory* space_; |
76 MemoryRegion* to_; | 77 MemoryRegion* to_; |
77 MemoryRegion* from_; | 78 MemoryRegion* from_; |
78 | 79 |
79 Heap* heap_; | 80 Heap* heap_; |
80 | 81 |
81 // Current allocation top and end. These values are being accessed directly | 82 // Current allocation top and end. These values are being accessed directly |
(...skipping 10 matching lines...) Expand all Loading... |
92 bool scavenging_; | 93 bool scavenging_; |
93 | 94 |
94 friend class ScavengerVisitor; | 95 friend class ScavengerVisitor; |
95 | 96 |
96 DISALLOW_COPY_AND_ASSIGN(Scavenger); | 97 DISALLOW_COPY_AND_ASSIGN(Scavenger); |
97 }; | 98 }; |
98 | 99 |
99 } // namespace dart | 100 } // namespace dart |
100 | 101 |
101 #endif // VM_SCAVENGER_H_ | 102 #endif // VM_SCAVENGER_H_ |
OLD | NEW |