summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Noordhuis <info@bnoordhuis.nl>2013-08-03 22:18:35 +0200
committerBen Noordhuis <info@bnoordhuis.nl>2013-08-03 22:23:28 +0200
commitd4cc30f18c2bf446c31ee8f7d05260a1c540fd1a (patch)
treeb310ac55fc92e3182775830951f4068cd6756426
parente5791f74f0bb3f52efa5429b5ae9425cbde46f97 (diff)
downloadandroid-node-v8-d4cc30f18c2bf446c31ee8f7d05260a1c540fd1a.tar.gz
android-node-v8-d4cc30f18c2bf446c31ee8f7d05260a1c540fd1a.tar.bz2
android-node-v8-d4cc30f18c2bf446c31ee8f7d05260a1c540fd1a.zip
src: use PersistentToLocal() in a few more places
Update a few more `Local<T>::New(isolate, persistent)` call sites to `PersistentToLocal(isolate, persistent)` - the latter has a fast path for non-weak persistent references.
-rw-r--r--src/handle_wrap.h2
-rw-r--r--src/node_crypto.cc3
-rw-r--r--src/node_script.cc4
-rw-r--r--src/req_wrap.h3
-rw-r--r--src/tls_wrap.h7
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<v8::Object> object() {
- return v8::Local<v8::Object>::New(node_isolate, persistent());
+ return PersistentToLocal(node_isolate, persistent());
}
inline v8::Persistent<v8::Object>& 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<Object> obj = Local<Object>::New(node_isolate, req->obj);
req->obj.Dispose();
Local<Value> 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<Object> WrappedContext::NewInstance() {
Local<Context> WrappedContext::GetV8Context() {
- return Local<Context>::New(node_isolate, context_);
+ return PersistentToLocal(node_isolate, context_);
}
@@ -404,7 +404,7 @@ void WrappedScript::EvalMachine(const FunctionCallbackInfo<Value>& args) {
"'this' must be a result of previous new Script(code) call.");
}
- script = Local<Script>::New(node_isolate, n_script->script_);
+ script = PersistentToLocal(node_isolate, n_script->script_);
}
if (output_flag == returnResult) {
diff --git a/src/req_wrap.h b/src/req_wrap.h
index d4c1180ded..794e4f3769 100644
--- a/src/req_wrap.h
+++ b/src/req_wrap.h
@@ -22,6 +22,7 @@
#ifndef SRC_REQ_WRAP_H_
#define SRC_REQ_WRAP_H_
+#include "node.h"
#include "queue.h"
namespace node {
@@ -69,7 +70,7 @@ class ReqWrap {
}
inline v8::Local<v8::Object> object() {
- return v8::Local<v8::Object>::New(node_isolate, persistent());
+ return PersistentToLocal(node_isolate, persistent());
}
inline v8::Persistent<v8::Object>& persistent() {
diff --git a/src/tls_wrap.h b/src/tls_wrap.h
index 3e56926328..6db4b6e41b 100644
--- a/src/tls_wrap.h
+++ b/src/tls_wrap.h
@@ -22,9 +22,10 @@
#ifndef SRC_TLS_WRAP_H_
#define SRC_TLS_WRAP_H_
-#include "v8.h"
-#include "stream_wrap.h"
+#include "node.h"
#include "queue.h"
+#include "stream_wrap.h"
+#include "v8.h"
#include <openssl/ssl.h>
@@ -162,7 +163,7 @@ class TLSCallbacks : public StreamWrapCallbacks {
#endif // SSL_CTRL_SET_TLSEXT_SERVERNAME_CB
inline v8::Local<v8::Object> object() {
- return v8::Local<v8::Object>::New(node_isolate, persistent());
+ return PersistentToLocal(node_isolate, persistent());
}
inline v8::Persistent<v8::Object>& persistent() {