Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 135 // | 135 // |
| 136 // Before: The heap has been prepared for garbage collection by | 136 // Before: The heap has been prepared for garbage collection by |
| 137 // MarkCompactCollector::Prepare() and is otherwise in its | 137 // MarkCompactCollector::Prepare() and is otherwise in its |
| 138 // normal state. | 138 // normal state. |
| 139 // | 139 // |
| 140 // After: Live objects are marked and non-live objects are unmarked. | 140 // After: Live objects are marked and non-live objects are unmarked. |
| 141 | 141 |
| 142 | 142 |
| 143 friend class RootMarkingVisitor; | 143 friend class RootMarkingVisitor; |
| 144 friend class MarkingVisitor; | 144 friend class MarkingVisitor; |
| 145 friend class UnmarkingVisitor; | |
| 146 | 145 |
| 147 // Marking operations for objects reachable from roots. | 146 // Marking operations for objects reachable from roots. |
| 148 static void MarkLiveObjects(); | 147 static void MarkLiveObjects(); |
| 149 | 148 |
| 150 static void MarkUnmarkedObject(HeapObject* obj); | 149 static void MarkUnmarkedObject(HeapObject* obj); |
| 151 | 150 |
| 152 static inline void MarkObject(HeapObject* obj) { | 151 static inline void MarkObject(HeapObject* obj) { |
| 153 if (!obj->IsMarked()) MarkUnmarkedObject(obj); | 152 if (!obj->IsMarked()) MarkUnmarkedObject(obj); |
| 154 } | 153 } |
| 155 | 154 |
| 156 static inline void SetMark(HeapObject* obj) { | 155 static inline void SetMark(HeapObject* obj) { |
| 157 tracer_->increment_marked_count(); | 156 tracer_->increment_marked_count(); |
| 158 #ifdef DEBUG | 157 #ifdef DEBUG |
| 159 UpdateLiveObjectCount(obj, 1); | 158 UpdateLiveObjectCount(obj); |
| 160 #endif | 159 #endif |
| 161 obj->SetMark(); | 160 obj->SetMark(); |
| 162 } | 161 } |
| 163 | 162 |
| 164 // Creates back pointers for all map transitions, stores them in | 163 // Creates back pointers for all map transitions, stores them in |
| 165 // the prototype field. The original prototype pointers are restored | 164 // the prototype field. The original prototype pointers are restored |
| 166 // in ClearNonLiveTransitions(). All JSObject maps | 165 // in ClearNonLiveTransitions(). All JSObject maps |
| 167 // connected by map transitions have the same prototype object, which | 166 // connected by map transitions have the same prototype object, which |
| 168 // is why we can use this field temporarily for back pointers. | 167 // is why we can use this field temporarily for back pointers. |
| 169 static void CreateBackPointers(); | 168 static void CreateBackPointers(); |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 196 // stack. This function empties the marking stack, but may leave | 195 // stack. This function empties the marking stack, but may leave |
| 197 // overflowed objects in the heap, in which case the marking stack's | 196 // overflowed objects in the heap, in which case the marking stack's |
| 198 // overflow flag will be set. | 197 // overflow flag will be set. |
| 199 static void EmptyMarkingStack(MarkingVisitor* visitor); | 198 static void EmptyMarkingStack(MarkingVisitor* visitor); |
| 200 | 199 |
| 201 // Refill the marking stack with overflowed objects from the heap. This | 200 // Refill the marking stack with overflowed objects from the heap. This |
| 202 // function either leaves the marking stack full or clears the overflow | 201 // function either leaves the marking stack full or clears the overflow |
| 203 // flag on the marking stack. | 202 // flag on the marking stack. |
| 204 static void RefillMarkingStack(); | 203 static void RefillMarkingStack(); |
| 205 | 204 |
| 206 // Callback function for telling whether the object *p must be marked. | 205 // Callback function for telling whether the object *p must be marked. |
|
Kasper Lund
2009/05/05 09:23:14
Update comment?
Kevin Millikin (Chromium)
2009/05/05 09:29:53
Thanks, done.
| |
| 207 static bool MustBeMarked(Object** p); | 206 static bool IsUnmarkedHeapObject(Object** p); |
| 208 | 207 |
| 209 #ifdef DEBUG | 208 #ifdef DEBUG |
| 210 // The scale argument is positive 1 if we are marking an object and | 209 static void UpdateLiveObjectCount(HeapObject* obj); |
| 211 // -1 if we are clearing the mark bit of an object that we didn't | |
| 212 // actually want marked. | |
| 213 static void UpdateLiveObjectCount(HeapObject* obj, int scale); | |
| 214 #endif | 210 #endif |
| 215 | 211 |
| 216 // We sweep the large object space in the same way whether we are | 212 // We sweep the large object space in the same way whether we are |
| 217 // compacting or not, because the large object space is never compacted. | 213 // compacting or not, because the large object space is never compacted. |
| 218 static void SweepLargeObjectSpace(); | 214 static void SweepLargeObjectSpace(); |
| 219 | 215 |
| 220 // Test whether a (possibly marked) object is a Map. | 216 // Test whether a (possibly marked) object is a Map. |
| 221 static inline bool SafeIsMap(HeapObject* object); | 217 static inline bool SafeIsMap(HeapObject* object); |
| 222 | 218 |
| 223 // Map transitions from a live map to a dead map must be killed. | 219 // Map transitions from a live map to a dead map must be killed. |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 406 | 402 |
| 407 friend class UnmarkObjectVisitor; | 403 friend class UnmarkObjectVisitor; |
| 408 static void UnmarkObject(HeapObject* obj); | 404 static void UnmarkObject(HeapObject* obj); |
| 409 #endif | 405 #endif |
| 410 }; | 406 }; |
| 411 | 407 |
| 412 | 408 |
| 413 } } // namespace v8::internal | 409 } } // namespace v8::internal |
| 414 | 410 |
| 415 #endif // V8_MARK_COMPACT_H_ | 411 #endif // V8_MARK_COMPACT_H_ |
| OLD | NEW |