src: remove non-isolate PersistentToLocal()
authorBen Noordhuis <info@bnoordhuis.nl>
Fri, 2 Aug 2013 21:12:56 +0000 (23:12 +0200)
committerBen Noordhuis <info@bnoordhuis.nl>
Fri, 2 Aug 2013 21:16:00 +0000 (23:16 +0200)
There is no need for it and it's a tiny bit slower than the version of
PersistentToLocal() that takes a v8::Isolate* as its first argument.

src/cares_wrap.cc
src/node.cc
src/node_crypto.cc
src/node_file.cc
src/node_internals.h
src/node_script.cc
src/smalloc.cc
src/tls_wrap.cc

index e930431..6cb55a5 100644 (file)
@@ -261,7 +261,7 @@ class QueryWrap {
   }
 
   inline Local<Object> object() {
-    return PersistentToLocal(persistent());
+    return PersistentToLocal(node_isolate, persistent());
   }
 
  protected:
index 4e6c5b5..bcc3996 100644 (file)
@@ -894,7 +894,7 @@ void SetupDomainUse(const FunctionCallbackInfo<Value>& args) {
   if (using_domains) return;
   HandleScope scope(node_isolate);
   using_domains = true;
-  Local<Object> process = PersistentToLocal(process_p);
+  Local<Object> process = PersistentToLocal(node_isolate, process_p);
   Local<Value> tdc_v = process->Get(String::New("_tickDomainCallback"));
   Local<Value> ndt_v = process->Get(String::New("_nextDomainTick"));
   if (!tdc_v->IsFunction()) {
@@ -983,8 +983,8 @@ MakeDomainCallback(const Handle<Object> object,
   }
 
   // process nextTicks after call
-  Local<Object> process = PersistentToLocal(process_p);
-  Local<Function> fn = PersistentToLocal(process_tickCallback);
+  Local<Object> process = PersistentToLocal(node_isolate, process_p);
+  Local<Function> fn = PersistentToLocal(node_isolate, process_tickCallback);
   fn->Call(process, 0, NULL);
 
   if (try_catch.HasCaught()) {
@@ -1001,7 +1001,7 @@ MakeCallback(const Handle<Object> object,
              int argc,
              Handle<Value> argv[]) {
   // TODO(trevnorris) Hook for long stack traces to be made here.
-  Local<Object> process = PersistentToLocal(process_p);
+  Local<Object> process = PersistentToLocal(node_isolate, process_p);
 
   if (using_domains)
     return MakeDomainCallback(object, callback, argc, argv);
@@ -1035,7 +1035,7 @@ MakeCallback(const Handle<Object> object,
   }
 
   // process nextTicks after call
-  Local<Function> fn = PersistentToLocal(process_tickCallback);
+  Local<Function> fn = PersistentToLocal(node_isolate, process_tickCallback);
   fn->Call(process, 0, NULL);
 
   if (try_catch.HasCaught()) {
@@ -1873,7 +1873,7 @@ void FatalException(Handle<Value> error, Handle<Message> message) {
   if (fatal_exception_symbol.IsEmpty())
     fatal_exception_symbol = String::New("_fatalException");
 
-  Local<Object> process = PersistentToLocal(process_p);
+  Local<Object> process = PersistentToLocal(node_isolate, process_p);
   Local<Value> fatal_v = process->Get(fatal_exception_symbol);
 
   if (!fatal_v->IsFunction()) {
@@ -1928,7 +1928,7 @@ static void Binding(const FunctionCallbackInfo<Value>& args) {
   String::Utf8Value module_v(module);
   node_module_struct* modp;
 
-  Local<Object> cache = PersistentToLocal(binding_cache);
+  Local<Object> cache = PersistentToLocal(node_isolate, binding_cache);
   Local<Object> exports;
 
   if (cache->Has(module)) {
@@ -1941,7 +1941,7 @@ static void Binding(const FunctionCallbackInfo<Value>& args) {
   char buf[1024];
   snprintf(buf, sizeof(buf), "Binding %s", *module_v);
 
-  Local<Array> modules = PersistentToLocal(module_load_list);
+  Local<Array> modules = PersistentToLocal(node_isolate, module_load_list);
   uint32_t l = modules->Length();
   modules->Set(l, String::New(buf));
 
index 754ec65..540d9cd 100644 (file)
@@ -1179,7 +1179,7 @@ int Connection::AdvertiseNextProtoCallback_(SSL *s,
     *data = reinterpret_cast<const unsigned char*>("");
     *len = 0;
   } else {
-    Local<Object> obj = PersistentToLocal(p->npnProtos_);
+    Local<Object> obj = PersistentToLocal(node_isolate, p->npnProtos_);
     *data = reinterpret_cast<const unsigned char*>(Buffer::Data(obj));
     *len = Buffer::Length(obj);
   }
@@ -1208,7 +1208,7 @@ int Connection::SelectNextProtoCallback_(SSL *s,
     return SSL_TLSEXT_ERR_OK;
   }
 
-  Local<Object> obj = PersistentToLocal(p->npnProtos_);
+  Local<Object> obj = PersistentToLocal(node_isolate, p->npnProtos_);
   const unsigned char* npnProtos =
       reinterpret_cast<const unsigned char*>(Buffer::Data(obj));
 
@@ -1250,7 +1250,7 @@ int Connection::SelectSNIContextCallback_(SSL *s, int *ad, void* arg) {
     if (!p->sniObject_.IsEmpty()) {
       p->sniContext_.Dispose();
 
-      Local<Value> arg = PersistentToLocal(p->servername_);
+      Local<Value> arg = PersistentToLocal(node_isolate, p->servername_);
       Local<Value> ret = MakeCallback(p->sniObject_, "onselect", 1, &arg);
 
       // If ret is SecureContext
index 403ec10..15f6427 100644 (file)
@@ -305,7 +305,8 @@ Local<Object> BuildStatsObject(const uv_stat_t* s) {
     ctime_symbol = String::New("ctime");
   }
 
-  Local<Function> constructor = PersistentToLocal(stats_constructor);
+  Local<Function> constructor =
+      PersistentToLocal(node_isolate, stats_constructor);
   Local<Object> stats = constructor->NewInstance();
   if (stats.IsEmpty()) return Local<Object>();
 
index b6dd676..c8d12f4 100644 (file)
@@ -69,13 +69,6 @@ class Cached<v8::Value> : public CachedBase<v8::Value> {
 // reference to the object.
 template <class TypeName>
 inline v8::Local<TypeName> PersistentToLocal(
-    const v8::Persistent<TypeName>& persistent);
-
-// If persistent.IsWeak() == false, then do not call persistent.Dispose()
-// while the returned Local<T> is still in scope, it will destroy the
-// reference to the object.
-template <class TypeName>
-inline v8::Local<TypeName> PersistentToLocal(
     v8::Isolate* isolate,
     const v8::Persistent<TypeName>& persistent);
 
index 5cf9189..9c6a598 100644 (file)
@@ -168,7 +168,7 @@ WrappedContext::~WrappedContext() {
 
 Local<Object> WrappedContext::NewInstance() {
   Local<FunctionTemplate> constructor_template_handle =
-      PersistentToLocal(constructor_template);
+      PersistentToLocal(node_isolate, constructor_template);
   return constructor_template_handle->GetFunction()->NewInstance();
 }
 
index 8694d80..7ef17d5 100644 (file)
@@ -204,7 +204,7 @@ void AllocDispose(Handle<Object> obj) {
   if (using_alloc_cb && obj->Has(smalloc_sym)) {
     Local<External> ext = obj->GetHiddenValue(smalloc_sym).As<External>();
     CallbackInfo* cb_info = static_cast<CallbackInfo*>(ext->Value());
-    Local<Object> obj = PersistentToLocal(cb_info->p_obj);
+    Local<Object> obj = PersistentToLocal(node_isolate, cb_info->p_obj);
     TargetFreeCallback(node_isolate, obj, cb_info);
     return;
   }
index 6261ec8..f7fe4e1 100644 (file)
@@ -1205,7 +1205,7 @@ int TLSCallbacks::AdvertiseNextProtoCallback(SSL* s,
     *data = reinterpret_cast<const unsigned char*>("");
     *len = 0;
   } else {
-    Local<Object> obj = PersistentToLocal(p->npn_protos_);
+    Local<Object> obj = PersistentToLocal(node_isolate, p->npn_protos_);
     *data = reinterpret_cast<const unsigned char*>(Buffer::Data(obj));
     *len = Buffer::Length(obj);
   }
@@ -1237,7 +1237,7 @@ int TLSCallbacks::SelectNextProtoCallback(SSL* s,
     return SSL_TLSEXT_ERR_OK;
   }
 
-  Local<Object> obj = PersistentToLocal(p->npn_protos_);
+  Local<Object> obj = PersistentToLocal(node_isolate, p->npn_protos_);
   const unsigned char* npn_protos =
       reinterpret_cast<const unsigned char*>(Buffer::Data(obj));
   size_t len = Buffer::Length(obj);
@@ -1354,7 +1354,7 @@ int TLSCallbacks::SelectSNIContextCallback(SSL* s, int* ad, void* arg) {
     if (object->Has(onsniselect_sym)) {
       p->sni_context_.Dispose();
 
-      Local<Value> arg = PersistentToLocal(p->servername_);
+      Local<Value> arg = PersistentToLocal(node_isolate, p->servername_);
       Handle<Value> ret = MakeCallback(object, onsniselect_sym, 1, &arg);
 
       // If ret is SecureContext