From d4cc30f18c2bf446c31ee8f7d05260a1c540fd1a Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Sat, 3 Aug 2013 22:18:35 +0200 Subject: [PATCH] src: use PersistentToLocal() in a few more places Update a few more `Local::New(isolate, persistent)` call sites to `PersistentToLocal(isolate, persistent)` - the latter has a fast path for non-weak persistent references. --- src/handle_wrap.h | 2 +- src/node_crypto.cc | 3 +++ src/node_script.cc | 4 ++-- src/req_wrap.h | 3 ++- src/tls_wrap.h | 7 ++++--- 5 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/handle_wrap.h b/src/handle_wrap.h index 6e6f3904b8..cbe7e3248b 100644 --- a/src/handle_wrap.h +++ b/src/handle_wrap.h @@ -69,7 +69,7 @@ class HandleWrap { virtual ~HandleWrap(); inline v8::Local object() { - return v8::Local::New(node_isolate, persistent()); + return PersistentToLocal(node_isolate, persistent()); } inline v8::Persistent& persistent() { diff --git a/src/node_crypto.cc b/src/node_crypto.cc index 540d9cdabc..e68d91dccb 100644 --- a/src/node_crypto.cc +++ b/src/node_crypto.cc @@ -3315,6 +3315,9 @@ void EIO_PBKDF2After(uv_work_t* work_req, int status) { assert(status == 0); pbkdf2_req* req = container_of(work_req, pbkdf2_req, work_req); HandleScope scope(node_isolate); + // Create a new Local that's associated with the current HandleScope. + // PersistentToLocal() returns a handle that gets zeroed when we call + // Dispose() so don't use that. Local obj = Local::New(node_isolate, req->obj); req->obj.Dispose(); Local argv[2]; diff --git a/src/node_script.cc b/src/node_script.cc index 9c6a598848..d155c51fad 100644 --- a/src/node_script.cc +++ b/src/node_script.cc @@ -174,7 +174,7 @@ Local WrappedContext::NewInstance() { Local WrappedContext::GetV8Context() { - return Local::New(node_isolate, context_); + return PersistentToLocal(node_isolate, context_); } @@ -404,7 +404,7 @@ void WrappedScript::EvalMachine(const FunctionCallbackInfo& args) { "'this' must be a result of previous new Script(code) call."); } - script = Local