fix(codegen): gate closure-local-call implicit-this reset on callee reading dynamic this#5032
Closed
proggeramlug wants to merge 1 commit into
Closed
fix(codegen): gate closure-local-call implicit-this reset on callee reading dynamic this#5032proggeramlug wants to merge 1 commit into
proggeramlug wants to merge 1 commit into
Conversation
…eading dynamic this (#5030)
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #5030 — unbreaks the required
compiler-output-regressioncheck, red onmainsince #5004 (verified by adjacent-commit runs: gate green at 50c1a64 / #5003, red at f991e2e / #5004 with the exact failure signature from CI).Root cause
#5004 added an OrdinaryCallBindThis reset (
js_implicit_this_set(undefined)+ restore) around receiverless calls. TheFuncRefpath correctly gates it onfuncs_reading_dynamic_this("ordinary helper calls pay nothing"), buttry_lower_closure_typed_local_call(early_branches.rs) emits the pair unconditionally. In theh1_buffer_alias_negativefixture,closureCapture()'s hot loop calls a this-free arrow (read(i)) — the per-iterationjs_implicit_this_setpair tripshot_loops_no_runtime_calls(it is the only call in the failing report that is not on the workload's allowlist).Fix
Mirror the FuncRef gating in the closure-typed-local path:
this(funcs_reading_dynamic_this, which conservatively includes arrows capturing lexicalthis).js_closure_callN. (Fallback blocks are not hot-loop blocks, so the gate stays green while runtime/object-model: implement strict and sloppy function this binding #3576 semantics are preserved even for reassigned closure locals.)js_closure_callNtail (unknown func id / rest params / arity mismatch): unconditional reset, as before.Validation
compiler_output_regression.py suite --suite native-region-proof→ all workloads pass (failed_workloads: []), previouslyh1_buffer_alias_negativefailed.capture --gateforvectorized_buffer_transformandhir_fact_rewrite→ pass.python3 -m unittest tests.test_compiler_output_regression→ 40/40.test-files/test_object_model_semantics_3986.ts(the fix(runtime,hir): object-model semantics — Object boxing, this-binding, var-hoisting (#3986/#3577/#3576/#3575) #5004 semantics test) still printsobject-model-semantics: okunder Perry.this-reading function — guard fallback bindsthisto undefined/globalThis, no receiver leak; (2) this-reading closure local on the fast path — reset still applied; (3) the CI: compiler-output-regression red on main (h1_buffer_alias_negative native-region-proof workload) #5030 hot-loop helper shape computes correctly.cargo test --release -p perry-codegen→ green exceptmanifest_param_counts_match_dispatch_table(zlib::deflateRawSync arity drift), which is pre-existing macOS-local and unrelated (my diff touches neither manifest nor dispatch; the test passes in Linux CI on current main).Related: #5031 fixes the cargo-test red (stream unshift); #5029 (gc_write_barrier_stress) is being bisected separately.
No version bump / changelog per external-PR convention.