v8: export cpu_profiler_metadata_size in getHeapCodeStatistics

PR-URL: https://github.com/nodejs/node/pull/42818
Reviewed-By: Darshan Sen <raisinten@gmail.com>
This commit is contained in:
theanarkh 2022-04-29 23:21:41 +08:00 committed by GitHub
parent 27ecf1d94c
commit 000a0c853b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 5 deletions

View File

@ -41,11 +41,14 @@ added: v12.8.0
* Returns: {Object}
Returns an object with the following properties:
Get statistics about code and its metadata in the heap, see V8
[`GetHeapCodeAndMetadataStatistics`][] API. Returns an object with the
following properties:
* `code_and_metadata_size` {number}
* `bytecode_and_metadata_size` {number}
* `external_script_source_size` {number}
* `cpu_profiler_metadata_size` {number}
<!-- eslint-skip -->
@ -53,7 +56,8 @@ Returns an object with the following properties:
{
code_and_metadata_size: 212208,
bytecode_and_metadata_size: 161368,
external_script_source_size: 1410794
external_script_source_size: 1410794,
cpu_profiler_metadata_size: 0,
}
```
@ -882,6 +886,7 @@ occur synchronously in the case of `Promise.resolve()` or `Promise.reject()`.
[`Deserializer`]: #class-v8deserializer
[`ERR_BUFFER_TOO_LARGE`]: errors.md#err_buffer_too_large
[`Error`]: errors.md#class-error
[`GetHeapCodeAndMetadataStatistics`]: https://v8docs.nodesource.com/node-13.2/d5/dda/classv8_1_1_isolate.html#a6079122af17612ef54ef3348ce170866
[`GetHeapSpaceStatistics`]: https://v8docs.nodesource.com/node-13.2/d5/dda/classv8_1_1_isolate.html#ac673576f24fdc7a33378f8f57e1d13a4
[`NODE_V8_COVERAGE`]: cli.md#node_v8_coveragedir
[`Serializer`]: #class-v8serializer

View File

@ -121,7 +121,8 @@ const {
// Properties for heap code statistics buffer extraction.
kCodeAndMetadataSizeIndex,
kBytecodeAndMetadataSizeIndex,
kExternalScriptSourceSizeIndex
kExternalScriptSourceSizeIndex,
kCPUProfilerMetaDataSizeIndex,
} = binding;
const kNumberOfHeapSpaces = kHeapSpaces.length;
@ -209,6 +210,7 @@ function getHeapSpaceStatistics() {
* code_and_metadata_size: number;
* bytecode_and_metadata_size: number;
* external_script_source_size: number;
* cpu_profiler_metadata_size: number;
* }}
*/
function getHeapCodeStatistics() {
@ -218,7 +220,8 @@ function getHeapCodeStatistics() {
return {
code_and_metadata_size: buffer[kCodeAndMetadataSizeIndex],
bytecode_and_metadata_size: buffer[kBytecodeAndMetadataSizeIndex],
external_script_source_size: buffer[kExternalScriptSourceSizeIndex]
external_script_source_size: buffer[kExternalScriptSourceSizeIndex],
cpu_profiler_metadata_size: buffer[kCPUProfilerMetaDataSizeIndex],
};
}

View File

@ -82,7 +82,8 @@ static constexpr size_t kHeapSpaceStatisticsPropertiesCount =
#define HEAP_CODE_STATISTICS_PROPERTIES(V) \
V(0, code_and_metadata_size, kCodeAndMetadataSizeIndex) \
V(1, bytecode_and_metadata_size, kBytecodeAndMetadataSizeIndex) \
V(2, external_script_source_size, kExternalScriptSourceSizeIndex)
V(2, external_script_source_size, kExternalScriptSourceSizeIndex) \
V(3, cpu_profiler_metadata_size, kCPUProfilerMetaDataSizeIndex)
#define V(a, b, c) +1
static const size_t kHeapCodeStatisticsPropertiesCount =

View File

@ -29,6 +29,7 @@ const heapCodeStatistics = v8.getHeapCodeStatistics();
const heapCodeStatisticsKeys = [
'bytecode_and_metadata_size',
'code_and_metadata_size',
'cpu_profiler_metadata_size',
'external_script_source_size'];
assert.deepStrictEqual(Object.keys(heapCodeStatistics).sort(),
heapCodeStatisticsKeys);