Skip to content

[codex] Support typed array own properties#4363

Merged
proggeramlug merged 1 commit into
PerryTS:mainfrom
andrewtdiz:codex/node-typedarray-own-props
Jun 4, 2026
Merged

[codex] Support typed array own properties#4363
proggeramlug merged 1 commit into
PerryTS:mainfrom
andrewtdiz:codex/node-typedarray-own-props

Conversation

@andrewtdiz
Copy link
Copy Markdown
Contributor

Summary

Fixes #4349.

This adds typed-array own-property support for Perry's Integer-Indexed exotic objects while preserving element-slot behavior for canonical numeric indices. The change introduces a typed-array own-property side table, routes Object/descriptor/reflection helpers through it, and updates codegen paths that previously lowered Uint8Array string indexes through numeric element access.

Why This PR Cut

This is a focused runtime/codegen compatibility slice for one typed-array object-model gap. It was not batched with unrelated Node modules because the implementation touches a shared object/descriptor/indexing path and has enough reflection and codegen surface to stand alone safely.

Behavior Covered

  • Object.defineProperty(ta, "length", { value }) creates an own property that shadows .length reads without changing the indexed element length.
  • Ordinary named data/accessor properties on typed arrays are stored, assigned, enumerated, described, and deleted through typed-array-aware paths.
  • Integer-index descriptors continue to expose element descriptors and enforce typed-array numeric-index define restrictions.
  • Uint8Array string index reads/writes route through dynamic typed-array lookup instead of accidental numeric element access.
  • Reflection order keeps integer indices first, then non-index own properties.

Tests

Added test-parity/node-suite/globals/typedarray-own-properties.ts plus an expected-output fallback because the local system Node is Node 22 and does not support the TypeScript-strip flag used by the parity runner.

Validation run:

  • NODE26_BIN=$(npm exec --yes --package=node@26 -- node -e 'console.log(process.execPath)'); "$NODE26_BIN" --experimental-strip-types --no-warnings test-parity/node-suite/globals/typedarray-own-properties.ts
  • ./run_parity_tests.sh --suite node-suite --module globals --filter typedarray-own-properties
  • cargo fmt --all -- --check
  • ./scripts/check_file_size.sh
  • git diff --check HEAD
  • cargo check -p perry-runtime -p perry-codegen (passed earlier in the slice with existing warnings; not rerun after the final no-conflict rebase because unrelated release builds were active in other worktrees)

Known Limitations / Non-Goals

  • This does not attempt a broad rewrite of Perry's descriptor invariants outside typed-array own-property behavior.
  • Detached ArrayBuffer semantics remain out of scope for Perry's current typed-array model.

@proggeramlug proggeramlug force-pushed the codex/node-typedarray-own-props branch from 674efd8 to 1674fa5 Compare June 4, 2026 12:20
@proggeramlug proggeramlug marked this pull request as ready for review June 4, 2026 12:20
@proggeramlug proggeramlug merged commit 2eccf72 into PerryTS:main Jun 4, 2026
10 of 12 checks passed
proggeramlug added a commit that referenced this pull request Jun 4, 2026
…et-key buffer metadata (#4399)

#4363 (typed array own properties) added a typed-array own-property block at
the top of js_object_get_field_by_name that, for a Uint8Array-backed buffer,
returns undefined for any key it doesn't recognize. A KeyObject's secret-key
backing buffer is a Uint8Array, so its type / symmetricKeySize / asymmetricKey*
metadata (resolved by the KeyObject block later in the same function) was
shadowed and read back as undefined — a deterministic regression that fails
the secret_key_buffer_metadata_survives_ic_miss_for_aes_sizes unit test on
main (and every PR's cargo-test).

Fix: fall through to the metadata block for a secret-key buffer instead of
returning the typed-array undefined fallback. Plain typed arrays are
unchanged (still return undefined for unknown keys).

cargo test -p perry-runtime --lib: 979 passed, 0 failed (was 1 failed).

Co-authored-by: Ralph Küpper <ralph@skelpo.com>
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.

runtime: Object.defineProperty on a TypedArray spuriously throws (TAs aren't ObjectHeaders)

2 participants