refactor: 迁出日志宏,移除直接依赖
This commit is contained in:
@@ -12,6 +12,7 @@ oxide_kernel = { path = "../oxide_kernel" }
|
||||
oxide_runtime_api = { path = "../oxide_runtime_api" }
|
||||
oxide_builtins = { path = "../oxide_builtins" }
|
||||
oxide_types = { path = "../oxide_types" }
|
||||
oxide_log = { path = "../oxide_log" }
|
||||
bumpalo.workspace = true
|
||||
fast-float.workspace = true
|
||||
ryu.workspace = true
|
||||
@@ -22,7 +23,6 @@ chrono.workspace = true
|
||||
indexmap.workspace = true
|
||||
smallvec.workspace = true
|
||||
unicode-normalization.workspace = true
|
||||
tracing.workspace = true
|
||||
rustc-hash.workspace = true
|
||||
|
||||
[dev-dependencies]
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use crate::native::NativeFn;
|
||||
use crate::vm::{native_fn_ptr_to_fn, CallFrame, FrameContinuation, Vm};
|
||||
use oxide_builtins::{builtins_debug, builtins_trace};
|
||||
use oxide_bytecode::opcode;
|
||||
use oxide_kernel::{builtins_debug, builtins_trace};
|
||||
use oxide_runtime_api::NativeResult;
|
||||
use oxide_types::object::JsObject;
|
||||
use oxide_types::value::JsValue;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use crate::{ic_debug, ic_trace};
|
||||
use oxide_bytecode::opcode::OpCode;
|
||||
use oxide_kernel::prop_forge::PropTemplate;
|
||||
use oxide_kernel::{ic_debug, ic_trace};
|
||||
use oxide_types::object::JsObject;
|
||||
use oxide_types::private_key::make_private_name_id;
|
||||
use oxide_types::value::JsValue;
|
||||
|
||||
@@ -9,6 +9,7 @@ pub mod session_gc;
|
||||
pub mod vm;
|
||||
mod vm_dispatch_ctrl;
|
||||
mod vm_dispatch_misc;
|
||||
pub mod vm_log;
|
||||
pub mod vm_pool;
|
||||
mod vm_props;
|
||||
mod vm_runtime;
|
||||
|
||||
@@ -2,7 +2,7 @@ use std::collections::{HashMap, HashSet};
|
||||
use std::mem::size_of;
|
||||
use std::time::Instant;
|
||||
|
||||
use oxide_kernel::vm_debug;
|
||||
use crate::vm_debug;
|
||||
use oxide_types::object::{JsObject, JsString, PropMetaEntry};
|
||||
use oxide_types::value::JsValue;
|
||||
use rustc_hash::FxBuildHasher;
|
||||
|
||||
@@ -23,13 +23,7 @@ impl Vm {
|
||||
let ext = self.bytecode[self.pc];
|
||||
self.pc += 1;
|
||||
let arg_count = (ext & 0xFF) as usize;
|
||||
oxide_kernel::vm_debug!(
|
||||
"CALL rd={} this={} args={} depth={}",
|
||||
rd,
|
||||
this_reg,
|
||||
arg_count,
|
||||
self.frames.len()
|
||||
);
|
||||
crate::vm_debug!("CALL rd={} this={} args={} depth={}", rd, this_reg, arg_count, self.frames.len());
|
||||
|
||||
if obj.native_fn().is_some() {
|
||||
self.dispatch_native_call(obj, callee, this_reg, first_arg_reg, arg_count)?;
|
||||
@@ -77,7 +71,7 @@ impl Vm {
|
||||
let ext = self.bytecode[self.pc];
|
||||
self.pc += 1;
|
||||
let arg_count = (ext & 0xFF) as usize;
|
||||
oxide_kernel::vm_debug!("CALL_NATIVE rd={} args={}", rd, arg_count);
|
||||
crate::vm_debug!("CALL_NATIVE rd={} args={}", rd, arg_count);
|
||||
self.dispatch_native_call(obj, callee, this_reg, first_arg_reg, arg_count)
|
||||
}
|
||||
|
||||
@@ -115,7 +109,7 @@ impl Vm {
|
||||
|
||||
pub(crate) fn dispatch_return(&mut self, rd: usize) -> Result<Option<JsValue>, String> {
|
||||
let result = self.regs[rd];
|
||||
oxide_kernel::vm_debug!("RETURN depth={}", self.frames.len());
|
||||
crate::vm_debug!("RETURN depth={}", self.frames.len());
|
||||
if let Some(frame) = self.frames.pop() {
|
||||
let construct_result_reg = frame.construct_result_reg;
|
||||
let constructed_this = frame.constructed_this;
|
||||
@@ -144,7 +138,7 @@ impl Vm {
|
||||
}
|
||||
|
||||
pub(crate) fn dispatch_throw(&mut self, rd: usize) -> Result<bool, String> {
|
||||
oxide_kernel::vm_debug!("THROW pc={}", self.pc);
|
||||
crate::vm_debug!("THROW pc={}", self.pc);
|
||||
let exc_value = self.regs[rd];
|
||||
self.exception_value = Some(exc_value);
|
||||
self.pending_error_kind = Some(self.thrown_error_kind(exc_value));
|
||||
@@ -152,7 +146,7 @@ impl Vm {
|
||||
}
|
||||
|
||||
pub(crate) fn dispatch_try_begin(&mut self, instr: u32) {
|
||||
oxide_kernel::vm_trace!("TRY_BEGIN frame_depth={}", self.frames.len());
|
||||
crate::vm_trace!("TRY_BEGIN frame_depth={}", self.frames.len());
|
||||
let offset = opcode::offset16(instr) as isize;
|
||||
let catch_pc = if offset == 0 {
|
||||
None
|
||||
|
||||
@@ -2,6 +2,7 @@ use std::sync::Arc;
|
||||
|
||||
use crate::native::NativeFn;
|
||||
use crate::vm::{native_fn_ptr_to_fn, CallFrame, ForInIter, FrameContinuation, Vm, MAX_PROTO_CHAIN_DEPTH};
|
||||
use crate::vm_debug;
|
||||
use oxide_runtime_api::{to_boolean, NativeResult};
|
||||
use oxide_types::object::{JsObject, PropAttributes};
|
||||
use oxide_types::private_key::is_private_name_key;
|
||||
@@ -11,7 +12,7 @@ impl Vm {
|
||||
pub(crate) fn dispatch_new_expression(&mut self, rd: usize, a: usize, b: usize) -> Result<bool, String> {
|
||||
let constructor_reg = a;
|
||||
let first_arg_reg = b as u8;
|
||||
oxide_kernel::vm_debug!("NEW_EXPRESSION rd={}", rd);
|
||||
vm_debug!("NEW_EXPRESSION rd={}", rd);
|
||||
|
||||
let constructor = self.regs[constructor_reg];
|
||||
if !constructor.is_object() {
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
#[macro_export]
|
||||
macro_rules! vm_error {
|
||||
($($arg:tt)*) => {
|
||||
oxide_log::__log_event!("oxide::vm", oxide_log::tracing::Level::ERROR, $($arg)*)
|
||||
};
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! vm_warn {
|
||||
($($arg:tt)*) => {
|
||||
oxide_log::__log_event!("oxide::vm", oxide_log::tracing::Level::WARN, $($arg)*)
|
||||
};
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! vm_info {
|
||||
($($arg:tt)*) => {
|
||||
oxide_log::__log_event!("oxide::vm", oxide_log::tracing::Level::INFO, $($arg)*)
|
||||
};
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! vm_debug {
|
||||
($($arg:tt)*) => {
|
||||
oxide_log::__log_event!("oxide::vm", oxide_log::tracing::Level::DEBUG, $($arg)*)
|
||||
};
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! vm_trace {
|
||||
($($arg:tt)*) => {
|
||||
oxide_log::__log_event!("oxide::vm", oxide_log::tracing::Level::TRACE, $($arg)*)
|
||||
};
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! ic_error {
|
||||
($($arg:tt)*) => {
|
||||
oxide_log::__log_event!("oxide::ic", oxide_log::tracing::Level::ERROR, $($arg)*)
|
||||
};
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! ic_warn {
|
||||
($($arg:tt)*) => {
|
||||
oxide_log::__log_event!("oxide::ic", oxide_log::tracing::Level::WARN, $($arg)*)
|
||||
};
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! ic_info {
|
||||
($($arg:tt)*) => {
|
||||
oxide_log::__log_event!("oxide::ic", oxide_log::tracing::Level::INFO, $($arg)*)
|
||||
};
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! ic_debug {
|
||||
($($arg:tt)*) => {
|
||||
oxide_log::__log_event!("oxide::ic", oxide_log::tracing::Level::DEBUG, $($arg)*)
|
||||
};
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! ic_trace {
|
||||
($($arg:tt)*) => {
|
||||
oxide_log::__log_event!("oxide::ic", oxide_log::tracing::Level::TRACE, $($arg)*)
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user