Commit 4f3009eb
4f3009ebeb75Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 1 file · ~1 modified
Description
Drop the over-conservative setjmp/volatile scope for a bare raise
body_uses_setjmp? returned 1 for any function whose body contains a
raise call, which forced every non-pointer local in that function to
be emitted volatile. But a function with a bare raise and no enclosing
rescue/ensure/retry establishes no setjmp landing pad of its own: the
raise longjmps to a handler in a caller (or the top-level net) and never
returns, so this frame's locals never live across a setjmp/longjmp pair
in this function and do not need the volatile qualifier.
Only the handler-bearing nodes (BeginNode with rescue/ensure, RetryNode) genuinely emit a setjmp here and require volatile locals; the #548 retry-counter hang stays covered by those arms. Removing the raise arm therefore narrows volatile to exactly the functions that need it.
Effect: hot methods that carry a bare raise ... unless assertion (e.g.
optcarrot's PPU/ROM checks) stop pessimizing their loop locals to memory
and become register-allocatable again. No change to the exception model
itself -- raise still propagates via longjmp.
Co-Authored-By: Claude Opus 4.8 (1M context) [email protected]
Details
- Commit
- 4f3009ebeb75
- Parent
- 3fcbfd648b3f
spinel_codegen.rbmodifiedView file
if t == "RetryNode" return 1 end if t == "CallNode" && @nd_name[nid] == "raise" return 1 end # A bare `raise` (with no enclosing rescue/ensure/retry in this # function) needs no setjmp scope here: it longjmps to a handler in # a caller (or the top-level net) and never returns, so this frame's # locals never live across a setjmp/longjmp pair *in this function* # and do not need the volatile qualifier. Only the handler-bearing # nodes above establish a setjmp landing pad in this function; the # retry-counter volatile case is covered by the RetryNode/BeginNode # arms, not by the raise itself. # # push_child_ids already includes @nd_body, @nd_stmts, and # every other AST link -- recursing on those separately would # 2x-fan-out per level and explode exponentially on deep bodies