Skip to content

Commit 535faee

Browse files
committed
v8: export cpu_profiler_metadata_size in getHeapCodeStatistics
1 parent a2d86f6 commit 535faee

File tree

4 files changed

+13
-5
lines changed

4 files changed

+13
-5
lines changed

doc/api/v8.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,23 @@ added: v12.8.0
4141

4242
* Returns: {Object}
4343

44-
Returns an object with the following properties:
44+
Get statistics about code and its metadata in the heap, see V8
45+
`GetHeapCodeAndMetadataStatistics` API. Returns an object with the
46+
following properties:
4547

4648
* `code_and_metadata_size` {number}
4749
* `bytecode_and_metadata_size` {number}
4850
* `external_script_source_size` {number}
51+
* `cpu_profiler_metadata_size` {number}
4952

5053
<!-- eslint-skip -->
5154

5255
```js
5356
{
5457
code_and_metadata_size: 212208,
5558
bytecode_and_metadata_size: 161368,
56-
external_script_source_size: 1410794
59+
external_script_source_size: 1410794,
60+
cpu_profiler_metadata_size: 0
5761
}
5862
```
5963

lib/v8.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,8 @@ const {
118118
// Properties for heap code statistics buffer extraction.
119119
kCodeAndMetadataSizeIndex,
120120
kBytecodeAndMetadataSizeIndex,
121-
kExternalScriptSourceSizeIndex
121+
kExternalScriptSourceSizeIndex,
122+
kCPUProfilerMetaDataSizeIndex
122123
} = binding;
123124

124125
const kNumberOfHeapSpaces = kHeapSpaces.length;
@@ -212,7 +213,8 @@ function getHeapCodeStatistics() {
212213
return {
213214
code_and_metadata_size: buffer[kCodeAndMetadataSizeIndex],
214215
bytecode_and_metadata_size: buffer[kBytecodeAndMetadataSizeIndex],
215-
external_script_source_size: buffer[kExternalScriptSourceSizeIndex]
216+
external_script_source_size: buffer[kExternalScriptSourceSizeIndex],
217+
cpu_profiler_metadata_size: buffer[kCPUProfilerMetaDataSizeIndex]
216218
};
217219
}
218220

src/node_v8.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ static constexpr size_t kHeapSpaceStatisticsPropertiesCount =
8080
#define HEAP_CODE_STATISTICS_PROPERTIES(V) \
8181
V(0, code_and_metadata_size, kCodeAndMetadataSizeIndex) \
8282
V(1, bytecode_and_metadata_size, kBytecodeAndMetadataSizeIndex) \
83-
V(2, external_script_source_size, kExternalScriptSourceSizeIndex)
83+
V(2, external_script_source_size, kExternalScriptSourceSizeIndex) \
84+
V(3, cpu_profiler_metadata_size, kCPUProfilerMetaDataSizeIndex)
8485

8586
#define V(a, b, c) +1
8687
static const size_t kHeapCodeStatisticsPropertiesCount =

test/parallel/test-v8-stats.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ const heapCodeStatistics = v8.getHeapCodeStatistics();
2626
const heapCodeStatisticsKeys = [
2727
'bytecode_and_metadata_size',
2828
'code_and_metadata_size',
29+
'cpu_profiler_metadata_size',
2930
'external_script_source_size'];
3031
assert.deepStrictEqual(Object.keys(heapCodeStatistics).sort(),
3132
heapCodeStatisticsKeys);

0 commit comments

Comments
 (0)