Skip to content
This repository was archived by the owner on Aug 18, 2025. It is now read-only.

Commit e81bf49

Browse files
committed
优化JIT编译逻辑,确保编译成功后缓存结果,提升数学表达式求值性能和稳定性。
1 parent eb88e5b commit e81bf49

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/interpreter/jit.rs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1261,20 +1261,27 @@ impl JitCompiler {
12611261
}
12621262

12631263
// 根据优化策略选择编译方法
1264-
match optimization {
1264+
let compiled_result = match optimization {
12651265
MathOptimization::SIMDVectorization => {
1266-
self.compile_simd_math_expression(expression, key, expr_type, debug_mode)
1266+
self.compile_simd_math_expression(expression, key.clone(), expr_type, debug_mode)
12671267
},
12681268
MathOptimization::LookupTable => {
1269-
self.compile_lookup_table_math(expression, key, expr_type, debug_mode)
1269+
self.compile_lookup_table_math(expression, key.clone(), expr_type, debug_mode)
12701270
},
12711271
MathOptimization::FastApproximation => {
1272-
self.compile_fast_approximation_math(expression, key, expr_type, debug_mode)
1272+
self.compile_fast_approximation_math(expression, key.clone(), expr_type, debug_mode)
12731273
},
12741274
_ => {
1275-
self.compile_standard_math_expression(expression, key, expr_type, debug_mode)
1275+
self.compile_standard_math_expression(expression, key.clone(), expr_type, debug_mode)
12761276
}
1277+
};
1278+
1279+
// 如果编译成功,缓存结果
1280+
if let Ok(ref compiled) = compiled_result {
1281+
self.compiled_math_expressions.insert(key, compiled.clone());
12771282
}
1283+
1284+
compiled_result
12781285
}
12791286

12801287
/// 计算表达式复杂度

0 commit comments

Comments
 (0)