Skip to content

batch: land #8784, #8788, #8785, #8786 - #8803

Merged
proggeramlug merged 15 commits into
mainfrom
merge/batch-8784-8788-8785-8786
Aug 25, 2026
Merged

batch: land #8784, #8788, #8785, #8786#8803
proggeramlug merged 15 commits into
mainfrom
merge/batch-8784-8788-8785-8786

Conversation

@proggeramlug

@proggeramlug proggeramlug commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Batch landing of four reviewed PRs, validated once as a single merged tree.

PR
#8784 fix(ffi): reject extension failures with Error objects
#8788 perf(codegen): direct-call stable methods with short packed spread tails
#8785 perf(codegen): specialize imported object literal methods
#8786 perf(codegen): version nested packed loops over closure captures

Fixes applied while landing

Validation (merged tree)

  • all 30 lint-job gates pass
  • perry-runtime 2680, perry-codegen 1238, perry-hir 336, perry-stdlib 120 — all 0 failed

Summary by CodeRabbit

  • New Features

    • Improved performance for stable imported object methods through guarded direct calls.
    • Optimized method calls using short packed-array spread arguments without unnecessary argument-array creation.
    • Optimized loops over immutable closure-captured packed arrays while preserving safe fallbacks.
  • Bug Fixes

    • Native extension and asynchronous failures now reject with JavaScript Error objects containing message and stack.
    • MySQL errors preserve compatible code and errno metadata.
    • Preserved correct iterator, proxy, mutation, and fallback behavior for optimized array operations.
  • Documentation

    • Documented structured asynchronous rejection and JavaScript Error behavior.

@coderabbitai

coderabbitai Bot commented Aug 25, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 3792e59c-b5f5-41c9-92b2-d4ef2dc667c7

📥 Commits

Reviewing files that changed from the base of the PR and between 4cb7376 and 2ba7336.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (74)
  • benchmarks/compiler_output/workloads.toml
  • changelog.d/8750-ext-error-objects.md
  • changelog.d/8785-imported-object-method-specialization.md
  • changelog.d/8786-closure-captured-packed-loops.md
  • changelog.d/8788-short-packed-spread.md
  • crates/perry-codegen/src/codegen/closure.rs
  • crates/perry-codegen/src/codegen/entry.rs
  • crates/perry-codegen/src/codegen/function.rs
  • crates/perry-codegen/src/codegen/method.rs
  • crates/perry-codegen/src/codegen/mod.rs
  • crates/perry-codegen/src/codegen/opts.rs
  • crates/perry-codegen/src/collectors/mod.rs
  • crates/perry-codegen/src/collectors/object_literal_exports.rs
  • crates/perry-codegen/src/expr/call_spread.rs
  • crates/perry-codegen/src/expr/call_spread_short.rs
  • crates/perry-codegen/src/expr/call_spread_short_tests.rs
  • crates/perry-codegen/src/expr/mod.rs
  • crates/perry-codegen/src/lib.rs
  • crates/perry-codegen/src/lower_call/property_get.rs
  • crates/perry-codegen/src/lower_call/property_get/imported_object.rs
  • crates/perry-codegen/src/lower_call/typed_shape_bake_tests.rs
  • crates/perry-codegen/src/runtime_decls/arrays.rs
  • crates/perry-codegen/src/runtime_decls/strings.rs
  • crates/perry-codegen/src/stmt/let_object_facts.rs
  • crates/perry-codegen/src/stmt/let_stmt.rs
  • crates/perry-codegen/src/stmt/loops.rs
  • crates/perry-codegen/src/stmt/mod.rs
  • crates/perry-codegen/src/stmt/stable_packed_loop.rs
  • crates/perry-ext-events/src/test_async_shims.rs
  • crates/perry-ext-fetch/src/test_async_shims.rs
  • crates/perry-ext-http/src/test_async_shims.rs
  • crates/perry-ext-mysql2/src/lib.rs
  • crates/perry-ext-mysql2/src/test_async_shims.rs
  • crates/perry-ext-net/src/test_async_shims.rs
  • crates/perry-ext-sharp/Cargo.toml
  • crates/perry-ext-sharp/src/lib.rs
  • crates/perry-ext-sharp/src/test_async_shims.rs
  • crates/perry-ffi/src/async_runtime.rs
  • crates/perry-hir/src/lower/context.rs
  • crates/perry-hir/src/lower/expr_object.rs
  • crates/perry-hir/src/lower/lowering_context.rs
  • crates/perry-hir/src/lower/module_decl.rs
  • crates/perry-hir/src/lower/module_decl/object_literal.rs
  • crates/perry-hir/src/lower/tests.rs
  • crates/perry-runtime/src/array/flat_clone.rs
  • crates/perry-runtime/src/array/iter_object.rs
  • crates/perry-runtime/src/array/iterator.rs
  • crates/perry-runtime/src/array/mod.rs
  • crates/perry-runtime/src/array/spread_dense_tests.rs
  • crates/perry-runtime/src/array/subclass.rs
  • crates/perry-runtime/src/array/tests.rs
  • crates/perry-runtime/src/native_abi.rs
  • crates/perry-runtime/src/object/native_call_method.rs
  • crates/perry-runtime/src/promise/native_async.rs
  • crates/perry-runtime/src/symbol/iterator.rs
  • crates/perry-stdlib/src/perry_ffi_async.rs
  • crates/perry/src/commands/compile/object_cache.rs
  • crates/perry/src/commands/compile/object_cache/object_cache_tests.rs
  • crates/perry/src/commands/compile/run_pipeline.rs
  • crates/perry/tests/issue_8772_short_packed_spread.rs
  • crates/perry/tests/issue_8773_closure_capture_packed_loops.rs
  • crates/perry/tests/issue_8775_imported_object_specialization.rs
  • docs/src/native-libraries/abi.md
  • docs/src/native-libraries/authoring-guide.md
  • docs/src/native-libraries/overview.md
  • scripts/shape_descriptor_census_baseline.json
  • test-files/fixtures/issue_8772_short_packed_spread/main.ts
  • test-files/fixtures/issue_8772_short_packed_spread/semantics.ts
  • test-files/fixtures/issue_8772_short_packed_spread/throwing.ts
  • test-files/fixtures/issue_8775_imported_object/adapter.js
  • test-files/fixtures/issue_8775_imported_object/barrel.js
  • test-files/fixtures/issue_8775_imported_object/main.js
  • test-files/fixtures/issue_8775_imported_object/package.json
  • test-files/fixtures/issue_8775_imported_object/semantics.js

📝 Walkthrough

Walkthrough

This PR adds imported object-literal method specialization, guarded short-spread calls, closure-captured packed-loop optimization, proxy-aware array iteration, and JavaScript Error rejection for native async failures with structured mysql2 metadata.

Changes

Imported object-literal specialization

Layer / File(s) Summary
Capability collection and import wiring
crates/perry-hir/..., crates/perry-codegen/src/collectors/*, crates/perry/src/commands/compile/...
Exported object literals now publish method capabilities. The compile pipeline resolves these capabilities into imported-class metadata and cache keys.
Guarded direct method calls
crates/perry-codegen/src/lower_call/property_get/*, crates/perry-codegen/src/stmt/*
Stable imported methods use receiver, shape, slot, and closure guards before direct calls. Generic method dispatch remains the fallback.
Integration coverage
test-files/fixtures/issue_8775_imported_object/*, crates/perry/tests/issue_8775_imported_object_specialization.rs, benchmarks/compiler_output/workloads.toml
Tests cover mutation, rebinding, proxies, barrel imports, moving GC, IR, lowering metadata, and benchmark output.

Packed spread and loop optimization

Layer / File(s) Summary
Short packed-spread lowering
crates/perry-codegen/src/expr/call_spread*
Short packed arrays use guarded direct method calls for arities zero through four. Guard misses use iterator-aware apply dispatch.
Runtime spread and iterator support
crates/perry-runtime/src/array/*, crates/perry-runtime/src/object/native_call_method.rs
The runtime adds short spread copying, rooted fallback materialization, proxy-aware iteration, and moving-GC-safe live receiver handling.
Closure-captured packed loops
crates/perry-codegen/src/stmt/stable_packed_loop.rs, crates/perry-codegen/src/expr/mod.rs
Immutable captured arrays and nested derived receivers are revalidated during loop execution. Generic side exits remain for rejected cases.
Regression tests and fixtures
crates/perry/tests/issue_8772_short_packed_spread.rs, crates/perry/tests/issue_8773_closure_capture_packed_loops.rs, test-files/fixtures/issue_8772_short_packed_spread/*
Tests compare compiled behavior with Node and validate direct paths, fallback paths, iterator errors, array semantics, and moving-GC behavior.

Native async errors

Layer / File(s) Summary
Error rejection contract
crates/perry-ffi/src/async_runtime.rs, crates/perry-runtime/src/promise/native_async.rs, crates/perry-stdlib/src/perry_ffi_async.rs
String rejection now constructs a JavaScript Error on the main thread. Deferred rejection APIs carry encoded values through the FFI.
Extension and mysql2 integration
crates/perry-ext-*/src/*
Extension shims support deferred rejection. mysql2 errors preserve symbolic codes and numeric errno values.
Documentation and tests
docs/src/native-libraries/*, crates/perry-ext-mysql2/src/lib.rs, crates/perry-ext-sharp/src/lib.rs
Documentation and tests describe and validate Error identity, messages, stacks, and structured metadata.

Estimated code review effort: 5 (Critical) | ~120 minutes

Possibly related PRs

  • PerryTS/perry#5874 — Related import plumbing through FnCtx, CrossModuleCtx, and import/re-export resolution.
  • PerryTS/perry#8082 — Related FnCtx initialization changes for cross-module metadata.

Suggested labels: type:bug

Suggested reviewers: thehypnoo

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch merge/batch-8784-8788-8785-8786

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.

1 participant