From 4d255c023598336ff21819b06650309b3531a05e Mon Sep 17 00:00:00 2001 From: Trevor Norris Date: Wed, 7 Jan 2015 13:29:58 -0800 Subject: [PATCH 1/2] src: pass Isolate where necessary --- src/node.cc | 30 +++++++++++++++--------------- src/node_buffer.cc | 6 +++--- src/node_contextify.cc | 13 ++++++++----- src/node_crypto.cc | 20 ++++++++++++++------ src/node_dtrace.cc | 2 +- src/node_file.cc | 2 +- src/node_http_parser.cc | 4 ++-- src/node_zlib.cc | 6 +++--- src/process_wrap.cc | 2 +- src/smalloc.cc | 3 ++- src/spawn_sync.cc | 4 ++-- src/stream_wrap.cc | 4 ++-- src/string_bytes.cc | 4 ++-- src/util.cc | 2 +- 14 files changed, 57 insertions(+), 45 deletions(-) diff --git a/src/node.cc b/src/node.cc index e2a506680b4c94..685d3839e334cf 100644 --- a/src/node.cc +++ b/src/node.cc @@ -757,7 +757,7 @@ Local ErrnoException(Isolate* isolate, e = Exception::Error(cons2); } - Local obj = e->ToObject(); + Local obj = e->ToObject(env->isolate()); obj->Set(env->errno_string(), Integer::New(env->isolate(), errorno)); obj->Set(env->code_string(), estring); @@ -819,7 +819,7 @@ Local UVException(Isolate* isolate, e = Exception::Error(cons2); } - Local obj = e->ToObject(); + Local obj = e->ToObject(env->isolate()); // TODO(piscisaureus) errno should probably go obj->Set(env->errno_string(), Integer::New(env->isolate(), errorno)); obj->Set(env->code_string(), estring); @@ -899,7 +899,7 @@ Local WinapiErrnoException(Isolate* isolate, e = Exception::Error(message); } - Local obj = e->ToObject(); + Local obj = e->ToObject(env->isolate()); obj->Set(env->errno_string(), Integer::New(isolate, errorno)); if (path != nullptr) { @@ -1350,9 +1350,9 @@ void AppendExceptionLine(Environment* env, goto print; err_obj->Set(env->message_string(), - String::Concat(arrow_str, msg->ToString())); + String::Concat(arrow_str, msg->ToString(env->isolate()))); err_obj->Set(env->stack_string(), - String::Concat(arrow_str, stack->ToString())); + String::Concat(arrow_str, stack->ToString(env->isolate()))); return; print: @@ -1376,7 +1376,7 @@ static void ReportException(Environment* env, if (er->IsUndefined() || er->IsNull()) trace_value = Undefined(env->isolate()); else - trace_value = er->ToObject()->Get(env->stack_string()); + trace_value = er->ToObject(env->isolate())->Get(env->stack_string()); node::Utf8Value trace(trace_value); @@ -1988,7 +1988,7 @@ void DLOpen(const FunctionCallbackInfo& args) { return; } - Local module = args[0]->ToObject(); // Cast + Local module = args[0]->ToObject(env->isolate()); // Cast node::Utf8Value filename(args[1]); // Cast const bool is_dlopen_error = uv_dlopen(*filename, &lib); @@ -2002,7 +2002,7 @@ void DLOpen(const FunctionCallbackInfo& args) { Local errmsg = OneByteString(env->isolate(), uv_dlerror(&lib)); #ifdef _WIN32 // Windows needs to add the filename into the error message - errmsg = String::Concat(errmsg, args[1]->ToString()); + errmsg = String::Concat(errmsg, args[1]->ToString(env->isolate())); #endif // _WIN32 env->isolate()->ThrowException(Exception::Error(errmsg)); return; @@ -2031,7 +2031,7 @@ void DLOpen(const FunctionCallbackInfo& args) { modlist_addon = mp; Local exports_string = env->exports_string(); - Local exports = module->Get(exports_string)->ToObject(); + Local exports = module->Get(exports_string)->ToObject(env->isolate()); if (mp->nm_context_register_func != nullptr) { mp->nm_context_register_func(exports, module, env->context(), mp->nm_priv); @@ -2123,14 +2123,14 @@ void OnMessage(Handle message, Handle error) { static void Binding(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); - Local module = args[0]->ToString(); + Local module = args[0]->ToString(env->isolate()); node::Utf8Value module_v(module); Local cache = env->binding_cache_object(); Local exports; if (cache->Has(module)) { - exports = cache->Get(module)->ToObject(); + exports = cache->Get(module)->ToObject(env->isolate()); args.GetReturnValue().Set(exports); return; } @@ -2176,7 +2176,7 @@ static void Binding(const FunctionCallbackInfo& args) { static void LinkedBinding(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args.GetIsolate()); - Local module = args[0]->ToString(); + Local module = args[0]->ToString(env->isolate()); Local cache = env->binding_cache_object(); Local exports_v = cache->Get(module); @@ -2792,8 +2792,8 @@ static void RawDebug(const FunctionCallbackInfo& args) { void LoadEnvironment(Environment* env) { HandleScope handle_scope(env->isolate()); - V8::SetFatalErrorHandler(node::OnFatalError); - V8::AddMessageListener(OnMessage); + env->isolate()->SetFatalErrorHandler(node::OnFatalError); + env->isolate()->AddMessageListener(OnMessage); // Compile, execute the src/node.js file. (Which was included as static C // string in node_natives.h. 'natve_node' is the string containing that @@ -3485,7 +3485,7 @@ void EmitBeforeExit(Environment* env) { Local exit_code = FIXED_ONE_BYTE_STRING(env->isolate(), "exitCode"); Local args[] = { FIXED_ONE_BYTE_STRING(env->isolate(), "beforeExit"), - process_object->Get(exit_code)->ToInteger() + process_object->Get(exit_code)->ToInteger(env->isolate()) }; MakeCallback(env, process_object, "emit", ARRAY_SIZE(args), args); } diff --git a/src/node_buffer.cc b/src/node_buffer.cc index 420dc293af5684..e9f3415511f6a4 100644 --- a/src/node_buffer.cc +++ b/src/node_buffer.cc @@ -336,7 +336,7 @@ void Base64Slice(const FunctionCallbackInfo& args) { void Copy(const FunctionCallbackInfo &args) { Environment* env = Environment::GetCurrent(args); - Local target = args[0]->ToObject(); + Local target = args[0]->ToObject(env->isolate()); if (!HasInstance(target)) return env->ThrowTypeError("first arg should be a Buffer"); @@ -421,7 +421,7 @@ void StringWrite(const FunctionCallbackInfo& args) { if (!args[0]->IsString()) return env->ThrowTypeError("Argument must be a string"); - Local str = args[0]->ToString(); + Local str = args[0]->ToString(env->isolate()); if (encoding == HEX && str->Length() % 2 != 0) return env->ThrowTypeError("Invalid hex string"); @@ -583,7 +583,7 @@ void ByteLength(const FunctionCallbackInfo &args) { if (!args[0]->IsString()) return env->ThrowTypeError("Argument must be a string"); - Local s = args[0]->ToString(); + Local s = args[0]->ToString(env->isolate()); enum encoding e = ParseEncoding(env->isolate(), args[1], UTF8); uint32_t size = StringBytes::Size(env->isolate(), s, e); diff --git a/src/node_contextify.cc b/src/node_contextify.cc index ead5e3efc3bf42..11712f727a388e 100644 --- a/src/node_contextify.cc +++ b/src/node_contextify.cc @@ -144,7 +144,8 @@ class ContextifyContext { HandleScope scope(env()->isolate()); Local context = PersistentToLocal(env()->isolate(), context_); - Local global = context->Global()->GetPrototype()->ToObject(); + Local global = + context->Global()->GetPrototype()->ToObject(env()->isolate()); Local sandbox = PersistentToLocal(env()->isolate(), sandbox_); Local clone_property_method; @@ -152,7 +153,7 @@ class ContextifyContext { Local names = global->GetOwnPropertyNames(); int length = names->Length(); for (int i = 0; i < length; i++) { - Local key = names->Get(i)->ToString(); + Local key = names->Get(i)->ToString(env()->isolate()); bool has = sandbox->HasOwnProperty(key); if (!has) { // Could also do this like so: @@ -253,7 +254,7 @@ class ContextifyContext { static void RunInDebugContext(const FunctionCallbackInfo& args) { - Local script_source(args[0]->ToString()); + Local script_source(args[0]->ToString(args.GetIsolate())); if (script_source.IsEmpty()) return; // Exception pending. Context::Scope context_scope(Debug::GetDebugContext()); @@ -476,7 +477,7 @@ class ContextifyScript : public BaseObject { new ContextifyScript(env, args.This()); TryCatch try_catch; - Local code = args[0]->ToString(); + Local code = args[0]->ToString(env->isolate()); Local filename = GetFilenameArg(args, 1); bool display_errors = GetDisplayErrorsArg(args, 1); if (try_catch.HasCaught()) { @@ -643,7 +644,9 @@ class ContextifyScript : public BaseObject { Local key = FIXED_ONE_BYTE_STRING(args.GetIsolate(), "filename"); Local value = args[i].As()->Get(key); - return value->IsUndefined() ? defaultFilename : value->ToString(); + if (value->IsUndefined()) + return defaultFilename; + return value->ToString(args.GetIsolate()); } diff --git a/src/node_crypto.cc b/src/node_crypto.cc index f65a7b902f510a..96101911442ee4 100644 --- a/src/node_crypto.cc +++ b/src/node_crypto.cc @@ -1686,7 +1686,7 @@ void SSLWrap::VerifyError(const FunctionCallbackInfo& args) { Isolate* isolate = args.GetIsolate(); Local reason_string = OneByteString(isolate, reason); Local exception_value = Exception::Error(reason_string); - Local exception_object = exception_value->ToObject(); + Local exception_object = exception_value->ToObject(isolate); exception_object->Set(FIXED_ONE_BYTE_STRING(isolate, "code"), OneByteString(isolate, code)); args.GetReturnValue().Set(exception_object); @@ -2169,7 +2169,7 @@ void Connection::New(const FunctionCallbackInfo& args) { return; } - SecureContext* sc = Unwrap(args[0]->ToObject()); + SecureContext* sc = Unwrap(args[0]->ToObject(env->isolate())); bool is_server = args[1]->BooleanValue(); @@ -3004,7 +3004,9 @@ void Hmac::HmacDigest(const FunctionCallbackInfo& args) { enum encoding encoding = BUFFER; if (args.Length() >= 1) { - encoding = ParseEncoding(env->isolate(), args[0]->ToString(), BUFFER); + encoding = ParseEncoding(env->isolate(), + args[0]->ToString(env->isolate()), + BUFFER); } unsigned char* md_value = nullptr; @@ -3119,7 +3121,9 @@ void Hash::HashDigest(const FunctionCallbackInfo& args) { enum encoding encoding = BUFFER; if (args.Length() >= 1) { - encoding = ParseEncoding(env->isolate(), args[0]->ToString(), BUFFER); + encoding = ParseEncoding(env->isolate(), + args[0]->ToString(env->isolate()), + BUFFER); } unsigned char md_value[EVP_MAX_MD_SIZE]; @@ -3319,7 +3323,9 @@ void Sign::SignFinal(const FunctionCallbackInfo& args) { unsigned int len = args.Length(); enum encoding encoding = BUFFER; if (len >= 2 && args[1]->IsString()) { - encoding = ParseEncoding(env->isolate(), args[1]->ToString(), BUFFER); + encoding = ParseEncoding(env->isolate(), + args[1]->ToString(env->isolate()), + BUFFER); } node::Utf8Value passphrase(args[2]); @@ -3532,7 +3538,9 @@ void Verify::VerifyFinal(const FunctionCallbackInfo& args) { // BINARY works for both buffers and binary strings. enum encoding encoding = BINARY; if (args.Length() >= 3) { - encoding = ParseEncoding(env->isolate(), args[2]->ToString(), BINARY); + encoding = ParseEncoding(env->isolate(), + args[2]->ToString(env->isolate()), + BINARY); } ssize_t hlen = StringBytes::Size(env->isolate(), args[1], encoding); diff --git a/src/node_dtrace.cc b/src/node_dtrace.cc index 7fb2312c9a86f3..8feedb600f8baf 100644 --- a/src/node_dtrace.cc +++ b/src/node_dtrace.cc @@ -87,7 +87,7 @@ using v8::Value; "expected object for " #obj " to contain integer member " #member); \ } \ *valp = obj->Get(OneByteString(env->isolate(), #member)) \ - ->ToInteger()->Value(); + ->ToInteger(env->isolate())->Value(); #define SLURP_OBJECT(obj, member, valp) \ if (!(obj)->IsObject()) { \ diff --git a/src/node_file.cc b/src/node_file.cc index 88b1262e168953..e6ef3cbbf24999 100644 --- a/src/node_file.cc +++ b/src/node_file.cc @@ -927,7 +927,7 @@ static void Read(const FunctionCallbackInfo& args) { return env->ThrowError("Second argument needs to be a buffer"); } - Local buffer_obj = args[1]->ToObject(); + Local buffer_obj = args[1]->ToObject(env->isolate()); char *buffer_data = Buffer::Data(buffer_obj); size_t buffer_length = Buffer::Length(buffer_obj); diff --git a/src/node_http_parser.cc b/src/node_http_parser.cc index ee312ddedf071a..e9422ca1dca3b8 100644 --- a/src/node_http_parser.cc +++ b/src/node_http_parser.cc @@ -421,7 +421,7 @@ class Parser : public BaseObject { enum http_errno err = HTTP_PARSER_ERRNO(&parser->parser_); Local e = Exception::Error(env->parse_error_string()); - Local obj = e->ToObject(); + Local obj = e->ToObject(env->isolate()); obj->Set(env->bytes_parsed_string(), nparsed_obj); obj->Set(env->code_string(), OneByteString(env->isolate(), http_errno_name(err))); @@ -450,7 +450,7 @@ class Parser : public BaseObject { enum http_errno err = HTTP_PARSER_ERRNO(&parser->parser_); Local e = env->parse_error_string(); - Local obj = e->ToObject(); + Local obj = e->ToObject(env->isolate()); obj->Set(env->bytes_parsed_string(), Integer::New(env->isolate(), 0)); obj->Set(env->code_string(), OneByteString(env->isolate(), http_errno_name(err))); diff --git a/src/node_zlib.cc b/src/node_zlib.cc index 5b8024330b0163..f59e60015a4915 100644 --- a/src/node_zlib.cc +++ b/src/node_zlib.cc @@ -178,7 +178,7 @@ class ZCtx : public AsyncWrap { } else { CHECK(Buffer::HasInstance(args[1])); Local in_buf; - in_buf = args[1]->ToObject(); + in_buf = args[1]->ToObject(args.GetIsolate()); in_off = args[2]->Uint32Value(); in_len = args[3]->Uint32Value(); @@ -187,7 +187,7 @@ class ZCtx : public AsyncWrap { } CHECK(Buffer::HasInstance(args[4])); - Local out_buf = args[4]->ToObject(); + Local out_buf = args[4]->ToObject(args.GetIsolate()); out_off = args[5]->Uint32Value(); out_len = args[6]->Uint32Value(); CHECK(Buffer::IsWithinBounds(out_off, out_len, Buffer::Length(out_buf))); @@ -420,7 +420,7 @@ class ZCtx : public AsyncWrap { char* dictionary = nullptr; size_t dictionary_len = 0; if (args.Length() >= 5 && Buffer::HasInstance(args[4])) { - Local dictionary_ = args[4]->ToObject(); + Local dictionary_ = args[4]->ToObject(args.GetIsolate()); dictionary_len = Buffer::Length(dictionary_); dictionary = new char[dictionary_len]; diff --git a/src/process_wrap.cc b/src/process_wrap.cc index ab7d9bfddbf05a..5368e2803bba5a 100644 --- a/src/process_wrap.cc +++ b/src/process_wrap.cc @@ -130,7 +130,7 @@ class ProcessWrap : public HandleWrap { ProcessWrap* wrap = Unwrap(args.Holder()); - Local js_options = args[0]->ToObject(); + Local js_options = args[0]->ToObject(env->isolate()); uv_process_options_t options; memset(&options, 0, sizeof(uv_process_options_t)); diff --git a/src/smalloc.cc b/src/smalloc.cc index 38adce304f525e..4d85acd60955de 100644 --- a/src/smalloc.cc +++ b/src/smalloc.cc @@ -493,7 +493,8 @@ const char RetainedAllocInfo::label_[] = "smalloc"; RetainedAllocInfo::RetainedAllocInfo(Handle wrapper) { - Local obj = wrapper->ToObject(); + // TODO(trevnorris): Fix to properly acquire the Isolate. + Local obj = wrapper->ToObject(Isolate::GetCurrent()); length_ = obj->GetIndexedPropertiesExternalArrayDataLength(); data_ = static_cast(obj->GetIndexedPropertiesExternalArrayData()); } diff --git a/src/spawn_sync.cc b/src/spawn_sync.cc index bb5c606afceec9..62ef7e21bc423f 100644 --- a/src/spawn_sync.cc +++ b/src/spawn_sync.cc @@ -958,7 +958,7 @@ int SyncProcessRunner::CopyJsString(Local js_value, if (js_value->IsString()) js_string = js_value.As(); else - js_string = js_value->ToString(); + js_string = js_value->ToString(env()->isolate()); // Include space for null terminator byte. size = StringBytes::StorageSize(isolate, js_string, UTF8) + 1; @@ -992,7 +992,7 @@ int SyncProcessRunner::CopyJsStringArray(Local js_value, // needed - it's okay since we cloned the original object. for (uint32_t i = 0; i < length; i++) { if (!js_array->Get(i)->IsString()) - js_array->Set(i, js_array->Get(i)->ToString()); + js_array->Set(i, js_array->Get(i)->ToString(env()->isolate())); } // Index has a pointer to every string element, plus one more for a final diff --git a/src/stream_wrap.cc b/src/stream_wrap.cc index 2d13ae0f8887e8..830f1b5757e02d 100644 --- a/src/stream_wrap.cc +++ b/src/stream_wrap.cc @@ -433,7 +433,7 @@ void StreamWrap::Writev(const FunctionCallbackInfo& args) { // Buffer chunk, no additional storage required // String chunk - Handle string = chunk->ToString(); + Handle string = chunk->ToString(env->isolate()); enum encoding encoding = ParseEncoding(env->isolate(), chunks->Get(i * 2 + 1)); size_t chunk_size; @@ -477,7 +477,7 @@ void StreamWrap::Writev(const FunctionCallbackInfo& args) { char* str_storage = storage + offset; size_t str_size = storage_size - offset; - Handle string = chunk->ToString(); + Handle string = chunk->ToString(env->isolate()); enum encoding encoding = ParseEncoding(env->isolate(), chunks->Get(i * 2 + 1)); str_size = StringBytes::Write(env->isolate(), diff --git a/src/string_bytes.cc b/src/string_bytes.cc index f1ff697452f58c..8ab977b11ab063 100644 --- a/src/string_bytes.cc +++ b/src/string_bytes.cc @@ -409,7 +409,7 @@ size_t StringBytes::StorageSize(Isolate* isolate, return Buffer::Length(val); } - Local str = val->ToString(); + Local str = val->ToString(isolate); switch (encoding) { case BINARY: @@ -461,7 +461,7 @@ size_t StringBytes::Size(Isolate* isolate, if (GetExternalParts(isolate, val, &data, &data_size)) return data_size; - Local str = val->ToString(); + Local str = val->ToString(isolate); switch (encoding) { case BINARY: diff --git a/src/util.cc b/src/util.cc index 5a652663c87103..a42e8934014411 100644 --- a/src/util.cc +++ b/src/util.cc @@ -30,7 +30,7 @@ Utf8Value::Utf8Value(v8::Handle value) if (value.IsEmpty()) return; - v8::Local val_ = value->ToString(); + v8::Local val_ = value->ToString(v8::Isolate::GetCurrent()); if (val_.IsEmpty()) return; From ba6507cb3365810ea40bd8a87714f7d86eba90dc Mon Sep 17 00:00:00 2001 From: Trevor Norris Date: Wed, 7 Jan 2015 14:13:35 -0800 Subject: [PATCH 2/2] src: pass Isolate to node::Utf8Value constructor --- src/cares_wrap.cc | 10 ++++----- src/fs_event_wrap.cc | 2 +- src/node.cc | 46 +++++++++++++++++++++------------------- src/node_buffer.cc | 2 +- src/node_crypto.cc | 36 +++++++++++++++---------------- src/node_dtrace.cc | 6 +++--- src/node_file.cc | 38 ++++++++++++++++----------------- src/node_stat_watcher.cc | 2 +- src/pipe_wrap.cc | 4 ++-- src/process_wrap.cc | 14 ++++++------ src/tcp_wrap.cc | 8 +++---- src/tls_wrap.cc | 2 +- src/udp_wrap.cc | 8 +++---- src/util.cc | 4 ++-- src/util.h | 2 +- 15 files changed, 94 insertions(+), 90 deletions(-) diff --git a/src/cares_wrap.cc b/src/cares_wrap.cc index e59d2a87f93b26..256dff76d6fbc3 100644 --- a/src/cares_wrap.cc +++ b/src/cares_wrap.cc @@ -884,7 +884,7 @@ static void Query(const FunctionCallbackInfo& args) { Local string = args[1].As(); Wrap* wrap = new Wrap(env, req_wrap_obj); - node::Utf8Value name(string); + node::Utf8Value name(env->isolate(), string); int err = wrap->Send(*name); if (err) delete wrap; @@ -1023,7 +1023,7 @@ void AfterGetNameInfo(uv_getnameinfo_t* req, static void IsIP(const FunctionCallbackInfo& args) { - node::Utf8Value ip(args[0]); + node::Utf8Value ip(args.GetIsolate(), args[0]); char address_buffer[sizeof(struct in6_addr)]; int rc = 0; @@ -1043,7 +1043,7 @@ static void GetAddrInfo(const FunctionCallbackInfo& args) { CHECK(args[1]->IsString()); CHECK(args[2]->IsInt32()); Local req_wrap_obj = args[0].As(); - node::Utf8Value hostname(args[1]); + node::Utf8Value hostname(env->isolate(), args[1]); int32_t flags = (args[3]->IsInt32()) ? args[3]->Int32Value() : 0; int family; @@ -1092,7 +1092,7 @@ static void GetNameInfo(const FunctionCallbackInfo& args) { CHECK(args[1]->IsString()); CHECK(args[2]->IsUint32()); Local req_wrap_obj = args[0].As(); - node::Utf8Value ip(args[1]); + node::Utf8Value ip(env->isolate(), args[1]); const unsigned port = args[2]->Uint32Value(); struct sockaddr_storage addr; @@ -1171,7 +1171,7 @@ static void SetServers(const FunctionCallbackInfo& args) { CHECK(elm->Get(1)->IsString()); int fam = elm->Get(0)->Int32Value(); - node::Utf8Value ip(elm->Get(1)); + node::Utf8Value ip(env->isolate(), elm->Get(1)); ares_addr_node* cur = &servers[i]; diff --git a/src/fs_event_wrap.cc b/src/fs_event_wrap.cc index 57d07272ecc58f..be472dde76cee5 100644 --- a/src/fs_event_wrap.cc +++ b/src/fs_event_wrap.cc @@ -110,7 +110,7 @@ void FSEventWrap::Start(const FunctionCallbackInfo& args) { return env->ThrowTypeError("Bad arguments"); } - node::Utf8Value path(args[0]); + node::Utf8Value path(env->isolate(), args[0]); unsigned int flags = 0; if (args[2]->IsTrue()) diff --git a/src/node.cc b/src/node.cc index 685d3839e334cf..1a4b18089042cc 100644 --- a/src/node.cc +++ b/src/node.cc @@ -1177,7 +1177,7 @@ enum encoding ParseEncoding(Isolate* isolate, if (!encoding_v->IsString()) return _default; - node::Utf8Value encoding(encoding_v); + node::Utf8Value encoding(isolate, encoding_v); if (strcasecmp(*encoding, "utf8") == 0) { return UTF8; @@ -1275,11 +1275,11 @@ void AppendExceptionLine(Environment* env, char arrow[1024]; // Print (filename):(line number): (message). - node::Utf8Value filename(message->GetScriptResourceName()); + node::Utf8Value filename(env->isolate(), message->GetScriptResourceName()); const char* filename_string = *filename; int linenum = message->GetLineNumber(); // Print line of source code. - node::Utf8Value sourceline(message->GetSourceLine()); + node::Utf8Value sourceline(env->isolate(), message->GetSourceLine()); const char* sourceline_string = *sourceline; // Because of how node modules work, all scripts are wrapped with a @@ -1378,7 +1378,7 @@ static void ReportException(Environment* env, else trace_value = er->ToObject(env->isolate())->Get(env->stack_string()); - node::Utf8Value trace(trace_value); + node::Utf8Value trace(env->isolate(), trace_value); // range errors have a trace member set to undefined if (trace.length() > 0 && !trace_value->IsUndefined()) { @@ -1401,11 +1401,11 @@ static void ReportException(Environment* env, name.IsEmpty() || name->IsUndefined()) { // Not an error object. Just print as-is. - node::Utf8Value message(er); + node::Utf8Value message(env->isolate(), er); fprintf(stderr, "%s\n", *message); } else { - node::Utf8Value name_string(name); - node::Utf8Value message_string(message); + node::Utf8Value name_string(env->isolate(), name); + node::Utf8Value message_string(env->isolate(), message); fprintf(stderr, "%s: %s\n", *name_string, *message_string); } } @@ -1503,7 +1503,7 @@ static void Chdir(const FunctionCallbackInfo& args) { return env->ThrowError("Bad argument."); } - node::Utf8Value path(args[0]); + node::Utf8Value path(args.GetIsolate(), args[0]); int err = uv_chdir(*path); if (err) { return env->ThrowUVException(err, "uv_chdir"); @@ -1549,7 +1549,7 @@ static void Umask(const FunctionCallbackInfo& args) { oct = args[0]->Uint32Value(); } else { oct = 0; - node::Utf8Value str(args[0]); + node::Utf8Value str(env->isolate(), args[0]); // Parse the octal string. for (size_t i = 0; i < str.length(); i++) { @@ -1656,7 +1656,8 @@ static uid_t uid_by_name(Handle value) { if (value->IsUint32()) { return static_cast(value->Uint32Value()); } else { - node::Utf8Value name(value); + // TODO(trevnorris): Fix to not use GetCurrent(). + node::Utf8Value name(Isolate::GetCurrent(), value); return uid_by_name(*name); } } @@ -1666,7 +1667,8 @@ static gid_t gid_by_name(Handle value) { if (value->IsUint32()) { return static_cast(value->Uint32Value()); } else { - node::Utf8Value name(value); + // TODO(trevnorris): Fix to not use GetCurrent(). + node::Utf8Value name(Isolate::GetCurrent(), value); return gid_by_name(*name); } } @@ -1802,7 +1804,7 @@ static void InitGroups(const FunctionCallbackInfo& args) { return env->ThrowTypeError("argument 2 must be a number or a string"); } - node::Utf8Value arg0(args[0]); + node::Utf8Value arg0(env->isolate(), args[0]); gid_t extra_group; bool must_free; char* user; @@ -1989,7 +1991,7 @@ void DLOpen(const FunctionCallbackInfo& args) { } Local module = args[0]->ToObject(env->isolate()); // Cast - node::Utf8Value filename(args[1]); // Cast + node::Utf8Value filename(env->isolate(), args[1]); // Cast const bool is_dlopen_error = uv_dlopen(*filename, &lib); // Objects containing v14 or later modules will have registered themselves @@ -2124,7 +2126,7 @@ static void Binding(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); Local module = args[0]->ToString(env->isolate()); - node::Utf8Value module_v(module); + node::Utf8Value module_v(env->isolate(), module); Local cache = env->binding_cache_object(); Local exports; @@ -2184,7 +2186,7 @@ static void LinkedBinding(const FunctionCallbackInfo& args) { if (exports_v->IsObject()) return args.GetReturnValue().Set(exports_v.As()); - node::Utf8Value module_v(module); + node::Utf8Value module_v(env->isolate(), module); node_module* mod = get_linked_module(*module_v); if (mod == nullptr) { @@ -2229,7 +2231,7 @@ static void ProcessTitleSetter(Local property, const PropertyCallbackInfo& info) { Environment* env = Environment::GetCurrent(info.GetIsolate()); HandleScope scope(env->isolate()); - node::Utf8Value title(value); + node::Utf8Value title(env->isolate(), value); // TODO(piscisaureus): protect with a lock uv_set_process_title(*title); } @@ -2240,7 +2242,7 @@ static void EnvGetter(Local property, Environment* env = Environment::GetCurrent(info.GetIsolate()); HandleScope scope(env->isolate()); #ifdef __POSIX__ - node::Utf8Value key(property); + node::Utf8Value key(env->isolate(), property); const char* val = getenv(*key); if (val) { return info.GetReturnValue().Set(String::NewFromUtf8(env->isolate(), val)); @@ -2273,8 +2275,8 @@ static void EnvSetter(Local property, Environment* env = Environment::GetCurrent(info.GetIsolate()); HandleScope scope(env->isolate()); #ifdef __POSIX__ - node::Utf8Value key(property); - node::Utf8Value val(value); + node::Utf8Value key(env->isolate(), property); + node::Utf8Value val(env->isolate(), value); setenv(*key, *val, 1); #else // _WIN32 String::Value key(property); @@ -2296,7 +2298,7 @@ static void EnvQuery(Local property, HandleScope scope(env->isolate()); int32_t rc = -1; // Not found unless proven otherwise. #ifdef __POSIX__ - node::Utf8Value key(property); + node::Utf8Value key(env->isolate(), property); if (getenv(*key)) rc = 0; #else // _WIN32 @@ -2324,7 +2326,7 @@ static void EnvDeleter(Local property, HandleScope scope(env->isolate()); bool rc = true; #ifdef __POSIX__ - node::Utf8Value key(property); + node::Utf8Value key(env->isolate(), property); rc = getenv(*key) != nullptr; if (rc) unsetenv(*key); @@ -2783,7 +2785,7 @@ static void SignalExit(int signo) { static void RawDebug(const FunctionCallbackInfo& args) { CHECK(args.Length() == 1 && args[0]->IsString() && "must be called with a single string"); - node::Utf8Value message(args[0]); + node::Utf8Value message(args.GetIsolate(), args[0]); fprintf(stderr, "%s\n", *message); fflush(stderr); } diff --git a/src/node_buffer.cc b/src/node_buffer.cc index e9f3415511f6a4..e23046be2f8b0d 100644 --- a/src/node_buffer.cc +++ b/src/node_buffer.cc @@ -386,7 +386,7 @@ void Fill(const FunctionCallbackInfo& args) { return; } - node::Utf8Value str(args[1]); + node::Utf8Value str(args.GetIsolate(), args[1]); size_t str_length = str.length(); size_t in_there = str_length; char* ptr = obj_data + start + str_length; diff --git a/src/node_crypto.cc b/src/node_crypto.cc index 96101911442ee4..fc7549991ae7df 100644 --- a/src/node_crypto.cc +++ b/src/node_crypto.cc @@ -307,7 +307,7 @@ void SecureContext::Init(const FunctionCallbackInfo& args) { OPENSSL_CONST SSL_METHOD *method = SSLv23_method(); if (args.Length() == 1 && args[0]->IsString()) { - const node::Utf8Value sslmethod(args[0]); + const node::Utf8Value sslmethod(env->isolate(), args[0]); if (strcmp(*sslmethod, "SSLv2_method") == 0) { #ifndef OPENSSL_NO_SSL2 @@ -400,7 +400,7 @@ static BIO* LoadBIO(Environment* env, Handle v) { int r = -1; if (v->IsString()) { - const node::Utf8Value s(v); + const node::Utf8Value s(env->isolate(), v); r = BIO_write(bio, *s, s.length()); } else if (Buffer::HasInstance(v)) { char* buffer_data = Buffer::Data(v); @@ -454,7 +454,7 @@ void SecureContext::SetKey(const FunctionCallbackInfo& args) { if (!bio) return; - node::Utf8Value passphrase(args[1]); + node::Utf8Value passphrase(env->isolate(), args[1]); EVP_PKEY* key = PEM_read_bio_PrivateKey(bio, nullptr, @@ -719,7 +719,7 @@ void SecureContext::SetCiphers(const FunctionCallbackInfo& args) { return sc->env()->ThrowTypeError("Bad parameter"); } - const node::Utf8Value ciphers(args[0]); + const node::Utf8Value ciphers(args.GetIsolate(), args[0]); SSL_CTX_set_cipher_list(sc->ctx_, *ciphers); } @@ -731,7 +731,7 @@ void SecureContext::SetECDHCurve(const FunctionCallbackInfo& args) { if (args.Length() != 1 || !args[0]->IsString()) return env->ThrowTypeError("First argument should be a string"); - node::Utf8Value curve(args[0]); + node::Utf8Value curve(env->isolate(), args[0]); int nid = OBJ_sn2nid(*curve); @@ -798,7 +798,7 @@ void SecureContext::SetSessionIdContext( return sc->env()->ThrowTypeError("Bad parameter"); } - const node::Utf8Value sessionIdContext(args[0]); + const node::Utf8Value sessionIdContext(args.GetIsolate(), args[0]); const unsigned char* sid_ctx = reinterpret_cast(*sessionIdContext); unsigned int sid_ctx_len = sessionIdContext.length(); @@ -2190,7 +2190,7 @@ void Connection::New(const FunctionCallbackInfo& args) { if (is_server) { SSL_CTX_set_tlsext_servername_callback(sc->ctx_, SelectSNIContextCallback_); } else if (args[2]->IsString()) { - const node::Utf8Value servername(args[2]); + const node::Utf8Value servername(env->isolate(), args[2]); SSL_set_tlsext_host_name(conn->ssl_, *servername); } #endif @@ -2591,7 +2591,7 @@ void CipherBase::Init(const FunctionCallbackInfo& args) { return cipher->env()->ThrowError("Must give cipher-type, key"); } - const node::Utf8Value cipher_type(args[0]); + const node::Utf8Value cipher_type(args.GetIsolate(), args[0]); const char* key_buf = Buffer::Data(args[1]); ssize_t key_buf_len = Buffer::Length(args[1]); cipher->Init(*cipher_type, key_buf, key_buf_len); @@ -2645,7 +2645,7 @@ void CipherBase::InitIv(const FunctionCallbackInfo& args) { ASSERT_IS_BUFFER(args[1]); ASSERT_IS_BUFFER(args[2]); - const node::Utf8Value cipher_type(args[0]); + const node::Utf8Value cipher_type(env->isolate(), args[0]); ssize_t key_len = Buffer::Length(args[1]); const char* key_buf = Buffer::Data(args[1]); ssize_t iv_len = Buffer::Length(args[2]); @@ -2936,7 +2936,7 @@ void Hmac::HmacInit(const FunctionCallbackInfo& args) { ASSERT_IS_BUFFER(args[1]); - const node::Utf8Value hash_type(args[0]); + const node::Utf8Value hash_type(env->isolate(), args[0]); const char* buffer_data = Buffer::Data(args[1]); size_t buffer_length = Buffer::Length(args[1]); hmac->HmacInit(*hash_type, buffer_data, buffer_length); @@ -3046,7 +3046,7 @@ void Hash::New(const FunctionCallbackInfo& args) { return env->ThrowError("Must give hashtype string as argument"); } - const node::Utf8Value hash_type(args[0]); + const node::Utf8Value hash_type(env->isolate(), args[0]); Hash* hash = new Hash(env, args.This()); if (!hash->HashInit(*hash_type)) { @@ -3222,7 +3222,7 @@ void Sign::SignInit(const FunctionCallbackInfo& args) { return sign->env()->ThrowError("Must give signtype string as argument"); } - const node::Utf8Value sign_type(args[0]); + const node::Utf8Value sign_type(args.GetIsolate(), args[0]); sign->CheckThrow(sign->SignInit(*sign_type)); } @@ -3328,7 +3328,7 @@ void Sign::SignFinal(const FunctionCallbackInfo& args) { BUFFER); } - node::Utf8Value passphrase(args[2]); + node::Utf8Value passphrase(env->isolate(), args[2]); ASSERT_IS_BUFFER(args[0]); size_t buf_len = Buffer::Length(args[0]); @@ -3401,7 +3401,7 @@ void Verify::VerifyInit(const FunctionCallbackInfo& args) { return verify->env()->ThrowError("Must give verifytype string as argument"); } - const node::Utf8Value verify_type(args[0]); + const node::Utf8Value verify_type(args.GetIsolate(), args[0]); verify->CheckThrow(verify->VerifyInit(*verify_type)); } @@ -3800,7 +3800,7 @@ void DiffieHellman::DiffieHellmanGroup( bool initialized = false; - const node::Utf8Value group_name(args[0]); + const node::Utf8Value group_name(env->isolate(), args[0]); for (unsigned int i = 0; i < ARRAY_SIZE(modp_groups); ++i) { const modp_group* it = modp_groups + i; @@ -4113,7 +4113,7 @@ void ECDH::New(const FunctionCallbackInfo& args) { // TODO(indutny): Support raw curves? CHECK(args[0]->IsString()); - node::Utf8Value curve(args[0]); + node::Utf8Value curve(env->isolate(), args[0]); int nid = OBJ_sn2nid(*curve); if (nid == NID_undef) @@ -4513,7 +4513,7 @@ void PBKDF2(const FunctionCallbackInfo& args) { } if (args[4]->IsString()) { - node::Utf8Value digest_name(args[4]); + node::Utf8Value digest_name(env->isolate(), args[4]); digest = EVP_get_digestbyname(*digest_name); if (digest == nullptr) { type_error = "Bad digest name"; @@ -5014,7 +5014,7 @@ void SetEngine(const FunctionCallbackInfo& args) { ClearErrorOnReturn clear_error_on_return; (void) &clear_error_on_return; // Silence compiler warning. - const node::Utf8Value engine_id(args[0]); + const node::Utf8Value engine_id(env->isolate(), args[0]); ENGINE* engine = ENGINE_by_id(*engine_id); // Engine not found, try loading dynamically diff --git a/src/node_dtrace.cc b/src/node_dtrace.cc index 8feedb600f8baf..a695b076d74210 100644 --- a/src/node_dtrace.cc +++ b/src/node_dtrace.cc @@ -76,8 +76,8 @@ using v8::Value; return env->ThrowError( \ "expected object for " #obj " to contain string member " #member); \ } \ - node::Utf8Value _##member(obj->Get(OneByteString(env->isolate(), \ - #member))); \ + node::Utf8Value _##member(env->isolate(), \ + obj->Get(OneByteString(env->isolate(), #member))); \ if ((*(const char **)valp = *_##member) == nullptr) \ *(const char **)valp = ""; @@ -215,7 +215,7 @@ void DTRACE_HTTP_SERVER_REQUEST(const FunctionCallbackInfo& args) { } Local strfwdfor = headers->Get(env->x_forwarded_string()); - node::Utf8Value fwdfor(strfwdfor); + node::Utf8Value fwdfor(env->isolate(), strfwdfor); if (!strfwdfor->IsString() || (req.forwardedFor = *fwdfor) == nullptr) req.forwardedFor = const_cast(""); diff --git a/src/node_file.cc b/src/node_file.cc index e6ef3cbbf24999..1077929fcf47aa 100644 --- a/src/node_file.cc +++ b/src/node_file.cc @@ -329,7 +329,7 @@ static void Access(const FunctionCallbackInfo& args) { if (!args[1]->IsInt32()) return TYPE_ERROR("mode must be an integer"); - node::Utf8Value path(args[0]); + node::Utf8Value path(env->isolate(), args[0]); int mode = static_cast(args[1]->Int32Value()); if (args[2]->IsObject()) { @@ -462,7 +462,7 @@ static void Stat(const FunctionCallbackInfo& args) { if (!args[0]->IsString()) return TYPE_ERROR("path must be a string"); - node::Utf8Value path(args[0]); + node::Utf8Value path(env->isolate(), args[0]); if (args[1]->IsObject()) { ASYNC_CALL(stat, args[1], *path) @@ -481,7 +481,7 @@ static void LStat(const FunctionCallbackInfo& args) { if (!args[0]->IsString()) return TYPE_ERROR("path must be a string"); - node::Utf8Value path(args[0]); + node::Utf8Value path(env->isolate(), args[0]); if (args[1]->IsObject()) { ASYNC_CALL(lstat, args[1], *path) @@ -523,12 +523,12 @@ static void Symlink(const FunctionCallbackInfo& args) { if (!args[1]->IsString()) return TYPE_ERROR("src path must be a string"); - node::Utf8Value dest(args[0]); - node::Utf8Value path(args[1]); + node::Utf8Value dest(env->isolate(), args[0]); + node::Utf8Value path(env->isolate(), args[1]); int flags = 0; if (args[2]->IsString()) { - node::Utf8Value mode(args[2]); + node::Utf8Value mode(env->isolate(), args[2]); if (strcmp(*mode, "dir") == 0) { flags |= UV_FS_SYMLINK_DIR; } else if (strcmp(*mode, "junction") == 0) { @@ -558,8 +558,8 @@ static void Link(const FunctionCallbackInfo& args) { if (!args[1]->IsString()) return TYPE_ERROR("src path must be a string"); - node::Utf8Value orig_path(args[0]); - node::Utf8Value new_path(args[1]); + node::Utf8Value orig_path(env->isolate(), args[0]); + node::Utf8Value new_path(env->isolate(), args[1]); if (args[2]->IsObject()) { ASYNC_DEST_CALL(link, args[2], *new_path, *orig_path, *new_path) @@ -576,7 +576,7 @@ static void ReadLink(const FunctionCallbackInfo& args) { if (!args[0]->IsString()) return TYPE_ERROR("path must be a string"); - node::Utf8Value path(args[0]); + node::Utf8Value path(env->isolate(), args[0]); if (args[1]->IsObject()) { ASYNC_CALL(readlink, args[1], *path) @@ -601,8 +601,8 @@ static void Rename(const FunctionCallbackInfo& args) { if (!args[1]->IsString()) return TYPE_ERROR("new path must be a string"); - node::Utf8Value old_path(args[0]); - node::Utf8Value new_path(args[1]); + node::Utf8Value old_path(env->isolate(), args[0]); + node::Utf8Value new_path(env->isolate(), args[1]); if (args[2]->IsObject()) { ASYNC_DEST_CALL(rename, args[2], *new_path, *old_path, *new_path) @@ -670,7 +670,7 @@ static void Unlink(const FunctionCallbackInfo& args) { if (!args[0]->IsString()) return TYPE_ERROR("path must be a string"); - node::Utf8Value path(args[0]); + node::Utf8Value path(env->isolate(), args[0]); if (args[1]->IsObject()) { ASYNC_CALL(unlink, args[1], *path) @@ -687,7 +687,7 @@ static void RMDir(const FunctionCallbackInfo& args) { if (!args[0]->IsString()) return TYPE_ERROR("path must be a string"); - node::Utf8Value path(args[0]); + node::Utf8Value path(env->isolate(), args[0]); if (args[1]->IsObject()) { ASYNC_CALL(rmdir, args[1], *path) @@ -703,7 +703,7 @@ static void MKDir(const FunctionCallbackInfo& args) { return THROW_BAD_ARGS; } - node::Utf8Value path(args[0]); + node::Utf8Value path(env->isolate(), args[0]); int mode = static_cast(args[1]->Int32Value()); if (args[2]->IsObject()) { @@ -721,7 +721,7 @@ static void ReadDir(const FunctionCallbackInfo& args) { if (!args[0]->IsString()) return TYPE_ERROR("path must be a string"); - node::Utf8Value path(args[0]); + node::Utf8Value path(env->isolate(), args[0]); if (args[1]->IsObject()) { ASYNC_CALL(scandir, args[1], *path, 0 /*flags*/) @@ -767,7 +767,7 @@ static void Open(const FunctionCallbackInfo& args) { if (!args[2]->IsInt32()) return TYPE_ERROR("mode must be an int"); - node::Utf8Value path(args[0]); + node::Utf8Value path(env->isolate(), args[0]); int flags = args[1]->Int32Value(); int mode = static_cast(args[2]->Int32Value()); @@ -966,7 +966,7 @@ static void Chmod(const FunctionCallbackInfo& args) { if (args.Length() < 2 || !args[0]->IsString() || !args[1]->IsInt32()) { return THROW_BAD_ARGS; } - node::Utf8Value path(args[0]); + node::Utf8Value path(env->isolate(), args[0]); int mode = static_cast(args[1]->Int32Value()); if (args[2]->IsObject()) { @@ -1017,7 +1017,7 @@ static void Chown(const FunctionCallbackInfo& args) { if (!args[2]->IsUint32()) return TYPE_ERROR("gid must be an unsigned int"); - node::Utf8Value path(args[0]); + node::Utf8Value path(env->isolate(), args[0]); uv_uid_t uid = static_cast(args[1]->Uint32Value()); uv_gid_t gid = static_cast(args[2]->Uint32Value()); @@ -1078,7 +1078,7 @@ static void UTimes(const FunctionCallbackInfo& args) { if (!args[2]->IsNumber()) return TYPE_ERROR("mtime must be a number"); - const node::Utf8Value path(args[0]); + const node::Utf8Value path(env->isolate(), args[0]); const double atime = static_cast(args[1]->NumberValue()); const double mtime = static_cast(args[2]->NumberValue()); diff --git a/src/node_stat_watcher.cc b/src/node_stat_watcher.cc index 43112933fefaff..ece49a96bb011a 100644 --- a/src/node_stat_watcher.cc +++ b/src/node_stat_watcher.cc @@ -107,7 +107,7 @@ void StatWatcher::Start(const FunctionCallbackInfo& args) { CHECK_EQ(args.Length(), 3); StatWatcher* wrap = Unwrap(args.Holder()); - node::Utf8Value path(args[0]); + node::Utf8Value path(args.GetIsolate(), args[0]); const bool persistent = args[1]->BooleanValue(); const uint32_t interval = args[2]->Uint32Value(); diff --git a/src/pipe_wrap.cc b/src/pipe_wrap.cc index b91ebe0e5ed09e..c4bc3e1668053a 100644 --- a/src/pipe_wrap.cc +++ b/src/pipe_wrap.cc @@ -177,7 +177,7 @@ PipeWrap::PipeWrap(Environment* env, void PipeWrap::Bind(const FunctionCallbackInfo& args) { PipeWrap* wrap = Unwrap(args.Holder()); - node::Utf8Value name(args[0]); + node::Utf8Value name(args.GetIsolate(), args[0]); int err = uv_pipe_bind(&wrap->handle_, *name); args.GetReturnValue().Set(err); } @@ -300,7 +300,7 @@ void PipeWrap::Connect(const FunctionCallbackInfo& args) { CHECK(args[1]->IsString()); Local req_wrap_obj = args[0].As(); - node::Utf8Value name(args[1]); + node::Utf8Value name(env->isolate(), args[1]); PipeConnectWrap* req_wrap = new PipeConnectWrap(env, req_wrap_obj); uv_pipe_connect(&req_wrap->req_, diff --git a/src/process_wrap.cc b/src/process_wrap.cc index 5368e2803bba5a..c1bffcb11f196e 100644 --- a/src/process_wrap.cc +++ b/src/process_wrap.cc @@ -167,7 +167,8 @@ class ProcessWrap : public HandleWrap { // options.file Local file_v = js_options->Get(env->file_string()); - node::Utf8Value file(file_v->IsString() ? file_v : Local()); + node::Utf8Value file(env->isolate(), + file_v->IsString() ? file_v : Local()); if (file.length() > 0) { options.file = *file; } else { @@ -182,7 +183,7 @@ class ProcessWrap : public HandleWrap { // Heap allocate to detect errors. +1 is for nullptr. options.args = new char*[argc + 1]; for (int i = 0; i < argc; i++) { - node::Utf8Value arg(js_argv->Get(i)); + node::Utf8Value arg(env->isolate(), js_argv->Get(i)); options.args[i] = strdup(*arg); } options.args[argc] = nullptr; @@ -190,7 +191,8 @@ class ProcessWrap : public HandleWrap { // options.cwd Local cwd_v = js_options->Get(env->cwd_string()); - node::Utf8Value cwd(cwd_v->IsString() ? cwd_v : Local()); + node::Utf8Value cwd(env->isolate(), + cwd_v->IsString() ? cwd_v : Local()); if (cwd.length() > 0) { options.cwd = *cwd; } @@ -198,11 +200,11 @@ class ProcessWrap : public HandleWrap { // options.env Local env_v = js_options->Get(env->env_pairs_string()); if (!env_v.IsEmpty() && env_v->IsArray()) { - Local env = Local::Cast(env_v); - int envc = env->Length(); + Local env_opt = Local::Cast(env_v); + int envc = env_opt->Length(); options.env = new char*[envc + 1]; // Heap allocated to detect errors. for (int i = 0; i < envc; i++) { - node::Utf8Value pair(env->Get(i)); + node::Utf8Value pair(env->isolate(), env_opt->Get(i)); options.env[i] = strdup(*pair); } options.env[envc] = nullptr; diff --git a/src/tcp_wrap.cc b/src/tcp_wrap.cc index 3b280990436dd1..7d5664510e183c 100644 --- a/src/tcp_wrap.cc +++ b/src/tcp_wrap.cc @@ -279,7 +279,7 @@ void TCPWrap::Open(const FunctionCallbackInfo& args) { void TCPWrap::Bind(const FunctionCallbackInfo& args) { TCPWrap* wrap = Unwrap(args.Holder()); - node::Utf8Value ip_address(args[0]); + node::Utf8Value ip_address(args.GetIsolate(), args[0]); int port = args[1]->Int32Value(); sockaddr_in addr; int err = uv_ip4_addr(*ip_address, port, &addr); @@ -294,7 +294,7 @@ void TCPWrap::Bind(const FunctionCallbackInfo& args) { void TCPWrap::Bind6(const FunctionCallbackInfo& args) { TCPWrap* wrap = Unwrap(args.Holder()); - node::Utf8Value ip6_address(args[0]); + node::Utf8Value ip6_address(args.GetIsolate(), args[0]); int port = args[1]->Int32Value(); sockaddr_in6 addr; int err = uv_ip6_addr(*ip6_address, port, &addr); @@ -391,7 +391,7 @@ void TCPWrap::Connect(const FunctionCallbackInfo& args) { CHECK(args[2]->Uint32Value()); Local req_wrap_obj = args[0].As(); - node::Utf8Value ip_address(args[1]); + node::Utf8Value ip_address(env->isolate(), args[1]); int port = args[2]->Uint32Value(); sockaddr_in addr; @@ -422,7 +422,7 @@ void TCPWrap::Connect6(const FunctionCallbackInfo& args) { CHECK(args[2]->Uint32Value()); Local req_wrap_obj = args[0].As(); - node::Utf8Value ip_address(args[1]); + node::Utf8Value ip_address(env->isolate(), args[1]); int port = args[2]->Int32Value(); sockaddr_in6 addr; diff --git a/src/tls_wrap.cc b/src/tls_wrap.cc index 3d8097042240f2..1fb4d5474a1074 100644 --- a/src/tls_wrap.cc +++ b/src/tls_wrap.cc @@ -748,7 +748,7 @@ void TLSCallbacks::SetServername(const FunctionCallbackInfo& args) { return; #ifdef SSL_CTRL_SET_TLSEXT_SERVERNAME_CB - node::Utf8Value servername(args[0].As()); + node::Utf8Value servername(env->isolate(), args[0].As()); SSL_set_tlsext_host_name(wrap->ssl_, *servername); #endif // SSL_CTRL_SET_TLSEXT_SERVERNAME_CB } diff --git a/src/udp_wrap.cc b/src/udp_wrap.cc index e58503b40acfa8..155f21a012b7ff 100644 --- a/src/udp_wrap.cc +++ b/src/udp_wrap.cc @@ -170,7 +170,7 @@ void UDPWrap::DoBind(const FunctionCallbackInfo& args, int family) { // bind(ip, port, flags) CHECK_EQ(args.Length(), 3); - node::Utf8Value address(args[0]); + node::Utf8Value address(args.GetIsolate(), args[0]); const int port = args[1]->Uint32Value(); const int flags = args[2]->Uint32Value(); char addr[sizeof(sockaddr_in6)]; @@ -231,8 +231,8 @@ void UDPWrap::SetMembership(const FunctionCallbackInfo& args, CHECK_EQ(args.Length(), 2); - node::Utf8Value address(args[0]); - node::Utf8Value iface(args[1]); + node::Utf8Value address(args.GetIsolate(), args[0]); + node::Utf8Value iface(args.GetIsolate(), args[1]); const char* iface_cstr = *iface; if (args[1]->IsUndefined() || args[1]->IsNull()) { @@ -276,7 +276,7 @@ void UDPWrap::DoSend(const FunctionCallbackInfo& args, int family) { size_t offset = args[2]->Uint32Value(); size_t length = args[3]->Uint32Value(); const unsigned short port = args[4]->Uint32Value(); - node::Utf8Value address(args[5]); + node::Utf8Value address(env->isolate(), args[5]); const bool have_callback = args[6]->IsTrue(); CHECK_LE(length, Buffer::Length(buffer_obj) - offset); diff --git a/src/util.cc b/src/util.cc index a42e8934014411..9a21709150c475 100644 --- a/src/util.cc +++ b/src/util.cc @@ -25,12 +25,12 @@ namespace node { -Utf8Value::Utf8Value(v8::Handle value) +Utf8Value::Utf8Value(v8::Isolate* isolate, v8::Handle value) : length_(0), str_(nullptr) { if (value.IsEmpty()) return; - v8::Local val_ = value->ToString(v8::Isolate::GetCurrent()); + v8::Local val_ = value->ToString(isolate); if (val_.IsEmpty()) return; diff --git a/src/util.h b/src/util.h index 7bafe79e3010bf..f266f0d99f4410 100644 --- a/src/util.h +++ b/src/util.h @@ -121,7 +121,7 @@ inline TypeName* Unwrap(v8::Local object); class Utf8Value { public: - explicit Utf8Value(v8::Handle value); + explicit Utf8Value(v8::Isolate* isolate, v8::Handle value); ~Utf8Value() { free(str_);