From 562947e01268d03af2d0ffbbf51b6b19e24477ae Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Sat, 23 Dec 2023 13:38:24 +0100 Subject: [PATCH] lib: fix use of `--frozen-intrinsics` with `--jitless` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/51248 Fixes: https://github.com/nodejs/node/issues/51232 Reviewed-By: Michaël Zasso Reviewed-By: Richard Lau Reviewed-By: Vinícius Lourenço Claro Cardoso Reviewed-By: Luigi Pinca Reviewed-By: James M Snell --- lib/internal/freeze_intrinsics.js | 21 +++++++++++++-------- test/parallel/test-freeze-intrinsics.js | 2 +- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/lib/internal/freeze_intrinsics.js b/lib/internal/freeze_intrinsics.js index 793c19df1e9138..ab00f6b1c4a72f 100644 --- a/lib/internal/freeze_intrinsics.js +++ b/lib/internal/freeze_intrinsics.js @@ -220,13 +220,6 @@ module.exports = function() { // Other APIs / Web Compatibility Console.prototype, - WebAssembly.Module.prototype, - WebAssembly.Instance.prototype, - WebAssembly.Table.prototype, - WebAssembly.Memory.prototype, - WebAssembly.CompileError.prototype, - WebAssembly.LinkError.prototype, - WebAssembly.RuntimeError.prototype, ]; const intrinsics = [ // 10.2.4.1 ThrowTypeError @@ -349,7 +342,6 @@ module.exports = function() { setInterval, setTimeout, console, - WebAssembly, ]; if (typeof SharedArrayBuffer !== 'undefined') { // 25.2 @@ -357,6 +349,19 @@ module.exports = function() { ArrayPrototypePush(intrinsics, SharedArrayBuffer); } + if (typeof WebAssembly !== 'undefined') { + ArrayPrototypePush(intrinsicPrototypes, + WebAssembly.Module.prototype, + WebAssembly.Instance.prototype, + WebAssembly.Table.prototype, + WebAssembly.Memory.prototype, + WebAssembly.CompileError.prototype, + WebAssembly.LinkError.prototype, + WebAssembly.RuntimeError.prototype, + ); + ArrayPrototypePush(intrinsics, WebAssembly); + } + if (typeof Intl !== 'undefined') { ArrayPrototypePush(intrinsicPrototypes, Intl.Collator.prototype, diff --git a/test/parallel/test-freeze-intrinsics.js b/test/parallel/test-freeze-intrinsics.js index 4e20346a9deda8..b3a2503d1d5b40 100644 --- a/test/parallel/test-freeze-intrinsics.js +++ b/test/parallel/test-freeze-intrinsics.js @@ -1,4 +1,4 @@ -// Flags: --frozen-intrinsics +// Flags: --frozen-intrinsics --jitless 'use strict'; require('../common'); const assert = require('assert');