mirror of
https://github.com/pjh456/OxideJS.git
synced 2026-10-27 12:11:12 +08:00
refactor: 收集路径原地化退役移动式sweep与门控
This commit is contained in:
@@ -33,11 +33,11 @@ pub(crate) fn promise_native_edges(obj: &JsObject) -> Vec<JsValue> {
|
||||
edges
|
||||
}
|
||||
|
||||
/// 用转发函数重写状态盒中的所有 JsValue(session GC 移动式清扫 / promote 用)。
|
||||
/// 用转发函数重写状态盒中的所有 JsValue(promote 用)。
|
||||
///
|
||||
/// 结算链指针是裸指针边、不在本函数改写面:晋升路径克隆新分配于 session
|
||||
/// arena(原件地址不变),同 arena 改写场景指针天然有效;搬移换址场景由
|
||||
/// 调用方在重写完成后经 `repoint_promise_promoted_clone` 按转发表重定位。
|
||||
/// 结算链指针是裸指针边、不在本函数改写面:晋升克隆新分配于 session arena
|
||||
/// (原件地址不变),改写场景指针天然有效;结算链接链由
|
||||
/// `migrate_settlement_to_newest_clone` 负责。
|
||||
pub(crate) fn rewrite_promise_native(obj: &JsObject, mut rewrite: impl FnMut(JsValue) -> JsValue) {
|
||||
let Some(state) = promise_state_mut(obj) else {
|
||||
return;
|
||||
@@ -53,12 +53,12 @@ pub(crate) fn rewrite_promise_native(obj: &JsObject, mut rewrite: impl FnMut(JsV
|
||||
}
|
||||
}
|
||||
|
||||
/// 深拷贝状态盒到新对象(promote / sweep 用):新对象持独立 Box,源盒可安全释放。
|
||||
/// 深拷贝状态盒到新对象(promote 用):新对象持独立 Box,源盒可安全释放。
|
||||
///
|
||||
/// 源的反应**迁移**(非复制)进新对象:源盒随 epoch 释放,留在源上的反应会
|
||||
/// 永久丢失、原件侧消费者永不触发;每条反应的 JsValue 随状态盒其余字段同一
|
||||
/// pass 晋升/改写。结算链指针按原值保留(晋升场景由
|
||||
/// `migrate_settlement_to_newest_clone` 接链,搬移场景按转发表重定位)。
|
||||
/// pass 晋升/改写。结算链指针按原值保留(接链由
|
||||
/// `migrate_settlement_to_newest_clone` 负责)。
|
||||
pub(crate) fn clone_promise_native_with_rewrite(
|
||||
old: &JsObject, new: &mut JsObject, mut rewrite: impl FnMut(JsValue) -> JsValue,
|
||||
) {
|
||||
@@ -144,16 +144,6 @@ pub(crate) fn migrate_settlement_to_newest_clone(
|
||||
}
|
||||
}
|
||||
|
||||
/// 按给定转发改写结算链指针(裸指针边、非 JsValue),session GC 搬移后调用。
|
||||
pub(crate) fn repoint_promise_promoted_clone(obj: &JsObject, forward: impl FnOnce(*mut JsObject) -> *mut JsObject) {
|
||||
let Some(state) = promise_state_mut(obj) else {
|
||||
return;
|
||||
};
|
||||
if !state.promoted_clone.is_null() {
|
||||
state.promoted_clone = forward(state.promoted_clone);
|
||||
}
|
||||
}
|
||||
|
||||
/// 改写单条反应的四条 JsValue 引用(派生 promise 能力与处理器),源反应迁移
|
||||
/// 与再晋升合并共用。
|
||||
fn rewrite_reaction<F: FnMut(JsValue) -> JsValue>(r: PromiseReaction, rewrite: &mut F) -> PromiseReaction {
|
||||
|
||||
@@ -19,7 +19,7 @@ mod settlement;
|
||||
|
||||
pub(crate) use gc_edges::{
|
||||
clone_promise_native_with_rewrite, drop_promise_native, migrate_settlement_to_newest_clone, promise_native_edges,
|
||||
promise_native_size, repoint_promise_promoted_clone, rewrite_promise_native,
|
||||
promise_native_size, rewrite_promise_native,
|
||||
};
|
||||
pub(crate) use jobs::{for_each_job_value, rewrite_job_values};
|
||||
pub use reactions::promise_settled_value;
|
||||
|
||||
Reference in New Issue
Block a user