HandleScope
成员
HandleScope类重要的3个成员
internal::Isolate* isolate_;
intieral::Object** prev_next_;
internal::Object** prev_limit_;
HandleScope::CreateHandle
Object** HandleScope::CreateHandle(Isolate* isolate, Object* value) {
DCHECK(AllowHandleAllocation::IsAllowed());
HandleScopeData* data = isolate->handle_scope_data();
Object** result = data->next;
if (result == data->limit) result = Extend(isolate);
// Update the current next field, set the value in the created
// handle, and return the result.
DCHECK(result < data->limit);
data->next = result + 1;
*result = value;
return result;
}
HandleScopeData对象,是一个struct

V8引擎中的HandleScope负责管理对象的引用,不存储对象内容。它使用HandleScopeData对象,通过Isolate的block数组动态扩展内存。HandleScope形成链表,析构时关闭作用域并释放引用,而EscopeHandleScope则用于保留关键对象,提供一种临时对象管理的方式。
最低0.47元/天 解锁文章
3922

被折叠的 条评论
为什么被折叠?



