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 | 463 |
464 // Forward declarations. | 464 // Forward declarations. |
465 class ArrayBufferTracker; | 465 class ArrayBufferTracker; |
466 class GCIdleTimeAction; | 466 class GCIdleTimeAction; |
467 class GCIdleTimeHandler; | 467 class GCIdleTimeHandler; |
468 class GCIdleTimeHeapState; | 468 class GCIdleTimeHeapState; |
469 class GCTracer; | 469 class GCTracer; |
470 class HeapObjectsFilter; | 470 class HeapObjectsFilter; |
471 class HeapStats; | 471 class HeapStats; |
472 class HistogramTimer; | 472 class HistogramTimer; |
473 class InlineAllocationObserver; | |
474 class Isolate; | 473 class Isolate; |
475 class MemoryReducer; | 474 class MemoryReducer; |
476 class ObjectStats; | 475 class ObjectStats; |
477 class Scavenger; | 476 class Scavenger; |
478 class ScavengeJob; | 477 class ScavengeJob; |
479 class WeakObjectRetainer; | 478 class WeakObjectRetainer; |
480 | 479 |
481 | 480 |
482 // A queue of objects promoted during scavenge. Each object is accompanied | 481 // A queue of objects promoted during scavenge. Each object is accompanied |
483 // by it's size to avoid dereferencing a map pointer for scanning. | 482 // by it's size to avoid dereferencing a map pointer for scanning. |
(...skipping 2265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2749 WhatToFind what_to_find_; | 2748 WhatToFind what_to_find_; |
2750 VisitMode visit_mode_; | 2749 VisitMode visit_mode_; |
2751 List<Object*> object_stack_; | 2750 List<Object*> object_stack_; |
2752 | 2751 |
2753 DisallowHeapAllocation no_allocation; // i.e. no gc allowed. | 2752 DisallowHeapAllocation no_allocation; // i.e. no gc allowed. |
2754 | 2753 |
2755 private: | 2754 private: |
2756 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); | 2755 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); |
2757 }; | 2756 }; |
2758 #endif // DEBUG | 2757 #endif // DEBUG |
2759 | |
2760 // ----------------------------------------------------------------------------- | |
2761 // Allows observation of inline allocation in the new space. | |
2762 class InlineAllocationObserver { | |
2763 public: | |
2764 explicit InlineAllocationObserver(intptr_t step_size) | |
2765 : step_size_(step_size), bytes_to_next_step_(step_size) { | |
2766 DCHECK(step_size >= kPointerSize); | |
2767 } | |
2768 virtual ~InlineAllocationObserver() {} | |
2769 | |
2770 // Called each time the new space does an inline allocation step. This may be | |
2771 // more frequently than the step_size we are monitoring (e.g. when there are | |
2772 // multiple observers, or when page or space boundary is encountered.) | |
2773 void InlineAllocationStep(int bytes_allocated, Address soon_object, | |
2774 size_t size) { | |
2775 bytes_to_next_step_ -= bytes_allocated; | |
2776 if (bytes_to_next_step_ <= 0) { | |
2777 Step(static_cast<int>(step_size_ - bytes_to_next_step_), soon_object, | |
2778 size); | |
2779 step_size_ = GetNextStepSize(); | |
2780 bytes_to_next_step_ = step_size_; | |
2781 } | |
2782 } | |
2783 | |
2784 protected: | |
2785 intptr_t step_size() const { return step_size_; } | |
2786 intptr_t bytes_to_next_step() const { return bytes_to_next_step_; } | |
2787 | |
2788 // Pure virtual method provided by the subclasses that gets called when at | |
2789 // least step_size bytes have been allocated. soon_object is the address just | |
2790 // allocated (but not yet initialized.) size is the size of the object as | |
2791 // requested (i.e. w/o the alignment fillers). Some complexities to be aware | |
2792 // of: | |
2793 // 1) soon_object will be nullptr in cases where we end up observing an | |
2794 // allocation that happens to be a filler space (e.g. page boundaries.) | |
2795 // 2) size is the requested size at the time of allocation. Right-trimming | |
2796 // may change the object size dynamically. | |
2797 // 3) soon_object may actually be the first object in an allocation-folding | |
2798 // group. In such a case size is the size of the group rather than the | |
2799 // first object. | |
2800 virtual void Step(int bytes_allocated, Address soon_object, size_t size) = 0; | |
2801 | |
2802 // Subclasses can override this method to make step size dynamic. | |
2803 virtual intptr_t GetNextStepSize() { return step_size_; } | |
2804 | |
2805 intptr_t step_size_; | |
2806 intptr_t bytes_to_next_step_; | |
2807 | |
2808 private: | |
2809 friend class NewSpace; | |
2810 DISALLOW_COPY_AND_ASSIGN(InlineAllocationObserver); | |
2811 }; | |
2812 | |
2813 } // namespace internal | 2758 } // namespace internal |
2814 } // namespace v8 | 2759 } // namespace v8 |
2815 | 2760 |
2816 #endif // V8_HEAP_HEAP_H_ | 2761 #endif // V8_HEAP_HEAP_H_ |
OLD | NEW |