From a3830ebacbc9430345ef3723574feee32b622a26 Mon Sep 17 00:00:00 2001 From: ishabi Date: Sun, 28 Dec 2025 11:34:09 +0100 Subject: [PATCH] v8: add GCProfiler support for erm --- lib/v8.js | 4 +++ .../test-v8-collect-gc-profile-using.js | 26 +++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 test/parallel/test-v8-collect-gc-profile-using.js diff --git a/lib/v8.js b/lib/v8.js index 54395945aa1787..c0d4074aac21d5 100644 --- a/lib/v8.js +++ b/lib/v8.js @@ -488,6 +488,10 @@ class GCProfiler { return JSONParse(data); } } + + [SymbolDispose]() { + this.stop(); + } } module.exports = { diff --git a/test/parallel/test-v8-collect-gc-profile-using.js b/test/parallel/test-v8-collect-gc-profile-using.js new file mode 100644 index 00000000000000..4e048548f29868 --- /dev/null +++ b/test/parallel/test-v8-collect-gc-profile-using.js @@ -0,0 +1,26 @@ +'use strict'; + +require('../common'); +const assert = require('assert'); +const { GCProfiler } = require('v8'); + +{ + const profiler = new GCProfiler(); + profiler.start(); + + const result = profiler[Symbol.dispose](); + + assert.strictEqual(result, undefined); + assert.strictEqual(profiler.stop(), undefined); +} + +{ + const profiler = new GCProfiler(); + profiler.start(); + + profiler[Symbol.dispose](); + // Repeat invocations should not throw + profiler[Symbol.dispose](); + + assert.strictEqual(profiler.stop(), undefined); +}