feat: async/await 语法支持(AWAIT 帧快照挂起/恢复 + 微任务驱动 + AsyncFunction intrinsics)

This commit is contained in:
2026-08-09 22:02:15 +08:00
parent 538a5670dc
commit fd47cd56d0
28 changed files with 1055 additions and 28 deletions
+15
View File
@@ -95,6 +95,9 @@ impl SessionGc {
if obj.is_promise_obj() {
edges.extend(crate::promise::promise_native_edges(obj));
}
if obj.is_async_obj() {
edges.extend(crate::async_func::async_native_edges(obj));
}
// 遍历 upvalue cell 中的对象引用。
for cell_ptr in obj.upvalues_slice() {
if cell_ptr.is_null() {
@@ -164,6 +167,13 @@ impl SessionGc {
}
}
}
if obj.is_async_obj() {
for value in crate::async_func::async_native_edges(obj) {
if value.is_string() {
live.insert(value.as_string_ptr_mut());
}
}
}
}
pub(crate) fn mark(&mut self, vm: &Vm) {
@@ -275,6 +285,7 @@ impl SessionGc {
freed_bytes += data_view::drop_data_view_native(obj);
freed_bytes += crate::generator::drop_generator_native(obj);
freed_bytes += crate::promise::drop_promise_native(obj);
freed_bytes += crate::async_func::drop_async_native(obj);
freed_bytes
}
@@ -333,6 +344,8 @@ impl SessionGc {
data_view::clone_data_view_native_with_rewrite(old_ref, new_ref, |value| value);
} else if old_ref.is_promise_obj() {
crate::promise::clone_promise_native_with_rewrite(old_ref, new_ref, |value| value);
} else if old_ref.is_async_obj() {
crate::async_func::clone_async_native_with_rewrite(old_ref, new_ref, |value| value);
}
forwarding.insert(old_ptr, new_ptr);
freed_bytes += Self::drop_session_object_heap_data(old_ptr);
@@ -366,6 +379,8 @@ impl SessionGc {
crate::generator::rewrite_generator_native(obj, |value| rewrite_forwarded_value(value, &forwarding));
} else if obj.is_promise_obj() {
crate::promise::rewrite_promise_native(obj, |value| rewrite_forwarded_value(value, &forwarding));
} else if obj.is_async_obj() {
crate::async_func::rewrite_async_native(obj, |value| rewrite_forwarded_value(value, &forwarding));
}
}