mirror of
https://github.com/pjh456/OxideJS.git
synced 2026-10-24 10:41:11 +08:00
227dfe008f
- 泄漏修复:KernelSession 收尾(teardown_intrinsic_protos/free_session_upvalues) 释放内建对象 Box::into_raw 裸堆区(release_raw_heap 四区置空幂等)与 session upvalue 原件/晋升克隆别名去重释放;bindings 原生盒负载边、 session_gc 边记录、vm_props 属性区同步收尾 - 失控测试封顶:runner kernel max_alloc_bytes=256MiB(dispatch 采样口径 run_alloc_bytes/run_alloc_bytes_full),超限计 memory-limit 失败而非拖垮 进程 RSS(arena 高水位 GB 级 × 多 worker = 宿主 OOM) - 归属:RSS 泄漏 pre-existing(HEAD 无 WIP 同现);identifiers escaped unicode 挂死族另立 B132(pre-existing,supervise 超时自愈) - 验证:build/clippy/四 crate 测试全绿零新增告警;language 前 5000 测试 单窗峰值 330MB(旧 ~4.5MB/测试 单调增长→88GB OOM 签名消失), 窗口间峰值 0.17-1.6GB 有界、逐测试释放回基线
70 lines
2.8 KiB
Rust
70 lines
2.8 KiB
Rust
use std::sync::Arc;
|
|
|
|
use crate::bindings::{apply_binding_table, bind_global_value};
|
|
use oxide_kernel::kernel::{KernelCore, KernelSession};
|
|
use oxide_kernel::shape_forge::EMPTY_SHAPE_ID;
|
|
use oxide_types::object::JsObject;
|
|
use oxide_types::value::JsValue;
|
|
|
|
/// 把 Reflect 单例对象及其方法(get/set/construct/defineProperty 等)绑定到 global。
|
|
pub fn bind_reflect(core: &Arc<KernelCore>, session: &KernelSession, global: &mut JsObject) {
|
|
let mut reflect = Box::new(JsObject::new_empty(
|
|
EMPTY_SHAPE_ID,
|
|
JsValue::from_js_object(session.builtin_world().object_proto.as_ptr() as *mut JsObject),
|
|
));
|
|
|
|
apply_binding_table(
|
|
session.builtin_world(),
|
|
&mut reflect,
|
|
core,
|
|
&[
|
|
("apply", oxide_builtins::reflect::reflect_apply::<crate::vm::Vm> as *const (), 3),
|
|
("construct", oxide_builtins::reflect::reflect_construct::<crate::vm::Vm> as *const (), 2),
|
|
(
|
|
"defineProperty",
|
|
oxide_builtins::reflect::reflect_define_property::<crate::vm::Vm> as *const (),
|
|
3,
|
|
),
|
|
(
|
|
"deleteProperty",
|
|
oxide_builtins::reflect::reflect_delete_property::<crate::vm::Vm> as *const (),
|
|
2,
|
|
),
|
|
("get", oxide_builtins::reflect::reflect_get::<crate::vm::Vm> as *const (), 2),
|
|
(
|
|
"getOwnPropertyDescriptor",
|
|
oxide_builtins::reflect::reflect_get_own_property_descriptor::<crate::vm::Vm> as *const (),
|
|
2,
|
|
),
|
|
(
|
|
"getPrototypeOf",
|
|
oxide_builtins::reflect::reflect_get_prototype_of::<crate::vm::Vm> as *const (),
|
|
1,
|
|
),
|
|
("has", oxide_builtins::reflect::reflect_has::<crate::vm::Vm> as *const (), 2),
|
|
(
|
|
"isExtensible",
|
|
oxide_builtins::reflect::reflect_is_extensible::<crate::vm::Vm> as *const (),
|
|
1,
|
|
),
|
|
("ownKeys", oxide_builtins::reflect::reflect_own_keys::<crate::vm::Vm> as *const (), 1),
|
|
(
|
|
"preventExtensions",
|
|
oxide_builtins::reflect::reflect_prevent_extensions::<crate::vm::Vm> as *const (),
|
|
1,
|
|
),
|
|
("set", oxide_builtins::reflect::reflect_set::<crate::vm::Vm> as *const (), 3),
|
|
(
|
|
"setPrototypeOf",
|
|
oxide_builtins::reflect::reflect_set_prototype_of::<crate::vm::Vm> as *const (),
|
|
2,
|
|
),
|
|
],
|
|
);
|
|
|
|
let reflect_ptr = Box::into_raw(reflect);
|
|
// 登记进 world 释放表:session 收尾统一释放对象本体与属性区。
|
|
session.builtin_world().track_leaked_object(reflect_ptr);
|
|
bind_global_value(core, global, "Reflect", JsValue::from_js_object(reflect_ptr));
|
|
}
|