Loading...
Searching...
No Matches
v8-statistics.h
Go to the documentation of this file.
1// Copyright 2021 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 INCLUDE_V8_STATISTICS_H_
6#define INCLUDE_V8_STATISTICS_H_
7
8#include <stddef.h>
9#include <stdint.h>
10
11#include <memory>
12#include <utility>
13#include <vector>
14
15#include "v8-local-handle.h" // NOLINT(build/include_directory)
16#include "v8-memory-span.h" // NOLINT(build/include_directory)
17#include "v8-promise.h" // NOLINT(build/include_directory)
18#include "v8config.h" // NOLINT(build/include_directory)
19
20namespace v8 {
21
22class Context;
23class Isolate;
24
25namespace internal {
26class ReadOnlyHeap;
27} // namespace internal
28
35
44
56 public:
57 virtual ~MeasureMemoryDelegate() = default;
58
62 virtual bool ShouldMeasure(Local<Context> context) = 0;
63
65 struct Result {
74
80
83
86 };
87
93 virtual void MeasurementComplete(Result result) {}
94
105 static std::unique_ptr<MeasureMemoryDelegate> Default(
106 Isolate* isolate, Local<Context> context,
107 Local<Promise::Resolver> promise_resolver, MeasureMemoryMode mode);
108};
109
117 public:
119 size_t read_only_space_size() { return read_only_space_size_; }
120 size_t read_only_space_used_size() { return read_only_space_used_size_; }
122 return read_only_space_physical_size_;
123 }
124
125 private:
126 size_t read_only_space_size_;
127 size_t read_only_space_used_size_;
128 size_t read_only_space_physical_size_;
129
130 friend class V8;
131 friend class internal::ReadOnlyHeap;
132};
133
141 public:
143 size_t total_heap_size() { return total_heap_size_; }
144 size_t total_heap_size_executable() { return total_heap_size_executable_; }
145 size_t total_physical_size() { return total_physical_size_; }
146 size_t total_available_size() { return total_available_size_; }
147 size_t total_global_handles_size() { return total_global_handles_size_; }
148 size_t used_global_handles_size() { return used_global_handles_size_; }
149 size_t used_heap_size() { return used_heap_size_; }
150 size_t heap_size_limit() { return heap_size_limit_; }
151 size_t malloced_memory() { return malloced_memory_; }
152 size_t external_memory() { return external_memory_; }
153 size_t peak_malloced_memory() { return peak_malloced_memory_; }
154 size_t number_of_native_contexts() { return number_of_native_contexts_; }
155 size_t number_of_detached_contexts() { return number_of_detached_contexts_; }
156
161 size_t does_zap_garbage() { return does_zap_garbage_; }
162
163 private:
164 size_t total_heap_size_;
165 size_t total_heap_size_executable_;
166 size_t total_physical_size_;
167 size_t total_available_size_;
168 size_t used_heap_size_;
169 size_t heap_size_limit_;
170 size_t malloced_memory_;
171 size_t external_memory_;
172 size_t peak_malloced_memory_;
173 bool does_zap_garbage_;
174 size_t number_of_native_contexts_;
175 size_t number_of_detached_contexts_;
176 size_t total_global_handles_size_;
177 size_t used_global_handles_size_;
178
179 friend class V8;
180 friend class Isolate;
181};
182
184 public:
186 const char* space_name() { return space_name_; }
187 size_t space_size() { return space_size_; }
188 size_t space_used_size() { return space_used_size_; }
189 size_t space_available_size() { return space_available_size_; }
190 size_t physical_space_size() { return physical_space_size_; }
191
192 private:
193 const char* space_name_;
194 size_t space_size_;
195 size_t space_used_size_;
196 size_t space_available_size_;
197 size_t physical_space_size_;
198
199 friend class Isolate;
200};
201
203 public:
205 const char* object_type() { return object_type_; }
206 const char* object_sub_type() { return object_sub_type_; }
207 size_t object_count() { return object_count_; }
208 size_t object_size() { return object_size_; }
209
210 private:
211 const char* object_type_;
212 const char* object_sub_type_;
213 size_t object_count_;
214 size_t object_size_;
215
216 friend class Isolate;
217};
218
220 public:
222 size_t code_and_metadata_size() { return code_and_metadata_size_; }
223 size_t bytecode_and_metadata_size() { return bytecode_and_metadata_size_; }
224 size_t external_script_source_size() { return external_script_source_size_; }
225 size_t cpu_profiler_metadata_size() { return cpu_profiler_metadata_size_; }
226
227 private:
228 size_t code_and_metadata_size_;
229 size_t bytecode_and_metadata_size_;
230 size_t external_script_source_size_;
231 size_t cpu_profiler_metadata_size_;
232
233 friend class Isolate;
234};
235
236} // namespace v8
237
238#endif // INCLUDE_V8_STATISTICS_H_
Definition: v8-statistics.h:219
size_t external_script_source_size()
Definition: v8-statistics.h:224
size_t bytecode_and_metadata_size()
Definition: v8-statistics.h:223
size_t code_and_metadata_size()
Definition: v8-statistics.h:222
size_t cpu_profiler_metadata_size()
Definition: v8-statistics.h:225
Definition: v8-statistics.h:202
const char * object_sub_type()
Definition: v8-statistics.h:206
size_t object_count()
Definition: v8-statistics.h:207
size_t object_size()
Definition: v8-statistics.h:208
const char * object_type()
Definition: v8-statistics.h:205
Definition: v8-statistics.h:183
size_t physical_space_size()
Definition: v8-statistics.h:190
const char * space_name()
Definition: v8-statistics.h:186
size_t space_used_size()
Definition: v8-statistics.h:188
size_t space_size()
Definition: v8-statistics.h:187
size_t space_available_size()
Definition: v8-statistics.h:189
Definition: v8-statistics.h:140
size_t total_global_handles_size()
Definition: v8-statistics.h:147
size_t used_heap_size()
Definition: v8-statistics.h:149
size_t total_physical_size()
Definition: v8-statistics.h:145
size_t heap_size_limit()
Definition: v8-statistics.h:150
size_t malloced_memory()
Definition: v8-statistics.h:151
size_t number_of_native_contexts()
Definition: v8-statistics.h:154
size_t does_zap_garbage()
Definition: v8-statistics.h:161
size_t number_of_detached_contexts()
Definition: v8-statistics.h:155
size_t used_global_handles_size()
Definition: v8-statistics.h:148
size_t total_available_size()
Definition: v8-statistics.h:146
size_t total_heap_size_executable()
Definition: v8-statistics.h:144
size_t external_memory()
Definition: v8-statistics.h:152
size_t total_heap_size()
Definition: v8-statistics.h:143
size_t peak_malloced_memory()
Definition: v8-statistics.h:153
Definition: v8-isolate.h:261
Definition: v8-local-handle.h:266
Definition: v8-statistics.h:55
static std::unique_ptr< MeasureMemoryDelegate > Default(Isolate *isolate, Local< Context > context, Local< Promise::Resolver > promise_resolver, MeasureMemoryMode mode)
virtual bool ShouldMeasure(Local< Context > context)=0
virtual ~MeasureMemoryDelegate()=default
virtual void MeasurementComplete(Result result)
Definition: v8-statistics.h:93
Definition: v8-memory-span.h:64
Definition: v8-statistics.h:116
size_t read_only_space_physical_size()
Definition: v8-statistics.h:121
size_t read_only_space_size()
Definition: v8-statistics.h:119
size_t read_only_space_used_size()
Definition: v8-statistics.h:120
Definition: v8-initialization.h:61
Definition: libplatform.h:15
MeasureMemoryExecution
Definition: v8-statistics.h:43
MeasureMemoryMode
Definition: v8-statistics.h:34
Definition: v8-statistics.h:65
size_t wasm_code_size_in_bytes
Definition: v8-statistics.h:82
size_t wasm_metadata_size_in_bytes
Definition: v8-statistics.h:85
size_t unattributed_size_in_bytes
Definition: v8-statistics.h:79
const MemorySpan< const size_t > & sizes_in_bytes
Definition: v8-statistics.h:73
const MemorySpan< const Local< Context > > & contexts
Definition: v8-statistics.h:72
#define V8_EXPORT
Definition: v8config.h:793