LATX, opt: batch load 4 × 4KB pages in AOT loadee#294
Merged
Conversation
Load 4 consecutive 4KB pages spanning from current PC to PC + 4 * TARGET_PAGE_SIZE.
luzeng87
approved these changes
May 21, 2026
Contributor
luzeng87
left a comment
There was a problem hiding this comment.
审查总结
重构 AOT 页面加载逻辑:将 load_aot 中的状态检查和批量加载提取为独立函数,load_page 内聚化。
变更分析
1. load_page 内聚化
状态检查(PAGE_LOADED / PAGE_SMC+ELF)和 page_set_page_state 从 load_aot 移入 load_page:
// 新增边界检查
if (pc < info->seg_begin || pc >= info->seg_end) return 0;
// 新增状态检查
int page_state = page_get_page_state(pc);
if (page_state >= PAGE_LOADED || ...) return 0;
page_set_page_state(pc, PAGE_LOADED);load_page 现在独立可调用,不依赖调用者做前置校验。✅
2. 提取 load_all_seg
option_aot == 2 路径的循环体从 load_aot 提取为独立函数,设置 SEG_RUNNING + 遍历全段加载 + try_aot_link()。同旧行为。✅
3. load_page_4 添加 try_aot_link
旧代码由 load_aot 调用者在成功后调 try_aot_link,新代码移入 load_page_4 内部。load_page 返回 0 时 try_aot_link 也无副作用(无 TB 可链接)。✅
4. page_set_page_state_range → 逐页设置
load_all_seg 不再用 page_set_page_state_range 批量标记,改为各页 load_page 自行设置。行为一致 — 旧代码也是先标记再加载。✅
未发现问题
load_page_4返回值:返回首个load_page的返回值,同旧行为- 边界检查新增 O(1),安全
- 无新增变量,无内存泄漏
结论
通过。 干净的内聚化重构,无行为变更,无副作用。
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.
Load 4 consecutive 4KB pages spanning from current PC to PC + 4 * TARGET_PAGE_SIZE.