Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
src: remove non-isolate PersistentToLocal()
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
bnoordhuis committed Aug 2, 2013
1 parent 2dafa19 commit 78d9094
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 25 deletions.
2 changes: 1 addition & 1 deletion src/cares_wrap.cc
Expand Up @@ -261,7 +261,7 @@ class QueryWrap {
}

inline Local<Object> object() {
return PersistentToLocal(persistent());
return PersistentToLocal(node_isolate, persistent());
}

protected:
Expand Down
16 changes: 8 additions & 8 deletions src/node.cc
Expand Up @@ -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()) {
Expand Down Expand Up @@ -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()) {
Expand All @@ -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);
Expand Down Expand Up @@ -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()) {
Expand Down Expand Up @@ -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()) {
Expand Down Expand Up @@ -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)) {
Expand All @@ -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));

Expand Down
6 changes: 3 additions & 3 deletions src/node_crypto.cc
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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));

Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion src/node_file.cc
Expand Up @@ -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>();

Expand Down
7 changes: 0 additions & 7 deletions src/node_internals.h
Expand Up @@ -64,13 +64,6 @@ class Cached<v8::Value> : public CachedBase<v8::Value> {
void operator=(v8::Handle<v8::Value> that);
};

// 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(
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.
Expand Down
2 changes: 1 addition & 1 deletion src/node_script.cc
Expand Up @@ -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();
}

Expand Down
2 changes: 1 addition & 1 deletion src/smalloc.cc
Expand Up @@ -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;
}
Expand Down
6 changes: 3 additions & 3 deletions src/tls_wrap.cc
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 78d9094

Please sign in to comment.