Skip to content

add several TypedArray methods to Rust JSG#6386

Merged
anonrig merged 2 commits intomainfrom
yagiz/add-typed-array-methods
Mar 26, 2026
Merged

add several TypedArray methods to Rust JSG#6386
anonrig merged 2 commits intomainfrom
yagiz/add-typed-array-methods

Conversation

@anonrig
Copy link
Copy Markdown
Member

@anonrig anonrig commented Mar 23, 2026

Adds byte_offset(), byte_length(), data(), as_slice() and as_mut_slice() methods for TypedArray (and other *Array structs)

Changes are splitted from #6360

@anonrig anonrig requested review from guybedford and jasnell March 23, 2026 16:34
@anonrig anonrig requested review from a team as code owners March 23, 2026 16:34
@anonrig anonrig force-pushed the yagiz/add-typed-array-methods branch from c1ad28b to 0cf950c Compare March 23, 2026 16:36
Copy link
Copy Markdown
Contributor

@ask-bonk ask-bonk bot left a comment

Choose a reason for hiding this comment

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

I'm Bonk, and I've done a quick review of your PR.

Adds byte_offset(), data(), as_slice(), as_mut_slice() methods to TypedArray locals, plus FromJS impls for Local<T> typed arrays. Overall well-structured with good test coverage.

Findings (highest severity first):

  1. [MED] as_mut_slice safety comment understates the aliasing risk — two different Local handles can alias the same buffer memory.
  2. [LOW] local_typed_array_byte_length is declared in FFI (C++, header, and Rust bridge) but never called from Rust — dead code.

This review was generated by an AI assistant and may contain inaccuracies.

@ask-bonk
Copy link
Copy Markdown
Contributor

ask-bonk bot commented Mar 23, 2026

I'm Bonk, and I've done a quick review of your PR.

Review posted on PR #6386 with 2 findings:

  1. [MED] as_mut_slice safety comment — &mut self prevents aliasing the Local handle but not the underlying ArrayBuffer memory. Two different Local handles can back the same buffer. Suggested an improved safety comment (with code suggestion), or alternatively marking the method unsafe.

  2. [LOW] local_typed_array_byte_length — declared across all 3 FFI layers (Rust bridge, ffi.c++, ffi.h) but never called from Rust. Dead code unless intended for future use.

github run

@anonrig anonrig force-pushed the yagiz/add-typed-array-methods branch 2 times, most recently from 93902ba to 8e79e53 Compare March 23, 2026 16:40
@anonrig anonrig force-pushed the yagiz/add-typed-array-methods branch from 8e79e53 to 08cae6c Compare March 25, 2026 16:23
@anonrig anonrig requested review from guybedford and jasnell March 25, 2026 16:25
@anonrig anonrig enabled auto-merge (squash) March 25, 2026 16:25
@anonrig anonrig requested a review from jasnell March 25, 2026 17:46
@anonrig anonrig force-pushed the yagiz/add-typed-array-methods branch from 9b527bb to d88cf6b Compare March 26, 2026 19:23
@anonrig anonrig merged commit ac4bdf9 into main Mar 26, 2026
24 checks passed
@anonrig anonrig deleted the yagiz/add-typed-array-methods branch March 26, 2026 19:59
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