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 |
11 #include "src/allocation.h" | 11 #include "src/allocation.h" |
12 #include "src/assert-scope.h" | 12 #include "src/assert-scope.h" |
13 #include "src/counters.h" | 13 #include "src/counters.h" |
14 #include "src/globals.h" | 14 #include "src/globals.h" |
15 #include "src/heap/gc-idle-time-handler.h" | 15 #include "src/heap/gc-idle-time-handler.h" |
16 #include "src/heap/gc-tracer.h" | 16 #include "src/heap/gc-tracer.h" |
17 #include "src/heap/incremental-marking.h" | 17 #include "src/heap/incremental-marking.h" |
18 #include "src/heap/mark-compact.h" | 18 #include "src/heap/mark-compact.h" |
19 #include "src/heap/memory-reducer.h" | |
20 #include "src/heap/objects-visiting.h" | 19 #include "src/heap/objects-visiting.h" |
21 #include "src/heap/spaces.h" | 20 #include "src/heap/spaces.h" |
22 #include "src/heap/store-buffer.h" | 21 #include "src/heap/store-buffer.h" |
23 #include "src/list.h" | 22 #include "src/list.h" |
24 #include "src/splay-tree-inl.h" | 23 #include "src/splay-tree-inl.h" |
25 | 24 |
26 namespace v8 { | 25 namespace v8 { |
27 namespace internal { | 26 namespace internal { |
28 | 27 |
29 // Defines all the roots in Heap. | 28 // Defines all the roots in Heap. |
(...skipping 795 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
825 | 824 |
826 // Last hope GC, should try to squeeze as much as possible. | 825 // Last hope GC, should try to squeeze as much as possible. |
827 void CollectAllAvailableGarbage(const char* gc_reason = NULL); | 826 void CollectAllAvailableGarbage(const char* gc_reason = NULL); |
828 | 827 |
829 // Check whether the heap is currently iterable. | 828 // Check whether the heap is currently iterable. |
830 bool IsHeapIterable(); | 829 bool IsHeapIterable(); |
831 | 830 |
832 // Notify the heap that a context has been disposed. | 831 // Notify the heap that a context has been disposed. |
833 int NotifyContextDisposed(bool dependant_context); | 832 int NotifyContextDisposed(bool dependant_context); |
834 | 833 |
835 // Start incremental marking and ensure that idle time handler can perform | |
836 // incremental steps. | |
837 void StartIdleIncrementalMarking(); | |
838 | |
839 inline void increment_scan_on_scavenge_pages() { | 834 inline void increment_scan_on_scavenge_pages() { |
840 scan_on_scavenge_pages_++; | 835 scan_on_scavenge_pages_++; |
841 if (FLAG_gc_verbose) { | 836 if (FLAG_gc_verbose) { |
842 PrintF("Scan-on-scavenge pages: %d\n", scan_on_scavenge_pages_); | 837 PrintF("Scan-on-scavenge pages: %d\n", scan_on_scavenge_pages_); |
843 } | 838 } |
844 } | 839 } |
845 | 840 |
846 inline void decrement_scan_on_scavenge_pages() { | 841 inline void decrement_scan_on_scavenge_pages() { |
847 scan_on_scavenge_pages_--; | 842 scan_on_scavenge_pages_--; |
848 if (FLAG_gc_verbose) { | 843 if (FLAG_gc_verbose) { |
(...skipping 762 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1611 // marking or scavenge phase. | 1606 // marking or scavenge phase. |
1612 void FreeDeadArrayBuffers(bool from_scavenge); | 1607 void FreeDeadArrayBuffers(bool from_scavenge); |
1613 | 1608 |
1614 // Prepare for a new scavenge phase. A new marking phase is implicitly | 1609 // Prepare for a new scavenge phase. A new marking phase is implicitly |
1615 // prepared by finishing the previous one. | 1610 // prepared by finishing the previous one. |
1616 void PrepareArrayBufferDiscoveryInNewSpace(); | 1611 void PrepareArrayBufferDiscoveryInNewSpace(); |
1617 | 1612 |
1618 // An ArrayBuffer moved from new space to old space. | 1613 // An ArrayBuffer moved from new space to old space. |
1619 void PromoteArrayBuffer(Object* buffer); | 1614 void PromoteArrayBuffer(Object* buffer); |
1620 | 1615 |
1621 bool HasLowAllocationRate(); | |
1622 bool HasHighFragmentation(); | |
1623 bool HasHighFragmentation(intptr_t used, intptr_t committed); | |
1624 | |
1625 protected: | 1616 protected: |
1626 // Methods made available to tests. | 1617 // Methods made available to tests. |
1627 | 1618 |
1628 // Allocates a JS Map in the heap. | 1619 // Allocates a JS Map in the heap. |
1629 MUST_USE_RESULT AllocationResult | 1620 MUST_USE_RESULT AllocationResult |
1630 AllocateMap(InstanceType instance_type, int instance_size, | 1621 AllocateMap(InstanceType instance_type, int instance_size, |
1631 ElementsKind elements_kind = TERMINAL_FAST_ELEMENTS_KIND); | 1622 ElementsKind elements_kind = TERMINAL_FAST_ELEMENTS_KIND); |
1632 | 1623 |
1633 // Allocates and initializes a new JavaScript object based on a | 1624 // Allocates and initializes a new JavaScript object based on a |
1634 // constructor. | 1625 // constructor. |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1775 // remain until the next failure and garbage collection. | 1766 // remain until the next failure and garbage collection. |
1776 int allocation_timeout_; | 1767 int allocation_timeout_; |
1777 #endif // DEBUG | 1768 #endif // DEBUG |
1778 | 1769 |
1779 // Limit that triggers a global GC on the next (normally caused) GC. This | 1770 // Limit that triggers a global GC on the next (normally caused) GC. This |
1780 // is checked when we have already decided to do a GC to help determine | 1771 // is checked when we have already decided to do a GC to help determine |
1781 // which collector to invoke, before expanding a paged space in the old | 1772 // which collector to invoke, before expanding a paged space in the old |
1782 // generation and on every allocation in large object space. | 1773 // generation and on every allocation in large object space. |
1783 intptr_t old_generation_allocation_limit_; | 1774 intptr_t old_generation_allocation_limit_; |
1784 | 1775 |
| 1776 // The allocation limit when there is >16.66ms idle time in the idle time |
| 1777 // handler. |
| 1778 intptr_t idle_old_generation_allocation_limit_; |
| 1779 |
1785 // Indicates that an allocation has failed in the old generation since the | 1780 // Indicates that an allocation has failed in the old generation since the |
1786 // last GC. | 1781 // last GC. |
1787 bool old_gen_exhausted_; | 1782 bool old_gen_exhausted_; |
1788 | 1783 |
1789 // Indicates that inline bump-pointer allocation has been globally disabled | 1784 // Indicates that inline bump-pointer allocation has been globally disabled |
1790 // for all spaces. This is used to disable allocations in generated code. | 1785 // for all spaces. This is used to disable allocations in generated code. |
1791 bool inline_allocation_disabled_; | 1786 bool inline_allocation_disabled_; |
1792 | 1787 |
1793 // Weak list heads, threaded through the objects. | 1788 // Weak list heads, threaded through the objects. |
1794 // List heads are initialized lazily and contain the undefined_value at start. | 1789 // List heads are initialized lazily and contain the undefined_value at start. |
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2249 bool IsHighSurvivalRate() { return high_survival_rate_period_length_ > 0; } | 2244 bool IsHighSurvivalRate() { return high_survival_rate_period_length_ > 0; } |
2250 | 2245 |
2251 void ConfigureInitialOldGenerationSize(); | 2246 void ConfigureInitialOldGenerationSize(); |
2252 | 2247 |
2253 void ConfigureNewGenerationSize(); | 2248 void ConfigureNewGenerationSize(); |
2254 | 2249 |
2255 void SelectScavengingVisitorsTable(); | 2250 void SelectScavengingVisitorsTable(); |
2256 | 2251 |
2257 bool HasLowYoungGenerationAllocationRate(); | 2252 bool HasLowYoungGenerationAllocationRate(); |
2258 bool HasLowOldGenerationAllocationRate(); | 2253 bool HasLowOldGenerationAllocationRate(); |
| 2254 bool HasLowAllocationRate(); |
2259 | 2255 |
2260 void ReduceNewSpaceSize(); | 2256 void ReduceNewSpaceSize(); |
2261 | 2257 |
2262 bool TryFinalizeIdleIncrementalMarking( | 2258 bool TryFinalizeIdleIncrementalMarking( |
2263 double idle_time_in_ms, size_t size_of_objects, | 2259 double idle_time_in_ms, size_t size_of_objects, |
2264 size_t mark_compact_speed_in_bytes_per_ms); | 2260 size_t mark_compact_speed_in_bytes_per_ms); |
2265 | 2261 |
2266 GCIdleTimeHandler::HeapState ComputeHeapState(); | 2262 GCIdleTimeHandler::HeapState ComputeHeapState(); |
2267 | 2263 |
2268 bool PerformIdleTimeAction(GCIdleTimeAction action, | 2264 bool PerformIdleTimeAction(GCIdleTimeAction action, |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2315 MarkCompactCollector mark_compact_collector_; | 2311 MarkCompactCollector mark_compact_collector_; |
2316 | 2312 |
2317 StoreBuffer store_buffer_; | 2313 StoreBuffer store_buffer_; |
2318 | 2314 |
2319 Marking marking_; | 2315 Marking marking_; |
2320 | 2316 |
2321 IncrementalMarking incremental_marking_; | 2317 IncrementalMarking incremental_marking_; |
2322 | 2318 |
2323 GCIdleTimeHandler gc_idle_time_handler_; | 2319 GCIdleTimeHandler gc_idle_time_handler_; |
2324 | 2320 |
2325 MemoryReducer memory_reducer_; | |
2326 | |
2327 // These two counters are monotomically increasing and never reset. | 2321 // These two counters are monotomically increasing and never reset. |
2328 size_t full_codegen_bytes_generated_; | 2322 size_t full_codegen_bytes_generated_; |
2329 size_t crankshaft_codegen_bytes_generated_; | 2323 size_t crankshaft_codegen_bytes_generated_; |
2330 | 2324 |
2331 // This counter is increased before each GC and never reset. | 2325 // This counter is increased before each GC and never reset. |
2332 // To account for the bytes allocated since the last GC, use the | 2326 // To account for the bytes allocated since the last GC, use the |
2333 // NewSpaceAllocationCounter() function. | 2327 // NewSpaceAllocationCounter() function. |
2334 size_t new_space_allocation_counter_; | 2328 size_t new_space_allocation_counter_; |
2335 | 2329 |
2336 // This counter is increased before each GC and never reset. To | 2330 // This counter is increased before each GC and never reset. To |
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2858 DisallowHeapAllocation no_allocation; // i.e. no gc allowed. | 2852 DisallowHeapAllocation no_allocation; // i.e. no gc allowed. |
2859 | 2853 |
2860 private: | 2854 private: |
2861 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); | 2855 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); |
2862 }; | 2856 }; |
2863 #endif // DEBUG | 2857 #endif // DEBUG |
2864 } | 2858 } |
2865 } // namespace v8::internal | 2859 } // namespace v8::internal |
2866 | 2860 |
2867 #endif // V8_HEAP_HEAP_H_ | 2861 #endif // V8_HEAP_HEAP_H_ |
OLD | NEW |