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

feat(ext/web): BYOB support for ReadableStream #12616

Merged
merged 16 commits into from
Nov 3, 2021

Conversation

crowlKats
Copy link
Member

@crowlKats crowlKats commented Oct 31, 2021

Closes #11025

Copy link
Contributor

@kitsonk kitsonk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there no WPT tests that need to be enabled?

@crowlKats
Copy link
Member Author

crowlKats commented Oct 31, 2021

Yes, its not completely done yet. there are a few TODOs that hopefully will get resolved in the morning. once those are solved, I will enable all the WPT tests related to this, and then it should be ready for merging if there are no issues

Copy link
Member

@lucacasonato lucacasonato left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, did an initial review. This looks very promising.

ext/web/06_streams.js Outdated Show resolved Hide resolved
ext/web/06_streams.js Show resolved Hide resolved
ext/web/06_streams.js Outdated Show resolved Hide resolved
ext/web/06_streams.js Show resolved Hide resolved
ext/web/06_streams.js Outdated Show resolved Hide resolved
ext/web/06_streams.js Show resolved Hide resolved
ext/web/06_streams.js Outdated Show resolved Hide resolved
ext/web/06_streams.js Outdated Show resolved Hide resolved
ext/web/06_streams.js Outdated Show resolved Hide resolved
ext/web/06_streams.js Outdated Show resolved Hide resolved
*/
function canTransferArrayBuffer(O) {
assert(typeof O === "object");
assert(O instanceof ArrayBuffer || O instanceof SharedArrayBuffer);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SharedArrayBuffers aren't transferable, and I don't think this spec algorithm is meant to be passed a SAB.

if (isDetachedBuffer(O)) {
return false;
}
// TODO(@crowlKats): 4. If SameValue(O.[[ArrayBufferDetachKey]], undefined) is false, return false.
Copy link
Contributor

@andreubotella andreubotella Nov 2, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this check is the same as v8::ArrayBuffer::is_detachable. The reason for this seems to be to make it impossible to detach the buffer that backs a WebAssembly.Memory object other than through its grow method (https://webassembly.github.io/spec/js-api/#create-a-memory-buffer).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. I suggest we do this in a follow up, as it requires core bindings.

"ReadableStream with byte source: respondWithNewView() with a zero-length view (in the closed state)",
"ReadableStream with byte source: respondWithNewView() with a transferred non-zero-length view (in the readable state)",
"ReadableStream with byte source: respondWithNewView() with a transferred zero-length view (in the closed state)"
"ReadableStream with byte source: Respond to multiple pull() by separate enqueue()"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After investigation I am about 80% confident this test being broken is a result of our broken microtask queuing: #11731

Copy link
Member

@lucacasonato lucacasonato left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @crowlKats. Awesome to have this implemented now!

Other than the one failing test due to microtask queuing, all WPT pass.

@lucacasonato lucacasonato merged commit 95b2955 into denoland:main Nov 3, 2021
@crowlKats crowlKats deleted the byobstream branch November 3, 2021 10:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support BYOB ReadableStream
4 participants