| 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 948 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1824 // given old generation size. | 1809 // given old generation size. |
| 1825 intptr_t CalculateOldGenerationAllocationLimit(double factor, | 1810 intptr_t CalculateOldGenerationAllocationLimit(double factor, |
| 1826 intptr_t old_gen_size); | 1811 intptr_t old_gen_size); |
| 1827 | 1812 |
| 1828 // Sets the allocation limit to trigger the next full garbage collection. | 1813 // Sets the allocation limit to trigger the next full garbage collection. |
| 1829 void SetOldGenerationAllocationLimit(intptr_t old_gen_size, double gc_speed, | 1814 void SetOldGenerationAllocationLimit(intptr_t old_gen_size, double gc_speed, |
| 1830 double mutator_speed); | 1815 double mutator_speed); |
| 1831 | 1816 |
| 1832 intptr_t MinimumAllocationLimitGrowingStep(); | 1817 intptr_t MinimumAllocationLimitGrowingStep(); |
| 1833 | 1818 |
| 1819 intptr_t old_generation_allocation_limit() const { |
| 1820 return old_generation_allocation_limit_; |
| 1821 } |
| 1822 |
| 1823 bool always_allocate() { return always_allocate_scope_count_.Value() != 0; } |
| 1824 |
| 1825 bool CanExpandOldGeneration(int size) { |
| 1826 if (force_oom_) return false; |
| 1827 return (OldGenerationCapacity() + size) < MaxOldGenerationSize(); |
| 1828 } |
| 1829 |
| 1830 bool ShouldExpandOldGenerationOnAllocationFailure(); |
| 1831 |
| 1832 enum class IncrementalMarkingLimit { kNoLimit, kSoftLimit, kHardLimit }; |
| 1833 IncrementalMarkingLimit IncrementalMarkingLimitReached(); |
| 1834 |
| 1834 // =========================================================================== | 1835 // =========================================================================== |
| 1835 // Idle notification. ======================================================== | 1836 // Idle notification. ======================================================== |
| 1836 // =========================================================================== | 1837 // =========================================================================== |
| 1837 | 1838 |
| 1838 bool RecentIdleNotificationHappened(); | 1839 bool RecentIdleNotificationHappened(); |
| 1839 void ScheduleIdleScavengeIfNeeded(int bytes_allocated); | 1840 void ScheduleIdleScavengeIfNeeded(int bytes_allocated); |
| 1840 | 1841 |
| 1841 // =========================================================================== | 1842 // =========================================================================== |
| 1842 // HeapIterator helpers. ===================================================== | 1843 // HeapIterator helpers. ===================================================== |
| 1843 // =========================================================================== | 1844 // =========================================================================== |
| (...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2296 // Used for testing purposes. | 2297 // Used for testing purposes. |
| 2297 bool force_oom_; | 2298 bool force_oom_; |
| 2298 | 2299 |
| 2299 // Classes in "heap" can be friends. | 2300 // Classes in "heap" can be friends. |
| 2300 friend class AlwaysAllocateScope; | 2301 friend class AlwaysAllocateScope; |
| 2301 friend class GCCallbacksScope; | 2302 friend class GCCallbacksScope; |
| 2302 friend class GCTracer; | 2303 friend class GCTracer; |
| 2303 friend class HeapIterator; | 2304 friend class HeapIterator; |
| 2304 friend class IdleScavengeObserver; | 2305 friend class IdleScavengeObserver; |
| 2305 friend class IncrementalMarking; | 2306 friend class IncrementalMarking; |
| 2307 friend class IncrementalMarkingJob; |
| 2306 friend class IteratePromotedObjectsVisitor; | 2308 friend class IteratePromotedObjectsVisitor; |
| 2309 friend class LargeObjectSpace; |
| 2307 friend class MarkCompactCollector; | 2310 friend class MarkCompactCollector; |
| 2308 friend class MarkCompactMarkingVisitor; | 2311 friend class MarkCompactMarkingVisitor; |
| 2309 friend class NewSpace; | 2312 friend class NewSpace; |
| 2310 friend class ObjectStatsCollector; | 2313 friend class ObjectStatsCollector; |
| 2311 friend class Page; | 2314 friend class Page; |
| 2315 friend class PagedSpace; |
| 2312 friend class Scavenger; | 2316 friend class Scavenger; |
| 2313 friend class StoreBuffer; | 2317 friend class StoreBuffer; |
| 2314 friend class TestMemoryAllocatorScope; | 2318 friend class TestMemoryAllocatorScope; |
| 2315 | 2319 |
| 2316 // The allocator interface. | 2320 // The allocator interface. |
| 2317 friend class Factory; | 2321 friend class Factory; |
| 2318 | 2322 |
| 2319 // The Isolate constructs us. | 2323 // The Isolate constructs us. |
| 2320 friend class Isolate; | 2324 friend class Isolate; |
| 2321 | 2325 |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2607 friend class LargeObjectSpace; | 2611 friend class LargeObjectSpace; |
| 2608 friend class NewSpace; | 2612 friend class NewSpace; |
| 2609 friend class PagedSpace; | 2613 friend class PagedSpace; |
| 2610 DISALLOW_COPY_AND_ASSIGN(AllocationObserver); | 2614 DISALLOW_COPY_AND_ASSIGN(AllocationObserver); |
| 2611 }; | 2615 }; |
| 2612 | 2616 |
| 2613 } // namespace internal | 2617 } // namespace internal |
| 2614 } // namespace v8 | 2618 } // namespace v8 |
| 2615 | 2619 |
| 2616 #endif // V8_HEAP_HEAP_H_ | 2620 #endif // V8_HEAP_HEAP_H_ |
| OLD | NEW |