diff --git a/App/lib/core/Gen/Call/CallGenBase.vp b/App/lib/core/Gen/Call/CallGenBase.vp index 41801fb..07e040b 100644 --- a/App/lib/core/Gen/Call/CallGenBase.vp +++ b/App/lib/core/Gen/Call/CallGenBase.vp @@ -556,9 +556,11 @@ class CallGenBase: # (mangled 模块级函数名含且只含一个 '.'),不匹配 # "{sha1}.Class.method" 等方法名。是否 IsDeclared==0 均可返回: # 前向 declare 与 define 同名同符号。只在 owner_sha1 提供且尚未 - # 命中时计算,避免多做一次 strlen。 + # 命中时计算,避免多做一次名字长度读取。 if owner_sha1 is not None and mangle_hit is None: - cur_len_o: sizet = string.strlen(cur_name) + # 名字长度改取 Function.NameLen(创建时一次算好),免去对热链 + # 每个节点重复 strlen(cur_name)(全程序 strlen 热点来源)。 + cur_len_o: sizet = llvmlite.function_get_name_len(cur) if cur_len_o == 17 + name_len: if string.strncmp(cur_name, owner_sha1, 16) == 0 and cur_name[16] == '.': suffix_start_o: sizet = cur_len_o - name_len @@ -590,7 +592,9 @@ class CallGenBase: while cur is not None: cur_name2: str = llvmlite.function_get_name(cur) if cur_name2 is not None: - cur_len: sizet = string.strlen(cur_name2) + # 名字长度改取 Function.NameLen(创建时一次算好),免去热链上 + # 每个节点重复 strlen(cur_name2);与 strlen(Name) 恒等,不改匹配语义。 + cur_len: sizet = llvmlite.function_get_name_len(cur) if cur_len > name_len + 1: suffix_start: sizet = cur_len - name_len if cur_name2[suffix_start - 1] == '.': diff --git a/App/lib/core/Gen/Call/CallGenLib.vp b/App/lib/core/Gen/Call/CallGenLib.vp index bc70ac8..e6868cb 100644 --- a/App/lib/core/Gen/Call/CallGenLib.vp +++ b/App/lib/core/Gen/Call/CallGenLib.vp @@ -467,6 +467,12 @@ class CallGenLib(CallGenBase.CallGenBase): return llvmlite.Int64(pool) if string.strcmp(func_name, "atoll") == 0: return llvmlite.Int64(pool) + # llvmlite 函数名长度访问器返回 t.CSizeT(i64):stub/vpi 尚未注入时若 + # 默认 i32 会与 declare 的 i64 签名不一致(call i32 vs declare i64), + # 与 function_get_name 指针白名单同理须登记返回类型。 + if string.strcmp(bare_name, "function_get_name_len") == 0 or \ + string.strcmp(func_name, "function_get_name_len") == 0: + return llvmlite.Int64(pool) # 返回 double 的函数 if string.strcmp(func_name, "atof") == 0: