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 911 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
922 void PrintShortHeapStatistics(); | 922 void PrintShortHeapStatistics(); |
923 | 923 |
924 inline HeapState gc_state() { return gc_state_; } | 924 inline HeapState gc_state() { return gc_state_; } |
925 | 925 |
926 inline bool IsInGCPostProcessing() { return gc_post_processing_depth_ > 0; } | 926 inline bool IsInGCPostProcessing() { return gc_post_processing_depth_ > 0; } |
927 | 927 |
928 // If an object has an AllocationMemento trailing it, return it, otherwise | 928 // If an object has an AllocationMemento trailing it, return it, otherwise |
929 // return NULL; | 929 // return NULL; |
930 inline AllocationMemento* FindAllocationMemento(HeapObject* object); | 930 inline AllocationMemento* FindAllocationMemento(HeapObject* object); |
931 | 931 |
932 inline AllocationMemento* FindAllocationMementoCandidate(HeapObject* object); | |
933 | |
932 // Returns false if not able to reserve. | 934 // Returns false if not able to reserve. |
933 bool ReserveSpace(Reservation* reservations); | 935 bool ReserveSpace(Reservation* reservations); |
934 | 936 |
935 // | 937 // |
936 // Support for the API. | 938 // Support for the API. |
937 // | 939 // |
938 | 940 |
939 void CreateApiObjects(); | 941 void CreateApiObjects(); |
940 | 942 |
941 // Implements the corresponding V8 API function. | 943 // Implements the corresponding V8 API function. |
(...skipping 1796 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2738 public: | 2740 public: |
2739 virtual ~WeakObjectRetainer() {} | 2741 virtual ~WeakObjectRetainer() {} |
2740 | 2742 |
2741 // Return whether this object should be retained. If NULL is returned the | 2743 // Return whether this object should be retained. If NULL is returned the |
2742 // object has no references. Otherwise the address of the retained object | 2744 // object has no references. Otherwise the address of the retained object |
2743 // should be returned as in some GC situations the object has been moved. | 2745 // should be returned as in some GC situations the object has been moved. |
2744 virtual Object* RetainAs(Object* object) = 0; | 2746 virtual Object* RetainAs(Object* object) = 0; |
2745 }; | 2747 }; |
2746 | 2748 |
2747 | 2749 |
2750 class TimedScope { | |
Hannes Payer (out of office)
2016/01/18 11:46:33
That sounds like a general util class.
Michael Lippautz
2016/01/19 14:56:52
Done.
| |
2751 public: | |
2752 TimedScope(Heap* heap, double* result) | |
2753 : heap_(heap), | |
2754 start_(heap->MonotonicallyIncreasingTimeInMs()), | |
2755 result_(result) {} | |
2756 | |
2757 ~TimedScope() { | |
2758 *result_ = heap_->MonotonicallyIncreasingTimeInMs() - start_; | |
2759 } | |
2760 | |
2761 private: | |
2762 Heap* heap_; | |
2763 double start_; | |
2764 double* result_; | |
2765 }; | |
2766 | |
2767 | |
2748 #ifdef DEBUG | 2768 #ifdef DEBUG |
2749 // Helper class for tracing paths to a search target Object from all roots. | 2769 // Helper class for tracing paths to a search target Object from all roots. |
2750 // The TracePathFrom() method can be used to trace paths from a specific | 2770 // The TracePathFrom() method can be used to trace paths from a specific |
2751 // object to the search target object. | 2771 // object to the search target object. |
2752 class PathTracer : public ObjectVisitor { | 2772 class PathTracer : public ObjectVisitor { |
2753 public: | 2773 public: |
2754 enum WhatToFind { | 2774 enum WhatToFind { |
2755 FIND_ALL, // Will find all matches. | 2775 FIND_ALL, // Will find all matches. |
2756 FIND_FIRST // Will stop the search after first match. | 2776 FIND_FIRST // Will stop the search after first match. |
2757 }; | 2777 }; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2799 DisallowHeapAllocation no_allocation; // i.e. no gc allowed. | 2819 DisallowHeapAllocation no_allocation; // i.e. no gc allowed. |
2800 | 2820 |
2801 private: | 2821 private: |
2802 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); | 2822 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); |
2803 }; | 2823 }; |
2804 #endif // DEBUG | 2824 #endif // DEBUG |
2805 } // namespace internal | 2825 } // namespace internal |
2806 } // namespace v8 | 2826 } // namespace v8 |
2807 | 2827 |
2808 #endif // V8_HEAP_HEAP_H_ | 2828 #endif // V8_HEAP_HEAP_H_ |
OLD | NEW |