mirror of
https://github.com/pjh456/OxideJS.git
synced 2026-10-24 02:31:13 +08:00
docs: 补全 Promise 状态盒与 GC 安全注释
This commit is contained in:
@@ -175,6 +175,7 @@ pub(crate) fn promise_native_size(obj: &JsObject) -> u64 {
|
||||
if ptr.is_null() {
|
||||
return 0;
|
||||
}
|
||||
// SAFETY: !is_promise_obj 与 ptr.is_null 已早退,ptr 非空且指向存活 Box<PromiseState>,此处只读容量不释放。
|
||||
unsafe {
|
||||
std::mem::size_of::<PromiseState>() as u64
|
||||
+ (*ptr).reactions.capacity() as u64 * std::mem::size_of::<PromiseReaction>() as u64
|
||||
|
||||
@@ -126,6 +126,7 @@ fn is_constructor_value(c: JsValue) -> bool {
|
||||
if !c.is_object() {
|
||||
return false;
|
||||
}
|
||||
// SAFETY: is_object 保证指针非空且指向存活 arena 对象,此处只读函数标志并立即消费。
|
||||
let c_obj = unsafe { &*c.as_js_object_ptr() };
|
||||
c_obj.is_function()
|
||||
&& !c_obj.is_arrow()
|
||||
|
||||
Reference in New Issue
Block a user