Skip to content

Commit 71a10f7

Browse files
proggeramlugRalph Küpper
andauthored
batch: land #8784, #8788, #8785, #8786 (#8803)
* fix(ffi): reject extension failures with Error objects * perf(codegen): version packed loops over closure captures * perf(codegen): specialize imported object literal methods * docs(changelog): note imported object method specialization * fix(codegen): address imported method review feedback * perf(codegen): specialize short packed spread calls * fix: address short packed spread review feedback * fix(hir): compose imported methods with static literals * fix(runtime): root native async error messages * chore: batch-landing fixes (fmt, payload baseline, module_decl 2000-line split) * fix(runtime): scope the native-async error message pointer (#7341) --------- Co-authored-by: Ralph Küpper <ralph@skelpo.com>
1 parent 4cb7376 commit 71a10f7

75 files changed

Lines changed: 3885 additions & 324 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

benchmarks/compiler_output/workloads.toml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2134,3 +2134,62 @@ name = "imported_registry_generic_fallback_retained"
21342134
consumer = "proven_this_method_direct_call"
21352135
notes_contains = "generic_dispatch_fallback=js_native_call_method_by_id"
21362136
min = 2
2137+
2138+
[workloads.issue_8775_imported_object]
2139+
source = "test-files/fixtures/issue_8775_imported_object/main.js"
2140+
kind = "imported_object_literal_method_specialization"
2141+
allow_hot_loop_conversions = true
2142+
allow_dynamic_property_runtime = true
2143+
2144+
[workloads.issue_8775_imported_object.vectorization]
2145+
min_vectorized_loops = 0
2146+
scalar_baseline = "allowed: this fixture gates cross-module own-method dispatch"
2147+
allowed_missed_reason_kinds = [
2148+
"call_instruction",
2149+
"control_flow",
2150+
"generic_not_vectorized",
2151+
"not_beneficial",
2152+
"uncountable_loop",
2153+
"unknown_trip_count",
2154+
"unsupported_instruction",
2155+
"unsupported_reduction",
2156+
]
2157+
2158+
[workloads.issue_8775_imported_object.runtime_budgets]
2159+
2160+
[[workloads.issue_8775_imported_object.stdout_checks]]
2161+
name = "imported_object_checksum"
2162+
equals = "{\"checksum\":400000,\"remaining\":0}\n"
2163+
detail = "stable imported object methods preserve the Node checksum"
2164+
2165+
[[workloads.issue_8775_imported_object.ir_checks]]
2166+
name = "direct_producer_closure_calls"
2167+
section = "llvm_before"
2168+
contains_all = [
2169+
"call double @perry_closure_adapter_js__6",
2170+
"call double @perry_closure_adapter_js__7",
2171+
"call double @perry_closure_adapter_js__8",
2172+
"call double @perry_closure_adapter_js__9",
2173+
]
2174+
detail = "stable arms directly call producer closure bodies"
2175+
2176+
[[workloads.issue_8775_imported_object.ir_checks]]
2177+
name = "generic_method_fallback_retained"
2178+
section = "llvm_before"
2179+
contains = "call double @js_native_call_method_by_id"
2180+
detail = "guard failures retain the universal method dispatcher"
2181+
2182+
[workloads.issue_8775_imported_object.native_rep_checks]
2183+
allow_materialization_reasons = ["runtime_api"]
2184+
2185+
[[workloads.issue_8775_imported_object.native_rep_checks.require_records]]
2186+
name = "imported_object_direct_selection"
2187+
consumer = "imported_object_literal_method_direct_call"
2188+
notes_contains = "receiver_provenance=imported_object_literal_metadata"
2189+
min = 5
2190+
2191+
[[workloads.issue_8775_imported_object.native_rep_checks.require_records]]
2192+
name = "imported_object_generic_fallback_retained"
2193+
consumer = "imported_object_literal_method_direct_call"
2194+
notes_contains = "generic_dispatch_fallback=js_native_call_method_by_id"
2195+
min = 5
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Reject native-extension failures with real JavaScript `Error` objects, including `.message`/`.stack`, and preserve mysql2-compatible `.code`/`.errno` metadata for common MySQL server errors.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Stable imported object-literal methods now use guarded direct calls to their defining closure bodies. The fast path validates the exported receiver identity, exact own-property shape, and live function identity, while replacements, deletions, accessors, proxies, receiver changes, and other dynamic cases retain the universal method-dispatch fallback.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Optimize immutable closure-captured packed Array and Array-subclass loops, including nested arrays derived from guarded indexed reads, while retaining generic side exits for rebinding, layout changes, and moving GC.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## perf(codegen): direct-call stable methods with short packed spread tails
2+
3+
`receiver.method(fixed, ...args)` now emits guarded direct-call arms when the final spread is an exact ordinary packed Array with zero through four present elements. The guard rejects holes, iterator/prototype overrides, proxies, Array subclasses, descriptors, and oversized tails; method class/shape/invalidation guards select the concrete body, and every miss retains the full iterator-aware apply dispatcher. This removes argument-array materialization and dynamic method lookup from the common empty/one-element ECS dispatch path while preserving source-order evaluation and moving-GC roots.

crates/perry-codegen/src/codegen/closure.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1116,7 +1116,9 @@ pub(super) fn compile_closure(
11161116
local_class_field_aliases: HashMap::new(),
11171117
local_id_to_name: HashMap::new(),
11181118
local_value_aliases: HashMap::new(),
1119+
local_imported_object_aliases: HashMap::new(),
11191120
imported_vars: &cross_module.imported_vars,
1121+
imported_object_literals: &cross_module.imported_object_literals,
11201122
compile_time_constants: native_facts.compile_time_constants(),
11211123
target_triple: &cross_module.target_triple,
11221124
app_metadata: &cross_module.app_metadata,

crates/perry-codegen/src/codegen/entry.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -914,7 +914,9 @@ pub(super) fn compile_module_entry(
914914
local_class_field_aliases: HashMap::new(),
915915
local_id_to_name: HashMap::new(),
916916
local_value_aliases: HashMap::new(),
917+
local_imported_object_aliases: HashMap::new(),
917918
imported_vars: &cross_module.imported_vars,
919+
imported_object_literals: &cross_module.imported_object_literals,
918920
compile_time_constants: main_native_facts.compile_time_constants(),
919921
target_triple: &cross_module.target_triple,
920922
app_metadata: &cross_module.app_metadata,
@@ -1619,7 +1621,9 @@ pub(super) fn compile_module_entry(
16191621
local_class_field_aliases: HashMap::new(),
16201622
local_id_to_name: HashMap::new(),
16211623
local_value_aliases: HashMap::new(),
1624+
local_imported_object_aliases: HashMap::new(),
16221625
imported_vars: &cross_module.imported_vars,
1626+
imported_object_literals: &cross_module.imported_object_literals,
16231627
compile_time_constants: init_native_facts.compile_time_constants(),
16241628
target_triple: &cross_module.target_triple,
16251629
app_metadata: &cross_module.app_metadata,

crates/perry-codegen/src/codegen/function.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1166,7 +1166,9 @@ pub(super) fn compile_function(
11661166
local_class_field_aliases: HashMap::new(),
11671167
local_id_to_name: HashMap::new(),
11681168
local_value_aliases: HashMap::new(),
1169+
local_imported_object_aliases: HashMap::new(),
11691170
imported_vars: &cross_module.imported_vars,
1171+
imported_object_literals: &cross_module.imported_object_literals,
11701172
compile_time_constants: native_facts.compile_time_constants(),
11711173
target_triple: &cross_module.target_triple,
11721174
app_metadata: &cross_module.app_metadata,

crates/perry-codegen/src/codegen/method.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,9 @@ pub(super) fn compile_method(
498498
local_class_field_aliases: HashMap::new(),
499499
local_id_to_name: HashMap::new(),
500500
local_value_aliases: HashMap::new(),
501+
local_imported_object_aliases: HashMap::new(),
501502
imported_vars: &cross_module.imported_vars,
503+
imported_object_literals: &cross_module.imported_object_literals,
502504
compile_time_constants: native_facts.compile_time_constants(),
503505
target_triple: &cross_module.target_triple,
504506
app_metadata: &cross_module.app_metadata,
@@ -1770,7 +1772,9 @@ pub(super) fn compile_static_method(
17701772
local_class_field_aliases: HashMap::new(),
17711773
local_id_to_name: HashMap::new(),
17721774
local_value_aliases: HashMap::new(),
1775+
local_imported_object_aliases: HashMap::new(),
17731776
imported_vars: &cross_module.imported_vars,
1777+
imported_object_literals: &cross_module.imported_object_literals,
17741778
compile_time_constants: native_facts.compile_time_constants(),
17751779
target_triple: &cross_module.target_triple,
17761780
app_metadata: &cross_module.app_metadata,

0 commit comments

Comments
 (0)