Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Float16Array support #23512

Merged
merged 6 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cli/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ fn resolve_flags_and_init(
// Using same default as VSCode:
// https://github.com/microsoft/vscode/blob/48d4ba271686e8072fc6674137415bc80d936bc7/extensions/typescript-language-features/src/configuration/configuration.ts#L213-L214
DenoSubcommand::Lsp => vec!["--max-old-space-size=3072".to_string()],
_ => vec!["--js-float16array".to_string()],
_ => vec![],
};

init_v8_flags(&default_v8_flags, &flags.v8_flags, get_v8_flags_from_env());
Expand Down
4 changes: 4 additions & 0 deletions ext/node/polyfills/internal/util/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ export function isBigUint64Array(value: unknown): value is BigUint64Array {
return TypedArrayPrototypeGetSymbolToStringTag(value) === "BigUint64Array";
}

export function isFloat16Array(value: unknown): value is Float16Array {
return TypedArrayPrototypeGetSymbolToStringTag(value) === "Float16Array";
}

export function isFloat32Array(value: unknown): value is Float32Array {
return TypedArrayPrototypeGetSymbolToStringTag(value) === "Float32Array";
}
Expand Down
4 changes: 2 additions & 2 deletions ext/web/02_structured_clone.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ const {
Uint16Array,
Uint32Array,
BigUint64Array,
Float16Array,
Float32Array,
Float64Array,
} = primordials;
Expand All @@ -59,7 +58,7 @@ function cloneArrayBuffer(
);
}

// TODO(petamoriken): Resizable ArrayBuffer support in the future
// TODO(petamoriken): add Resizable ArrayBuffer support
/** Clone a value in a similar way to structured cloning. It is similar to a
* StructureDeserialize(StructuredSerialize(...)). */
function structuredClone(value) {
Expand Down Expand Up @@ -117,6 +116,7 @@ function structuredClone(value) {
Constructor = BigUint64Array;
break;
case "Float16Array":
// TODO(petamoriken): add Float16Array to primordials
Constructor = Float16Array;
break;
case "Float32Array":
Expand Down
4 changes: 4 additions & 0 deletions ext/web/06_streams.js
Original file line number Diff line number Diff line change
Expand Up @@ -1995,6 +1995,10 @@ function readableByteStreamControllerPullInto(
case "Uint32Array":
ctor = Uint32Array;
break;
case "Float16Array":
// TODO(petamoriken): add Float16Array to primordials
ctor = Float16Array;
break;
case "Float32Array":
ctor = Float32Array;
break;
Expand Down
2 changes: 2 additions & 0 deletions ext/webidl/00_webidl.js
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,8 @@ ArrayPrototypeForEach(
Uint16Array,
Uint32Array,
Uint8ClampedArray,
// TODO(petamoriken): add Float16Array converter
// Float16Array,
Float32Array,
Float64Array,
],
Expand Down
8 changes: 2 additions & 6 deletions tests/wpt/runner/expectation.json
Original file line number Diff line number Diff line change
Expand Up @@ -7158,12 +7158,8 @@
"response-from-stream.any.worker.html": true,
"response-cancel-stream.any.html": true,
"response-cancel-stream.any.worker.html": true,
"response-clone.any.html": [
"Check response clone use structureClone for teed ReadableStreams (Float16Arraychunk)"
],
"response-clone.any.worker.html": [
"Check response clone use structureClone for teed ReadableStreams (Float16Arraychunk)"
],
"response-clone.any.html": true,
"response-clone.any.worker.html": true,
"response-consume-empty.any.html": [
"Consume empty FormData response body as text"
],
Expand Down