OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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_OBJECT_STATS_H_ | 5 #ifndef V8_HEAP_OBJECT_STATS_H_ |
6 #define V8_HEAP_OBJECT_STATS_H_ | 6 #define V8_HEAP_OBJECT_STATS_H_ |
7 | 7 |
8 #include <math.h> | 8 #include "src/base/ieee754.h" |
9 | |
10 #include "src/heap/heap.h" | 9 #include "src/heap/heap.h" |
11 #include "src/heap/objects-visiting.h" | 10 #include "src/heap/objects-visiting.h" |
12 #include "src/objects.h" | 11 #include "src/objects.h" |
13 | 12 |
14 namespace v8 { | 13 namespace v8 { |
15 namespace internal { | 14 namespace internal { |
16 | 15 |
17 class ObjectStats { | 16 class ObjectStats { |
18 public: | 17 public: |
19 explicit ObjectStats(Heap* heap) : heap_(heap) { ClearObjectStats(); } | 18 explicit ObjectStats(Heap* heap) : heap_(heap) { ClearObjectStats(); } |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 | 84 |
86 private: | 85 private: |
87 static const int kFirstBucketShift = 5; // <=32 | 86 static const int kFirstBucketShift = 5; // <=32 |
88 static const int kLastBucketShift = 19; // >512k | 87 static const int kLastBucketShift = 19; // >512k |
89 static const int kFirstBucket = 1 << kFirstBucketShift; | 88 static const int kFirstBucket = 1 << kFirstBucketShift; |
90 static const int kLastBucket = 1 << kLastBucketShift; | 89 static const int kLastBucket = 1 << kLastBucketShift; |
91 static const int kNumberOfBuckets = kLastBucketShift - kFirstBucketShift; | 90 static const int kNumberOfBuckets = kLastBucketShift - kFirstBucketShift; |
92 | 91 |
93 int HistogramIndexFromSize(size_t size) { | 92 int HistogramIndexFromSize(size_t size) { |
94 if (size == 0) return 0; | 93 if (size == 0) return 0; |
95 int idx = | 94 int idx = static_cast<int>(base::ieee754::log2(static_cast<double>(size))) - |
96 static_cast<int>(log2(static_cast<double>(size))) - kFirstBucketShift; | 95 kFirstBucketShift; |
97 return idx < 0 ? 0 : idx; | 96 return idx < 0 ? 0 : idx; |
98 } | 97 } |
99 | 98 |
100 Heap* heap_; | 99 Heap* heap_; |
101 // Object counts and used memory by InstanceType. | 100 // Object counts and used memory by InstanceType. |
102 size_t object_counts_[OBJECT_STATS_COUNT]; | 101 size_t object_counts_[OBJECT_STATS_COUNT]; |
103 size_t object_counts_last_time_[OBJECT_STATS_COUNT]; | 102 size_t object_counts_last_time_[OBJECT_STATS_COUNT]; |
104 size_t object_sizes_[OBJECT_STATS_COUNT]; | 103 size_t object_sizes_[OBJECT_STATS_COUNT]; |
105 size_t object_sizes_last_time_[OBJECT_STATS_COUNT]; | 104 size_t object_sizes_last_time_[OBJECT_STATS_COUNT]; |
106 // Approximation of overallocated memory by InstanceType. | 105 // Approximation of overallocated memory by InstanceType. |
(...skipping 19 matching lines...) Expand all Loading... |
126 static void RecordJSObjectDetails(ObjectStats* stats, Heap* heap, | 125 static void RecordJSObjectDetails(ObjectStats* stats, Heap* heap, |
127 JSObject* object); | 126 JSObject* object); |
128 static void RecordJSWeakCollectionDetails(ObjectStats* stats, Heap* heap, | 127 static void RecordJSWeakCollectionDetails(ObjectStats* stats, Heap* heap, |
129 JSWeakCollection* obj); | 128 JSWeakCollection* obj); |
130 }; | 129 }; |
131 | 130 |
132 } // namespace internal | 131 } // namespace internal |
133 } // namespace v8 | 132 } // namespace v8 |
134 | 133 |
135 #endif // V8_HEAP_OBJECT_STATS_H_ | 134 #endif // V8_HEAP_OBJECT_STATS_H_ |
OLD | NEW |