mirror of
https://github.com/pjh456/OxideJS.git
synced 2026-10-24 02:31:13 +08:00
fix: new 构造入口补齐 sub_modules 上下文切换
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
use std::sync::Arc;
|
||||
use std::sync::{Arc, OnceLock};
|
||||
|
||||
use crate::native::NativeFn;
|
||||
use crate::vm::{native_fn_ptr_to_fn, CallFrame, ForInIter, FrameContinuation, Vm, MAX_PROTO_CHAIN_DEPTH};
|
||||
@@ -153,6 +153,16 @@ impl Vm {
|
||||
}
|
||||
}
|
||||
|
||||
let callee_subs = &subs[sub_idx].sub_modules;
|
||||
if callee_subs.is_empty() {
|
||||
self.sub_module_stack.push((Arc::clone(&self.sub_modules), None));
|
||||
} else {
|
||||
self.sub_module_stack
|
||||
.push((Arc::clone(&self.sub_modules), Some(std::mem::take(&mut self.immutables_cache))));
|
||||
self.sub_modules = Arc::new(callee_subs.clone());
|
||||
self.immutables_cache = (0..=callee_subs.len()).map(|_| OnceLock::new()).collect();
|
||||
}
|
||||
|
||||
self.active_reg_limit = sub_n_registers.max(1);
|
||||
self.pc = 0;
|
||||
Ok(true)
|
||||
|
||||
Reference in New Issue
Block a user