| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/heap/mark-compact.h" | 5 #include "src/heap/mark-compact.h" |
| 6 | 6 |
| 7 #include "src/base/atomicops.h" | 7 #include "src/base/atomicops.h" |
| 8 #include "src/base/bits.h" | 8 #include "src/base/bits.h" |
| 9 #include "src/base/sys-info.h" | 9 #include "src/base/sys-info.h" |
| 10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
| (...skipping 2180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2191 void MarkCompactCollector::ClearNonLiveReferences() { | 2191 void MarkCompactCollector::ClearNonLiveReferences() { |
| 2192 GCTracer::Scope gc_scope(heap()->tracer(), | 2192 GCTracer::Scope gc_scope(heap()->tracer(), |
| 2193 GCTracer::Scope::MC_NONLIVEREFERENCES); | 2193 GCTracer::Scope::MC_NONLIVEREFERENCES); |
| 2194 // Iterate over the map space, setting map transitions that go from | 2194 // Iterate over the map space, setting map transitions that go from |
| 2195 // a marked map to an unmarked map to null transitions. This action | 2195 // a marked map to an unmarked map to null transitions. This action |
| 2196 // is carried out only on maps of JSObjects and related subtypes. | 2196 // is carried out only on maps of JSObjects and related subtypes. |
| 2197 HeapObjectIterator map_iterator(heap()->map_space()); | 2197 HeapObjectIterator map_iterator(heap()->map_space()); |
| 2198 for (HeapObject* obj = map_iterator.Next(); obj != NULL; | 2198 for (HeapObject* obj = map_iterator.Next(); obj != NULL; |
| 2199 obj = map_iterator.Next()) { | 2199 obj = map_iterator.Next()) { |
| 2200 Map* map = Map::cast(obj); | 2200 Map* map = Map::cast(obj); |
| 2201 | |
| 2202 if (!map->CanTransition()) continue; | 2201 if (!map->CanTransition()) continue; |
| 2203 | |
| 2204 MarkBit map_mark = Marking::MarkBitFrom(map); | 2202 MarkBit map_mark = Marking::MarkBitFrom(map); |
| 2205 ClearNonLivePrototypeTransitions(map); | 2203 bool alive = Marking::IsBlackOrGrey(map_mark); |
| 2206 ClearNonLiveMapTransitions(map, map_mark); | 2204 if (alive) { |
| 2207 | 2205 ClearNonLivePrototypeTransitions(map); |
| 2208 if (Marking::IsWhite(map_mark)) { | 2206 } else { |
| 2207 ClearNonLiveMapTransitions(map); |
| 2209 have_code_to_deoptimize_ |= | 2208 have_code_to_deoptimize_ |= |
| 2210 map->dependent_code()->MarkCodeForDeoptimization( | 2209 map->dependent_code()->MarkCodeForDeoptimization( |
| 2211 isolate(), DependentCode::kWeakCodeGroup); | 2210 isolate(), DependentCode::kWeakCodeGroup); |
| 2212 map->set_dependent_code(DependentCode::cast(heap()->empty_fixed_array())); | 2211 map->set_dependent_code(DependentCode::cast(heap()->empty_fixed_array())); |
| 2213 } | 2212 } |
| 2214 } | 2213 } |
| 2215 | 2214 |
| 2216 WeakHashTable* table = heap_->weak_object_to_code_table(); | 2215 WeakHashTable* table = heap_->weak_object_to_code_table(); |
| 2217 uint32_t capacity = table->Capacity(); | 2216 uint32_t capacity = table->Capacity(); |
| 2218 for (uint32_t i = 0; i < capacity; i++) { | 2217 for (uint32_t i = 0; i < capacity; i++) { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2260 new_number_of_transitions); | 2259 new_number_of_transitions); |
| 2261 } | 2260 } |
| 2262 | 2261 |
| 2263 // Fill slots that became free with undefined value. | 2262 // Fill slots that became free with undefined value. |
| 2264 for (int i = new_number_of_transitions; i < number_of_transitions; i++) { | 2263 for (int i = new_number_of_transitions; i < number_of_transitions; i++) { |
| 2265 prototype_transitions->set_undefined(header + i); | 2264 prototype_transitions->set_undefined(header + i); |
| 2266 } | 2265 } |
| 2267 } | 2266 } |
| 2268 | 2267 |
| 2269 | 2268 |
| 2270 void MarkCompactCollector::ClearNonLiveMapTransitions(Map* map, | 2269 void MarkCompactCollector::ClearNonLiveMapTransitions(Map* map) { |
| 2271 MarkBit map_mark) { | |
| 2272 Object* potential_parent = map->GetBackPointer(); | 2270 Object* potential_parent = map->GetBackPointer(); |
| 2273 if (!potential_parent->IsMap()) return; | 2271 if (!potential_parent->IsMap()) return; |
| 2274 Map* parent = Map::cast(potential_parent); | 2272 Map* parent = Map::cast(potential_parent); |
| 2275 | 2273 |
| 2276 // Follow back pointer, check whether we are dealing with a map transition | 2274 // Follow back pointer, check whether we are dealing with a map transition |
| 2277 // from a live map to a dead path and in case clear transitions of parent. | 2275 // from a live map to a dead path and in case clear transitions of parent. |
| 2278 bool current_is_alive = Marking::IsBlackOrGrey(map_mark); | 2276 DCHECK(!Marking::IsBlackOrGrey(Marking::MarkBitFrom(map))); |
| 2279 bool parent_is_alive = Marking::IsBlackOrGrey(Marking::MarkBitFrom(parent)); | 2277 bool parent_is_alive = Marking::IsBlackOrGrey(Marking::MarkBitFrom(parent)); |
| 2280 if (!current_is_alive && parent_is_alive) { | 2278 if (parent_is_alive) { |
| 2281 ClearMapTransitions(parent, map); | 2279 ClearMapTransitions(parent, map); |
| 2282 } | 2280 } |
| 2283 } | 2281 } |
| 2284 | 2282 |
| 2285 | 2283 |
| 2286 // Clear a possible back pointer in case the transition leads to a dead map. | 2284 // Clear a possible back pointer in case the transition leads to a dead map. |
| 2287 // Return true in case a back pointer has been cleared and false otherwise. | 2285 // Return true in case a back pointer has been cleared and false otherwise. |
| 2288 bool MarkCompactCollector::ClearMapBackPointer(Map* target) { | 2286 bool MarkCompactCollector::ClearMapBackPointer(Map* target) { |
| 2289 if (Marking::IsBlackOrGrey(Marking::MarkBitFrom(target))) return false; | 2287 if (Marking::IsBlackOrGrey(Marking::MarkBitFrom(target))) return false; |
| 2290 target->SetBackPointer(heap_->undefined_value(), SKIP_WRITE_BARRIER); | 2288 target->SetBackPointer(heap_->undefined_value(), SKIP_WRITE_BARRIER); |
| (...skipping 2284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4575 MarkBit mark_bit = Marking::MarkBitFrom(host); | 4573 MarkBit mark_bit = Marking::MarkBitFrom(host); |
| 4576 if (Marking::IsBlack(mark_bit)) { | 4574 if (Marking::IsBlack(mark_bit)) { |
| 4577 RelocInfo rinfo(pc, RelocInfo::CODE_TARGET, 0, host); | 4575 RelocInfo rinfo(pc, RelocInfo::CODE_TARGET, 0, host); |
| 4578 RecordRelocSlot(&rinfo, target); | 4576 RecordRelocSlot(&rinfo, target); |
| 4579 } | 4577 } |
| 4580 } | 4578 } |
| 4581 } | 4579 } |
| 4582 | 4580 |
| 4583 } // namespace internal | 4581 } // namespace internal |
| 4584 } // namespace v8 | 4582 } // namespace v8 |
| OLD | NEW |