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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 // next live object in the same page. For spaces using a different | 68 // next live object in the same page. For spaces using a different |
69 // encoding (ie, contiguous spaces), the offset parameter is ignored. | 69 // encoding (ie, contiguous spaces), the offset parameter is ignored. |
70 typedef void (*EncodingFunction)(HeapObject* old_object, | 70 typedef void (*EncodingFunction)(HeapObject* old_object, |
71 int object_size, | 71 int object_size, |
72 Object* new_object, | 72 Object* new_object, |
73 int* offset); | 73 int* offset); |
74 | 74 |
75 // Type of functions to process non-live objects. | 75 // Type of functions to process non-live objects. |
76 typedef void (*ProcessNonLiveFunction)(HeapObject* object); | 76 typedef void (*ProcessNonLiveFunction)(HeapObject* object); |
77 | 77 |
| 78 // Set the global force_compaction flag, it must be called before Prepare |
| 79 // to take effect. |
| 80 static void SetForceCompaction(bool value) { |
| 81 force_compaction_ = value; |
| 82 } |
| 83 |
78 // Prepares for GC by resetting relocation info in old and map spaces and | 84 // Prepares for GC by resetting relocation info in old and map spaces and |
79 // choosing spaces to compact. | 85 // choosing spaces to compact. |
80 static void Prepare(GCTracer* tracer); | 86 static void Prepare(GCTracer* tracer); |
81 | 87 |
82 // Performs a global garbage collection. | 88 // Performs a global garbage collection. |
83 static void CollectGarbage(); | 89 static void CollectGarbage(); |
84 | 90 |
85 // True if the last full GC performed heap compaction. | 91 // True if the last full GC performed heap compaction. |
86 static bool HasCompacted() { return compacting_collection_; } | 92 static bool HasCompacted() { return compacting_collection_; } |
87 | 93 |
(...skipping 22 matching lines...) Expand all Loading... |
110 SWEEP_SPACES, | 116 SWEEP_SPACES, |
111 ENCODE_FORWARDING_ADDRESSES, | 117 ENCODE_FORWARDING_ADDRESSES, |
112 UPDATE_POINTERS, | 118 UPDATE_POINTERS, |
113 RELOCATE_OBJECTS, | 119 RELOCATE_OBJECTS, |
114 REBUILD_RSETS | 120 REBUILD_RSETS |
115 }; | 121 }; |
116 | 122 |
117 // The current stage of the collector. | 123 // The current stage of the collector. |
118 static CollectorState state_; | 124 static CollectorState state_; |
119 #endif | 125 #endif |
| 126 |
| 127 // Global flag that forces a compaction. |
| 128 static bool force_compaction_; |
| 129 |
120 // Global flag indicating whether spaces were compacted on the last GC. | 130 // Global flag indicating whether spaces were compacted on the last GC. |
121 static bool compacting_collection_; | 131 static bool compacting_collection_; |
122 | 132 |
123 // The number of objects left marked at the end of the last completed full | 133 // The number of objects left marked at the end of the last completed full |
124 // GC (expected to be zero). | 134 // GC (expected to be zero). |
125 static int previous_marked_count_; | 135 static int previous_marked_count_; |
126 | 136 |
127 // A pointer to the current stack-allocated GC tracer object during a full | 137 // A pointer to the current stack-allocated GC tracer object during a full |
128 // collection (NULL before and after). | 138 // collection (NULL before and after). |
129 static GCTracer* tracer_; | 139 static GCTracer* tracer_; |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
412 | 422 |
413 friend class UnmarkObjectVisitor; | 423 friend class UnmarkObjectVisitor; |
414 static void UnmarkObject(HeapObject* obj); | 424 static void UnmarkObject(HeapObject* obj); |
415 #endif | 425 #endif |
416 }; | 426 }; |
417 | 427 |
418 | 428 |
419 } } // namespace v8::internal | 429 } } // namespace v8::internal |
420 | 430 |
421 #endif // V8_MARK_COMPACT_H_ | 431 #endif // V8_MARK_COMPACT_H_ |
OLD | NEW |