mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-19 07:49:05 +00:00
LibJS: Add support for Float16Array
Implements TC39 stage three proposal for Float16Arrays: https://tc39.es/proposal-float16array
This commit is contained in:
parent
c1ec2ddb63
commit
ea20545853
Notes:
github-actions[bot]
2024-11-10 21:49:20 +00:00
Author: https://github.com/rmg-x
Commit: ea20545853
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2184
Reviewed-by: https://github.com/ADKaster ✅
Reviewed-by: https://github.com/trflynn89
49 changed files with 133 additions and 8 deletions
8
Libraries/LibJS/Tests/builtins/Math/Math.f16round.js
Normal file
8
Libraries/LibJS/Tests/builtins/Math/Math.f16round.js
Normal file
|
@ -0,0 +1,8 @@
|
|||
test("basic functionality", () => {
|
||||
expect(Math.f16round).toHaveLength(1);
|
||||
|
||||
expect(Math.f16round(5.5)).toBe(5.5);
|
||||
expect(Math.f16round(5.05)).toBe(5.05078125);
|
||||
expect(Math.f16round(5)).toBe(5);
|
||||
expect(Math.f16round(-5.05)).toBe(-5.05078125);
|
||||
});
|
|
@ -8,6 +8,7 @@ test("basic functionality", () => {
|
|||
expect(Int16Array.BYTES_PER_ELEMENT).toBe(2);
|
||||
expect(Int32Array.BYTES_PER_ELEMENT).toBe(4);
|
||||
expect(BigInt64Array.BYTES_PER_ELEMENT).toBe(8);
|
||||
expect(Float16Array.BYTES_PER_ELEMENT).toBe(2);
|
||||
expect(Float32Array.BYTES_PER_ELEMENT).toBe(4);
|
||||
expect(Float64Array.BYTES_PER_ELEMENT).toBe(8);
|
||||
});
|
||||
|
|
|
@ -6,6 +6,7 @@ const TYPED_ARRAYS = [
|
|||
Int8Array,
|
||||
Int16Array,
|
||||
Int32Array,
|
||||
Float16Array,
|
||||
Float32Array,
|
||||
Float64Array,
|
||||
];
|
||||
|
|
|
@ -6,6 +6,7 @@ const TYPED_ARRAYS = [
|
|||
Int8Array,
|
||||
Int16Array,
|
||||
Int32Array,
|
||||
Float16Array,
|
||||
Float32Array,
|
||||
Float64Array,
|
||||
];
|
||||
|
@ -185,8 +186,9 @@ test("typed array from TypedArray element cast", () => {
|
|||
[0x100, 0xff],
|
||||
[0x100, 0xff],
|
||||
[0x100, 0xff],
|
||||
[0x100, 0xff],
|
||||
];
|
||||
const u8Expected = [0xff, 0xff, 0xff, 0xff, -1, 0xff, 0xff, 0xff, 0xff];
|
||||
const u8Expected = [0xff, 0xff, 0xff, 0xff, -1, 0xff, 0xff, 0xff, 0xff, 0xff];
|
||||
|
||||
TYPED_ARRAYS.forEach((T, i) => {
|
||||
const newArrFromU32 = new T(u32Array);
|
||||
|
|
|
@ -6,6 +6,7 @@ const TYPED_ARRAYS = [
|
|||
Int8Array,
|
||||
Int16Array,
|
||||
Int32Array,
|
||||
Float16Array,
|
||||
Float32Array,
|
||||
Float64Array,
|
||||
];
|
||||
|
|
|
@ -6,6 +6,7 @@ const TYPED_ARRAYS = [
|
|||
Int8Array,
|
||||
Int16Array,
|
||||
Int32Array,
|
||||
Float16Array,
|
||||
Float32Array,
|
||||
Float64Array,
|
||||
];
|
||||
|
|
|
@ -8,6 +8,7 @@ const TYPED_ARRAYS = [
|
|||
{ array: Int16Array, expected: 2 },
|
||||
{ array: Int32Array, expected: 4 },
|
||||
{ array: BigInt64Array, expected: 8 },
|
||||
{ array: Float16Array, expected: 2 },
|
||||
{ array: Float32Array, expected: 4 },
|
||||
{ array: Float64Array, expected: 8 },
|
||||
];
|
||||
|
|
|
@ -6,6 +6,7 @@ const TYPED_ARRAYS = [
|
|||
Int8Array,
|
||||
Int16Array,
|
||||
Int32Array,
|
||||
Float16Array,
|
||||
Float32Array,
|
||||
Float64Array,
|
||||
];
|
||||
|
|
|
@ -8,6 +8,7 @@ const TYPED_ARRAYS = [
|
|||
Int16Array,
|
||||
Int32Array,
|
||||
BigInt64Array,
|
||||
Float16Array,
|
||||
Float32Array,
|
||||
Float64Array,
|
||||
];
|
||||
|
|
|
@ -8,6 +8,7 @@ const TYPED_ARRAYS = [
|
|||
{ array: Int16Array, expected: 6 },
|
||||
{ array: Int32Array, expected: 12 },
|
||||
{ array: BigInt64Array, expected: 24 },
|
||||
{ array: Float16Array, expected: 6 },
|
||||
{ array: Float32Array, expected: 12 },
|
||||
{ array: Float64Array, expected: 24 },
|
||||
];
|
||||
|
|
|
@ -8,6 +8,7 @@ const TYPED_ARRAYS = [
|
|||
Int16Array,
|
||||
Int32Array,
|
||||
BigInt64Array,
|
||||
Float16Array,
|
||||
Float32Array,
|
||||
Float64Array,
|
||||
];
|
||||
|
|
|
@ -6,6 +6,7 @@ const TYPED_ARRAYS = [
|
|||
Int8Array,
|
||||
Int16Array,
|
||||
Int32Array,
|
||||
Float16Array,
|
||||
Float32Array,
|
||||
Float64Array,
|
||||
];
|
||||
|
|
|
@ -6,6 +6,7 @@ const TYPED_ARRAYS = [
|
|||
Int8Array,
|
||||
Int16Array,
|
||||
Int32Array,
|
||||
Float16Array,
|
||||
Float32Array,
|
||||
Float64Array,
|
||||
];
|
||||
|
|
|
@ -6,6 +6,7 @@ const TYPED_ARRAYS = [
|
|||
Int8Array,
|
||||
Int16Array,
|
||||
Int32Array,
|
||||
Float16Array,
|
||||
Float32Array,
|
||||
Float64Array,
|
||||
];
|
||||
|
|
|
@ -6,6 +6,7 @@ const TYPED_ARRAYS = [
|
|||
Int8Array,
|
||||
Int16Array,
|
||||
Int32Array,
|
||||
Float16Array,
|
||||
Float32Array,
|
||||
Float64Array,
|
||||
];
|
||||
|
|
|
@ -6,6 +6,7 @@ const TYPED_ARRAYS = [
|
|||
Int8Array,
|
||||
Int16Array,
|
||||
Int32Array,
|
||||
Float16Array,
|
||||
Float32Array,
|
||||
Float64Array,
|
||||
];
|
||||
|
|
|
@ -6,6 +6,7 @@ const TYPED_ARRAYS = [
|
|||
Int8Array,
|
||||
Int16Array,
|
||||
Int32Array,
|
||||
Float16Array,
|
||||
Float32Array,
|
||||
Float64Array,
|
||||
];
|
||||
|
|
|
@ -6,6 +6,7 @@ const TYPED_ARRAYS = [
|
|||
Int8Array,
|
||||
Int16Array,
|
||||
Int32Array,
|
||||
Float16Array,
|
||||
Float32Array,
|
||||
Float64Array,
|
||||
];
|
||||
|
|
|
@ -6,6 +6,7 @@ const TYPED_ARRAYS = [
|
|||
Int8Array,
|
||||
Int16Array,
|
||||
Int32Array,
|
||||
Float16Array,
|
||||
Float32Array,
|
||||
Float64Array,
|
||||
];
|
||||
|
|
|
@ -6,6 +6,7 @@ const TYPED_ARRAYS = [
|
|||
Int8Array,
|
||||
Int16Array,
|
||||
Int32Array,
|
||||
Float16Array,
|
||||
Float32Array,
|
||||
Float64Array,
|
||||
];
|
||||
|
|
|
@ -6,6 +6,7 @@ const TYPED_ARRAYS = [
|
|||
Int8Array,
|
||||
Int16Array,
|
||||
Int32Array,
|
||||
Float16Array,
|
||||
Float32Array,
|
||||
Float64Array,
|
||||
];
|
||||
|
|
|
@ -6,6 +6,7 @@ const TYPED_ARRAYS = [
|
|||
Int8Array,
|
||||
Int16Array,
|
||||
Int32Array,
|
||||
Float16Array,
|
||||
Float32Array,
|
||||
Float64Array,
|
||||
];
|
||||
|
|
|
@ -6,6 +6,7 @@ const TYPED_ARRAYS = [
|
|||
Int8Array,
|
||||
Int16Array,
|
||||
Int32Array,
|
||||
Float16Array,
|
||||
Float32Array,
|
||||
Float64Array,
|
||||
];
|
||||
|
|
|
@ -6,6 +6,7 @@ const TYPED_ARRAYS = [
|
|||
Int8Array,
|
||||
Int16Array,
|
||||
Int32Array,
|
||||
Float16Array,
|
||||
Float32Array,
|
||||
Float64Array,
|
||||
];
|
||||
|
|
|
@ -6,6 +6,7 @@ const TYPED_ARRAYS = [
|
|||
Int8Array,
|
||||
Int16Array,
|
||||
Int32Array,
|
||||
Float16Array,
|
||||
Float32Array,
|
||||
Float64Array,
|
||||
];
|
||||
|
|
|
@ -8,6 +8,7 @@ const TYPED_ARRAYS = [
|
|||
Int16Array,
|
||||
Int32Array,
|
||||
BigInt64Array,
|
||||
Float16Array,
|
||||
Float32Array,
|
||||
Float64Array,
|
||||
];
|
||||
|
|
|
@ -6,6 +6,7 @@ const TYPED_ARRAYS = [
|
|||
Int8Array,
|
||||
Int16Array,
|
||||
Int32Array,
|
||||
Float16Array,
|
||||
Float32Array,
|
||||
Float64Array,
|
||||
];
|
||||
|
|
|
@ -6,6 +6,7 @@ const TYPED_ARRAYS = [
|
|||
Int8Array,
|
||||
Int16Array,
|
||||
Int32Array,
|
||||
Float16Array,
|
||||
Float32Array,
|
||||
Float64Array,
|
||||
];
|
||||
|
|
|
@ -6,6 +6,7 @@ const TYPED_ARRAYS = [
|
|||
Int8Array,
|
||||
Int16Array,
|
||||
Int32Array,
|
||||
Float16Array,
|
||||
Float32Array,
|
||||
Float64Array,
|
||||
];
|
||||
|
|
|
@ -6,6 +6,7 @@ const TYPED_ARRAYS = [
|
|||
Int8Array,
|
||||
Int16Array,
|
||||
Int32Array,
|
||||
Float16Array,
|
||||
Float32Array,
|
||||
Float64Array,
|
||||
];
|
||||
|
|
|
@ -6,6 +6,7 @@ const TYPED_ARRAYS = [
|
|||
{ array: Int8Array, maxUnsignedInteger: 2 ** 7 - 1 },
|
||||
{ array: Int16Array, maxUnsignedInteger: 2 ** 15 - 1 },
|
||||
{ array: Int32Array, maxUnsignedInteger: 2 ** 31 - 1 },
|
||||
{ array: Float16Array, maxUnsignedInteger: 2 ** 11 - 1 },
|
||||
{ array: Float32Array, maxUnsignedInteger: 2 ** 24 - 1 },
|
||||
{ array: Float64Array, maxUnsignedInteger: Number.MAX_SAFE_INTEGER },
|
||||
];
|
||||
|
|
|
@ -6,6 +6,7 @@ const TYPED_ARRAYS = [
|
|||
Int8Array,
|
||||
Int16Array,
|
||||
Int32Array,
|
||||
Float16Array,
|
||||
Float32Array,
|
||||
Float64Array,
|
||||
];
|
||||
|
|
|
@ -6,6 +6,7 @@ const TYPED_ARRAYS = [
|
|||
Int8Array,
|
||||
Int16Array,
|
||||
Int32Array,
|
||||
Float16Array,
|
||||
Float32Array,
|
||||
Float64Array,
|
||||
];
|
||||
|
|
|
@ -6,6 +6,7 @@ const TYPED_ARRAYS = [
|
|||
Int8Array,
|
||||
Int16Array,
|
||||
Int32Array,
|
||||
Float16Array,
|
||||
Float32Array,
|
||||
Float64Array,
|
||||
];
|
||||
|
|
|
@ -6,6 +6,7 @@ const TYPED_ARRAYS = [
|
|||
Int8Array,
|
||||
Int16Array,
|
||||
Int32Array,
|
||||
Float16Array,
|
||||
Float32Array,
|
||||
Float64Array,
|
||||
];
|
||||
|
|
|
@ -6,6 +6,7 @@ const TYPED_ARRAYS = [
|
|||
Int8Array,
|
||||
Int16Array,
|
||||
Int32Array,
|
||||
Float16Array,
|
||||
Float32Array,
|
||||
Float64Array,
|
||||
];
|
||||
|
|
|
@ -6,6 +6,7 @@ const TYPED_ARRAYS = [
|
|||
Int8Array,
|
||||
Int16Array,
|
||||
Int32Array,
|
||||
Float16Array,
|
||||
Float32Array,
|
||||
Float64Array,
|
||||
];
|
||||
|
|
|
@ -6,6 +6,7 @@ const TYPED_ARRAYS = [
|
|||
Int8Array,
|
||||
Int16Array,
|
||||
Int32Array,
|
||||
Float16Array,
|
||||
Float32Array,
|
||||
Float64Array,
|
||||
];
|
||||
|
|
|
@ -6,6 +6,7 @@ const TYPED_ARRAYS = [
|
|||
Int8Array,
|
||||
Int16Array,
|
||||
Int32Array,
|
||||
Float16Array,
|
||||
Float32Array,
|
||||
Float64Array,
|
||||
];
|
||||
|
|
|
@ -6,6 +6,7 @@ const TYPED_ARRAYS = [
|
|||
Int8Array,
|
||||
Int16Array,
|
||||
Int32Array,
|
||||
Float16Array,
|
||||
Float32Array,
|
||||
Float64Array,
|
||||
];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue