feat: 搭建闭包捕获基础设施

This commit is contained in:
2026-06-30 19:58:58 +08:00
parent 930b14b3f0
commit c58aae4862
17 changed files with 660 additions and 12 deletions
+20
View File
@@ -82,6 +82,16 @@ impl SessionGc {
if obj.is_data_view_obj() {
edges.extend(data_view::data_view_native_edges(obj));
}
// Traverse upvalue cells for object references
for cell_ptr in obj.upvalues_slice() {
if cell_ptr.is_null() {
continue;
}
let cell = unsafe { &**cell_ptr };
if cell.value.is_object() {
edges.push(cell.value);
}
}
edges
}
@@ -103,6 +113,16 @@ impl SessionGc {
if obj.home_object().is_string() {
live.insert(obj.home_object().as_string_ptr_mut());
}
// Scan upvalue cells for string references
for cell_ptr in obj.upvalues_slice() {
if cell_ptr.is_null() {
continue;
}
let cell = unsafe { &**cell_ptr };
if cell.value.is_string() {
live.insert(cell.value.as_string_ptr_mut());
}
}
if obj.is_map() {
for value in map::map_native_edges(obj) {
if value.is_string() {