refactor: 扁平化对象属性存储并优化常量池与 IC 热路径
This commit is contained in:
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user