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

Commit 78d9094

Browse files
committed
src: remove non-isolate PersistentToLocal()
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.
1 parent 2dafa19 commit 78d9094

8 files changed

Lines changed: 19 additions & 25 deletions

File tree

src/cares_wrap.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ class QueryWrap {
261261
}
262262

263263
inline Local<Object> object() {
264-
return PersistentToLocal(persistent());
264+
return PersistentToLocal(node_isolate, persistent());
265265
}
266266

267267
protected:

src/node.cc

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -894,7 +894,7 @@ void SetupDomainUse(const FunctionCallbackInfo<Value>& args) {
894894
if (using_domains) return;
895895
HandleScope scope(node_isolate);
896896
using_domains = true;
897-
Local<Object> process = PersistentToLocal(process_p);
897+
Local<Object> process = PersistentToLocal(node_isolate, process_p);
898898
Local<Value> tdc_v = process->Get(String::New("_tickDomainCallback"));
899899
Local<Value> ndt_v = process->Get(String::New("_nextDomainTick"));
900900
if (!tdc_v->IsFunction()) {
@@ -983,8 +983,8 @@ MakeDomainCallback(const Handle<Object> object,
983983
}
984984

985985
// process nextTicks after call
986-
Local<Object> process = PersistentToLocal(process_p);
987-
Local<Function> fn = PersistentToLocal(process_tickCallback);
986+
Local<Object> process = PersistentToLocal(node_isolate, process_p);
987+
Local<Function> fn = PersistentToLocal(node_isolate, process_tickCallback);
988988
fn->Call(process, 0, NULL);
989989

990990
if (try_catch.HasCaught()) {
@@ -1001,7 +1001,7 @@ MakeCallback(const Handle<Object> object,
10011001
int argc,
10021002
Handle<Value> argv[]) {
10031003
// TODO(trevnorris) Hook for long stack traces to be made here.
1004-
Local<Object> process = PersistentToLocal(process_p);
1004+
Local<Object> process = PersistentToLocal(node_isolate, process_p);
10051005

10061006
if (using_domains)
10071007
return MakeDomainCallback(object, callback, argc, argv);
@@ -1035,7 +1035,7 @@ MakeCallback(const Handle<Object> object,
10351035
}
10361036

10371037
// process nextTicks after call
1038-
Local<Function> fn = PersistentToLocal(process_tickCallback);
1038+
Local<Function> fn = PersistentToLocal(node_isolate, process_tickCallback);
10391039
fn->Call(process, 0, NULL);
10401040

10411041
if (try_catch.HasCaught()) {
@@ -1873,7 +1873,7 @@ void FatalException(Handle<Value> error, Handle<Message> message) {
18731873
if (fatal_exception_symbol.IsEmpty())
18741874
fatal_exception_symbol = String::New("_fatalException");
18751875

1876-
Local<Object> process = PersistentToLocal(process_p);
1876+
Local<Object> process = PersistentToLocal(node_isolate, process_p);
18771877
Local<Value> fatal_v = process->Get(fatal_exception_symbol);
18781878

18791879
if (!fatal_v->IsFunction()) {
@@ -1928,7 +1928,7 @@ static void Binding(const FunctionCallbackInfo<Value>& args) {
19281928
String::Utf8Value module_v(module);
19291929
node_module_struct* modp;
19301930

1931-
Local<Object> cache = PersistentToLocal(binding_cache);
1931+
Local<Object> cache = PersistentToLocal(node_isolate, binding_cache);
19321932
Local<Object> exports;
19331933

19341934
if (cache->Has(module)) {
@@ -1941,7 +1941,7 @@ static void Binding(const FunctionCallbackInfo<Value>& args) {
19411941
char buf[1024];
19421942
snprintf(buf, sizeof(buf), "Binding %s", *module_v);
19431943

1944-
Local<Array> modules = PersistentToLocal(module_load_list);
1944+
Local<Array> modules = PersistentToLocal(node_isolate, module_load_list);
19451945
uint32_t l = modules->Length();
19461946
modules->Set(l, String::New(buf));
19471947

src/node_crypto.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1179,7 +1179,7 @@ int Connection::AdvertiseNextProtoCallback_(SSL *s,
11791179
*data = reinterpret_cast<const unsigned char*>("");
11801180
*len = 0;
11811181
} else {
1182-
Local<Object> obj = PersistentToLocal(p->npnProtos_);
1182+
Local<Object> obj = PersistentToLocal(node_isolate, p->npnProtos_);
11831183
*data = reinterpret_cast<const unsigned char*>(Buffer::Data(obj));
11841184
*len = Buffer::Length(obj);
11851185
}
@@ -1208,7 +1208,7 @@ int Connection::SelectNextProtoCallback_(SSL *s,
12081208
return SSL_TLSEXT_ERR_OK;
12091209
}
12101210

1211-
Local<Object> obj = PersistentToLocal(p->npnProtos_);
1211+
Local<Object> obj = PersistentToLocal(node_isolate, p->npnProtos_);
12121212
const unsigned char* npnProtos =
12131213
reinterpret_cast<const unsigned char*>(Buffer::Data(obj));
12141214

@@ -1250,7 +1250,7 @@ int Connection::SelectSNIContextCallback_(SSL *s, int *ad, void* arg) {
12501250
if (!p->sniObject_.IsEmpty()) {
12511251
p->sniContext_.Dispose();
12521252

1253-
Local<Value> arg = PersistentToLocal(p->servername_);
1253+
Local<Value> arg = PersistentToLocal(node_isolate, p->servername_);
12541254
Local<Value> ret = MakeCallback(p->sniObject_, "onselect", 1, &arg);
12551255

12561256
// If ret is SecureContext

src/node_file.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,8 @@ Local<Object> BuildStatsObject(const uv_stat_t* s) {
305305
ctime_symbol = String::New("ctime");
306306
}
307307

308-
Local<Function> constructor = PersistentToLocal(stats_constructor);
308+
Local<Function> constructor =
309+
PersistentToLocal(node_isolate, stats_constructor);
309310
Local<Object> stats = constructor->NewInstance();
310311
if (stats.IsEmpty()) return Local<Object>();
311312

src/node_internals.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,6 @@ class Cached<v8::Value> : public CachedBase<v8::Value> {
6464
void operator=(v8::Handle<v8::Value> that);
6565
};
6666

67-
// If persistent.IsWeak() == false, then do not call persistent.Dispose()
68-
// while the returned Local<T> is still in scope, it will destroy the
69-
// reference to the object.
70-
template <class TypeName>
71-
inline v8::Local<TypeName> PersistentToLocal(
72-
const v8::Persistent<TypeName>& persistent);
73-
7467
// If persistent.IsWeak() == false, then do not call persistent.Dispose()
7568
// while the returned Local<T> is still in scope, it will destroy the
7669
// reference to the object.

src/node_script.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ WrappedContext::~WrappedContext() {
168168

169169
Local<Object> WrappedContext::NewInstance() {
170170
Local<FunctionTemplate> constructor_template_handle =
171-
PersistentToLocal(constructor_template);
171+
PersistentToLocal(node_isolate, constructor_template);
172172
return constructor_template_handle->GetFunction()->NewInstance();
173173
}
174174

src/smalloc.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ void AllocDispose(Handle<Object> obj) {
204204
if (using_alloc_cb && obj->Has(smalloc_sym)) {
205205
Local<External> ext = obj->GetHiddenValue(smalloc_sym).As<External>();
206206
CallbackInfo* cb_info = static_cast<CallbackInfo*>(ext->Value());
207-
Local<Object> obj = PersistentToLocal(cb_info->p_obj);
207+
Local<Object> obj = PersistentToLocal(node_isolate, cb_info->p_obj);
208208
TargetFreeCallback(node_isolate, obj, cb_info);
209209
return;
210210
}

src/tls_wrap.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1205,7 +1205,7 @@ int TLSCallbacks::AdvertiseNextProtoCallback(SSL* s,
12051205
*data = reinterpret_cast<const unsigned char*>("");
12061206
*len = 0;
12071207
} else {
1208-
Local<Object> obj = PersistentToLocal(p->npn_protos_);
1208+
Local<Object> obj = PersistentToLocal(node_isolate, p->npn_protos_);
12091209
*data = reinterpret_cast<const unsigned char*>(Buffer::Data(obj));
12101210
*len = Buffer::Length(obj);
12111211
}
@@ -1237,7 +1237,7 @@ int TLSCallbacks::SelectNextProtoCallback(SSL* s,
12371237
return SSL_TLSEXT_ERR_OK;
12381238
}
12391239

1240-
Local<Object> obj = PersistentToLocal(p->npn_protos_);
1240+
Local<Object> obj = PersistentToLocal(node_isolate, p->npn_protos_);
12411241
const unsigned char* npn_protos =
12421242
reinterpret_cast<const unsigned char*>(Buffer::Data(obj));
12431243
size_t len = Buffer::Length(obj);
@@ -1354,7 +1354,7 @@ int TLSCallbacks::SelectSNIContextCallback(SSL* s, int* ad, void* arg) {
13541354
if (object->Has(onsniselect_sym)) {
13551355
p->sni_context_.Dispose();
13561356

1357-
Local<Value> arg = PersistentToLocal(p->servername_);
1357+
Local<Value> arg = PersistentToLocal(node_isolate, p->servername_);
13581358
Handle<Value> ret = MakeCallback(object, onsniselect_sym, 1, &arg);
13591359

13601360
// If ret is SecureContext

0 commit comments

Comments
 (0)