Skip to content

Support resizable typed arrays, ArrayBuffers, and DataViews#2273

Open
gbrail wants to merge 4 commits intomozilla:masterfrom
gbrail:greg-ani-resizable
Open

Support resizable typed arrays, ArrayBuffers, and DataViews#2273
gbrail wants to merge 4 commits intomozilla:masterfrom
gbrail:greg-ani-resizable

Conversation

@gbrail
Copy link
Collaborator

@gbrail gbrail commented Jan 29, 2026

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

import org.mozilla.javascript.drivers.ScriptTestsBase;

@RhinoTest("testsrc/jstests/harmony/dataview-resizablearraybuffer.js")
@LanguageVersion(Context.VERSION_ES6)
Copy link
Collaborator

Choose a reason for hiding this comment

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

as this test and TypedArrayResizableArrayBufferTest running with version es6 - should we place them in the es6 folder instead of harmony


// Flags: --allow-natives-syntax --js-staging

// This file was imported from the V8 project and processed using Babel
Copy link
Collaborator

Choose a reason for hiding this comment

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

do we need a similar comment at the top of typedarray-helpers.js and typedarray-resizablearraybuffer.js?

anivar and others added 4 commits March 7, 2026 17:00
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.
@gbrail gbrail force-pushed the greg-ani-resizable branch from b443a10 to 2202edc Compare March 8, 2026 03:03
@gbrail
Copy link
Collaborator Author

gbrail commented Mar 8, 2026

Makes sense to align these tests with the right language versions -- updated the test locations and added those comments.

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.

3 participants