v8 handlescope的机制

V8引擎中的HandleScope负责管理对象的引用,不存储对象内容。它使用HandleScopeData对象,通过Isolate的block数组动态扩展内存。HandleScope形成链表,析构时关闭作用域并释放引用,而EscopeHandleScope则用于保留关键对象,提供一种临时对象管理的方式。
摘要由CSDN通过智能技术生成

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;
}
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值