From 4cd3d985103adfcbaf225a86164b0c08022d6de4 Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Tue, 1 Sep 2026 11:34:21 +0200 Subject: [PATCH] lib: use `Float16Array` from primordials MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/65702 Reviewed-By: Marco Ippolito Reviewed-By: Filip Skokan Reviewed-By: Juan José Arboleda Signed-off-by: Antoine du Hamel --- lib/eslint.config_partial.mjs | 7 +------ lib/internal/freeze_intrinsics.js | 4 ++++ lib/internal/per_context/primordials.js | 1 + lib/internal/util/comparisons.js | 7 ++----- lib/v8.js | 4 +--- 5 files changed, 9 insertions(+), 14 deletions(-) diff --git a/lib/eslint.config_partial.mjs b/lib/eslint.config_partial.mjs index 638e60c923b..9240b00ac70 100644 --- a/lib/eslint.config_partial.mjs +++ b/lib/eslint.config_partial.mjs @@ -412,12 +412,6 @@ export default [ name: 'SubtleCrypto', message: "Use `const { SubtleCrypto } = require('internal/crypto/webcrypto');` instead of the global.", }, - // Float16Array is not available in primordials because it can be - // disabled with --no-js-float16array CLI flag. - { - name: 'Float16Array', - message: 'Use `const { Float16Array } = globalThis;` instead of the global.', - }, // DisposableStack and AsyncDisposableStack are not available in primordials because they can be // disabled with --no-js-explicit-resource-management CLI flag. { @@ -478,6 +472,7 @@ export default [ name: 'FinalizationRegistry', into: 'Safe', }, + { name: 'Float16Array' }, { name: 'Float32Array' }, { name: 'Float64Array' }, { name: 'Function' }, diff --git a/lib/internal/freeze_intrinsics.js b/lib/internal/freeze_intrinsics.js index 05437199726..5dd425cb093 100644 --- a/lib/internal/freeze_intrinsics.js +++ b/lib/internal/freeze_intrinsics.js @@ -54,6 +54,8 @@ const { EvalErrorPrototype, FinalizationRegistry, FinalizationRegistryPrototype, + Float16Array, + Float16ArrayPrototype, Float32Array, Float32ArrayPrototype, Float64Array, @@ -196,6 +198,7 @@ module.exports = function() { Uint16ArrayPrototype, Int32ArrayPrototype, Uint32ArrayPrototype, + Float16ArrayPrototype, Float32ArrayPrototype, Float64ArrayPrototype, BigInt64ArrayPrototype, @@ -296,6 +299,7 @@ module.exports = function() { Uint16Array, Int32Array, Uint32Array, + Float16Array, Float32Array, Float64Array, BigInt64Array, diff --git a/lib/internal/per_context/primordials.js b/lib/internal/per_context/primordials.js index 49576c2d949..2e610f4ab50 100644 --- a/lib/internal/per_context/primordials.js +++ b/lib/internal/per_context/primordials.js @@ -196,6 +196,7 @@ function copyPrototype(src, dest, prefix) { 'Error', 'EvalError', 'FinalizationRegistry', + 'Float16Array', 'Float32Array', 'Float64Array', 'Function', diff --git a/lib/internal/util/comparisons.js b/lib/internal/util/comparisons.js index 6b608a66733..92594e8994f 100644 --- a/lib/internal/util/comparisons.js +++ b/lib/internal/util/comparisons.js @@ -15,6 +15,7 @@ const { Date, DatePrototypeGetTime, Error, + Float16Array, Float32Array, Float64Array, Function, @@ -50,7 +51,6 @@ const { Uint8ClampedArray, WeakMap, WeakSet, - globalThis: { Float16Array }, } = primordials; const { compare } = internalBinding('buffer'); @@ -70,6 +70,7 @@ const wellKnownConstructors = new SafeSet() .add(DataView) .add(Date) .add(Error) + .add(Float16Array) .add(Float32Array) .add(Float64Array) .add(Function) @@ -91,10 +92,6 @@ const wellKnownConstructors = new SafeSet() .add(WeakMap) .add(WeakSet); -if (Float16Array) { // TODO(BridgeAR): Remove when Flag got removed from V8 - wellKnownConstructors.add(Float16Array); -} - const types = require('internal/util/types'); const { isAnyArrayBuffer, diff --git a/lib/v8.js b/lib/v8.js index b76722a3e61..ea3366bb961 100644 --- a/lib/v8.js +++ b/lib/v8.js @@ -20,6 +20,7 @@ const { BigUint64Array, DataView, Error, + Float16Array, Float32Array, Float64Array, Int16Array, @@ -32,9 +33,6 @@ const { Uint32Array, Uint8Array, Uint8ClampedArray, - globalThis: { - Float16Array, - }, } = primordials; const { Buffer } = require('buffer');