mirror of
https://github.com/pjh456/OxideJS.git
synced 2026-10-25 11:11:11 +08:00
fix: 模块求值状态表补入 GC 根遍历防命名空间对象悬垂
This commit is contained in:
@@ -8,7 +8,7 @@ use super::frames::Completion;
|
||||
use super::Vm;
|
||||
use crate::session_gc::SessionGc;
|
||||
|
||||
/// GC 根组来源:`for_each_value` 枚举的 27 个根组,变体顺序与根清单
|
||||
/// GC 根组来源:`for_each_value` 枚举的 29 个根组,变体顺序与根清单
|
||||
/// 的枚举顺序一致。
|
||||
///
|
||||
/// 变体下标是逐组计数数组(`SessionGc::root_counts`)的下标;`COUNT` 与
|
||||
@@ -43,11 +43,12 @@ pub(crate) enum RootGroup {
|
||||
WorkerObjects,
|
||||
DisposeStack,
|
||||
EventTargets,
|
||||
ModuleEvalStates,
|
||||
}
|
||||
|
||||
impl RootGroup {
|
||||
/// 根组总数(与变体数同源,绑定逐组计数数组的长度)。
|
||||
pub const COUNT: usize = 28;
|
||||
pub const COUNT: usize = 29;
|
||||
}
|
||||
|
||||
impl Vm {
|
||||
@@ -55,7 +56,7 @@ impl Vm {
|
||||
/// 覆盖执行核心的全部 JsValue 持有点:regs/帧/各栈段/cell/在途异常与完成/
|
||||
/// 挂起信号/迭代器/微任务/global/Worker 对象注册表。
|
||||
///
|
||||
/// 闭包接收根组来源(`RootGroup`)与根值:组是枚举顺序中的 27 根组之一,
|
||||
/// 闭包接收根组来源(`RootGroup`)与根值:组是枚举顺序中的 29 根组之一,
|
||||
/// 调用方按组计数(如 `SessionGc` 的逐组计数)。
|
||||
pub(crate) fn for_each_value(&self, mut f: impl FnMut(RootGroup, JsValue)) {
|
||||
for value in &self.regs {
|
||||
@@ -193,6 +194,11 @@ impl Vm {
|
||||
f(RootGroup::EventTargets, entry.callback);
|
||||
}
|
||||
}
|
||||
// per-module 求值状态表持命名空间对象与 capability promise:漏根 →
|
||||
// session GC 回收 → 后续读点(缓存命名空间取回 / 再查)解引用悬垂。
|
||||
for state in self.module_eval_states.values() {
|
||||
f(RootGroup::ModuleEvalStates, state.namespace);
|
||||
}
|
||||
}
|
||||
|
||||
/// GC 根统一枚举入口:遍历的字段清单与 `for_each_value` 相同。
|
||||
|
||||
Reference in New Issue
Block a user