| 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/heap.h" | 5 #include "src/heap/heap.h" |
| 6 | 6 |
| 7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
| 8 #include "src/api.h" | 8 #include "src/api.h" |
| 9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
| 10 #include "src/base/once.h" | 10 #include "src/base/once.h" |
| (...skipping 1364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1375 } else { | 1375 } else { |
| 1376 v8::Isolate* isolate = reinterpret_cast<v8::Isolate*>(this->isolate()); | 1376 v8::Isolate* isolate = reinterpret_cast<v8::Isolate*>(this->isolate()); |
| 1377 gc_epilogue_callbacks_[i].callback(isolate, gc_type, gc_callback_flags); | 1377 gc_epilogue_callbacks_[i].callback(isolate, gc_type, gc_callback_flags); |
| 1378 } | 1378 } |
| 1379 } | 1379 } |
| 1380 } | 1380 } |
| 1381 } | 1381 } |
| 1382 | 1382 |
| 1383 | 1383 |
| 1384 void Heap::MarkCompact() { | 1384 void Heap::MarkCompact() { |
| 1385 PauseInlineAllocationObserversScope pause_observers(new_space()); |
| 1386 |
| 1385 gc_state_ = MARK_COMPACT; | 1387 gc_state_ = MARK_COMPACT; |
| 1386 LOG(isolate_, ResourceEvent("markcompact", "begin")); | 1388 LOG(isolate_, ResourceEvent("markcompact", "begin")); |
| 1387 | 1389 |
| 1388 uint64_t size_of_objects_before_gc = SizeOfObjects(); | 1390 uint64_t size_of_objects_before_gc = SizeOfObjects(); |
| 1389 | 1391 |
| 1390 mark_compact_collector()->Prepare(); | 1392 mark_compact_collector()->Prepare(); |
| 1391 | 1393 |
| 1392 ms_count_++; | 1394 ms_count_++; |
| 1393 | 1395 |
| 1394 MarkCompactPrologue(); | 1396 MarkCompactPrologue(); |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1579 void Heap::Scavenge() { | 1581 void Heap::Scavenge() { |
| 1580 GCTracer::Scope gc_scope(tracer(), GCTracer::Scope::SCAVENGER_SCAVENGE); | 1582 GCTracer::Scope gc_scope(tracer(), GCTracer::Scope::SCAVENGER_SCAVENGE); |
| 1581 RelocationLock relocation_lock(this); | 1583 RelocationLock relocation_lock(this); |
| 1582 // There are soft limits in the allocation code, designed to trigger a mark | 1584 // There are soft limits in the allocation code, designed to trigger a mark |
| 1583 // sweep collection by failing allocations. There is no sense in trying to | 1585 // sweep collection by failing allocations. There is no sense in trying to |
| 1584 // trigger one during scavenge: scavenges allocation should always succeed. | 1586 // trigger one during scavenge: scavenges allocation should always succeed. |
| 1585 AlwaysAllocateScope scope(isolate()); | 1587 AlwaysAllocateScope scope(isolate()); |
| 1586 | 1588 |
| 1587 // Bump-pointer allocations done during scavenge are not real allocations. | 1589 // Bump-pointer allocations done during scavenge are not real allocations. |
| 1588 // Pause the inline allocation steps. | 1590 // Pause the inline allocation steps. |
| 1589 new_space()->PauseInlineAllocationObservers(); | 1591 PauseInlineAllocationObserversScope pause_observers(new_space()); |
| 1590 | 1592 |
| 1591 #ifdef VERIFY_HEAP | 1593 #ifdef VERIFY_HEAP |
| 1592 if (FLAG_verify_heap) VerifyNonPointerSpacePointers(this); | 1594 if (FLAG_verify_heap) VerifyNonPointerSpacePointers(this); |
| 1593 #endif | 1595 #endif |
| 1594 | 1596 |
| 1595 gc_state_ = SCAVENGE; | 1597 gc_state_ = SCAVENGE; |
| 1596 | 1598 |
| 1597 // Implements Cheney's copying algorithm | 1599 // Implements Cheney's copying algorithm |
| 1598 LOG(isolate_, ResourceEvent("scavenge", "begin")); | 1600 LOG(isolate_, ResourceEvent("scavenge", "begin")); |
| 1599 | 1601 |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1710 incremental_marking()->UpdateMarkingDequeAfterScavenge(); | 1712 incremental_marking()->UpdateMarkingDequeAfterScavenge(); |
| 1711 | 1713 |
| 1712 ScavengeWeakObjectRetainer weak_object_retainer(this); | 1714 ScavengeWeakObjectRetainer weak_object_retainer(this); |
| 1713 ProcessYoungWeakReferences(&weak_object_retainer); | 1715 ProcessYoungWeakReferences(&weak_object_retainer); |
| 1714 | 1716 |
| 1715 DCHECK(new_space_front == new_space_.top()); | 1717 DCHECK(new_space_front == new_space_.top()); |
| 1716 | 1718 |
| 1717 // Set age mark. | 1719 // Set age mark. |
| 1718 new_space_.set_age_mark(new_space_.top()); | 1720 new_space_.set_age_mark(new_space_.top()); |
| 1719 | 1721 |
| 1720 new_space()->ResumeInlineAllocationObservers(); | |
| 1721 | |
| 1722 array_buffer_tracker()->FreeDead(true); | 1722 array_buffer_tracker()->FreeDead(true); |
| 1723 | 1723 |
| 1724 // Update how much has survived scavenge. | 1724 // Update how much has survived scavenge. |
| 1725 IncrementYoungSurvivorsCounter(static_cast<int>( | 1725 IncrementYoungSurvivorsCounter(static_cast<int>( |
| 1726 (PromotedSpaceSizeOfObjects() - survived_watermark) + new_space_.Size())); | 1726 (PromotedSpaceSizeOfObjects() - survived_watermark) + new_space_.Size())); |
| 1727 | 1727 |
| 1728 LOG(isolate_, ResourceEvent("scavenge", "end")); | 1728 LOG(isolate_, ResourceEvent("scavenge", "end")); |
| 1729 | 1729 |
| 1730 gc_state_ = NOT_IN_GC; | 1730 gc_state_ = NOT_IN_GC; |
| 1731 } | 1731 } |
| (...skipping 4438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6170 } | 6170 } |
| 6171 | 6171 |
| 6172 | 6172 |
| 6173 // static | 6173 // static |
| 6174 int Heap::GetStaticVisitorIdForMap(Map* map) { | 6174 int Heap::GetStaticVisitorIdForMap(Map* map) { |
| 6175 return StaticVisitorBase::GetVisitorId(map); | 6175 return StaticVisitorBase::GetVisitorId(map); |
| 6176 } | 6176 } |
| 6177 | 6177 |
| 6178 } // namespace internal | 6178 } // namespace internal |
| 6179 } // namespace v8 | 6179 } // namespace v8 |
| OLD | NEW |