fix(_withcontent): _init_tls 加 _tls_index==0 守卫(TPV 未实现 @t.TLS 一次性语义)

TPV 编译器没有 @t.TLS 的首次执行守卫(TPC 有:全局标志+跳过块),
_init_tls 每次调用都重新 TlsAlloc → _get_stack 每次拿到新 TLS 索引和
新空栈 → push/find 各用各的栈,provider 永远匹配失败(Test 9 注入仍
FAIL 的根因)。_tls_index 初始为 0(TlsAlloc 成功不会返回 0),判重即
等价 TLS 语义。待办:TPV 函数翻译对齐 TPC HandlesFunctions.py L1763
实现 @t.TLS。
This commit is contained in:
TermiNexus committed 2026-08-15 06:36:53 +08:00
1 parent ba16d54f32
commit 6759406a7e
1 file changed
+6 -1
+6 -1
View File
@@ -26,7 +26,12 @@ _tls_index: ULONG = 0
def _init_tls():
"""Initialize TLS index (executes once; subsequent calls are skipped)."""
global _tls_index
_tls_index = TlsAlloc()
# TPV 未实现 @t.TLS 的"首次执行"守卫(函数每次调用都执行体),
# 不加守卫会导致每次 _get_stack 都 TlsAlloc 新索引 → 每次拿到新
# 空栈 → push/find 各用各的栈,provider 永远匹配失败。_tls_index
# 初始为 0(TlsAlloc 成功不会返回 0),以此判重即等价 TLS 语义。
if _tls_index == 0:
_tls_index = TlsAlloc()
def _get_stack() -> _ProviderStack | t.CPtr: