fix: upvalue cell 参与 mark-sweep 回收,闭合长 run 死闭包 cell 泄漏

This commit is contained in:
2026-09-26 18:27:21 +00:00
parent f1cd2cd612
commit 78953e338b
8 changed files with 377 additions and 22 deletions
+19 -1
View File
@@ -10,7 +10,7 @@
use oxide_kernel::shape_forge::EMPTY_SHAPE_ID;
use oxide_runtime_api::{to_boolean, NativeResult};
use oxide_types::object::{JsObject, NativeFnPtr, PropAttributes};
use oxide_types::object::{Cell, JsObject, NativeFnPtr, PropAttributes};
use oxide_types::value::JsValue;
use crate::vm::Vm;
@@ -556,6 +556,24 @@ pub(crate) fn async_native_string_edges(obj: &JsObject) -> Vec<*mut oxide_types:
out
}
/// 异步挂起帧 cell_stack 的 cell 指针扁平列表(GC mark cell 边)。
/// 与 `async_native_string_edges` 经同一字段清单(`suspended.cell_stack`)
/// 产出,cell 指针不经对象图、须独立入存活集。
pub(crate) fn async_native_cell_edges(obj: &JsObject) -> Vec<*mut Cell> {
let Some(state) = async_state_mut(obj) else {
return Vec::new();
};
let mut out = Vec::new();
for cells in &state.suspended.cell_stack {
for &cell_ptr in cells {
if !cell_ptr.is_null() {
out.push(cell_ptr);
}
}
}
out
}
/// 用转发函数重写状态快照中的所有 JsValue(session GC 移动式清扫 / promote 用)。
pub(crate) fn rewrite_async_native(obj: &JsObject, mut rewrite: impl FnMut(JsValue) -> JsValue) {
let Some(state) = async_state_mut(obj) else {