mirror of
https://github.com/pjh456/OxideJS.git
synced 2026-10-23 18:21:13 +08:00
perf: 实参打包缓冲回退 Vec(A/B 实测无可测收益)
This commit is contained in:
@@ -6,7 +6,6 @@ use std::sync::Arc;
|
||||
use oxide_runtime_api::NativeResult;
|
||||
use oxide_types::object::{Cell, JsObject};
|
||||
use oxide_types::value::JsValue;
|
||||
use smallvec::SmallVec;
|
||||
|
||||
use super::frames::{CallFrame, FrameArgs, FrameContinuation};
|
||||
use super::{native_fn_ptr_to_fn, Vm};
|
||||
@@ -14,14 +13,11 @@ use crate::native::NativeFn;
|
||||
use crate::{vm_debug, vm_trace};
|
||||
|
||||
impl Vm {
|
||||
fn pack_sync_native_call_args(
|
||||
&mut self, receiver: JsValue, callee: JsValue, args: &[JsValue],
|
||||
) -> SmallVec<[u8; 256]> {
|
||||
fn pack_sync_native_call_args(&mut self, receiver: JsValue, callee: JsValue, args: &[JsValue]) -> Vec<u8> {
|
||||
self.regs[253] = receiver;
|
||||
self.regs[254] = callee;
|
||||
|
||||
// 实参寄存器号列表容量恒 ≤ 254(253 实参 + receiver),栈内缓冲免每次 native 调用堆分配。
|
||||
let mut arg_regs = SmallVec::new();
|
||||
let mut arg_regs = Vec::with_capacity(args.len() + 1);
|
||||
arg_regs.push(253);
|
||||
for (idx, arg) in args.iter().enumerate() {
|
||||
let reg = (Self::SYNC_NATIVE_ARG_BASE + idx) as u8;
|
||||
|
||||
Reference in New Issue
Block a user