mirror of
https://github.com/pjh456/OxideJS.git
synced 2026-10-24 02:31:13 +08:00
feat: 为内核构造、BuiltinWorld 初始化、ShapeForge/StringForge/CodeForge 添加结构化日志
This commit is contained in:
@@ -3,6 +3,7 @@ use oxide_types::object::{JsObject, NativeFnPtr, PropAttributes};
|
||||
use oxide_types::value::JsValue;
|
||||
|
||||
use crate::kernel::{BuiltinDirtySet, BuiltinId};
|
||||
use crate::kernel_info;
|
||||
use crate::shape_forge::{ShapeForge, EMPTY_SHAPE_ID};
|
||||
use crate::string_forge::PermInterner;
|
||||
|
||||
@@ -643,6 +644,7 @@ impl BuiltinWorld {
|
||||
stub_objects,
|
||||
};
|
||||
wire_builtin_world_links(&world);
|
||||
kernel_info!("BuiltinWorld initialized");
|
||||
world
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ use oxide_types::value::JsValue;
|
||||
|
||||
use crate::builtin::BuiltinWorld;
|
||||
use crate::code_forge::CodeForge;
|
||||
use crate::kernel_info;
|
||||
use crate::prop_forge::PropForge;
|
||||
use crate::shape_forge::{ShapeForge, EMPTY_SHAPE_ID};
|
||||
use crate::string_forge::PermInterner;
|
||||
@@ -124,13 +125,17 @@ impl KernelCore {
|
||||
NonZeroUsize::new(config.max_cached_modules).expect("max_cached_modules must be greater than zero"),
|
||||
));
|
||||
let prop_forge = Arc::new(PropForge::new());
|
||||
Arc::new(Self {
|
||||
let max_cached = config.max_cached_modules;
|
||||
let min_pool = config.min_pool_size;
|
||||
let core = Arc::new(Self {
|
||||
config,
|
||||
perm_interner,
|
||||
shape_forge,
|
||||
code_forge,
|
||||
prop_forge,
|
||||
})
|
||||
});
|
||||
kernel_info!("KernelCore initialized: max_cached_modules={}, min_pool={}", max_cached, min_pool);
|
||||
core
|
||||
}
|
||||
|
||||
pub fn perm_interner(&self) -> &Arc<PermInterner> {
|
||||
|
||||
@@ -4,7 +4,7 @@ use std::sync::{Arc, RwLock};
|
||||
|
||||
use dashmap::DashMap;
|
||||
|
||||
use crate::kernel_debug;
|
||||
use crate::{kernel_debug, kernel_trace};
|
||||
|
||||
pub type ShapeId = u32;
|
||||
pub type StringIndex = u32;
|
||||
@@ -83,6 +83,8 @@ impl ShapeForge {
|
||||
pub fn make_shape(&self, parent_id: ShapeId, prop_name: StringIndex) -> ShapeId {
|
||||
let key = Self::pack_key(parent_id, prop_name);
|
||||
|
||||
kernel_trace!("ShapeForge lookup: parent={} prop={}", parent_id, prop_name);
|
||||
|
||||
if let Some(entry) = self.transitions.get(&key) {
|
||||
kernel_debug!("ShapeForge transition cached parent={} prop={} -> id={}", parent_id, prop_name, *entry);
|
||||
return *entry;
|
||||
|
||||
@@ -82,9 +82,13 @@ impl PermInterner {
|
||||
let id = entries.len() as u32;
|
||||
let leaked: &'static str = Box::leak(s.to_string().into_boxed_str());
|
||||
entries.push(PermEntry { data: leaked, hash });
|
||||
let entry_count = entries.len();
|
||||
drop(entries);
|
||||
self.hash_map.entry(hash).or_default().push(id);
|
||||
kernel_debug!("PermInterner intern new id={} len={}", id, s.len());
|
||||
if entry_count % 1000 == 0 {
|
||||
kernel_debug!("PermInterner stats: {} strings", entry_count);
|
||||
}
|
||||
(id, hash)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user