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