Repository navigation
m3core: make ex_stack target-independent - #1271
Conversation
|
This overlaps with #1269 and #1270 (the The two fit together. This PR moves the throw entry point ( The overlap is in how the walker is chosen. Here it is chosen by directory: the target's own directory if it is listed in I'm happy to make that change in this PR or follow up after it, depending on which lands first. |
c313fa7 to
60444cb
Compare
ex_stack raises with a C++ throw; the per-target libunwind code only serves stack dumps. Separate the two so any C-backend target can use ex_stack by setting M3_USE_STACK_WALKER in its config: - RTStack__ThrowM3Exc and struct _M3Exc move from the three per-target RTStackC.c files to ex_stack/RTExStackC.c (compiled as C++). - RTExStack no longer asserts a walker; PrintStack reports that no stack dump is available when RTStack.Has_walker () is FALSE. - runtime/m3makefile selects ex_stack from M3_USE_STACK_WALKER and M3_BACKEND_MODE = "C". HAS_STACK_WALKER now only says which targets have a libunwind walker; others get the stubs, moved from ex_frame/ to no_walker/, and the common RTMachine. - RTStackCommon.c tests the M3_HOST_* macros from m3core.h: the bare AMD64_DARWIN etc. are not defined, so Has_walker () returned FALSE on every target. No existing target changes mechanism. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
60444cb to
c86046c
Compare
|
@hosking I'm trying to patiently hold off. Please proceed. |
…, LOOPHOLE fix Brings in #1271 (ex_stack target-independent), #1294/#1299 (unused base pointer), #1295, #1296 (_m3_caught local), #1297, #1298, the RTStackC include fix and #1300 (LOOPHOLE between a float and a packed integer, with m3test p308). Conflicts: - RTStackC.c (ARM64_DARWIN, AMD64_DARWIN, AMD64_LINUX): take master's; RTStack__ThrowM3Exc now lives in ex_stack/RTExStackC.c (#1271). msir's terminate backstop moves there too, as in #1302 (text identical, so the merge of #1302 will be clean). - RTExStack.m3: master's (no Has_walker assertion, #1271) plus msir's @M3stackdump switch. - LoopholeExpr.m3: both import lists. - m3tests m3makefile: msir's p300 to p304 and master's p305 to p308. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
#1271 (merged from master) selects ex_stack only when M3_BACKEND_MODE is "C". MSIR's LLVM lowering (MSIRObj, MSIRAsm) also emits C++ EH (invoke/landingpad, __gxx_personality_v0) and supports only ex_stack, but m3core silently got ex_frame in those modes: an MSIR-built cm3 then recursed in RTHooks.Raise -> RTExFrame's backstop -> RuntimeError.Self -> RTHooks.Raise until the stack overflowed, as soon as anything raised (cm3 -clean in the LLVM ladder's stage 3). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
As discussed in #1266, this makes the
ex_stack(C++ zero-cost EH) runtime independent of the per-target stack walker, so any C-backend target can adopt it from its platform config.Under
ex_stacka raise is justthrow _M3Exc{act}; the libunwind code in the per-targetRTStackC.cis only needed for stack dumps. This PR separates the two.RTStack__ThrowM3Excandstruct _M3Excmove out of the three per-targetRTStackC.cfiles into a newruntime/ex_stack/RTExStackC.c. The file must be compiled as C++ and fails with#errorotherwise.RTExStackno longer assertsRTStack.Has_walker. On a target without a walker,PrintStack(@M3stackdump/@M3debugex) prints that no stack dump is available.runtime/m3makefilechoosesex_stackwhenM3_USE_STACK_WALKERis set andM3_BACKEND_MODE = "C", instead of using a target list.HAS_STACK_WALKERnow only lists the targets with a libunwind walker; those getinclude_dir(TARGET)and theUNWINDlibrary.RTStackC.c, moved fromex_frame/tono_walker/, and the commonRTMachine.No existing target changes mechanism. ARM64_DARWIN, AMD64_DARWIN and AMD64_LINUX still use
ex_stackwith their walkers, and everything else still usesex_frame. A new target still needs the two-phase bootstrap described inREADME-ex_stack.md, which this PR updates.Testing (ARM64_DARWIN):
HAS_STACK_WALKER, so it usedex_stack, the stub walker and the commonRTMachine. The output was identical.🤖 Generated with Claude Code