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(ext/web): use primordials of ES2024 ArrayBuffer transfer #24396

Merged
merged 4 commits into from
Jul 2, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
use ArrayBufferPrototypeTransferToFixedLength instead
  • Loading branch information
petamoriken committed Jul 2, 2024
commit c6d7b44c764cde0fcd1a7bb5f2a20d3a7e064d2a
18 changes: 11 additions & 7 deletions ext/web/06_streams.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 31,7 @@ const {
ArrayBufferPrototypeGetByteLength,
ArrayBufferPrototypeGetDetached,
ArrayBufferPrototypeSlice,
ArrayBufferPrototypeTransfer,
ArrayBufferPrototypeTransferToFixedLength,
ArrayPrototypeMap,
ArrayPrototypePush,
ArrayPrototypeShift,
Expand Down Expand Up @@ -1350,7 1350,7 @@ function readableByteStreamControllerEnqueue(controller, chunk) {
"chunk's buffer is detached and so cannot be enqueued",
);
}
const transferredBuffer = ArrayBufferPrototypeTransfer(buffer);
const transferredBuffer = ArrayBufferPrototypeTransferToFixedLength(buffer);
if (controller[_pendingPullIntos].length !== 0) {
const firstPendingPullInto = controller[_pendingPullIntos][0];
// deno-lint-ignore prefer-primordials
Expand All @@ -1360,7 1360,7 @@ function readableByteStreamControllerEnqueue(controller, chunk) {
);
}
readableByteStreamControllerInvalidateBYOBRequest(controller);
firstPendingPullInto.buffer = ArrayBufferPrototypeTransfer(
firstPendingPullInto.buffer = ArrayBufferPrototypeTransferToFixedLength(
// deno-lint-ignore prefer-primordials
firstPendingPullInto.buffer,
);
Expand Down Expand Up @@ -2020,7 2020,7 @@ function readableByteStreamControllerPullInto(
assert(minimumFill % elementSize === 0);

try {
buffer = ArrayBufferPrototypeTransfer(buffer);
buffer = ArrayBufferPrototypeTransferToFixedLength(buffer);
} catch (e) {
readIntoRequest.errorSteps(e);
return;
Expand Down Expand Up @@ -2114,7 2114,9 @@ function readableByteStreamControllerRespond(controller, bytesWritten) {
}
}
// deno-lint-ignore prefer-primordials
firstDescriptor.buffer = ArrayBufferPrototypeTransfer(firstDescriptor.buffer);
firstDescriptor.buffer = ArrayBufferPrototypeTransferToFixedLength(
firstDescriptor.buffer,
);
readableByteStreamControllerRespondInternal(controller, bytesWritten);
}

Expand Down Expand Up @@ -2331,7 2333,7 @@ function readableByteStreamControllerRespondWithNewView(controller, view) {
"The region specified by view is larger than byobRequest",
);
}
firstDescriptor.buffer = ArrayBufferPrototypeTransfer(buffer);
firstDescriptor.buffer = ArrayBufferPrototypeTransferToFixedLength(buffer);
readableByteStreamControllerRespondInternal(controller, byteLength);
}

Expand Down Expand Up @@ -2476,7 2478,9 @@ function readableByteStreamControllerConvertPullIntoDescriptor(
assert(bytesFilled <= pullIntoDescriptor.byteLength);
assert((bytesFilled % elementSize) === 0);
// deno-lint-ignore prefer-primordials
const buffer = ArrayBufferPrototypeTransfer(pullIntoDescriptor.buffer);
const buffer = ArrayBufferPrototypeTransferToFixedLength(
pullIntoDescriptor.buffer,
);
return new pullIntoDescriptor.viewConstructor(
buffer,
// deno-lint-ignore prefer-primordials
Expand Down
Loading