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 #ifndef V8_HEAP_HEAP_H_ | 5 #ifndef V8_HEAP_HEAP_H_ |
6 #define V8_HEAP_HEAP_H_ | 6 #define V8_HEAP_HEAP_H_ |
7 | 7 |
8 #include <cmath> | 8 #include <cmath> |
9 #include <map> | 9 #include <map> |
10 | 10 |
(...skipping 690 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
701 static inline void CopyBlock(Address dst, Address src, int byte_size); | 701 static inline void CopyBlock(Address dst, Address src, int byte_size); |
702 | 702 |
703 // Determines a static visitor id based on the given {map} that can then be | 703 // Determines a static visitor id based on the given {map} that can then be |
704 // stored on the map to facilitate fast dispatch for {StaticVisitorBase}. | 704 // stored on the map to facilitate fast dispatch for {StaticVisitorBase}. |
705 static int GetStaticVisitorIdForMap(Map* map); | 705 static int GetStaticVisitorIdForMap(Map* map); |
706 | 706 |
707 // Notifies the heap that is ok to start marking or other activities that | 707 // Notifies the heap that is ok to start marking or other activities that |
708 // should not happen during deserialization. | 708 // should not happen during deserialization. |
709 void NotifyDeserializationComplete(); | 709 void NotifyDeserializationComplete(); |
710 | 710 |
711 intptr_t old_generation_allocation_limit() const { | |
712 return old_generation_allocation_limit_; | |
713 } | |
714 | |
715 bool always_allocate() { return always_allocate_scope_count_.Value() != 0; } | |
716 | |
717 inline Address* NewSpaceAllocationTopAddress(); | 711 inline Address* NewSpaceAllocationTopAddress(); |
718 inline Address* NewSpaceAllocationLimitAddress(); | 712 inline Address* NewSpaceAllocationLimitAddress(); |
719 inline Address* OldSpaceAllocationTopAddress(); | 713 inline Address* OldSpaceAllocationTopAddress(); |
720 inline Address* OldSpaceAllocationLimitAddress(); | 714 inline Address* OldSpaceAllocationLimitAddress(); |
721 | 715 |
722 bool CanExpandOldGeneration(int size) { | |
723 if (force_oom_) return false; | |
724 return (OldGenerationCapacity() + size) < MaxOldGenerationSize(); | |
725 } | |
726 | |
727 // Clear the Instanceof cache (used when a prototype changes). | 716 // Clear the Instanceof cache (used when a prototype changes). |
728 inline void ClearInstanceofCache(); | 717 inline void ClearInstanceofCache(); |
729 | 718 |
730 // FreeSpace objects have a null map after deserialization. Update the map. | 719 // FreeSpace objects have a null map after deserialization. Update the map. |
731 void RepairFreeListsAfterDeserialization(); | 720 void RepairFreeListsAfterDeserialization(); |
732 | 721 |
733 // Move len elements within a given array from src_index index to dst_index | 722 // Move len elements within a given array from src_index index to dst_index |
734 // index. | 723 // index. |
735 void MoveElements(FixedArray* array, int dst_index, int src_index, int len); | 724 void MoveElements(FixedArray* array, int dst_index, int src_index, int len); |
736 | 725 |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
839 bool is_isolate_locked); | 828 bool is_isolate_locked); |
840 void CheckMemoryPressure(); | 829 void CheckMemoryPressure(); |
841 | 830 |
842 double MonotonicallyIncreasingTimeInMs(); | 831 double MonotonicallyIncreasingTimeInMs(); |
843 | 832 |
844 void RecordStats(HeapStats* stats, bool take_snapshot = false); | 833 void RecordStats(HeapStats* stats, bool take_snapshot = false); |
845 | 834 |
846 // Check new space expansion criteria and expand semispaces if it was hit. | 835 // Check new space expansion criteria and expand semispaces if it was hit. |
847 void CheckNewSpaceExpansionCriteria(); | 836 void CheckNewSpaceExpansionCriteria(); |
848 | 837 |
849 inline bool HeapIsFullEnoughToStartIncrementalMarking(intptr_t limit); | |
850 | |
851 void VisitExternalResources(v8::ExternalResourceVisitor* visitor); | 838 void VisitExternalResources(v8::ExternalResourceVisitor* visitor); |
852 | 839 |
853 // An object should be promoted if the object has survived a | 840 // An object should be promoted if the object has survived a |
854 // scavenge operation. | 841 // scavenge operation. |
855 template <PromotionMode promotion_mode> | 842 template <PromotionMode promotion_mode> |
856 inline bool ShouldBePromoted(Address old_address, int object_size); | 843 inline bool ShouldBePromoted(Address old_address, int object_size); |
857 | 844 |
858 inline PromotionMode CurrentPromotionMode(); | 845 inline PromotionMode CurrentPromotionMode(); |
859 | 846 |
860 void ClearNormalizedMapCaches(); | 847 void ClearNormalizedMapCaches(); |
861 | 848 |
862 void IncrementDeferredCount(v8::Isolate::UseCounterFeature feature); | 849 void IncrementDeferredCount(v8::Isolate::UseCounterFeature feature); |
863 | 850 |
864 inline bool OldGenerationAllocationLimitReached(); | |
865 | |
866 // Completely clear the Instanceof cache (to stop it keeping objects alive | 851 // Completely clear the Instanceof cache (to stop it keeping objects alive |
867 // around a GC). | 852 // around a GC). |
868 inline void CompletelyClearInstanceofCache(); | 853 inline void CompletelyClearInstanceofCache(); |
869 | 854 |
870 inline uint32_t HashSeed(); | 855 inline uint32_t HashSeed(); |
871 | 856 |
872 inline int NextScriptId(); | 857 inline int NextScriptId(); |
873 | 858 |
874 inline void SetArgumentsAdaptorDeoptPCOffset(int pc_offset); | 859 inline void SetArgumentsAdaptorDeoptPCOffset(int pc_offset); |
875 inline void SetConstructStubDeoptPCOffset(int pc_offset); | 860 inline void SetConstructStubDeoptPCOffset(int pc_offset); |
(...skipping 947 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1823 // given old generation size. | 1808 // given old generation size. |
1824 intptr_t CalculateOldGenerationAllocationLimit(double factor, | 1809 intptr_t CalculateOldGenerationAllocationLimit(double factor, |
1825 intptr_t old_gen_size); | 1810 intptr_t old_gen_size); |
1826 | 1811 |
1827 // Sets the allocation limit to trigger the next full garbage collection. | 1812 // Sets the allocation limit to trigger the next full garbage collection. |
1828 void SetOldGenerationAllocationLimit(intptr_t old_gen_size, double gc_speed, | 1813 void SetOldGenerationAllocationLimit(intptr_t old_gen_size, double gc_speed, |
1829 double mutator_speed); | 1814 double mutator_speed); |
1830 | 1815 |
1831 intptr_t MinimumAllocationLimitGrowingStep(); | 1816 intptr_t MinimumAllocationLimitGrowingStep(); |
1832 | 1817 |
| 1818 intptr_t old_generation_allocation_limit() const { |
| 1819 return old_generation_allocation_limit_; |
| 1820 } |
| 1821 |
| 1822 bool always_allocate() { return always_allocate_scope_count_.Value() != 0; } |
| 1823 |
| 1824 bool CanExpandOldGeneration(int size) { |
| 1825 if (force_oom_) return false; |
| 1826 return (OldGenerationCapacity() + size) < MaxOldGenerationSize(); |
| 1827 } |
| 1828 |
| 1829 bool ShouldExpandOldGenerationOnAllocationFailure(); |
| 1830 |
| 1831 enum class IncrementalMarkingLimit { kNoLimit, kSoftLimit, kHardLimit }; |
| 1832 IncrementalMarkingLimit ReachedIncrementalMarkingLimit(); |
| 1833 |
1833 // =========================================================================== | 1834 // =========================================================================== |
1834 // Idle notification. ======================================================== | 1835 // Idle notification. ======================================================== |
1835 // =========================================================================== | 1836 // =========================================================================== |
1836 | 1837 |
1837 bool RecentIdleNotificationHappened(); | 1838 bool RecentIdleNotificationHappened(); |
1838 void ScheduleIdleScavengeIfNeeded(int bytes_allocated); | 1839 void ScheduleIdleScavengeIfNeeded(int bytes_allocated); |
1839 | 1840 |
1840 // =========================================================================== | 1841 // =========================================================================== |
1841 // HeapIterator helpers. ===================================================== | 1842 // HeapIterator helpers. ===================================================== |
1842 // =========================================================================== | 1843 // =========================================================================== |
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2293 // Used for testing purposes. | 2294 // Used for testing purposes. |
2294 bool force_oom_; | 2295 bool force_oom_; |
2295 | 2296 |
2296 // Classes in "heap" can be friends. | 2297 // Classes in "heap" can be friends. |
2297 friend class AlwaysAllocateScope; | 2298 friend class AlwaysAllocateScope; |
2298 friend class GCCallbacksScope; | 2299 friend class GCCallbacksScope; |
2299 friend class GCTracer; | 2300 friend class GCTracer; |
2300 friend class HeapIterator; | 2301 friend class HeapIterator; |
2301 friend class IdleScavengeObserver; | 2302 friend class IdleScavengeObserver; |
2302 friend class IncrementalMarking; | 2303 friend class IncrementalMarking; |
| 2304 friend class IncrementalMarkingJob; |
2303 friend class IteratePromotedObjectsVisitor; | 2305 friend class IteratePromotedObjectsVisitor; |
| 2306 friend class LargeObjectSpace; |
2304 friend class MarkCompactCollector; | 2307 friend class MarkCompactCollector; |
2305 friend class MarkCompactMarkingVisitor; | 2308 friend class MarkCompactMarkingVisitor; |
2306 friend class NewSpace; | 2309 friend class NewSpace; |
2307 friend class ObjectStatsCollector; | 2310 friend class ObjectStatsCollector; |
2308 friend class Page; | 2311 friend class Page; |
| 2312 friend class PagedSpace; |
2309 friend class Scavenger; | 2313 friend class Scavenger; |
2310 friend class StoreBuffer; | 2314 friend class StoreBuffer; |
2311 friend class TestMemoryAllocatorScope; | 2315 friend class TestMemoryAllocatorScope; |
2312 | 2316 |
2313 // The allocator interface. | 2317 // The allocator interface. |
2314 friend class Factory; | 2318 friend class Factory; |
2315 | 2319 |
2316 // The Isolate constructs us. | 2320 // The Isolate constructs us. |
2317 friend class Isolate; | 2321 friend class Isolate; |
2318 | 2322 |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2610 friend class LargeObjectSpace; | 2614 friend class LargeObjectSpace; |
2611 friend class NewSpace; | 2615 friend class NewSpace; |
2612 friend class PagedSpace; | 2616 friend class PagedSpace; |
2613 DISALLOW_COPY_AND_ASSIGN(AllocationObserver); | 2617 DISALLOW_COPY_AND_ASSIGN(AllocationObserver); |
2614 }; | 2618 }; |
2615 | 2619 |
2616 } // namespace internal | 2620 } // namespace internal |
2617 } // namespace v8 | 2621 } // namespace v8 |
2618 | 2622 |
2619 #endif // V8_HEAP_HEAP_H_ | 2623 #endif // V8_HEAP_HEAP_H_ |
OLD | NEW |