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 1399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1410 | 1410 |
1411 typedef StringTableCleaner<false> InternalizedStringTableCleaner; | 1411 typedef StringTableCleaner<false> InternalizedStringTableCleaner; |
1412 typedef StringTableCleaner<true> ExternalStringTableCleaner; | 1412 typedef StringTableCleaner<true> ExternalStringTableCleaner; |
1413 | 1413 |
1414 | 1414 |
1415 // Implementation of WeakObjectRetainer for mark compact GCs. All marked objects | 1415 // Implementation of WeakObjectRetainer for mark compact GCs. All marked objects |
1416 // are retained. | 1416 // are retained. |
1417 class MarkCompactWeakObjectRetainer : public WeakObjectRetainer { | 1417 class MarkCompactWeakObjectRetainer : public WeakObjectRetainer { |
1418 public: | 1418 public: |
1419 virtual Object* RetainAs(Object* object) { | 1419 virtual Object* RetainAs(Object* object) { |
1420 if (Marking::IsBlackOrGrey( | 1420 MarkBit mark_bit = Marking::MarkBitFrom(HeapObject::cast(object)); |
1421 Marking::MarkBitFrom(HeapObject::cast(object)))) { | 1421 DCHECK(!Marking::IsGrey(mark_bit)); |
| 1422 if (Marking::IsBlack(mark_bit)) { |
1422 return object; | 1423 return object; |
1423 } else if (object->IsAllocationSite() && | 1424 } else if (object->IsAllocationSite() && |
1424 !(AllocationSite::cast(object)->IsZombie())) { | 1425 !(AllocationSite::cast(object)->IsZombie())) { |
1425 // "dead" AllocationSites need to live long enough for a traversal of new | 1426 // "dead" AllocationSites need to live long enough for a traversal of new |
1426 // space. These sites get a one-time reprieve. | 1427 // space. These sites get a one-time reprieve. |
1427 AllocationSite* site = AllocationSite::cast(object); | 1428 AllocationSite* site = AllocationSite::cast(object); |
1428 site->MarkZombie(); | 1429 site->MarkZombie(); |
1429 site->GetHeap()->mark_compact_collector()->MarkAllocationSite(site); | 1430 site->GetHeap()->mark_compact_collector()->MarkAllocationSite(site); |
1430 return object; | 1431 return object; |
1431 } else { | 1432 } else { |
(...skipping 888 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2320 } | 2321 } |
2321 | 2322 |
2322 | 2323 |
2323 void MarkCompactCollector::ClearNonLiveMapTransitions(Map* map) { | 2324 void MarkCompactCollector::ClearNonLiveMapTransitions(Map* map) { |
2324 Object* potential_parent = map->GetBackPointer(); | 2325 Object* potential_parent = map->GetBackPointer(); |
2325 if (!potential_parent->IsMap()) return; | 2326 if (!potential_parent->IsMap()) return; |
2326 Map* parent = Map::cast(potential_parent); | 2327 Map* parent = Map::cast(potential_parent); |
2327 | 2328 |
2328 // Follow back pointer, check whether we are dealing with a map transition | 2329 // Follow back pointer, check whether we are dealing with a map transition |
2329 // from a live map to a dead path and in case clear transitions of parent. | 2330 // from a live map to a dead path and in case clear transitions of parent. |
2330 DCHECK(!Marking::IsBlackOrGrey(Marking::MarkBitFrom(map))); | 2331 DCHECK(!Marking::IsGrey(Marking::MarkBitFrom(map))); |
2331 bool parent_is_alive = Marking::IsBlackOrGrey(Marking::MarkBitFrom(parent)); | 2332 bool parent_is_alive = Marking::IsBlack(Marking::MarkBitFrom(parent)); |
2332 if (parent_is_alive) { | 2333 if (parent_is_alive) { |
2333 ClearMapTransitions(parent, map); | 2334 ClearMapTransitions(parent, map); |
2334 } | 2335 } |
2335 } | 2336 } |
2336 | 2337 |
2337 | 2338 |
2338 // Clear a possible back pointer in case the transition leads to a dead map. | 2339 // Clear a possible back pointer in case the transition leads to a dead map. |
2339 // Return true in case a back pointer has been cleared and false otherwise. | 2340 // Return true in case a back pointer has been cleared and false otherwise. |
2340 bool MarkCompactCollector::ClearMapBackPointer(Map* target) { | 2341 bool MarkCompactCollector::ClearMapBackPointer(Map* target) { |
2341 if (Marking::IsBlackOrGrey(Marking::MarkBitFrom(target))) return false; | 2342 DCHECK(!Marking::IsGrey(Marking::MarkBitFrom(target))); |
| 2343 if (Marking::IsBlack(Marking::MarkBitFrom(target))) return false; |
2342 target->SetBackPointer(heap_->undefined_value(), SKIP_WRITE_BARRIER); | 2344 target->SetBackPointer(heap_->undefined_value(), SKIP_WRITE_BARRIER); |
2343 return true; | 2345 return true; |
2344 } | 2346 } |
2345 | 2347 |
2346 | 2348 |
2347 void MarkCompactCollector::ClearMapTransitions(Map* map, Map* dead_transition) { | 2349 void MarkCompactCollector::ClearMapTransitions(Map* map, Map* dead_transition) { |
2348 Object* transitions = map->raw_transitions(); | 2350 Object* transitions = map->raw_transitions(); |
2349 int num_transitions = TransitionArray::NumberOfTransitions(transitions); | 2351 int num_transitions = TransitionArray::NumberOfTransitions(transitions); |
2350 | 2352 |
2351 int number_of_own_descriptors = map->NumberOfOwnDescriptors(); | 2353 int number_of_own_descriptors = map->NumberOfOwnDescriptors(); |
(...skipping 1770 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4122 MarkBit mark_bit = Marking::MarkBitFrom(host); | 4124 MarkBit mark_bit = Marking::MarkBitFrom(host); |
4123 if (Marking::IsBlack(mark_bit)) { | 4125 if (Marking::IsBlack(mark_bit)) { |
4124 RelocInfo rinfo(pc, RelocInfo::CODE_TARGET, 0, host); | 4126 RelocInfo rinfo(pc, RelocInfo::CODE_TARGET, 0, host); |
4125 RecordRelocSlot(&rinfo, target); | 4127 RecordRelocSlot(&rinfo, target); |
4126 } | 4128 } |
4127 } | 4129 } |
4128 } | 4130 } |
4129 | 4131 |
4130 } // namespace internal | 4132 } // namespace internal |
4131 } // namespace v8 | 4133 } // namespace v8 |
OLD | NEW |