refactor: 扁平化对象属性存储并优化常量池与 IC 热路径

This commit is contained in:
爱特每羊队
2026-06-13 23:59:47 +08:00
parent dcc7db2575
commit bf74adf7f5
26 changed files with 307 additions and 87 deletions
@@ -52,6 +52,17 @@ fn compile_constants() {
assert_eq!(module.constants[0], oxide_compiler::compiler::Constant::Int(42));
}
#[test]
fn compile_dedups_identical_string_constants() {
let module = compile_source("var a = 'hello'; var b = 'hello';");
let count = module
.constants
.iter()
.filter(|c| matches!(c, oxide_compiler::compiler::Constant::String(s) if s == "hello"))
.count();
assert_eq!(count, 1, "identical string constants should be interned once per module");
}
#[test]
fn compile_negation() {
let module = compile_source("-5");