mirror of
https://github.com/pjh456/OxideJS.git
synced 2026-10-23 18:21:13 +08:00
perf: 不可变常量改 OnceLock 一次性缓存,删 Constant 死变体并移出 GC 根
This commit is contained in:
@@ -4,8 +4,9 @@ impl Vm {
|
||||
#[inline(always)]
|
||||
pub(crate) fn dispatch_load_const(&mut self, rd: usize, instr: u32) -> Result<(), String> {
|
||||
let idx = (instr >> 16) as usize;
|
||||
if idx < self.constants.len() {
|
||||
self.regs[rd] = self.constants[idx];
|
||||
let imm = self.immutables();
|
||||
if idx < imm.len() {
|
||||
self.regs[rd] = imm[idx];
|
||||
Ok(())
|
||||
} else {
|
||||
Err(format!("constant index {idx} out of bounds"))
|
||||
|
||||
Reference in New Issue
Block a user