| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 object = HeapObject::FromAddress(current); | 102 object = HeapObject::FromAddress(current); |
| 103 if (MarkCompactCollector::IsMarked(object)) { | 103 if (MarkCompactCollector::IsMarked(object)) { |
| 104 ASSERT(current >= next_object_must_be_here_or_later); | 104 ASSERT(current >= next_object_must_be_here_or_later); |
| 105 object->Iterate(&visitor); | 105 object->Iterate(&visitor); |
| 106 next_object_must_be_here_or_later = current + object->Size(); | 106 next_object_must_be_here_or_later = current + object->Size(); |
| 107 } | 107 } |
| 108 } | 108 } |
| 109 } | 109 } |
| 110 | 110 |
| 111 | 111 |
| 112 static void VerifyMarking(Page* p) { | |
| 113 VerifyMarking(p->ObjectAreaStart(), p->ObjectAreaEnd()); | |
| 114 } | |
| 115 | |
| 116 | |
| 117 static void VerifyMarking(NewSpace* space) { | 112 static void VerifyMarking(NewSpace* space) { |
| 118 Address end = space->top(); | 113 Address end = space->top(); |
| 119 NewSpacePageIterator it(space->bottom(), end); | 114 NewSpacePageIterator it(space->bottom(), end); |
| 120 // The bottom position is at the start of its page. Allows us to use | 115 // The bottom position is at the start of its page. Allows us to use |
| 121 // page->body() as start of range on all pages. | 116 // page->body() as start of range on all pages. |
| 122 ASSERT_EQ(space->bottom(), | 117 ASSERT_EQ(space->bottom(), |
| 123 NewSpacePage::FromAddress(space->bottom())->body()); | 118 NewSpacePage::FromAddress(space->bottom())->body()); |
| 124 while (it.has_next()) { | 119 while (it.has_next()) { |
| 125 NewSpacePage* page = it.next(); | 120 NewSpacePage* page = it.next(); |
| 126 Address limit = it.has_next() ? page->body_limit() : end; | 121 Address limit = it.has_next() ? page->body_limit() : end; |
| 127 ASSERT(limit == end || !page->Contains(end)); | 122 ASSERT(limit == end || !page->Contains(end)); |
| 128 VerifyMarking(page->body(), limit); | 123 VerifyMarking(page->body(), limit); |
| 129 } | 124 } |
| 130 } | 125 } |
| 131 | 126 |
| 132 | 127 |
| 133 static void VerifyMarking(PagedSpace* space) { | 128 static void VerifyMarking(PagedSpace* space) { |
| 134 PageIterator it(space); | 129 PageIterator it(space); |
| 135 | 130 |
| 136 while (it.has_next()) { | 131 while (it.has_next()) { |
| 137 VerifyMarking(it.next()); | 132 Page* p = it.next(); |
| 133 VerifyMarking(p->ObjectAreaStart(), p->ObjectAreaEnd()); |
| 138 } | 134 } |
| 139 } | 135 } |
| 140 | 136 |
| 141 | 137 |
| 142 static void VerifyMarking(Heap* heap) { | 138 static void VerifyMarking(Heap* heap) { |
| 143 VerifyMarking(heap->old_pointer_space()); | 139 VerifyMarking(heap->old_pointer_space()); |
| 144 VerifyMarking(heap->old_data_space()); | 140 VerifyMarking(heap->old_data_space()); |
| 145 VerifyMarking(heap->code_space()); | 141 VerifyMarking(heap->code_space()); |
| 146 VerifyMarking(heap->cell_space()); | 142 VerifyMarking(heap->cell_space()); |
| 147 VerifyMarking(heap->map_space()); | 143 VerifyMarking(heap->map_space()); |
| 148 VerifyMarking(heap->new_space()); | 144 VerifyMarking(heap->new_space()); |
| 149 | 145 |
| 150 VerifyMarkingVisitor visitor; | 146 VerifyMarkingVisitor visitor; |
| 151 heap->IterateStrongRoots(&visitor, VISIT_ONLY_STRONG); | 147 heap->IterateStrongRoots(&visitor, VISIT_ONLY_STRONG); |
| 152 } | 148 } |
| 153 | 149 |
| 154 | 150 |
| 155 class VerifyEvacuationVisitor: public ObjectVisitor { | 151 class VerifyEvacuationVisitor: public ObjectVisitor { |
| 156 public: | 152 public: |
| 157 void VisitPointers(Object** start, Object** end) { | 153 void VisitPointers(Object** start, Object** end) { |
| 158 for (Object** current = start; current < end; current++) { | 154 for (Object** current = start; current < end; current++) { |
| 159 if ((*current)->IsHeapObject()) { | 155 if ((*current)->IsHeapObject()) { |
| 160 HeapObject* object = HeapObject::cast(*current); | 156 HeapObject* object = HeapObject::cast(*current); |
| 161 if (MarkCompactCollector::IsOnEvacuationCandidate(object)) { | 157 CHECK(!MarkCompactCollector::IsOnEvacuationCandidate(object)); |
| 162 CHECK(false); | |
| 163 } | |
| 164 } | 158 } |
| 165 } | 159 } |
| 166 } | 160 } |
| 167 | |
| 168 HeapObject* source_; | |
| 169 }; | 161 }; |
| 170 | 162 |
| 171 | 163 |
| 172 static void VerifyEvacuation(Address bottom, Address top) { | 164 static void VerifyEvacuation(Address bottom, Address top) { |
| 173 VerifyEvacuationVisitor visitor; | 165 VerifyEvacuationVisitor visitor; |
| 174 HeapObject* object; | 166 HeapObject* object; |
| 175 Address next_object_must_be_here_or_later = bottom; | 167 Address next_object_must_be_here_or_later = bottom; |
| 176 | 168 |
| 177 for (Address current = bottom; | 169 for (Address current = bottom; |
| 178 current < top; | 170 current < top; |
| 179 current += kPointerSize) { | 171 current += kPointerSize) { |
| 180 object = HeapObject::FromAddress(current); | 172 object = HeapObject::FromAddress(current); |
| 181 if (MarkCompactCollector::IsMarked(object)) { | 173 if (MarkCompactCollector::IsMarked(object)) { |
| 182 ASSERT(current >= next_object_must_be_here_or_later); | 174 ASSERT(current >= next_object_must_be_here_or_later); |
| 183 visitor.source_ = object; | |
| 184 object->Iterate(&visitor); | 175 object->Iterate(&visitor); |
| 185 next_object_must_be_here_or_later = current + object->Size(); | 176 next_object_must_be_here_or_later = current + object->Size(); |
| 186 } | 177 } |
| 187 } | 178 } |
| 188 } | 179 } |
| 189 | 180 |
| 190 | 181 |
| 191 static void VerifyEvacuation(Page* p) { | |
| 192 if (p->IsEvacuationCandidate()) return; | |
| 193 | |
| 194 VerifyEvacuation(p->ObjectAreaStart(), p->ObjectAreaEnd()); | |
| 195 } | |
| 196 | |
| 197 | |
| 198 static void VerifyEvacuation(NewSpace* space) { | 182 static void VerifyEvacuation(NewSpace* space) { |
| 199 // TODO(gc) Verify evacution for new space. | 183 NewSpacePageIterator it(space->bottom(), space->top()); |
| 184 VerifyEvacuationVisitor visitor; |
| 185 |
| 186 while (it.has_next()) { |
| 187 NewSpacePage* page = it.next(); |
| 188 Address current = page->body(); |
| 189 Address limit = it.has_next() ? page->body_limit() : space->top(); |
| 190 ASSERT(limit == space->top() || !page->Contains(space->top())); |
| 191 while (current < limit) { |
| 192 HeapObject* object = HeapObject::FromAddress(current); |
| 193 object->Iterate(&visitor); |
| 194 current += object->Size(); |
| 195 } |
| 196 } |
| 200 } | 197 } |
| 201 | 198 |
| 202 | 199 |
| 203 static void VerifyEvacuation(PagedSpace* space) { | 200 static void VerifyEvacuation(PagedSpace* space) { |
| 204 PageIterator it(space); | 201 PageIterator it(space); |
| 205 | 202 |
| 206 while (it.has_next()) { | 203 while (it.has_next()) { |
| 207 VerifyEvacuation(it.next()); | 204 Page* p = it.next(); |
| 205 if (p->IsEvacuationCandidate()) continue; |
| 206 VerifyEvacuation(p->ObjectAreaStart(), p->ObjectAreaEnd()); |
| 208 } | 207 } |
| 209 } | 208 } |
| 210 | 209 |
| 211 | 210 |
| 212 static void VerifyEvacuation(Heap* heap) { | 211 static void VerifyEvacuation(Heap* heap) { |
| 213 VerifyEvacuation(heap->old_pointer_space()); | 212 VerifyEvacuation(heap->old_pointer_space()); |
| 214 VerifyEvacuation(heap->old_data_space()); | 213 VerifyEvacuation(heap->old_data_space()); |
| 215 VerifyEvacuation(heap->code_space()); | 214 VerifyEvacuation(heap->code_space()); |
| 216 VerifyEvacuation(heap->cell_space()); | 215 VerifyEvacuation(heap->cell_space()); |
| 217 VerifyEvacuation(heap->map_space()); | 216 VerifyEvacuation(heap->map_space()); |
| (...skipping 3378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3596 while (buffer != NULL) { | 3595 while (buffer != NULL) { |
| 3597 SlotsBuffer* next_buffer = buffer->next(); | 3596 SlotsBuffer* next_buffer = buffer->next(); |
| 3598 DeallocateBuffer(buffer); | 3597 DeallocateBuffer(buffer); |
| 3599 buffer = next_buffer; | 3598 buffer = next_buffer; |
| 3600 } | 3599 } |
| 3601 *buffer_address = NULL; | 3600 *buffer_address = NULL; |
| 3602 } | 3601 } |
| 3603 | 3602 |
| 3604 | 3603 |
| 3605 } } // namespace v8::internal | 3604 } } // namespace v8::internal |
| OLD | NEW |