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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 Finish(); | 89 Finish(); |
90 | 90 |
91 // Save the count of marked objects remaining after the collection and | 91 // Save the count of marked objects remaining after the collection and |
92 // null out the GC tracer. | 92 // null out the GC tracer. |
93 previous_marked_count_ = tracer_->marked_count(); | 93 previous_marked_count_ = tracer_->marked_count(); |
94 ASSERT(previous_marked_count_ == 0); | 94 ASSERT(previous_marked_count_ == 0); |
95 tracer_ = NULL; | 95 tracer_ = NULL; |
96 } | 96 } |
97 | 97 |
98 | 98 |
| 99 #ifdef DEBUG |
| 100 // Helper class for verifying the symbol table. |
| 101 class SymbolTableVerifier : public ObjectVisitor { |
| 102 public: |
| 103 SymbolTableVerifier() { } |
| 104 void VisitPointers(Object** start, Object** end) { |
| 105 // Visit all HeapObject pointers in [start, end). |
| 106 for (Object** p = start; p < end; p++) { |
| 107 if ((*p)->IsHeapObject()) { |
| 108 // Check that the symbol is actually a symbol. |
| 109 ASSERT((*p)->IsNull() || (*p)->IsUndefined() || (*p)->IsSymbol()); |
| 110 } |
| 111 } |
| 112 } |
| 113 }; |
| 114 #endif // DEBUG |
| 115 |
| 116 |
99 void MarkCompactCollector::Prepare(GCTracer* tracer) { | 117 void MarkCompactCollector::Prepare(GCTracer* tracer) { |
100 // Rather than passing the tracer around we stash it in a static member | 118 // Rather than passing the tracer around we stash it in a static member |
101 // variable. | 119 // variable. |
102 tracer_ = tracer; | 120 tracer_ = tracer; |
103 | 121 |
104 static const int kFragmentationLimit = 50; // Percent. | 122 static const int kFragmentationLimit = 50; // Percent. |
105 #ifdef DEBUG | 123 #ifdef DEBUG |
106 ASSERT(state_ == IDLE); | 124 ASSERT(state_ == IDLE); |
107 state_ = PREPARE_GC; | 125 state_ = PREPARE_GC; |
108 #endif | 126 #endif |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 Page::set_rset_state(Page::NOT_IN_USE); | 159 Page::set_rset_state(Page::NOT_IN_USE); |
142 } | 160 } |
143 #endif | 161 #endif |
144 | 162 |
145 PagedSpaces spaces; | 163 PagedSpaces spaces; |
146 while (PagedSpace* space = spaces.next()) { | 164 while (PagedSpace* space = spaces.next()) { |
147 space->PrepareForMarkCompact(compacting_collection_); | 165 space->PrepareForMarkCompact(compacting_collection_); |
148 } | 166 } |
149 | 167 |
150 #ifdef DEBUG | 168 #ifdef DEBUG |
| 169 SymbolTable* symbol_table = SymbolTable::cast(Heap::symbol_table()); |
| 170 SymbolTableVerifier v; |
| 171 symbol_table->IterateElements(&v); |
| 172 |
151 live_bytes_ = 0; | 173 live_bytes_ = 0; |
152 live_young_objects_ = 0; | 174 live_young_objects_ = 0; |
153 live_old_pointer_objects_ = 0; | 175 live_old_pointer_objects_ = 0; |
154 live_old_data_objects_ = 0; | 176 live_old_data_objects_ = 0; |
155 live_code_objects_ = 0; | 177 live_code_objects_ = 0; |
156 live_map_objects_ = 0; | 178 live_map_objects_ = 0; |
157 live_lo_objects_ = 0; | 179 live_lo_objects_ = 0; |
158 #endif | 180 #endif |
159 } | 181 } |
160 | 182 |
(...skipping 1597 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1758 | 1780 |
1759 void MarkCompactCollector::RebuildRSets() { | 1781 void MarkCompactCollector::RebuildRSets() { |
1760 #ifdef DEBUG | 1782 #ifdef DEBUG |
1761 ASSERT(state_ == RELOCATE_OBJECTS); | 1783 ASSERT(state_ == RELOCATE_OBJECTS); |
1762 state_ = REBUILD_RSETS; | 1784 state_ = REBUILD_RSETS; |
1763 #endif | 1785 #endif |
1764 Heap::RebuildRSets(); | 1786 Heap::RebuildRSets(); |
1765 } | 1787 } |
1766 | 1788 |
1767 } } // namespace v8::internal | 1789 } } // namespace v8::internal |
OLD | NEW |