feat(gen): P5 slife 登记表容量提到 256,超限 fail-fast
分配与上限判定共用 _SLIFE_MAX = 256(原 128 且满时静默停止登记)。_SlifeEnsureOwned 超限改为 fatal_error(LifetimeError):静默返回 None 会让该对象永不登记、永不释放(纯泄漏),与编译器自动管理的承诺矛盾。
This commit is contained in:
1 parent
efb4a54428
commit
b71ed43f10
1 file changed
+9
-3
@@ -42,7 +42,8 @@ define SCOPE_BLOCK = 2
|
||||
# · 登记区间是**栈式**的:[_g_slife_count, _g_slife_top) 属于当前函数。进入嵌套函数时
|
||||
# 起点抬到当前栈顶(_SlifeReset),退出时弹回(_SlifeRestore)——否则内层函数会在
|
||||
# 0 号槽覆写外层登记项,且内层出口会把外层的对象一起 free 掉。
|
||||
# 容量 128 项,满则停止登记(退化为不释放=泄漏,不报错也不悬垂)。
|
||||
# 登记表容量(P5:128 → 256)。超限时 **fail-fast**(不再静默退化为"不登记 = 不释放"的泄漏)。
|
||||
define _SLIFE_MAX = 256
|
||||
_g_slife_owned: sizet* = None
|
||||
_g_slife_count: int = 0
|
||||
_g_slife_top: int = 0
|
||||
@@ -448,7 +449,7 @@ novirtual class VarGenMixin:
|
||||
global _g_slife_owned, _g_slife_count, _g_slife_top
|
||||
if _g_slife_owned is None:
|
||||
if pool is None: return -1
|
||||
_g_slife_owned = sizet*(pool.alloc(128 * 16))
|
||||
_g_slife_owned = sizet*(pool.alloc(_SLIFE_MAX * 16))
|
||||
if _g_slife_owned is None: return -1
|
||||
old_base: int = _g_slife_count
|
||||
_g_slife_count = _g_slife_top
|
||||
@@ -484,7 +485,12 @@ novirtual class VarGenMixin:
|
||||
if alloca is None or _g_slife_owned is None: return None
|
||||
exist: mlirlite.Value* = self._SlifeShadow(alloca)
|
||||
if exist is not None: return exist
|
||||
if _g_slife_top >= 128: return None
|
||||
if _g_slife_top >= _SLIFE_MAX:
|
||||
# P5:超限 **fail-fast**(容量见文件头的 _SLIFE_MAX,此处文案里的数字与之同步)。
|
||||
# 静默返回 None 会让该对象永不登记 → 永不释放(纯泄漏),与"编译器自动管理"的承诺矛盾;
|
||||
# 下面的 return None 只是流程完整(fatal_error 已终止进程)。
|
||||
self.Gen.TypeGenErr.fatal_error(None, "the slife ownership table is full (capacity 256): this function registers too many compiler-owned slife bindings; split the function or reduce the number of live slife objects", "LifetimeError")
|
||||
return None
|
||||
if pool is None or builder is None: return None
|
||||
sh: mlirlite.Value* = self._alloca_at_entry(builder, mlirlite.Int8(pool))
|
||||
if sh is None: return None
|
||||
|
||||
Reference in new issue
Block a user