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

@@ -13581,9 +13581,15 @@
1358113581 if t == "RetryNode"
1358213582 return 1
1358313583 end
13584- if t == "CallNode" && @nd_name[nid] == "raise"
13585- return 1
13586- end
13584+ # A bare `raise` (with no enclosing rescue/ensure/retry in this
13585+ # function) needs no setjmp scope here: it longjmps to a handler in
13586+ # a caller (or the top-level net) and never returns, so this frame's
13587+ # locals never live across a setjmp/longjmp pair *in this function*
13588+ # and do not need the volatile qualifier. Only the handler-bearing
13589+ # nodes above establish a setjmp landing pad in this function; the
13590+ # retry-counter volatile case is covered by the RetryNode/BeginNode
13591+ # arms, not by the raise itself.
13592+ #
1358713593 # push_child_ids already includes @nd_body, @nd_stmts, and
1358813594 # every other AST link -- recursing on those separately would
1358913595 # 2x-fan-out per level and explode exponentially on deep bodies