Files
TransPyC/lib
TermiNexus bf4bab093a fix(hotspot): 深度栈改用 common linkage,修复跨模块 self 记账漏扣
症状:--hotspot-sites 下跨模块调用链的调用方 self 约等于 inc(子调用 inc 未被扣除),而同模块链正常,导致所有基于 self 的结论带偏差(实测 _translate_module_level 421.9e9/422.0e9、translate_children 164.5e9/164.9e9 等)。

根因:__fhs_tdepth/__fhs_tstart/__fhs_tchild 原为 internal linkage,Projectrans 多模块模式下每个 .vp 翻译单元各持一份独立深度栈;跨模块调用时被调方读到的深度为 0,slot=0,ret 时 slot>0 判定为假,其 inc 永远写不到调用方的 tchild[slot-1],于是调用方 self = inc - 0 = inc。

修复:三件套改 common linkage,由链接器合并为全程序唯一一份(与本仓库多模块同名全局的既有做法一致);__fhs_tscratch 与每函数计数器仍保持 internal。已用逐指令 Python 模拟验证:同模块各形态均正确、跨模块独立栈必然漏扣、共享栈后全部正确。

仅 --hotspot-sites 启用时生效,未启用路径逐字节不变。旧的 hotspot_time.txt 在跨模块链上的 self 列不可信,需重新测量。
2026-09-14 14:35:17 +08:00
..