perf(vm): 字符串拼接用 push_to_string 消去中间分配, GC阈值 8M→32M

- oxide_runtime_api 新增 push_to_string: 直接将 JsValue 写入 String buffer
- dispatch_add / dispatch_compound_add 复用 Vm::string_buf, 每次concat从4次分配降到1次
- vm_support 新增 new_string_owned 接受 String 转移所有权
- kernel session_gc_threshold 8MB→32MB 减少频繁 GC
- build.sh: make clean 清跨平台 .obj 残留

(cherry picked from commit ad7b044a5a24b23819d783c5419d3e33f936dfc5)
This commit is contained in:
爱特每羊队
2026-06-29 14:04:50 +08:00
parent 6edeadc149
commit 5ecb428320
6 changed files with 76 additions and 13 deletions
+12 -8
View File
@@ -10,10 +10,12 @@ impl Vm {
let lhs = self.coerce_primitive_bounded(self.regs[a], false)?;
let rhs = self.coerce_primitive_bounded(self.regs[b], false)?;
if lhs.is_string() || rhs.is_string() {
let ls = coercion::to_string(lhs);
let rs = coercion::to_string(rhs);
let concat = format!("{ls}{rs}");
self.regs[rd] = self.new_string(&concat);
let mut buf = std::mem::take(&mut self.string_buf);
buf.clear();
coercion::push_to_string(lhs, &mut buf);
coercion::push_to_string(rhs, &mut buf);
self.regs[rd] = self.new_string(&buf);
self.string_buf = buf;
} else {
let ln = coercion::to_number(lhs);
let rn = coercion::to_number(rhs);
@@ -43,10 +45,12 @@ impl Vm {
let lhs = self.coerce_primitive_bounded(self.regs[rd], false)?;
let rhs = self.coerce_primitive_bounded(self.regs[a], false)?;
if lhs.is_string() || rhs.is_string() {
let ls = coercion::to_string(lhs);
let rs = coercion::to_string(rhs);
let concat = format!("{ls}{rs}");
self.regs[rd] = self.new_string(&concat);
let mut buf = std::mem::take(&mut self.string_buf);
buf.clear();
coercion::push_to_string(lhs, &mut buf);
coercion::push_to_string(rhs, &mut buf);
self.regs[rd] = self.new_string(&buf);
self.string_buf = buf;
} else {
let ln = coercion::to_number(lhs);
let rn = coercion::to_number(rhs);