Commit Graph

478 Commits

Author SHA1 Message Date
pjh123 e36a69976e refactor: 清除 color() 冗余干涉图构建 + use_points 改用精确 use 判定
- color() 入口移除无用的 graph::build(run 内重建),删掉 _graph 参数
- graph.rs reg_count 改名 inst_count(实为指令数)
- use_points 由 live_before 活集改为 inst.use_regs() 精确 use 点,消除冗余 UNSPILL,spill 压力测试 38s→6s
2026-08-06 20:41:01 +08:00
pjh123 d65fa03de6 fix: nested 子模块引用父槽无预着色保护致读错物理槽
子模块 alloc 时引用父槽的 LOAD_VAR.a/STORE_VAR.rd 被当作自身 vreg 染色移走,
父侧 collect_escaped 只保护父不移动槽,子侧无对称保护。以 param_layout.base
(inherited_reg_start 分界)识别父槽引用并预着色恒等,spill 自由色排除。

新增 nested_parent_slot_regress 回归测试(field/method + 高压力变量),
workspace 全绿 + clippy 干净。
2026-08-06 20:34:55 +08:00
pjh123 c47a0a73d1 test: vreg 超 253 高复用复现样例 + n_registers 汇总断言 2026-08-06 19:33:16 +08:00
pjh123 50b843a72a fix: 调用参数打包连续寄存器 + 捕获参数建 cell + TEMPLATE_STR ext 重映射(修复 JSON/closures/template 回归) 2026-08-06 19:33:05 +08:00
pjh123 d3385bc838 feat: 管线接入 liveness/精确DCE/RegAlloc + --no-regalloc flag(D-17/D-18) 2026-08-06 17:56:55 +08:00
pjh123 08f061dfd3 feat: 指令改写 + 元数据回写 + alloc 入口,RegAlloc on/off 运行时等价(D-16/D-20) 2026-08-06 17:44:31 +08:00
pjh123 0b0d36fa85 feat: 新增 oxide_regalloc crate,干涉图 + graph coloring + spill 拆分(D-09/D-10/D-11) 2026-08-06 17:13:27 +08:00
pjh123 9d619cd9bb feat: liveness 驱动的精确二轮 dce_precise + is_top_level 标志(D-17/D-19/D-20) 2026-08-06 16:55:26 +08:00
pjh123 fd267816f4 feat: 新增 MOV/SPILL/UNSPILL 执行语义 + spill 栈帧边界(D-06/D-07/D-08) 2026-08-06 16:51:01 +08:00
pjh123 59d2c93bff feat: 新增 oxide_liveness crate,CFG 数据流 liveness + 逐指令 live range(D-15) 2026-08-06 16:41:57 +08:00
pjh123 c46f7023c6 feat: 新增 MOV/SPILL/UNSPILL opcode 登记 + 构造 API + 契约层(D-06/D-07) 2026-08-06 16:34:25 +08:00
pjh123 224d1347eb refactor: 寄存器号 u8→u32 全链放宽,vreg 化去 checkpoint/reg_overflow 2026-08-06 16:31:16 +08:00
pjh123 5988696f5b fix: const 声明 STORE_VAR 恒 b=0 致寄存器复用误抛 2026-08-06 16:03:09 +08:00
pjh123 be91604fef fix: upvalue_captures 按名字排序,修复 HashSet 非确定顺序致 LOAD_UPVALUE 错位 2026-08-06 14:29:04 +08:00
pjh123 8952c1eccd test: 迁移 lowering 测试到 oxide_ir(测试随实现落位) 2026-08-06 14:11:54 +08:00
pjh123 6db19bb693 test: 各 Pass 模块补模块级单测,测试随实现拆分 2026-08-06 14:09:03 +08:00
pjh123 77f819a826 refactor: 拆分寄存器契约(def/use/is_pure)为 contract 独立模块 2026-08-06 14:05:53 +08:00
pjh123 54720a9bfc refactor: 拆分单文件为三 Pass 独立模块(可达性/迭代删除/重建) 2026-08-06 14:01:31 +08:00
pjh123 6c84ccca07 fix: STORE_VAR 一律判有副作用,修复顶层变量赋值被误删 2026-08-06 13:29:07 +08:00
pjh123 bca499fc39 fix: Compiler 改带字段 struct 后 5 处 bench 用 new() 构造
04-03 将 Compiler 从 unit struct 改为带 enable_dce 字段后,
bench 里旧语法 'Compiler.compile(...)' 编译失败(clippy --all-targets
暴露,cargo test 不编 bench)。统一改 Compiler::new().compile(...)。
2026-08-06 12:17:13 +08:00
pjh123 d210fb1610 fix: label 目标与 nested 逃逸变量槽保活,修复两处误删
1. label 目标指令强制保留:块头是控制流汇合点,删除使存活 JMP
   的 label 引用悬空(do-while 锚暴露 'Label not found')。
2. nested 树引用的变量槽顶层写者保活:STORE_VAR 写槽可被闭包
   跨函数读取(computed class field key 场景),D-03 不递归使
   顶层 use 计数看不到跨函数读,误删 k 赋值致 key 变 undefined。
2026-08-06 12:17:06 +08:00
pjh123 63cec1d448 fix: 无条件 JMP 后继位置切成块头,修复跳转边丢失
Pass 1 仅对条件跳转切 fallthrough 后继,无条件 JMP 与其后指令
融块导致块尾判定错、Jump 边丢失,DCE 可达性误删 break 出口块
(label 悬空报 'Label not found')。JMP 后继同样置块头。
2026-08-06 12:16:58 +08:00
pjh123 27b7f28726 test: compile_multiple_stmts 锚按 D-11 放宽为存在性断言
DCE 默认开启删除死 '1; 2' 链的 LOAD_CONST,仅剩顶层值 '3'。
精确计数断言 load_count >= 3 实测失败,放宽为 any(LOAD_CONST)。
2026-08-06 12:16:51 +08:00
pjh123 957f8f0fe7 chore: 更新 Cargo.lock 记录 oxide_compiler → oxide_dce 依赖 2026-08-06 11:49:26 +08:00
pjh123 7a3b354f02 feat: compile 子命令新增 --no-dce flag 透传 Compiler(D-10)
- Commands::Compile 追加 #[arg(long)] no_dce 字段
- compile(expr, file, no_dce) 按 flag 选择 Compiler::new().with_dce(false)
- eval/run/repl 走默认 enable_dce=true 不变
2026-08-06 11:48:30 +08:00
pjh123 d1bfae2723 feat: Compiler 增加 enable_dce 字段与 with_dce 开关(D-10)
- unit struct 改带字段 struct,new() 默认开启 DCE
- compile 在 emit 与 lower 之间插入 oxide_dce::dce(nested 不递归 D-03)
- Cargo.toml 追加 oxide_dce path 依赖;dev 环经 resolver v2 解析通过
2026-08-06 11:45:26 +08:00
pjh123 b7b6ffd7b1 test: 新增运行时等价对比集成测试(D-08 主验证)
- parse→emit→(dce 开/关)→lower→Vm::run 双管线对比
- 覆盖语句丢弃/重复赋值/if(false)/死闭包/try-catch/对象算术/顶层返回值/先调用后丢弃/const 重赋值
2026-08-06 11:43:39 +08:00
pjh123 2724592cbb test: 补全 Pass C 单测与不动域断言(D-13/D-14/D-04/D-03)
- pass_c_sweep 尾部加 debug_assert 越界防御(T-04-03,空尾块映射合法透传)
- 存活 label 新旧下标对应、死 label 置 None、原 None 保持
- 空函数退化、幂等性(dce 两次一致)
- label_count/n_registers/constants/nested 不动断言
2026-08-06 11:35:58 +08:00
pjh123 213a9820de feat: 实现 Pass A 可达性 + Pass B use 计数迭代删除
- Pass A 消费 build_cfg,entry 沿 succs DFS(含 Exception 边保守,Pitfall 4)展开指令粒度 keep
- Pass B 可达存活指令聚合 use 计数,def 无 use 且 is_pure 迭代删至不动点(D-02 连锁)
- Pass C 最小 mark-sweep 重建 insts + label_pos 重映射(死 label 置 None)
- 依赖 oxide_bytecode(测试需 OpCode 常量,Rust 无 crate 传递可见性,与 oxide_cfg 骨架一致)
- 单测 8 条:死链/负例/STORE_VAR 特判/if-else/死块/Exception 保守/死闭包/连锁
2026-08-06 11:33:27 +08:00
pjh123 b0ba874844 feat: 新建 oxide_dce crate 骨架并接入 workspace
- workspace.members 在 oxide_cfg 后追加 crates/oxide_dce
- Cargo.toml 骨架照抄 oxide_cfg(oxide_ir + oxide_cfg 依赖,dev-deps parser/emit/vm)
- lib.rs 中文文档头 + pub fn dce 入口(空函数退化先例,非空路径 Task 2/3 骨架)
2026-08-06 11:27:44 +08:00
pjh123 100f78fdca feat: 实现 is_pure 精确纯表(Pattern 1 全表 + LOAD_VAR/STORE_VAR 特判) 2026-08-06 10:50:18 +08:00
pjh123 a0f6ede4db test: 新增 is_pure 纯表单测(Pattern 1 各族正负例 + 特判分支) 2026-08-06 10:49:08 +08:00
pjh123 64431d4a08 feat: 实现 def_reg/use_regs 寄存器扫描契约(Pattern 2 全表) 2026-08-06 10:47:56 +08:00
pjh123 1306efdc78 test: 新增 def_reg/use_regs 契约单测(Pattern 2 反直觉槽位) 2026-08-06 10:45:10 +08:00
pjh123 d4b64a2cc9 refactor: 拆分 build_cfg 四阶段为独立模块纯函数链 2026-08-06 01:10:56 +08:00
pjh123 261c62a37e fix: 修复 date_to_json 测试时区敏感断言(UTC+8 下用显式 UTC 时间戳) 2026-08-06 01:05:56 +08:00
pjh123 4a7d96d7f2 test: 新增真实编译产物集成回归锚(parse→emit→build_cfg) 2026-08-06 00:49:07 +08:00
pjh123 af93f6702d fix: 修复 clippy 阻塞(doc comment 空行 + single_match_else) 2026-08-06 00:45:49 +08:00
pjh123 acd8e54e59 feat: 新建 oxide_cfg crate(BB 划分 + CFG 构建 pass) 2026-08-06 00:45:48 +08:00
pjh123 3246d768d9 fix: 修复 main.rs:20 悬空 doc comment 恢复 workspace 构建 2026-08-06 00:39:33 +08:00
pjh123 263fd255b6 docs: 添加 Rustdoc 注释 2026-08-05 21:46:47 +08:00
pjh123 7c8f19f61a refactor: 拆分 oxide_emit 为独立 emit pass crate(依赖倒置) 2026-08-05 20:13:18 +08:00
pjh123 4f670eb7fd refactor: 拆分 oxide_ir 为独立 crate 2026-08-05 19:34:44 +08:00
pjh123 3ae2eeee42 refactor: 拆分闭包分析与预扫描模块,拆分函数体编译子步骤 2026-08-05 19:29:02 +08:00
pjh123 050f75c952 fix: 完善闭包捕获(cell 索引稳定、参数遮蔽、函数/类名捕获、b 槽立即数) 2026-08-05 19:19:29 +08:00
pjh123 179960ed75 fix: 重写闭包捕获分析为 AST 级,修复 MAKE_CELL 时序 2026-08-05 18:41:48 +08:00
pjh123 0028a1787e chore: 清理过时 dead_code 标注与空代码块 2026-08-05 18:26:46 +08:00
pjh123 1171c53ff6 test: 补 IR 结构测试 2026-08-05 18:03:21 +08:00
pjh123 90f932680d test: 补薄弱域字节码断言测试 2026-08-05 18:01:42 +08:00
pjh123 76e650ce82 refactor: 抽取 assemble_ir 共用出口组装 2026-08-05 17:55:32 +08:00