Chromium Code Reviews| 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 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 463 V(UninitializedMap) \ | 463 V(UninitializedMap) \ |
| 464 V(ArgumentsMarkerMap) \ | 464 V(ArgumentsMarkerMap) \ |
| 465 V(JSMessageObjectMap) \ | 465 V(JSMessageObjectMap) \ |
| 466 V(ForeignMap) \ | 466 V(ForeignMap) \ |
| 467 V(NeanderMap) \ | 467 V(NeanderMap) \ |
| 468 V(EmptyWeakCell) \ | 468 V(EmptyWeakCell) \ |
| 469 V(empty_string) \ | 469 V(empty_string) \ |
| 470 PRIVATE_SYMBOL_LIST(V) | 470 PRIVATE_SYMBOL_LIST(V) |
| 471 | 471 |
| 472 // Forward declarations. | 472 // Forward declarations. |
| 473 class AllocationObserver; | |
| 473 class ArrayBufferTracker; | 474 class ArrayBufferTracker; |
| 474 class GCIdleTimeAction; | 475 class GCIdleTimeAction; |
| 475 class GCIdleTimeHandler; | 476 class GCIdleTimeHandler; |
| 476 class GCIdleTimeHeapState; | 477 class GCIdleTimeHeapState; |
| 477 class GCTracer; | 478 class GCTracer; |
| 478 class HeapObjectsFilter; | 479 class HeapObjectsFilter; |
| 479 class HeapStats; | 480 class HeapStats; |
| 480 class HistogramTimer; | 481 class HistogramTimer; |
| 481 class InlineAllocationObserver; | |
| 482 class Isolate; | 482 class Isolate; |
| 483 class MemoryReducer; | 483 class MemoryReducer; |
| 484 class ObjectStats; | 484 class ObjectStats; |
| 485 class Scavenger; | 485 class Scavenger; |
| 486 class ScavengeJob; | 486 class ScavengeJob; |
| 487 class WeakObjectRetainer; | 487 class WeakObjectRetainer; |
| 488 | 488 |
| 489 | 489 |
| 490 // A queue of objects promoted during scavenge. Each object is accompanied | 490 // A queue of objects promoted during scavenge. Each object is accompanied |
| 491 // by it's size to avoid dereferencing a map pointer for scanning. | 491 // by it's size to avoid dereferencing a map pointer for scanning. |
| (...skipping 1843 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2335 IncrementalMarking* incremental_marking_; | 2335 IncrementalMarking* incremental_marking_; |
| 2336 | 2336 |
| 2337 GCIdleTimeHandler* gc_idle_time_handler_; | 2337 GCIdleTimeHandler* gc_idle_time_handler_; |
| 2338 | 2338 |
| 2339 MemoryReducer* memory_reducer_; | 2339 MemoryReducer* memory_reducer_; |
| 2340 | 2340 |
| 2341 ObjectStats* object_stats_; | 2341 ObjectStats* object_stats_; |
| 2342 | 2342 |
| 2343 ScavengeJob* scavenge_job_; | 2343 ScavengeJob* scavenge_job_; |
| 2344 | 2344 |
| 2345 InlineAllocationObserver* idle_scavenge_observer_; | 2345 AllocationObserver* idle_scavenge_observer_; |
| 2346 | 2346 |
| 2347 // These two counters are monotomically increasing and never reset. | 2347 // These two counters are monotomically increasing and never reset. |
| 2348 size_t full_codegen_bytes_generated_; | 2348 size_t full_codegen_bytes_generated_; |
| 2349 size_t crankshaft_codegen_bytes_generated_; | 2349 size_t crankshaft_codegen_bytes_generated_; |
| 2350 | 2350 |
| 2351 // This counter is increased before each GC and never reset. | 2351 // This counter is increased before each GC and never reset. |
| 2352 // To account for the bytes allocated since the last GC, use the | 2352 // To account for the bytes allocated since the last GC, use the |
| 2353 // NewSpaceAllocationCounter() function. | 2353 // NewSpaceAllocationCounter() function. |
| 2354 size_t new_space_allocation_counter_; | 2354 size_t new_space_allocation_counter_; |
| 2355 | 2355 |
| (...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2788 List<Object*> object_stack_; | 2788 List<Object*> object_stack_; |
| 2789 | 2789 |
| 2790 DisallowHeapAllocation no_allocation; // i.e. no gc allowed. | 2790 DisallowHeapAllocation no_allocation; // i.e. no gc allowed. |
| 2791 | 2791 |
| 2792 private: | 2792 private: |
| 2793 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); | 2793 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); |
| 2794 }; | 2794 }; |
| 2795 #endif // DEBUG | 2795 #endif // DEBUG |
| 2796 | 2796 |
| 2797 // ----------------------------------------------------------------------------- | 2797 // ----------------------------------------------------------------------------- |
| 2798 // Allows observation of inline allocation in the new space. | 2798 // Allows observation of allocations. |
| 2799 class InlineAllocationObserver { | 2799 class AllocationObserver { |
| 2800 public: | 2800 public: |
| 2801 explicit InlineAllocationObserver(intptr_t step_size) | 2801 explicit AllocationObserver(Heap* heap, intptr_t step_size) |
|
ofrobots
2016/01/23 16:16:30
'explicit' is only needed on single argument const
mattloring
2016/01/26 00:42:48
Done.
| |
| 2802 : step_size_(step_size), bytes_to_next_step_(step_size) { | 2802 : heap_(heap), step_size_(step_size), bytes_to_next_step_(step_size) { |
| 2803 DCHECK(step_size >= kPointerSize); | 2803 DCHECK(step_size >= kPointerSize); |
| 2804 } | 2804 } |
| 2805 virtual ~InlineAllocationObserver() {} | 2805 virtual ~AllocationObserver() {} |
| 2806 | 2806 |
| 2807 // Called each time the new space does an inline allocation step. This may be | 2807 // Called each time the new space does an inline allocation step. This may be |
|
ofrobots
2016/01/23 16:16:30
Update comment since it applies to more than just
mattloring
2016/01/26 00:42:48
Done.
| |
| 2808 // more frequently than the step_size we are monitoring (e.g. when there are | 2808 // more frequently than the step_size we are monitoring (e.g. when there are |
| 2809 // multiple observers, or when page or space boundary is encountered.) | 2809 // multiple observers, or when page or space boundary is encountered.) |
| 2810 void InlineAllocationStep(int bytes_allocated, Address soon_object, | 2810 void AllocationStep(int bytes_allocated, Address soon_object, size_t size) { |
| 2811 size_t size) { | 2811 if (heap_->gc_state() != Heap::NOT_IN_GC) return; |
|
ofrobots
2016/01/23 16:16:31
It would be better to generalize the PauseInlineAl
mattloring
2016/01/26 00:42:48
I've generalized it and pausing is unified across
ofrobots
2016/01/26 15:47:15
Looking at the way this works, it seems like non-N
| |
| 2812 bytes_to_next_step_ -= bytes_allocated; | 2812 bytes_to_next_step_ -= bytes_allocated; |
| 2813 if (bytes_to_next_step_ <= 0) { | 2813 if (bytes_to_next_step_ <= 0) { |
| 2814 Step(static_cast<int>(step_size_ - bytes_to_next_step_), soon_object, | 2814 Step(static_cast<int>(step_size_ - bytes_to_next_step_), soon_object, |
| 2815 size); | 2815 size); |
| 2816 step_size_ = GetNextStepSize(); | 2816 step_size_ = GetNextStepSize(); |
| 2817 bytes_to_next_step_ = step_size_; | 2817 bytes_to_next_step_ = step_size_; |
| 2818 } | 2818 } |
| 2819 } | 2819 } |
| 2820 | 2820 |
| 2821 protected: | 2821 protected: |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 2832 // 2) size is the requested size at the time of allocation. Right-trimming | 2832 // 2) size is the requested size at the time of allocation. Right-trimming |
| 2833 // may change the object size dynamically. | 2833 // may change the object size dynamically. |
| 2834 // 3) soon_object may actually be the first object in an allocation-folding | 2834 // 3) soon_object may actually be the first object in an allocation-folding |
| 2835 // group. In such a case size is the size of the group rather than the | 2835 // group. In such a case size is the size of the group rather than the |
| 2836 // first object. | 2836 // first object. |
| 2837 virtual void Step(int bytes_allocated, Address soon_object, size_t size) = 0; | 2837 virtual void Step(int bytes_allocated, Address soon_object, size_t size) = 0; |
| 2838 | 2838 |
| 2839 // Subclasses can override this method to make step size dynamic. | 2839 // Subclasses can override this method to make step size dynamic. |
| 2840 virtual intptr_t GetNextStepSize() { return step_size_; } | 2840 virtual intptr_t GetNextStepSize() { return step_size_; } |
| 2841 | 2841 |
| 2842 Heap* heap_; | |
| 2842 intptr_t step_size_; | 2843 intptr_t step_size_; |
| 2843 intptr_t bytes_to_next_step_; | 2844 intptr_t bytes_to_next_step_; |
| 2844 | 2845 |
| 2845 private: | 2846 private: |
| 2847 friend class LargeObjectSpace; | |
| 2846 friend class NewSpace; | 2848 friend class NewSpace; |
| 2847 DISALLOW_COPY_AND_ASSIGN(InlineAllocationObserver); | 2849 friend class PagedSpace; |
| 2850 DISALLOW_COPY_AND_ASSIGN(AllocationObserver); | |
| 2848 }; | 2851 }; |
| 2849 | 2852 |
| 2850 } // namespace internal | 2853 } // namespace internal |
| 2851 } // namespace v8 | 2854 } // namespace v8 |
| 2852 | 2855 |
| 2853 #endif // V8_HEAP_HEAP_H_ | 2856 #endif // V8_HEAP_HEAP_H_ |
| OLD | NEW |