Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(26)

Side by Side Diff: src/heap/object-stats.h

Issue 1326793002: [heap] Separate ObjectStats out into its own class. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/heap/mark-compact.cc ('k') | src/heap/object-stats.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef V8_HEAP_OBJECT_STATS_H_
6 #define V8_HEAP_OBJECT_STATS_H_
7
8 #include "src/heap/heap.h"
9 #include "src/objects.h"
10
11 namespace v8 {
12 namespace internal {
13
14 class ObjectStats {
15 public:
16 explicit ObjectStats(Heap* heap) : heap_(heap) {}
17
18 // ObjectStats are kept in two arrays, counts and sizes. Related stats are
19 // stored in a contiguous linear buffer. Stats groups are stored one after
20 // another.
21 enum {
22 FIRST_CODE_KIND_SUB_TYPE = LAST_TYPE + 1,
23 FIRST_FIXED_ARRAY_SUB_TYPE =
24 FIRST_CODE_KIND_SUB_TYPE + Code::NUMBER_OF_KINDS,
25 FIRST_CODE_AGE_SUB_TYPE =
26 FIRST_FIXED_ARRAY_SUB_TYPE + LAST_FIXED_ARRAY_SUB_TYPE + 1,
27 OBJECT_STATS_COUNT = FIRST_CODE_AGE_SUB_TYPE + Code::kCodeAgeCount + 1
28 };
29
30 void ClearObjectStats(bool clear_last_time_stats = false);
31
32 void TraceObjectStats();
33 void TraceObjectStat(const char* name, int count, int size, double time);
34 void CheckpointObjectStats();
35
36 void RecordObjectStats(InstanceType type, size_t size) {
37 DCHECK(type <= LAST_TYPE);
38 object_counts_[type]++;
39 object_sizes_[type] += size;
40 }
41
42 void RecordCodeSubTypeStats(int code_sub_type, int code_age, size_t size) {
43 int code_sub_type_index = FIRST_CODE_KIND_SUB_TYPE + code_sub_type;
44 int code_age_index =
45 FIRST_CODE_AGE_SUB_TYPE + code_age - Code::kFirstCodeAge;
46 DCHECK(code_sub_type_index >= FIRST_CODE_KIND_SUB_TYPE &&
47 code_sub_type_index < FIRST_CODE_AGE_SUB_TYPE);
48 DCHECK(code_age_index >= FIRST_CODE_AGE_SUB_TYPE &&
49 code_age_index < OBJECT_STATS_COUNT);
50 object_counts_[code_sub_type_index]++;
51 object_sizes_[code_sub_type_index] += size;
52 object_counts_[code_age_index]++;
53 object_sizes_[code_age_index] += size;
54 }
55
56 void RecordFixedArraySubTypeStats(int array_sub_type, size_t size) {
57 DCHECK(array_sub_type <= LAST_FIXED_ARRAY_SUB_TYPE);
58 object_counts_[FIRST_FIXED_ARRAY_SUB_TYPE + array_sub_type]++;
59 object_sizes_[FIRST_FIXED_ARRAY_SUB_TYPE + array_sub_type] += size;
60 }
61
62 size_t object_count_last_gc(size_t index) {
63 return object_counts_last_time_[index];
64 }
65
66 size_t object_size_last_gc(size_t index) {
67 return object_sizes_last_time_[index];
68 }
69
70 Isolate* isolate();
71 Heap* heap() { return heap_; }
72
73 private:
74 Heap* heap_;
75
76 // Object counts and used memory by InstanceType
77 size_t object_counts_[OBJECT_STATS_COUNT];
78 size_t object_counts_last_time_[OBJECT_STATS_COUNT];
79 size_t object_sizes_[OBJECT_STATS_COUNT];
80 size_t object_sizes_last_time_[OBJECT_STATS_COUNT];
81 };
82
83 } // namespace internal
84 } // namespace v8
85
86 #endif // V8_HEAP_OBJECT_STATS_H_
OLDNEW
« no previous file with comments | « src/heap/mark-compact.cc ('k') | src/heap/object-stats.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698