LATX, opt: classify AOT file types#292
Merged
Merged
Conversation
luzeng87
reviewed
May 12, 2026
Contributor
luzeng87
left a comment
There was a problem hiding this comment.
PR #292 审查 — AOT 文件类型分类
作者: ganjue66da | 1 提交, 12 文件
概述
将 bool is_pe 替换为 uint8_t aot_file_type 位掩码(ELF/PE/CACHE/HASH 四类)。按类型差异化 SMC 处理、IR1 校验、stat 检查。
审查项
| # | 问题 | 严重度 | 说明 |
|---|---|---|---|
| 1 | is_elf_file 的 perror 噪音 |
低 | segment_tree_insert 对每个段都调 is_elf_file。非 ELF/PE 文件(如 deepinwine cache 路径)文件不存在,perror("Error opening file") 会打 stderr 噪音。建议删掉 perror 或加 if (option_debug_aot) 守卫 |
| 2 | is_deepinwine_cache 的 malloc + assert |
低 | static buffer 用 malloc(PATH_MAX) + assert 守卫。失败直接 assert(0) 进程崩溃。改为栈变量 char path[PATH_MAX] 更安全 |
| 3 | HASH_PAGE_LOADED / HASH_PAGE_NOINFO |
低 | enum 定义但 diff 中未使用。dead code 还是预留?建议标注或移出此 PR |
| 4 | ONE_TB_IN_TU |
低 | seg_flag 定义但未使用。同上 |
| 5 | PE stat 检查行为变更 | 需确认 | do_generate_aot 中 PE 文件现在也做 stat 校验(ELF_AOT_FILE | PE_AOT_FILE)。之前 PE 是否跳过 stat?请确认预期行为 |
| 6 | HASH 文件类型注释掉 | 低 | get_file_type 中 HASH 判断被注释,回退到 CACHE_AOT_FILE。安全,建议标注 TODO |
正面变更
page_is_pe从page_info清理is_running→seg_flag & SEG_RUNNING位标记化- PE/CACHE 文件 SMC 后允许重新 load AOT(
load_aot中PAGE_SMC非 ELF 不拦截) page_set_flags中p_info全局变量消除
总结
分类思路正确。修复 perror 噪音 + dead code + PE stat 确认后合。
ELF_AOT_FILE: AOT files corresponding to ELF binaries PE_AOT_FILE: AOT files corresponding to PE binaries CACHE_AOT_FILE: AOT files from cache directories HASH_AOT_FILE: AOT files generated from hash Only track SMC pages for ELF files in page_set_flags. PE_AOT_FILE and CACHE_AOT_FILE need check ir1. CACHE_AOT_FILE do not check origin file change time. HASH_AOT_FILE in the draft.
8af943d to
7a37e7a
Compare
luzeng87
reviewed
May 14, 2026
Contributor
luzeng87
left a comment
There was a problem hiding this comment.
二次审查 — 已修复问题确认
对比上次审查(#6c72cc4),本次更新变动:
✅ 已修复
is_elf_file的perror噪音 — 已删除,非 ELF 文件不再打 stderr- PE stat 检查行为 —
do_generate_aot中明确ELF_AOT_FILE | PE_AOT_FILE都做 stat,行为变更已确认 page_set_flags全局变量 —p_info已消除,改用局部变量get_segmentPE unmapped — 死代码分支已清理,现在正确设置lib->is_unmapped = 1
⚠️ 仍未修复
1. is_deepinwine_cache 中 malloc + assert
static char *deepinwine_cache_path = NULL;
if (deepinwine_cache_path == NULL) {
deepinwine_cache_path = (char *)malloc(PATH_MAX);
assert(deepinwine_cache_path);malloc 失败直接 assert(0) 进程崩溃。改为栈变量即可:
char deepinwine_cache_path[PATH_MAX];static 缓存没必要,snprintf(PATH_MAX) 本身开销极小。
2. HASH_PAGE_LOADED / HASH_PAGE_NOINFO 仍未使用
page_state_type enum 中定义了但无调用点。PR 正文说 "HASH_AOT_FILE in the draft" — 如果后续 PR 会用到,建议加注释标注为预留而非 dead code。
新观察
load_aot中PAGE_SMC后 ELF 阻止 reload 但 PE/CACHE 允许 — 合理:ELF 有 SMC 哨兵保护,PE/cache 无 origin 文件校验load_page对 PE/CACHE 文件加 IR1 校验check_ir1— 正确补偿 SMC 保护的缺失get_file_type中非 ELF/PE 归为CACHE_AOT_FILE,注释WARNING: Not only deepinwine cache清楚
结论
上次审查的 5/6 问题已修复。剩余 2 条(malloc+assert、HASH dead code)非阻塞,可后续迭代处理。建议合入。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ELF_AOT_FILE: AOT files corresponding to ELF binaries
PE_AOT_FILE: AOT files corresponding to PE binaries
CACHE_AOT_FILE: AOT files from cache directories
HASH_AOT_FILE: AOT files generated from hash
Only track SMC pages for ELF files in page_set_flags. PE_AOT_FILE and CACHE_AOT_FILE need check ir1.
CACHE_AOT_FILE do not check origin file change time.