File tree Expand file tree Collapse file tree 3 files changed +16
-1
lines changed Open diff view settings
Expand file tree Collapse file tree 3 files changed +16
-1
lines changed Open diff view settings
Original file line number Diff line number Diff line change @@ -343,6 +343,11 @@ export default [
343343 name : 'SubtleCrypto' ,
344344 message : "Use `const { SubtleCrypto } = require('internal/crypto/webcrypto');` instead of the global." ,
345345 } ,
346+ // Float16Array is not available in primordials because it's only available with --js-float16array CLI flag.
347+ {
348+ name : 'Float16Array' ,
349+ message : 'Use `const { Float16Array } = globalThis;` instead of the global.' ,
350+ } ,
346351 ] ,
347352 'no-restricted-modules' : [
348353 'error' ,
Original file line number Diff line number Diff line change @@ -31,6 +31,9 @@ const {
3131 Uint32Array,
3232 Uint8Array,
3333 Uint8ClampedArray,
34+ globalThis : {
35+ Float16Array,
36+ } ,
3437} = primordials ;
3538
3639const { Buffer } = require ( 'buffer' ) ;
@@ -63,6 +66,7 @@ const {
6366} = require ( 'internal/heap_utils' ) ;
6467const promiseHooks = require ( 'internal/promise_hooks' ) ;
6568const { getOptionValue } = require ( 'internal/options' ) ;
69+
6670/**
6771 * Generates a snapshot of the current V8 heap
6872 * and writes it to a JSON file.
@@ -289,6 +293,7 @@ function arrayBufferViewTypeToIndex(abView) {
289293 // Index 10 is FastBuffer.
290294 if ( type === '[object BigInt64Array]' ) return 11 ;
291295 if ( type === '[object BigUint64Array]' ) return 12 ;
296+ if ( type === '[object Float16Array]' ) return 13 ;
292297 return - 1 ;
293298}
294299
@@ -306,6 +311,7 @@ function arrayBufferViewIndexToType(index) {
306311 if ( index === 10 ) return FastBuffer ;
307312 if ( index === 11 ) return BigInt64Array ;
308313 if ( index === 12 ) return BigUint64Array ;
314+ if ( index === 13 ) return Float16Array ;
309315 return undefined ;
310316}
311317
Original file line number Diff line number Diff line change 1- // Flags: --expose-internals
1+ // Flags: --expose-internals --js-float16array
22
33'use strict' ;
44
@@ -7,6 +7,9 @@ const { internalBinding } = require('internal/test/binding');
77const assert = require ( 'assert' ) ;
88const v8 = require ( 'v8' ) ;
99const os = require ( 'os' ) ;
10+ // TODO(bartlomieju): once `Float16Array` is available in stable V8,
11+ // remove this line and `--js-float16array` flag up top
12+ const { Float16Array } = globalThis ;
1013
1114const circular = { } ;
1215circular . circular = circular ;
@@ -26,6 +29,7 @@ const objects = [
2629 Buffer . from ( [ 1 , 2 , 3 , 4 ] ) ,
2730 new BigInt64Array ( [ 42n ] ) ,
2831 new BigUint64Array ( [ 42n ] ) ,
32+ new Float16Array ( [ 1 , 2 , 3 , 4 ] ) ,
2933 undefined ,
3034 null ,
3135 42 ,
You can’t perform that action at this time.
0 commit comments