Support resizable typed arrays, ArrayBuffers, and DataViews#2273
Open
gbrail wants to merge 4 commits intomozilla:masterfrom
Open
Support resizable typed arrays, ArrayBuffers, and DataViews#2273gbrail wants to merge 4 commits intomozilla:masterfrom
gbrail wants to merge 4 commits intomozilla:masterfrom
Conversation
8ac7969 to
5810bd5
Compare
ca1c22a to
b443a10
Compare
rbri
reviewed
Mar 1, 2026
| import org.mozilla.javascript.drivers.ScriptTestsBase; | ||
|
|
||
| @RhinoTest("testsrc/jstests/harmony/dataview-resizablearraybuffer.js") | ||
| @LanguageVersion(Context.VERSION_ES6) |
Collaborator
There was a problem hiding this comment.
as this test and TypedArrayResizableArrayBufferTest running with version es6 - should we place them in the es6 folder instead of harmony
rbri
reviewed
Mar 1, 2026
|
|
||
| // Flags: --allow-natives-syntax --js-staging | ||
|
|
||
| // This file was imported from the V8 project and processed using Babel |
Collaborator
There was a problem hiding this comment.
do we need a similar comment at the top of typedarray-helpers.js and typedarray-resizablearraybuffer.js?
Adds support for resizable ArrayBuffers as specified in ES2024.
Constructor accepts optional maxByteLength parameter:
new ArrayBuffer(length, { maxByteLength })
New resize() method allows in-place buffer resizing:
- Grows or shrinks buffer up to maxByteLength
- Preserves existing data, zeros new bytes
- Throws TypeError if not resizable or detached
- Throws RangeError if exceeds maxByteLength
New properties:
- resizable: true if buffer has maxByteLength
- maxByteLength: maximum size (equals byteLength for fixed-length)
# Conflicts:
# tests/src/test/java/org/mozilla/javascript/tests/Test262SuiteTest.java
# tests/testsrc/test262.properties
Bring in test cases from the V8 test suite for more comprehensive testing, since test262 tests fail due to other problems. Fix some problems especially with auto-length typed arrays and views. Add Float16Array, since we already have the primitives supported.
b443a10 to
2202edc
Compare
Collaborator
Author
|
Makes sense to align these tests with the right language versions -- updated the test locations and added those comments. |
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
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.
This starts with the work that @anivar did in #2182 and adds some additional tests and fixes to make the tests work. The test262 tests for this feature are unhelpful because they depend on features that we don't implement like classes and block-scoped "const." Other tests from the V8 suite cover the same ground and I was able to transpile them with Babel so that they run. The result matches the spec quite well.
This implementation just implements resizing by allocating a new byte[] and copying. Once we are done with this one, and now that we have tests, I'll open a new one with a different optimization mode for resizing