feat: 添加 Kernel 与 VM 分层结构化日志
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
use crate::native::{NativeFn, NativeResult};
|
||||
use crate::vm::{native_fn_ptr_to_fn, FrameContinuation, Vm};
|
||||
use oxide_kernel::{builtins_debug, builtins_trace};
|
||||
use oxide_types::object::JsObject;
|
||||
use oxide_types::value::JsValue;
|
||||
|
||||
@@ -24,6 +25,7 @@ impl Vm {
|
||||
}
|
||||
let (args_buf, len) = Self::build_native_args(first_arg_reg, arg_count, this_reg);
|
||||
let args_slice = &args_buf[..len];
|
||||
builtins_debug!("native_call depth={} args={}", self.native_call_depth, arg_count);
|
||||
|
||||
// SAFETY: native_fn was set via set_native_fn with a valid NativeFn pointer;
|
||||
// native_fn_ptr_to_fn is the single coercion point for NativeFnPtr → NativeFn.
|
||||
@@ -33,6 +35,7 @@ impl Vm {
|
||||
match func(self, args_slice) {
|
||||
NativeResult::Ok(val) => {
|
||||
self.native_call_depth -= 1;
|
||||
builtins_trace!("native_call ok depth={}", self.native_call_depth);
|
||||
self.regs[0] = val;
|
||||
Ok(())
|
||||
}
|
||||
@@ -49,6 +52,7 @@ impl Vm {
|
||||
} else {
|
||||
format!("{err_val}")
|
||||
};
|
||||
builtins_debug!("native_call err={}", msg);
|
||||
(crate::builtins::error::create_error(self, &msg), "Error")
|
||||
};
|
||||
self.exception_value = Some(error);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
use oxide_compiler::opcode::OpCode;
|
||||
use oxide_kernel::prop_forge::PropTemplate;
|
||||
use oxide_kernel::{ic_debug, ic_trace};
|
||||
use oxide_types::object::JsObject;
|
||||
|
||||
use crate::vm::Vm;
|
||||
@@ -71,18 +72,28 @@ impl Vm {
|
||||
|
||||
if cached_shape_id != 0 && cached_shape_id == obj.shape_id() && cached_slot < obj.prop_vec_len() as u32 {
|
||||
self.regs[a] = obj.get_prop_at(cached_slot);
|
||||
ic_trace!("IC_GET hit shape={} slot={}", cached_shape_id, cached_slot);
|
||||
} else if let Some(template) = self.kernel.prop_forge().get_template(obj.shape_id()) {
|
||||
if template.prop_name == prop_name_si {
|
||||
if template.position < obj.prop_vec_len() as u32 {
|
||||
self.write_ic_back(obj.shape_id(), template.position);
|
||||
ic_debug!(
|
||||
"IC_GET propforge hit shape={} prop={} slot={}",
|
||||
obj.shape_id(),
|
||||
prop_name_si,
|
||||
template.position
|
||||
);
|
||||
self.regs[a] = obj.get_prop_at(template.position);
|
||||
} else {
|
||||
ic_debug!("IC_GET miss shape={} prop={}", obj.shape_id(), prop_name_si);
|
||||
self.regs[a] = self.ordinary_get(obj, prop_name_si, val)?;
|
||||
}
|
||||
} else {
|
||||
ic_debug!("IC_GET miss shape={} prop={}", obj.shape_id(), prop_name_si);
|
||||
self.regs[a] = self.ordinary_get(obj, prop_name_si, val)?;
|
||||
}
|
||||
} else {
|
||||
ic_debug!("IC_GET miss shape={} prop={}", obj.shape_id(), prop_name_si);
|
||||
let resolved = self.ordinary_get(obj, prop_name_si, val)?;
|
||||
if let Some(pos) = self.kernel.shape_forge().lookup_position(obj.shape_id(), prop_name_si) {
|
||||
self.write_ic_back(obj.shape_id(), pos);
|
||||
@@ -127,15 +138,18 @@ impl Vm {
|
||||
|
||||
if cached_shape_id != 0 && cached_shape_id == obj.shape_id() && cached_slot < obj.prop_vec_len() as u32 {
|
||||
obj.set_prop_at(cached_slot, value);
|
||||
ic_trace!("IC_SET hit shape={} slot={}", cached_shape_id, cached_slot);
|
||||
} else if let Some(pos) = self.kernel.shape_forge().lookup_position(obj.shape_id(), prop_name_si) {
|
||||
obj.set_prop_at(pos, value);
|
||||
self.write_ic_back(obj.shape_id(), pos);
|
||||
ic_debug!("IC_SET write-back shape={} slot={}", obj.shape_id(), pos);
|
||||
} else {
|
||||
let old_shape = obj.shape_id();
|
||||
self.ordinary_set_dispatch(obj, prop_name_si, value, receiver)?;
|
||||
if old_shape != obj.shape_id() {
|
||||
if let Some(pos) = self.kernel.shape_forge().lookup_position(obj.shape_id(), prop_name_si) {
|
||||
self.write_ic_back(obj.shape_id(), pos);
|
||||
ic_debug!("IC_SET write-back shape={} slot={}", obj.shape_id(), pos);
|
||||
self.kernel.prop_forge().upsert(
|
||||
obj.shape_id(),
|
||||
PropTemplate {
|
||||
|
||||
Reference in New Issue
Block a user