-
Notifications
You must be signed in to change notification settings - Fork 185
Fix BufferSource algorithms for shared and resizable buffers
#1529
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
Open
MattiasBuelens
wants to merge
15
commits into
whatwg:main
Choose a base branch
from
MattiasBuelens:buffer-source-fixes
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Contributor
Author
|
@annevk Could you assign reviewer(s) to this? Thanks! 🙏 |
Member
annevk
reviewed
Nov 24, 2025
Member
annevk
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did an editorial pass.
Co-authored-by: Anne van Kesteren <annevk@annevk.nl>
Co-authored-by: Anne van Kesteren <annevk@annevk.nl>
MattiasBuelens
commented
Nov 24, 2025
Contributor
Author
MattiasBuelens
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quick self-review.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Previously, many
BufferSourcealgorithms were using internal slots such as[[ByteOffset]]and[[ByteLength]]directly. However, with the addition ofSharedArrayBuffer(#353, #1311) and[AllowResizable](#982), this comes with extra caveats:SharedArrayBuffer, we need to useArrayBufferByteLengthto matchSharedArrayBuffer.prototype.byteLength.TypedArrayByteLength. Similarly, for a length-trackingDataView, we need to useGetViewByteLength.DataView, we first need to check if the view is still inbounds usingIsArrayBufferViewOutOfBounds.Transferring an
ArrayBuffermust also take into account whether it should remain resizable or not. Fortunately, we can use the newArrayBufferCopyAndDetachoperation for that.preserveResizabilityparameter to "transfer anArrayBuffer", so specifications can choose whether to preserve resizability or not. By default, this is not preserved. (Most specs aren't using[AllowResizable]yet anyway.)realmparameter of that algorithm, sinceArrayBufferCopyAndDetachdoesn't accept such a parameter. According to WebDex, no specs were actually using that parameter anyway.Open questions:
SharedArrayBuffer, what memory ordering should we use? ECMAScript seems to useSEQ-CSTpretty much everywhere (e.g.%TypedArray%.prototype.byteLength), but "get a copy of the bytes" usesUNORDEREDforGetValueFromBuffer.Fixes #1312.
Fixes #1385.
(See WHATWG Working Mode: Changes for more details.)
Preview | Diff