diff --git a/src/cares_wrap.cc b/src/cares_wrap.cc index d9f6485edfb507..8cc2339872b553 100644 --- a/src/cares_wrap.cc +++ b/src/cares_wrap.cc @@ -1848,7 +1848,7 @@ void AfterGetAddrInfo(uv_getaddrinfo_t* req, int status, struct addrinfo* res) { continue; Local s = OneByteString(env->isolate(), ip); - results->Set(n, s); + results->Set(env->context(), n, s).FromJust(); n++; } }; @@ -2049,10 +2049,12 @@ void GetServers(const FunctionCallbackInfo& args) { CHECK_EQ(err, 0); Local ret = Array::New(env->isolate(), 2); - ret->Set(0, OneByteString(env->isolate(), ip)); - ret->Set(1, Integer::New(env->isolate(), cur->udp_port)); + ret->Set(env->context(), 0, OneByteString(env->isolate(), ip)).FromJust(); + ret->Set(env->context(), + 1, + Integer::New(env->isolate(), cur->udp_port)).FromJust(); - server_array->Set(i, ret); + server_array->Set(env->context(), i, ret).FromJust(); } ares_free_data(servers); @@ -2175,16 +2177,19 @@ void Initialize(Local target, env->SetMethod(target, "strerror", StrError); - target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "AF_INET"), - Integer::New(env->isolate(), AF_INET)); - target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "AF_INET6"), - Integer::New(env->isolate(), AF_INET6)); - target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "AF_UNSPEC"), - Integer::New(env->isolate(), AF_UNSPEC)); - target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "AI_ADDRCONFIG"), - Integer::New(env->isolate(), AI_ADDRCONFIG)); - target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "AI_V4MAPPED"), - Integer::New(env->isolate(), AI_V4MAPPED)); + target->Set(env->context(), FIXED_ONE_BYTE_STRING(env->isolate(), "AF_INET"), + Integer::New(env->isolate(), AF_INET)).FromJust(); + target->Set(env->context(), FIXED_ONE_BYTE_STRING(env->isolate(), "AF_INET6"), + Integer::New(env->isolate(), AF_INET6)).FromJust(); + target->Set(env->context(), FIXED_ONE_BYTE_STRING(env->isolate(), + "AF_UNSPEC"), + Integer::New(env->isolate(), AF_UNSPEC)).FromJust(); + target->Set(env->context(), FIXED_ONE_BYTE_STRING(env->isolate(), + "AI_ADDRCONFIG"), + Integer::New(env->isolate(), AI_ADDRCONFIG)).FromJust(); + target->Set(env->context(), FIXED_ONE_BYTE_STRING(env->isolate(), + "AI_V4MAPPED"), + Integer::New(env->isolate(), AI_V4MAPPED)).FromJust(); Local aiw = BaseObject::MakeLazilyInitializedJSTemplate(env); @@ -2192,7 +2197,9 @@ void Initialize(Local target, Local addrInfoWrapString = FIXED_ONE_BYTE_STRING(env->isolate(), "GetAddrInfoReqWrap"); aiw->SetClassName(addrInfoWrapString); - target->Set(addrInfoWrapString, aiw->GetFunction(context).ToLocalChecked()); + target->Set(env->context(), + addrInfoWrapString, + aiw->GetFunction(context).ToLocalChecked()).FromJust(); Local niw = BaseObject::MakeLazilyInitializedJSTemplate(env); @@ -2200,7 +2207,9 @@ void Initialize(Local target, Local nameInfoWrapString = FIXED_ONE_BYTE_STRING(env->isolate(), "GetNameInfoReqWrap"); niw->SetClassName(nameInfoWrapString); - target->Set(nameInfoWrapString, niw->GetFunction(context).ToLocalChecked()); + target->Set(env->context(), + nameInfoWrapString, + niw->GetFunction(context).ToLocalChecked()).FromJust(); Local qrw = BaseObject::MakeLazilyInitializedJSTemplate(env); @@ -2208,7 +2217,9 @@ void Initialize(Local target, Local queryWrapString = FIXED_ONE_BYTE_STRING(env->isolate(), "QueryReqWrap"); qrw->SetClassName(queryWrapString); - target->Set(queryWrapString, qrw->GetFunction(context).ToLocalChecked()); + target->Set(env->context(), + queryWrapString, + qrw->GetFunction(context).ToLocalChecked()).FromJust(); Local channel_wrap = env->NewFunctionTemplate(ChannelWrap::New); @@ -2235,8 +2246,8 @@ void Initialize(Local target, Local channelWrapString = FIXED_ONE_BYTE_STRING(env->isolate(), "ChannelWrap"); channel_wrap->SetClassName(channelWrapString); - target->Set(channelWrapString, - channel_wrap->GetFunction(context).ToLocalChecked()); + target->Set(env->context(), channelWrapString, + channel_wrap->GetFunction(context).ToLocalChecked()).FromJust(); } } // anonymous namespace diff --git a/src/env.cc b/src/env.cc index 9d8fd967a406a6..727d13b98b13a1 100644 --- a/src/env.cc +++ b/src/env.cc @@ -746,7 +746,9 @@ void CollectExceptionInfo(Environment* env, const char* message, const char* path, const char* dest) { - obj->Set(env->errno_string(), v8::Integer::New(env->isolate(), errorno)); + obj->Set(env->context(), + env->errno_string(), + v8::Integer::New(env->isolate(), errorno)).FromJust(); obj->Set(env->context(), env->code_string(), OneByteString(env->isolate(), err_string)).FromJust(); diff --git a/src/exceptions.cc b/src/exceptions.cc index 98c87603dd9be3..7bbee45467ff35 100644 --- a/src/exceptions.cc +++ b/src/exceptions.cc @@ -51,15 +51,19 @@ Local ErrnoException(Isolate* isolate, e = Exception::Error(cons); Local obj = e.As(); - obj->Set(env->errno_string(), Integer::New(isolate, errorno)); - obj->Set(env->code_string(), estring); + obj->Set(env->context(), + env->errno_string(), + Integer::New(isolate, errorno)).FromJust(); + obj->Set(env->context(), env->code_string(), estring).FromJust(); if (path_string.IsEmpty() == false) { - obj->Set(env->path_string(), path_string); + obj->Set(env->context(), env->path_string(), path_string).FromJust(); } if (syscall != nullptr) { - obj->Set(env->syscall_string(), OneByteString(isolate, syscall)); + obj->Set(env->context(), + env->syscall_string(), + OneByteString(isolate, syscall)).FromJust(); } return e; @@ -132,13 +136,15 @@ Local UVException(Isolate* isolate, Exception::Error(js_msg)->ToObject(isolate->GetCurrentContext()) .ToLocalChecked(); - e->Set(env->errno_string(), Integer::New(isolate, errorno)); - e->Set(env->code_string(), js_code); - e->Set(env->syscall_string(), js_syscall); + e->Set(env->context(), + env->errno_string(), + Integer::New(isolate, errorno)).FromJust(); + e->Set(env->context(), env->code_string(), js_code).FromJust(); + e->Set(env->context(), env->syscall_string(), js_syscall).FromJust(); if (!js_path.IsEmpty()) - e->Set(env->path_string(), js_path); + e->Set(env->context(), env->path_string(), js_path).FromJust(); if (!js_dest.IsEmpty()) - e->Set(env->dest_string(), js_dest); + e->Set(env->context(), env->dest_string(), js_dest).FromJust(); return e; } diff --git a/src/fs_event_wrap.cc b/src/fs_event_wrap.cc index 739794665b2cfe..057445776a5255 100644 --- a/src/fs_event_wrap.cc +++ b/src/fs_event_wrap.cc @@ -119,7 +119,9 @@ void FSEventWrap::Initialize(Local target, Local(), static_cast(ReadOnly | DontDelete | v8::DontEnum)); - target->Set(fsevent_string, t->GetFunction(context).ToLocalChecked()); + target->Set(env->context(), + fsevent_string, + t->GetFunction(context).ToLocalChecked()).FromJust(); } diff --git a/src/js_stream.cc b/src/js_stream.cc index 99ea7d870b8afb..2d07b11b636ef9 100644 --- a/src/js_stream.cc +++ b/src/js_stream.cc @@ -118,7 +118,7 @@ int JSStream::DoWrite(WriteWrap* w, Local buf; for (size_t i = 0; i < count; i++) { buf = Buffer::Copy(env(), bufs[i].base, bufs[i].len).ToLocalChecked(); - bufs_arr->Set(i, buf); + bufs_arr->Set(env()->context(), i, buf).FromJust(); } Local argv[] = { @@ -210,7 +210,9 @@ void JSStream::Initialize(Local target, env->SetProtoMethod(t, "emitEOF", EmitEOF); StreamBase::AddMethods(env, t); - target->Set(jsStreamString, t->GetFunction(context).ToLocalChecked()); + target->Set(env->context(), + jsStreamString, + t->GetFunction(context).ToLocalChecked()).FromJust(); } } // namespace node diff --git a/src/module_wrap.cc b/src/module_wrap.cc index ebe84fd1ec569d..5443b2e07dc856 100644 --- a/src/module_wrap.cc +++ b/src/module_wrap.cc @@ -837,8 +837,8 @@ void ModuleWrap::Initialize(Local target, env->SetProtoMethodNoSideEffect(tpl, "getStaticDependencySpecifiers", GetStaticDependencySpecifiers); - target->Set(FIXED_ONE_BYTE_STRING(isolate, "ModuleWrap"), - tpl->GetFunction(context).ToLocalChecked()); + target->Set(env->context(), FIXED_ONE_BYTE_STRING(isolate, "ModuleWrap"), + tpl->GetFunction(context).ToLocalChecked()).FromJust(); env->SetMethod(target, "resolve", Resolve); env->SetMethod(target, "setImportModuleDynamicallyCallback", diff --git a/src/node.cc b/src/node.cc index 9ed73b60511bbb..f1bfc89a3cd211 100644 --- a/src/node.cc +++ b/src/node.cc @@ -686,7 +686,8 @@ MaybeLocal MakeCallback(Isolate* isolate, int argc, Local argv[], async_context asyncContext) { - Local callback_v = recv->Get(symbol); + Local callback_v = recv->Get(isolate->GetCurrentContext(), + symbol).ToLocalChecked(); if (callback_v.IsEmpty()) return Local(); if (!callback_v->IsFunction()) return Local(); Local callback = callback_v.As(); @@ -1260,7 +1261,7 @@ static void GetLinkedBinding(const FunctionCallbackInfo& args) { Local exports = Object::New(env->isolate()); Local exports_prop = String::NewFromUtf8(env->isolate(), "exports", NewStringType::kNormal).ToLocalChecked(); - module->Set(exports_prop, exports); + module->Set(env->context(), exports_prop, exports).FromJust(); if (mod->nm_context_register_func != nullptr) { mod->nm_context_register_func(exports, @@ -1273,7 +1274,8 @@ static void GetLinkedBinding(const FunctionCallbackInfo& args) { return env->ThrowError("Linked module has no declared entry point."); } - auto effective_exports = module->Get(exports_prop); + auto effective_exports = module->Get(env->context(), + exports_prop).ToLocalChecked(); args.GetReturnValue().Set(effective_exports); } @@ -1288,10 +1290,16 @@ static Local GetFeatures(Environment* env) { Local debug = False(env->isolate()); #endif // defined(DEBUG) && DEBUG - obj->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "debug"), debug); - obj->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "uv"), True(env->isolate())); + obj->Set(env->context(), + FIXED_ONE_BYTE_STRING(env->isolate(), "debug"), + debug).FromJust(); + obj->Set(env->context(), + FIXED_ONE_BYTE_STRING(env->isolate(), "uv"), + True(env->isolate())).FromJust(); // TODO(bnoordhuis) ping libuv - obj->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "ipv6"), True(env->isolate())); + obj->Set(env->context(), + FIXED_ONE_BYTE_STRING(env->isolate(), "ipv6"), + True(env->isolate())).FromJust(); #ifdef HAVE_OPENSSL Local have_openssl = True(env->isolate()); @@ -1299,10 +1307,18 @@ static Local GetFeatures(Environment* env) { Local have_openssl = False(env->isolate()); #endif - obj->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "tls_alpn"), have_openssl); - obj->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "tls_sni"), have_openssl); - obj->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "tls_ocsp"), have_openssl); - obj->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "tls"), have_openssl); + obj->Set(env->context(), + FIXED_ONE_BYTE_STRING(env->isolate(), "tls_alpn"), + have_openssl).FromJust(); + obj->Set(env->context(), + FIXED_ONE_BYTE_STRING(env->isolate(), "tls_sni"), + have_openssl).FromJust(); + obj->Set(env->context(), + FIXED_ONE_BYTE_STRING(env->isolate(), "tls_ocsp"), + have_openssl).FromJust(); + obj->Set(env->context(), + FIXED_ONE_BYTE_STRING(env->isolate(), "tls"), + have_openssl).FromJust(); return scope.Escape(obj); } @@ -1464,7 +1480,9 @@ void SetupProcessObject(Environment* env, NewStringType::kNormal).ToLocalChecked()) .FromJust(); } - process->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "argv"), arguments); + process->Set(env->context(), + FIXED_ONE_BYTE_STRING(env->isolate(), "argv"), + arguments).FromJust(); // process.execArgv Local exec_arguments = Array::New(env->isolate(), exec_args.size()); @@ -1474,8 +1492,9 @@ void SetupProcessObject(Environment* env, NewStringType::kNormal).ToLocalChecked()) .FromJust(); } - process->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "execArgv"), - exec_arguments); + process->Set(env->context(), + FIXED_ONE_BYTE_STRING(env->isolate(), "execArgv"), + exec_arguments).FromJust(); // create process.env Local process_env_template = @@ -1490,7 +1509,9 @@ void SetupProcessObject(Environment* env, Local process_env = process_env_template->NewInstance(env->context()).ToLocalChecked(); - process->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "env"), process_env); + process->Set(env->context(), + FIXED_ONE_BYTE_STRING(env->isolate(), "env"), + process_env).FromJust(); READONLY_PROPERTY(process, "pid", Integer::New(env->isolate(), uv_os_getpid())); @@ -1535,7 +1556,7 @@ void SetupProcessObject(Environment* env, preload_modules[i].c_str(), NewStringType::kNormal) .ToLocalChecked(); - array->Set(i, module); + array->Set(env->context(), i, module).FromJust(); } READONLY_PROPERTY(process, "_preload_modules", @@ -1625,8 +1646,9 @@ void SetupProcessObject(Environment* env, exec_path_value = String::NewFromUtf8(env->isolate(), args[0].c_str(), NewStringType::kInternalized).ToLocalChecked(); } - process->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "execPath"), - exec_path_value); + process->Set(env->context(), + FIXED_ONE_BYTE_STRING(env->isolate(), "execPath"), + exec_path_value).FromJust(); delete[] exec_path; auto debug_port_string = FIXED_ONE_BYTE_STRING(env->isolate(), "debugPort"); @@ -1779,7 +1801,9 @@ void LoadEnvironment(Environment* env) { // Expose the global object as a property on itself // (Allows you to set stuff on `global` from anywhere in JavaScript.) - global->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "global"), global); + global->Set(env->context(), + FIXED_ONE_BYTE_STRING(env->isolate(), "global"), + global).FromJust(); // Create binding loaders Local get_binding_fn = @@ -2340,8 +2364,9 @@ int EmitExit(Environment* env) { HandleScope handle_scope(env->isolate()); Context::Scope context_scope(env->context()); Local process_object = env->process_object(); - process_object->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "_exiting"), - True(env->isolate())); + process_object->Set(env->context(), + FIXED_ONE_BYTE_STRING(env->isolate(), "_exiting"), + True(env->isolate())).FromJust(); Local exit_code = env->exit_code_string(); int code = process_object->Get(env->context(), exit_code).ToLocalChecked() diff --git a/src/node_constants.cc b/src/node_constants.cc index 753b8f8fe16602..3b028b52aa75cc 100644 --- a/src/node_constants.cc +++ b/src/node_constants.cc @@ -1347,15 +1347,33 @@ void DefineConstants(v8::Isolate* isolate, Local target) { // Define libuv constants. NODE_DEFINE_CONSTANT(os_constants, UV_UDP_REUSEADDR); - os_constants->Set(OneByteString(isolate, "dlopen"), dlopen_constants); - os_constants->Set(OneByteString(isolate, "errno"), err_constants); - os_constants->Set(OneByteString(isolate, "signals"), sig_constants); - os_constants->Set(OneByteString(isolate, "priority"), priority_constants); - target->Set(OneByteString(isolate, "os"), os_constants); - target->Set(OneByteString(isolate, "fs"), fs_constants); - target->Set(OneByteString(isolate, "crypto"), crypto_constants); - target->Set(OneByteString(isolate, "zlib"), zlib_constants); - target->Set(OneByteString(isolate, "trace"), trace_constants); + os_constants->Set(env->context(), + OneByteString(isolate, "dlopen"), + dlopen_constants).FromJust(); + os_constants->Set(env->context(), + OneByteString(isolate, "errno"), + err_constants).FromJust(); + os_constants->Set(env->context(), + OneByteString(isolate, "signals"), + sig_constants).FromJust(); + os_constants->Set(env->context(), + OneByteString(isolate, "priority"), + priority_constants).FromJust(); + target->Set(env->context(), + OneByteString(isolate, "os"), + os_constants).FromJust(); + target->Set(env->context(), + OneByteString(isolate, "fs"), + fs_constants).FromJust(); + target->Set(env->context(), + OneByteString(isolate, "crypto"), + crypto_constants).FromJust(); + target->Set(env->context(), + OneByteString(isolate, "zlib"), + zlib_constants).FromJust(); + target->Set(env->context(), + OneByteString(isolate, "trace"), + trace_constants).FromJust(); } } // namespace node diff --git a/src/node_contextify.cc b/src/node_contextify.cc index e878507731ef1c..37afead80896d0 100644 --- a/src/node_contextify.cc +++ b/src/node_contextify.cc @@ -392,7 +392,7 @@ void ContextifyContext::PropertySetterCallback( args.GetReturnValue().Set(false); } - ctx->sandbox()->Set(property, value); + ctx->sandbox()->Set(ctx->context(), property, value).FromJust(); } // static @@ -606,8 +606,8 @@ void ContextifyScript::Init(Environment* env, Local target) { env->SetProtoMethod(script_tmpl, "runInContext", RunInContext); env->SetProtoMethod(script_tmpl, "runInThisContext", RunInThisContext); - target->Set(class_name, - script_tmpl->GetFunction(env->context()).ToLocalChecked()); + target->Set(env->context(), class_name, + script_tmpl->GetFunction(env->context()).ToLocalChecked()).FromJust(); env->set_script_context_constructor_template(script_tmpl); } @@ -728,8 +728,9 @@ void ContextifyScript::New(const FunctionCallbackInfo& args) { if (compile_options == ScriptCompiler::kConsumeCodeCache) { args.This()->Set( + env->context(), env->cached_data_rejected_string(), - Boolean::New(isolate, source.GetCachedData()->rejected)); + Boolean::New(isolate, source.GetCachedData()->rejected)).FromJust(); } else if (produce_cached_data) { const ScriptCompiler::CachedData* cached_data = ScriptCompiler::CreateCodeCache(v8_script.ToLocalChecked()); @@ -739,11 +740,14 @@ void ContextifyScript::New(const FunctionCallbackInfo& args) { env, reinterpret_cast(cached_data->data), cached_data->length); - args.This()->Set(env->cached_data_string(), buf.ToLocalChecked()); + args.This()->Set(env->context(), + env->cached_data_string(), + buf.ToLocalChecked()).FromJust(); } args.This()->Set( + env->context(), env->cached_data_produced_string(), - Boolean::New(isolate, cached_data_produced)); + Boolean::New(isolate, cached_data_produced)).FromJust(); } TRACE_EVENT_NESTABLE_ASYNC_END0( TRACING_CATEGORY_NODE2(vm, script), diff --git a/src/node_crypto.cc b/src/node_crypto.cc index fa5335344c9f85..baa0fbe635cd8b 100644 --- a/src/node_crypto.cc +++ b/src/node_crypto.cc @@ -379,8 +379,8 @@ void SecureContext::Initialize(Environment* env, Local target) { Local(), static_cast(ReadOnly | DontDelete)); - target->Set(secureContextString, - t->GetFunction(env->context()).ToLocalChecked()); + target->Set(env->context(), secureContextString, + t->GetFunction(env->context()).ToLocalChecked()).FromJust(); env->set_secure_context_constructor_template(t); } @@ -1267,18 +1267,24 @@ int SecureContext::TicketKeyCallback(SSL* ssl, Local arr = ret.As(); int r = - arr->Get(kTicketKeyReturnIndex)->Int32Value(env->context()).FromJust(); + arr->Get(env->context(), + kTicketKeyReturnIndex).ToLocalChecked() + ->Int32Value(env->context()).FromJust(); if (r < 0) return r; - Local hmac = arr->Get(kTicketKeyHMACIndex); - Local aes = arr->Get(kTicketKeyAESIndex); + Local hmac = arr->Get(env->context(), + kTicketKeyHMACIndex).ToLocalChecked(); + Local aes = arr->Get(env->context(), + kTicketKeyAESIndex).ToLocalChecked(); if (Buffer::Length(aes) != kTicketPartSize) return -1; if (enc) { - Local name_val = arr->Get(kTicketKeyNameIndex); - Local iv_val = arr->Get(kTicketKeyIVIndex); + Local name_val = arr->Get(env->context(), + kTicketKeyNameIndex).ToLocalChecked(); + Local iv_val = arr->Get(env->context(), + kTicketKeyIVIndex).ToLocalChecked(); if (Buffer::Length(name_val) != kTicketPartSize || Buffer::Length(iv_val) != kTicketPartSize) { @@ -1658,7 +1664,7 @@ static Local X509ToObject(Environment* env, X509* cert) { unsigned char* pubserialized = reinterpret_cast(Buffer::Data(pubbuff)); i2d_RSA_PUBKEY(rsa.get(), &pubserialized); - info->Set(env->pubkey_string(), pubbuff); + info->Set(env->context(), env->pubkey_string(), pubbuff).FromJust(); } pkey.reset(); @@ -2413,7 +2419,8 @@ void SSLWrap::CertCbDone(const FunctionCallbackInfo& args) { CHECK(w->is_waiting_cert_cb() && w->cert_cb_running_); Local object = w->object(); - Local ctx = object->Get(env->sni_context_string()); + Local ctx = object->Get(env->context(), + env->sni_context_string()).ToLocalChecked(); Local cons = env->secure_context_constructor_template(); // Not an object, probably undefined or null @@ -2577,8 +2584,9 @@ void CipherBase::Initialize(Environment* env, Local target) { env->SetProtoMethod(t, "setAuthTag", SetAuthTag); env->SetProtoMethod(t, "setAAD", SetAAD); - target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "CipherBase"), - t->GetFunction(env->context()).ToLocalChecked()); + target->Set(env->context(), + FIXED_ONE_BYTE_STRING(env->isolate(), "CipherBase"), + t->GetFunction(env->context()).ToLocalChecked()).FromJust(); } @@ -3182,8 +3190,9 @@ void Hmac::Initialize(Environment* env, v8::Local target) { env->SetProtoMethod(t, "update", HmacUpdate); env->SetProtoMethod(t, "digest", HmacDigest); - target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "Hmac"), - t->GetFunction(env->context()).ToLocalChecked()); + target->Set(env->context(), + FIXED_ONE_BYTE_STRING(env->isolate(), "Hmac"), + t->GetFunction(env->context()).ToLocalChecked()).FromJust(); } @@ -3302,8 +3311,9 @@ void Hash::Initialize(Environment* env, v8::Local target) { env->SetProtoMethod(t, "update", HashUpdate); env->SetProtoMethod(t, "digest", HashDigest); - target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "Hash"), - t->GetFunction(env->context()).ToLocalChecked()); + target->Set(env->context(), + FIXED_ONE_BYTE_STRING(env->isolate(), "Hash"), + t->GetFunction(env->context()).ToLocalChecked()).FromJust(); } @@ -3497,8 +3507,9 @@ void Sign::Initialize(Environment* env, v8::Local target) { env->SetProtoMethod(t, "update", SignUpdate); env->SetProtoMethod(t, "sign", SignFinal); - target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "Sign"), - t->GetFunction(env->context()).ToLocalChecked()); + target->Set(env->context(), + FIXED_ONE_BYTE_STRING(env->isolate(), "Sign"), + t->GetFunction(env->context()).ToLocalChecked()).FromJust(); } @@ -3728,8 +3739,9 @@ void Verify::Initialize(Environment* env, v8::Local target) { env->SetProtoMethod(t, "update", VerifyUpdate); env->SetProtoMethod(t, "verify", VerifyFinal); - target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "Verify"), - t->GetFunction(env->context()).ToLocalChecked()); + target->Set(env->context(), + FIXED_ONE_BYTE_STRING(env->isolate(), "Verify"), + t->GetFunction(env->context()).ToLocalChecked()).FromJust(); } @@ -3965,7 +3977,9 @@ void DiffieHellman::Initialize(Environment* env, Local target) { Local(), attributes); - target->Set(name, t->GetFunction(env->context()).ToLocalChecked()); + target->Set(env->context(), + name, + t->GetFunction(env->context()).ToLocalChecked()).FromJust(); }; make(FIXED_ONE_BYTE_STRING(env->isolate(), "DiffieHellman"), New); @@ -4292,8 +4306,9 @@ void ECDH::Initialize(Environment* env, Local target) { env->SetProtoMethod(t, "setPublicKey", SetPublicKey); env->SetProtoMethod(t, "setPrivateKey", SetPrivateKey); - target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "ECDH"), - t->GetFunction(env->context()).ToLocalChecked()); + target->Set(env->context(), + FIXED_ONE_BYTE_STRING(env->isolate(), "ECDH"), + t->GetFunction(env->context()).ToLocalChecked()).FromJust(); } @@ -5300,7 +5315,9 @@ static void array_push_back(const TypeName* md, const char* to, void* arg) { CipherPushContext* ctx = static_cast(arg); - ctx->arr->Set(ctx->arr->Length(), OneByteString(ctx->env()->isolate(), from)); + ctx->arr->Set(ctx->env()->context(), + ctx->arr->Length(), + OneByteString(ctx->env()->isolate(), from)).FromJust(); } diff --git a/src/node_dtrace.cc b/src/node_dtrace.cc index 164a602fb62a09..cd3986cef56a97 100644 --- a/src/node_dtrace.cc +++ b/src/node_dtrace.cc @@ -65,7 +65,8 @@ using v8::Value; "expected object for " #obj " to contain string member " #member); \ } \ node::Utf8Value _##member(env->isolate(), \ - obj->Get(OneByteString(env->isolate(), #member))); \ + obj->Get(env->context(), \ + OneByteString(env->isolate(), #member)).ToLocalChecked()); \ if ((*(const char **)valp = *_##member) == nullptr) \ *(const char **)valp = ""; @@ -75,7 +76,8 @@ using v8::Value; env, \ "expected object for " #obj " to contain integer member " #member); \ } \ - *valp = obj->Get(OneByteString(env->isolate(), #member)) \ + *valp = obj->Get(env->context(), \ + OneByteString(env->isolate(), #member)).ToLocalChecked() \ ->Int32Value(env->context()) \ .FromJust(); @@ -84,7 +86,8 @@ using v8::Value; return node::THROW_ERR_INVALID_ARG_TYPE(env, \ "expected object for " #obj " to contain object member " #member); \ } \ - *valp = Local::Cast(obj->Get(OneByteString(env->isolate(), #member))); + *valp = Local::Cast(obj->Get(env->context(), \ + OneByteString(env->isolate(), #member)).ToLocalChecked()); #define SLURP_CONNECTION(arg, conn) \ if (!(arg)->IsObject()) { \ @@ -94,7 +97,9 @@ using v8::Value; node_dtrace_connection_t conn; \ Local _##conn = Local::Cast(arg); \ Local _handle = \ - (_##conn)->Get(FIXED_ONE_BYTE_STRING(env->isolate(), "_handle")); \ + (_##conn)->Get(env->context(), \ + FIXED_ONE_BYTE_STRING(env->isolate(), "_handle")) \ + .ToLocalChecked(); \ if (_handle->IsObject()) { \ SLURP_INT(_handle.As(), fd, &conn.fd); \ } else { \ @@ -173,7 +178,8 @@ void DTRACE_HTTP_SERVER_REQUEST(const FunctionCallbackInfo& args) { "expected object for request to contain string member headers"); } - Local strfwdfor = headers->Get(env->x_forwarded_string()); + Local strfwdfor = headers->Get( + env->context(), env->x_forwarded_string()).ToLocalChecked(); node::Utf8Value fwdfor(env->isolate(), strfwdfor); if (!strfwdfor->IsString() || (req.forwardedFor = *fwdfor) == nullptr) @@ -279,7 +285,7 @@ void InitDTrace(Environment* env, Local target) { Local val = env->NewFunctionTemplate(tab[i].func) ->GetFunction(env->context()) .ToLocalChecked(); - target->Set(key, val); + target->Set(env->context(), key, val).FromJust(); } #ifdef HAVE_ETW diff --git a/src/node_errors.cc b/src/node_errors.cc index cc8cff0f0ed2b8..d78608bf7bf24c 100644 --- a/src/node_errors.cc +++ b/src/node_errors.cc @@ -198,7 +198,8 @@ void ReportException(Environment* env, } else { Local err_obj = er->ToObject(env->context()).ToLocalChecked(); - trace_value = err_obj->Get(env->stack_string()); + trace_value = err_obj->Get(env->context(), + env->stack_string()).ToLocalChecked(); arrow = err_obj->GetPrivate(env->context(), env->arrow_message_private_symbol()) .ToLocalChecked(); @@ -223,8 +224,10 @@ void ReportException(Environment* env, if (er->IsObject()) { Local err_obj = er.As(); - message = err_obj->Get(env->message_string()); - name = err_obj->Get(FIXED_ONE_BYTE_STRING(env->isolate(), "name")); + message = err_obj->Get(env->context(), + env->message_string()).ToLocalChecked(); + name = err_obj->Get(env->context(), + FIXED_ONE_BYTE_STRING(env->isolate(), "name")).ToLocalChecked(); } if (message.IsEmpty() || message->IsUndefined() || name.IsEmpty() || @@ -269,7 +272,8 @@ void DecorateErrorStack(Environment* env, const TryCatch& try_catch) { if (IsExceptionDecorated(env, err_obj)) return; AppendExceptionLine(env, exception, try_catch.Message(), CONTEXTIFY_ERROR); - Local stack = err_obj->Get(env->stack_string()); + Local stack = err_obj->Get(env->context(), + env->stack_string()).ToLocalChecked(); MaybeLocal maybe_value = err_obj->GetPrivate(env->context(), env->arrow_message_private_symbol()); @@ -288,7 +292,7 @@ void DecorateErrorStack(Environment* env, const TryCatch& try_catch) { arrow.As(), FIXED_ONE_BYTE_STRING(env->isolate(), "\n")), stack.As()); - err_obj->Set(env->stack_string(), decorated_stack); + err_obj->Set(env->context(), env->stack_string(), decorated_stack).FromJust(); err_obj->SetPrivate( env->context(), env->decorated_private_symbol(), True(env->isolate())); } @@ -361,7 +365,8 @@ void FatalException(Isolate* isolate, Local process_object = env->process_object(); Local fatal_exception_string = env->fatal_exception_string(); Local fatal_exception_function = - process_object->Get(fatal_exception_string); + process_object->Get(env->context(), + fatal_exception_string).ToLocalChecked(); if (!fatal_exception_function->IsFunction()) { // Failed before the process._fatalException function was added! diff --git a/src/node_file.cc b/src/node_file.cc index 683aeee3440b55..cf3b944a5504bb 100644 --- a/src/node_file.cc +++ b/src/node_file.cc @@ -640,8 +640,14 @@ void AfterScanDirWithTypes(uv_fs_t* req) { } Local result = Array::New(isolate, 2); - result->Set(0, Array::New(isolate, name_v.data(), name_v.size())); - result->Set(1, Array::New(isolate, type_v.data(), type_v.size())); + result->Set(env->context(), + 0, + Array::New(isolate, name_v.data(), + name_v.size())).FromJust(); + result->Set(env->context(), + 1, + Array::New(isolate, type_v.data(), + type_v.size())).FromJust(); req_wrap->Resolve(result); } @@ -1482,8 +1488,11 @@ static void ReadDir(const FunctionCallbackInfo& args) { Local names = Array::New(isolate, name_v.data(), name_v.size()); if (with_types) { Local result = Array::New(isolate, 2); - result->Set(0, names); - result->Set(1, Array::New(isolate, type_v.data(), type_v.size())); + result->Set(env->context(), 0, names).FromJust(); + result->Set(env->context(), + 1, + Array::New(isolate, type_v.data(), + type_v.size())).FromJust(); args.GetReturnValue().Set(result); } else { args.GetReturnValue().Set(names); @@ -1667,7 +1676,7 @@ static void WriteBuffers(const FunctionCallbackInfo& args) { MaybeStackBuffer iovs(chunks->Length()); for (uint32_t i = 0; i < iovs.length(); i++) { - Local chunk = chunks->Get(i); + Local chunk = chunks->Get(env->context(), i).ToLocalChecked(); CHECK(Buffer::HasInstance(chunk)); iovs[i] = uv_buf_init(Buffer::Data(chunk), Buffer::Length(chunk)); } diff --git a/src/node_http2.cc b/src/node_http2.cc index 95f3f4a8f7c1d2..8ae58d5134e15d 100644 --- a/src/node_http2.cc +++ b/src/node_http2.cc @@ -3057,8 +3057,10 @@ void Initialize(Local target, #define V(name) \ NODE_DEFINE_CONSTANT(constants, name); \ - name_for_error_code->Set(static_cast(name), \ - FIXED_ONE_BYTE_STRING(isolate, #name)); + name_for_error_code->Set(env->context(), \ + static_cast(name), \ + FIXED_ONE_BYTE_STRING(isolate, \ + #name)).FromJust(); NODE_NGHTTP2_ERROR_CODES(V) #undef V diff --git a/src/node_http_parser.cc b/src/node_http_parser.cc index 482c7263ca719c..c9e057711d9253 100644 --- a/src/node_http_parser.cc +++ b/src/node_http_parser.cc @@ -265,7 +265,8 @@ class Parser : public AsyncWrap, public StreamListener { Local argv[A_MAX]; Local obj = object(); - Local cb = obj->Get(kOnHeadersComplete); + Local cb = obj->Get(env()->context(), + kOnHeadersComplete).ToLocalChecked(); if (!cb->IsFunction()) return 0; @@ -338,7 +339,7 @@ class Parser : public AsyncWrap, public StreamListener { EscapableHandleScope scope(env()->isolate()); Local obj = object(); - Local cb = obj->Get(kOnBody); + Local cb = obj->Get(env()->context(), kOnBody).ToLocalChecked(); if (!cb->IsFunction()) return 0; @@ -381,7 +382,8 @@ class Parser : public AsyncWrap, public StreamListener { Flush(); // Flush trailing HTTP headers. Local obj = object(); - Local cb = obj->Get(kOnMessageComplete); + Local cb = obj->Get(env()->context(), + kOnMessageComplete).ToLocalChecked(); if (!cb->IsFunction()) return 0; @@ -705,17 +707,23 @@ class Parser : public AsyncWrap, public StreamListener { Local e = Exception::Error(env()->parse_error_string()); Local obj = e->ToObject(env()->isolate()->GetCurrentContext()) .ToLocalChecked(); - obj->Set(env()->bytes_parsed_string(), nread_obj); + obj->Set(env()->context(), + env()->bytes_parsed_string(), + nread_obj).FromJust(); #ifdef NODE_EXPERIMENTAL_HTTP - obj->Set(env()->code_string(), - OneByteString(env()->isolate(), llhttp_errno_name(err))); - obj->Set(env()->reason_string(), - OneByteString(env()->isolate(), parser_.reason)); + obj->Set(env()->context(), + env()->code_string(), + OneByteString(env()->isolate(), + llhttp_errno_name(err))).FromJust(); + obj->Set(env()->context(), + env()->reason_string(), + OneByteString(env()->isolate(), parser_.reason)).FromJust(); #else /* !NODE_EXPERIMENTAL_HTTP */ - obj->Set(env()->code_string(), - OneByteString(env()->isolate(), http_errno_name(err))); + obj->Set(env()->context(), + env()->code_string(), + OneByteString(env()->isolate(), + http_errno_name(err))).FromJust(); #endif /* NODE_EXPERIMENTAL_HTTP */ - return scope.Escape(e); } @@ -750,7 +758,7 @@ class Parser : public AsyncWrap, public StreamListener { HandleScope scope(env()->isolate()); Local obj = object(); - Local cb = obj->Get(kOnHeaders); + Local cb = obj->Get(env()->context(), kOnHeaders).ToLocalChecked(); if (!cb->IsFunction()) return; @@ -902,10 +910,13 @@ void Initialize(Local target, Local methods = Array::New(env->isolate()); #define V(num, name, string) \ - methods->Set(num, FIXED_ONE_BYTE_STRING(env->isolate(), #string)); + methods->Set(env->context(), \ + num, FIXED_ONE_BYTE_STRING(env->isolate(), #string)).FromJust(); HTTP_METHOD_MAP(V) #undef V - target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "methods"), methods); + target->Set(env->context(), + FIXED_ONE_BYTE_STRING(env->isolate(), "methods"), + methods).FromJust(); t->Inherit(AsyncWrap::GetConstructorTemplate(env)); env->SetProtoMethod(t, "close", Parser::Close); @@ -919,8 +930,9 @@ void Initialize(Local target, env->SetProtoMethod(t, "unconsume", Parser::Unconsume); env->SetProtoMethod(t, "getCurrentBuffer", Parser::GetCurrentBuffer); - target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "HTTPParser"), - t->GetFunction(env->context()).ToLocalChecked()); + target->Set(env->context(), + FIXED_ONE_BYTE_STRING(env->isolate(), "HTTPParser"), + t->GetFunction(env->context()).ToLocalChecked()).FromJust(); } } // anonymous namespace diff --git a/src/node_os.cc b/src/node_os.cc index 723cf18b3efd27..5a2a7a4db05996 100644 --- a/src/node_os.cc +++ b/src/node_os.cc @@ -267,10 +267,11 @@ static void GetInterfaceAddresses(const FunctionCallbackInfo& args) { v8::NewStringType::kNormal).ToLocalChecked(); if (ret->Has(env->context(), name).FromJust()) { - ifarr = Local::Cast(ret->Get(name)); + ifarr = Local::Cast(ret->Get(env->context(), + name).ToLocalChecked()); } else { ifarr = Array::New(env->isolate()); - ret->Set(name, ifarr); + ret->Set(env->context(), name, ifarr).FromJust(); } snprintf(mac, @@ -297,22 +298,29 @@ static void GetInterfaceAddresses(const FunctionCallbackInfo& args) { } o = Object::New(env->isolate()); - o->Set(env->address_string(), OneByteString(env->isolate(), ip)); - o->Set(env->netmask_string(), OneByteString(env->isolate(), netmask)); - o->Set(env->family_string(), family); - o->Set(env->mac_string(), FIXED_ONE_BYTE_STRING(env->isolate(), mac)); + o->Set(env->context(), + env->address_string(), + OneByteString(env->isolate(), ip)).FromJust(); + o->Set(env->context(), + env->netmask_string(), + OneByteString(env->isolate(), netmask)).FromJust(); + o->Set(env->context(), + env->family_string(), family).FromJust(); + o->Set(env->context(), + env->mac_string(), + FIXED_ONE_BYTE_STRING(env->isolate(), mac)).FromJust(); if (interfaces[i].address.address4.sin_family == AF_INET6) { uint32_t scopeid = interfaces[i].address.address6.sin6_scope_id; - o->Set(env->scopeid_string(), - Integer::NewFromUnsigned(env->isolate(), scopeid)); + o->Set(env->context(), env->scopeid_string(), + Integer::NewFromUnsigned(env->isolate(), scopeid)).FromJust(); } const bool internal = interfaces[i].is_internal; - o->Set(env->internal_string(), - internal ? True(env->isolate()) : False(env->isolate())); + o->Set(env->context(), env->internal_string(), + internal ? True(env->isolate()) : False(env->isolate())).FromJust(); - ifarr->Set(ifarr->Length(), o); + ifarr->Set(env->context(), ifarr->Length(), o).FromJust(); } uv_free_interface_addresses(interfaces, count); @@ -397,11 +405,17 @@ static void GetUserInfo(const FunctionCallbackInfo& args) { Local entry = Object::New(env->isolate()); - entry->Set(env->uid_string(), uid); - entry->Set(env->gid_string(), gid); - entry->Set(env->username_string(), username.ToLocalChecked()); - entry->Set(env->homedir_string(), homedir.ToLocalChecked()); - entry->Set(env->shell_string(), shell.ToLocalChecked()); + entry->Set(env->context(), env->uid_string(), uid).FromJust(); + entry->Set(env->context(), env->gid_string(), gid).FromJust(); + entry->Set(env->context(), + env->username_string(), + username.ToLocalChecked()).FromJust(); + entry->Set(env->context(), + env->homedir_string(), + homedir.ToLocalChecked()).FromJust(); + entry->Set(env->context(), + env->shell_string(), + shell.ToLocalChecked()).FromJust(); args.GetReturnValue().Set(entry); } @@ -464,8 +478,9 @@ void Initialize(Local target, env->SetMethod(target, "getUserInfo", GetUserInfo); env->SetMethod(target, "setPriority", SetPriority); env->SetMethod(target, "getPriority", GetPriority); - target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "isBigEndian"), - Boolean::New(env->isolate(), IsBigEndian())); + target->Set(env->context(), + FIXED_ONE_BYTE_STRING(env->isolate(), "isBigEndian"), + Boolean::New(env->isolate(), IsBigEndian())).FromJust(); } } // namespace os diff --git a/src/node_process.cc b/src/node_process.cc index 600f85b8044671..6c12dcc02b2cd0 100644 --- a/src/node_process.cc +++ b/src/node_process.cc @@ -488,7 +488,8 @@ void GetGroups(const FunctionCallbackInfo& args) { gid_t egid = getegid(); for (int i = 0; i < ngroups; i++) { - groups_list->Set(i, Integer::New(env->isolate(), groups[i])); + groups_list->Set(env->context(), + i, Integer::New(env->isolate(), groups[i])).FromJust(); if (groups[i] == egid) seen_egid = true; } @@ -496,7 +497,9 @@ void GetGroups(const FunctionCallbackInfo& args) { delete[] groups; if (seen_egid == false) - groups_list->Set(ngroups, Integer::New(env->isolate(), egid)); + groups_list->Set(env->context(), + ngroups, + Integer::New(env->isolate(), egid)).FromJust(); args.GetReturnValue().Set(groups_list); } @@ -513,7 +516,9 @@ void SetGroups(const FunctionCallbackInfo& args) { gid_t* groups = new gid_t[size]; for (size_t i = 0; i < size; i++) { - gid_t gid = gid_by_name(env->isolate(), groups_list->Get(i)); + gid_t gid = gid_by_name(env->isolate(), + groups_list->Get(env->context(), + i).ToLocalChecked()); if (gid == gid_not_found) { delete[] groups; diff --git a/src/node_stat_watcher.cc b/src/node_stat_watcher.cc index ca0927af662200..2ad5ea2ffafd79 100644 --- a/src/node_stat_watcher.cc +++ b/src/node_stat_watcher.cc @@ -54,8 +54,8 @@ void StatWatcher::Initialize(Environment* env, Local target) { env->SetProtoMethod(t, "start", StatWatcher::Start); - target->Set(statWatcherString, - t->GetFunction(env->context()).ToLocalChecked()); + target->Set(env->context(), statWatcherString, + t->GetFunction(env->context()).ToLocalChecked()).FromJust(); } diff --git a/src/node_trace_events.cc b/src/node_trace_events.cc index 6530bdb04c44e8..f51db62ba38ac4 100644 --- a/src/node_trace_events.cc +++ b/src/node_trace_events.cc @@ -112,8 +112,10 @@ void Initialize(Local target, env->SetProtoMethod(category_set, "enable", NodeCategorySet::Enable); env->SetProtoMethod(category_set, "disable", NodeCategorySet::Disable); - target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "CategorySet"), - category_set->GetFunction(env->context()).ToLocalChecked()); + target->Set(env->context(), + FIXED_ONE_BYTE_STRING(env->isolate(), "CategorySet"), + category_set->GetFunction(env->context()).ToLocalChecked()) + .FromJust(); Local isTraceCategoryEnabled = FIXED_ONE_BYTE_STRING(env->isolate(), "isTraceCategoryEnabled"); diff --git a/src/node_util.cc b/src/node_util.cc index ac39be407dd47f..62af7a1115784e 100644 --- a/src/node_util.cc +++ b/src/node_util.cc @@ -57,6 +57,7 @@ static void GetOwnNonIndexProperties( } static void GetPromiseDetails(const FunctionCallbackInfo& args) { + Environment* env = Environment::GetCurrent(args); // Return undefined if it's not a Promise. if (!args[0]->IsPromise()) return; @@ -67,14 +68,15 @@ static void GetPromiseDetails(const FunctionCallbackInfo& args) { Local ret = Array::New(isolate, 2); int state = promise->State(); - ret->Set(0, Integer::New(isolate, state)); + ret->Set(env->context(), 0, Integer::New(isolate, state)).FromJust(); if (state != Promise::PromiseState::kPending) - ret->Set(1, promise->Result()); + ret->Set(env->context(), 1, promise->Result()).FromJust(); args.GetReturnValue().Set(ret); } static void GetProxyDetails(const FunctionCallbackInfo& args) { + Environment* env = Environment::GetCurrent(args); // Return undefined if it's not a proxy. if (!args[0]->IsProxy()) return; @@ -82,8 +84,8 @@ static void GetProxyDetails(const FunctionCallbackInfo& args) { Local proxy = args[0].As(); Local ret = Array::New(args.GetIsolate(), 2); - ret->Set(0, proxy->GetTarget()); - ret->Set(1, proxy->GetHandler()); + ret->Set(env->context(), 0, proxy->GetTarget()).FromJust(); + ret->Set(env->context(), 1, proxy->GetHandler()).FromJust(); args.GetReturnValue().Set(ret); } diff --git a/src/node_v8.cc b/src/node_v8.cc index 2a661d95497a85..ab453134fabfc0 100644 --- a/src/node_v8.cc +++ b/src/node_v8.cc @@ -134,23 +134,27 @@ void Initialize(Local target, const size_t heap_statistics_buffer_byte_length = sizeof(*env->heap_statistics_buffer()) * kHeapStatisticsPropertiesCount; - target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), + target->Set(env->context(), + FIXED_ONE_BYTE_STRING(env->isolate(), "heapStatisticsArrayBuffer"), ArrayBuffer::New(env->isolate(), env->heap_statistics_buffer(), - heap_statistics_buffer_byte_length)); + heap_statistics_buffer_byte_length)).FromJust(); #define V(i, _, name) \ - target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), #name), \ - Uint32::NewFromUnsigned(env->isolate(), i)); + target->Set(env->context(), \ + FIXED_ONE_BYTE_STRING(env->isolate(), #name), \ + Uint32::NewFromUnsigned(env->isolate(), i)).FromJust(); HEAP_STATISTICS_PROPERTIES(V) #undef V - target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), + target->Set(env->context(), + FIXED_ONE_BYTE_STRING(env->isolate(), "kHeapSpaceStatisticsPropertiesCount"), Uint32::NewFromUnsigned(env->isolate(), - kHeapSpaceStatisticsPropertiesCount)); + kHeapSpaceStatisticsPropertiesCount)) + .FromJust(); size_t number_of_heap_spaces = env->isolate()->NumberOfHeapSpaces(); @@ -165,10 +169,11 @@ void Initialize(Local target, s.space_name(), NewStringType::kNormal) .ToLocalChecked(); - heap_spaces->Set(i, heap_space_name); + heap_spaces->Set(env->context(), i, heap_space_name).FromJust(); } - target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "kHeapSpaces"), - heap_spaces); + target->Set(env->context(), + FIXED_ONE_BYTE_STRING(env->isolate(), "kHeapSpaces"), + heap_spaces).FromJust(); env->SetMethod(target, "updateHeapSpaceStatisticsArrayBuffer", @@ -182,15 +187,18 @@ void Initialize(Local target, kHeapSpaceStatisticsPropertiesCount * number_of_heap_spaces; - target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), + target->Set(env->context(), + FIXED_ONE_BYTE_STRING(env->isolate(), "heapSpaceStatisticsArrayBuffer"), ArrayBuffer::New(env->isolate(), env->heap_space_statistics_buffer(), - heap_space_statistics_buffer_byte_length)); + heap_space_statistics_buffer_byte_length)) + .FromJust(); #define V(i, _, name) \ - target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), #name), \ - Uint32::NewFromUnsigned(env->isolate(), i)); + target->Set(env->context(), \ + FIXED_ONE_BYTE_STRING(env->isolate(), #name), \ + Uint32::NewFromUnsigned(env->isolate(), i)).FromJust(); HEAP_SPACE_STATISTICS_PROPERTIES(V) #undef V diff --git a/src/node_worker.cc b/src/node_worker.cc index debec3078c55d9..38a92b34794dd2 100644 --- a/src/node_worker.cc +++ b/src/node_worker.cc @@ -492,7 +492,9 @@ void InitWorker(Local target, Local workerString = FIXED_ONE_BYTE_STRING(env->isolate(), "Worker"); w->SetClassName(workerString); - target->Set(workerString, w->GetFunction(env->context()).ToLocalChecked()); + target->Set(env->context(), + workerString, + w->GetFunction(env->context()).ToLocalChecked()).FromJust(); } env->SetMethod(target, "getEnvMessagePort", GetEnvMessagePort); diff --git a/src/node_zlib.cc b/src/node_zlib.cc index 8b257cf0d47934..6b050fcb40289a 100644 --- a/src/node_zlib.cc +++ b/src/node_zlib.cc @@ -896,10 +896,13 @@ void Initialize(Local target, Local zlibString = FIXED_ONE_BYTE_STRING(env->isolate(), "Zlib"); z->SetClassName(zlibString); - target->Set(zlibString, z->GetFunction(env->context()).ToLocalChecked()); + target->Set(env->context(), + zlibString, + z->GetFunction(env->context()).ToLocalChecked()).FromJust(); - target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "ZLIB_VERSION"), - FIXED_ONE_BYTE_STRING(env->isolate(), ZLIB_VERSION)); + target->Set(env->context(), + FIXED_ONE_BYTE_STRING(env->isolate(), "ZLIB_VERSION"), + FIXED_ONE_BYTE_STRING(env->isolate(), ZLIB_VERSION)).FromJust(); } } // anonymous namespace diff --git a/src/pipe_wrap.cc b/src/pipe_wrap.cc index 66b9677cc92fec..50e80b45a42f5e 100644 --- a/src/pipe_wrap.cc +++ b/src/pipe_wrap.cc @@ -90,7 +90,9 @@ void PipeWrap::Initialize(Local target, env->SetProtoMethod(t, "fchmod", Fchmod); - target->Set(pipeString, t->GetFunction(env->context()).ToLocalChecked()); + target->Set(env->context(), + pipeString, + t->GetFunction(env->context()).ToLocalChecked()).FromJust(); env->set_pipe_constructor_template(t); // Create FunctionTemplate for PipeConnectWrap. @@ -99,7 +101,9 @@ void PipeWrap::Initialize(Local target, Local wrapString = FIXED_ONE_BYTE_STRING(env->isolate(), "PipeConnectWrap"); cwt->SetClassName(wrapString); - target->Set(wrapString, cwt->GetFunction(env->context()).ToLocalChecked()); + target->Set(env->context(), + wrapString, + cwt->GetFunction(env->context()).ToLocalChecked()).FromJust(); // Define constants Local constants = Object::New(env->isolate()); diff --git a/src/process_wrap.cc b/src/process_wrap.cc index edf79177d32502..79d661c83fc023 100644 --- a/src/process_wrap.cc +++ b/src/process_wrap.cc @@ -62,8 +62,9 @@ class ProcessWrap : public HandleWrap { env->SetProtoMethod(constructor, "spawn", Spawn); env->SetProtoMethod(constructor, "kill", Kill); - target->Set(processString, - constructor->GetFunction(context).ToLocalChecked()); + target->Set(env->context(), + processString, + constructor->GetFunction(context).ToLocalChecked()).FromJust(); } SET_NO_MEMORY_INFO() diff --git a/src/signal_wrap.cc b/src/signal_wrap.cc index afdf140d8b07c3..613ee0926f5db1 100644 --- a/src/signal_wrap.cc +++ b/src/signal_wrap.cc @@ -55,8 +55,9 @@ class SignalWrap : public HandleWrap { env->SetProtoMethod(constructor, "start", Start); env->SetProtoMethod(constructor, "stop", Stop); - target->Set(signalString, - constructor->GetFunction(env->context()).ToLocalChecked()); + target->Set(env->context(), signalString, + constructor->GetFunction(env->context()).ToLocalChecked()) + .FromJust(); } SET_NO_MEMORY_INFO() diff --git a/src/stream_base-inl.h b/src/stream_base-inl.h index 0209281f942e1c..1d6ec17b802f3b 100644 --- a/src/stream_base-inl.h +++ b/src/stream_base-inl.h @@ -179,7 +179,9 @@ inline int StreamBase::Shutdown(v8::Local req_wrap_obj) { const char* msg = Error(); if (msg != nullptr) { - req_wrap_obj->Set(env->error_string(), OneByteString(env->isolate(), msg)); + req_wrap_obj->Set( + env->context(), + env->error_string(), OneByteString(env->isolate(), msg)).FromJust(); ClearError(); } @@ -228,7 +230,9 @@ inline StreamWriteResult StreamBase::Write( const char* msg = Error(); if (msg != nullptr) { - req_wrap_obj->Set(env->error_string(), OneByteString(env->isolate(), msg)); + req_wrap_obj->Set(env->context(), + env->error_string(), + OneByteString(env->isolate(), msg)).FromJust(); ClearError(); } @@ -434,8 +438,10 @@ inline void StreamReq::Done(int status, const char* error_str) { AsyncWrap* async_wrap = GetAsyncWrap(); Environment* env = async_wrap->env(); if (error_str != nullptr) { - async_wrap->object()->Set(env->error_string(), - OneByteString(env->isolate(), error_str)); + async_wrap->object()->Set(env->context(), + env->error_string(), + OneByteString(env->isolate(), error_str)) + .FromJust(); } OnDone(status); diff --git a/src/stream_base.cc b/src/stream_base.cc index 670b3cbd5091d1..26efa46ba02f83 100644 --- a/src/stream_base.cc +++ b/src/stream_base.cc @@ -83,7 +83,7 @@ int StreamBase::Writev(const FunctionCallbackInfo& args) { if (!all_buffers) { // Determine storage size first for (size_t i = 0; i < count; i++) { - Local chunk = chunks->Get(i * 2); + Local chunk = chunks->Get(env->context(), i * 2).ToLocalChecked(); if (Buffer::HasInstance(chunk)) continue; @@ -92,7 +92,7 @@ int StreamBase::Writev(const FunctionCallbackInfo& args) { // String chunk Local string = chunk->ToString(env->context()).ToLocalChecked(); enum encoding encoding = ParseEncoding(env->isolate(), - chunks->Get(i * 2 + 1)); + chunks->Get(env->context(), i * 2 + 1).ToLocalChecked()); size_t chunk_size; if (encoding == UTF8 && string->Length() > 65535 && !StringBytes::Size(env->isolate(), string, encoding).To(&chunk_size)) @@ -107,7 +107,7 @@ int StreamBase::Writev(const FunctionCallbackInfo& args) { return UV_ENOBUFS; } else { for (size_t i = 0; i < count; i++) { - Local chunk = chunks->Get(i); + Local chunk = chunks->Get(env->context(), i).ToLocalChecked(); bufs[i].base = Buffer::Data(chunk); bufs[i].len = Buffer::Length(chunk); } @@ -120,7 +120,7 @@ int StreamBase::Writev(const FunctionCallbackInfo& args) { offset = 0; if (!all_buffers) { for (size_t i = 0; i < count; i++) { - Local chunk = chunks->Get(i * 2); + Local chunk = chunks->Get(env->context(), i * 2).ToLocalChecked(); // Write buffer if (Buffer::HasInstance(chunk)) { @@ -136,7 +136,7 @@ int StreamBase::Writev(const FunctionCallbackInfo& args) { Local string = chunk->ToString(env->context()).ToLocalChecked(); enum encoding encoding = ParseEncoding(env->isolate(), - chunks->Get(i * 2 + 1)); + chunks->Get(env->context(), i * 2 + 1).ToLocalChecked()); str_size = StringBytes::Write(env->isolate(), str_storage, str_size, @@ -270,7 +270,9 @@ int StreamBase::WriteString(const FunctionCallbackInfo& args) { send_handle = reinterpret_cast(wrap->GetHandle()); // Reference LibuvStreamWrap instance to prevent it from being garbage // collected before `AfterWrite` is called. - req_wrap_obj->Set(env->handle_string(), send_handle_obj); + req_wrap_obj->Set(env->context(), + env->handle_string(), + send_handle_obj).FromJust(); } StreamWriteResult res = Write(&buf, 1, send_handle, req_wrap_obj); diff --git a/src/stream_wrap.cc b/src/stream_wrap.cc index dac5ebdeb32211..c7d5e2f23ff900 100644 --- a/src/stream_wrap.cc +++ b/src/stream_wrap.cc @@ -67,7 +67,9 @@ void LibuvStreamWrap::Initialize(Local target, FIXED_ONE_BYTE_STRING(env->isolate(), "ShutdownWrap"); sw->SetClassName(wrapString); sw->Inherit(AsyncWrap::GetConstructorTemplate(env)); - target->Set(wrapString, sw->GetFunction(env->context()).ToLocalChecked()); + target->Set(env->context(), + wrapString, + sw->GetFunction(env->context()).ToLocalChecked()).FromJust(); env->set_shutdown_wrap_template(sw->InstanceTemplate()); Local ww = @@ -77,8 +79,9 @@ void LibuvStreamWrap::Initialize(Local target, FIXED_ONE_BYTE_STRING(env->isolate(), "WriteWrap"); ww->SetClassName(writeWrapString); ww->Inherit(AsyncWrap::GetConstructorTemplate(env)); - target->Set(writeWrapString, - ww->GetFunction(env->context()).ToLocalChecked()); + target->Set(env->context(), + writeWrapString, + ww->GetFunction(env->context()).ToLocalChecked()).FromJust(); env->set_write_wrap_template(ww->InstanceTemplate()); NODE_DEFINE_CONSTANT(target, kReadBytesOrError); diff --git a/src/tcp_wrap.cc b/src/tcp_wrap.cc index d462eff15d391c..e1316b42cd206b 100644 --- a/src/tcp_wrap.cc +++ b/src/tcp_wrap.cc @@ -107,7 +107,9 @@ void TCPWrap::Initialize(Local target, env->SetProtoMethod(t, "setSimultaneousAccepts", SetSimultaneousAccepts); #endif - target->Set(tcpString, t->GetFunction(env->context()).ToLocalChecked()); + target->Set(env->context(), + tcpString, + t->GetFunction(env->context()).ToLocalChecked()).FromJust(); env->set_tcp_constructor_template(t); // Create FunctionTemplate for TCPConnectWrap. @@ -117,7 +119,9 @@ void TCPWrap::Initialize(Local target, Local wrapString = FIXED_ONE_BYTE_STRING(env->isolate(), "TCPConnectWrap"); cwt->SetClassName(wrapString); - target->Set(wrapString, cwt->GetFunction(env->context()).ToLocalChecked()); + target->Set(env->context(), + wrapString, + cwt->GetFunction(env->context()).ToLocalChecked()).FromJust(); // Define constants Local constants = Object::New(env->isolate()); @@ -349,22 +353,36 @@ Local AddressToJS(Environment* env, a6 = reinterpret_cast(addr); uv_inet_ntop(AF_INET6, &a6->sin6_addr, ip, sizeof ip); port = ntohs(a6->sin6_port); - info->Set(env->address_string(), OneByteString(env->isolate(), ip)); - info->Set(env->family_string(), env->ipv6_string()); - info->Set(env->port_string(), Integer::New(env->isolate(), port)); + info->Set(env->context(), + env->address_string(), + OneByteString(env->isolate(), ip)).FromJust(); + info->Set(env->context(), + env->family_string(), + env->ipv6_string()).FromJust(); + info->Set(env->context(), + env->port_string(), + Integer::New(env->isolate(), port)).FromJust(); break; case AF_INET: a4 = reinterpret_cast(addr); uv_inet_ntop(AF_INET, &a4->sin_addr, ip, sizeof ip); port = ntohs(a4->sin_port); - info->Set(env->address_string(), OneByteString(env->isolate(), ip)); - info->Set(env->family_string(), env->ipv4_string()); - info->Set(env->port_string(), Integer::New(env->isolate(), port)); + info->Set(env->context(), + env->address_string(), + OneByteString(env->isolate(), ip)).FromJust(); + info->Set(env->context(), + env->family_string(), + env->ipv4_string()).FromJust(); + info->Set(env->context(), + env->port_string(), + Integer::New(env->isolate(), port)).FromJust(); break; default: - info->Set(env->address_string(), String::Empty(env->isolate())); + info->Set(env->context(), + env->address_string(), + String::Empty(env->isolate())).FromJust(); } return scope.Escape(info); diff --git a/src/tls_wrap.cc b/src/tls_wrap.cc index 1d982db28e2558..52d4e7381318bc 100644 --- a/src/tls_wrap.cc +++ b/src/tls_wrap.cc @@ -909,7 +909,9 @@ void TLSWrap::Initialize(Local target, env->set_tls_wrap_constructor_function( t->GetFunction(env->context()).ToLocalChecked()); - target->Set(tlsWrapString, t->GetFunction(env->context()).ToLocalChecked()); + target->Set(env->context(), + tlsWrapString, + t->GetFunction(env->context()).ToLocalChecked()).FromJust(); } } // namespace node diff --git a/src/tty_wrap.cc b/src/tty_wrap.cc index c099b14ec4d7a1..2523f57b2d4aab 100644 --- a/src/tty_wrap.cc +++ b/src/tty_wrap.cc @@ -59,7 +59,9 @@ void TTYWrap::Initialize(Local target, env->SetMethodNoSideEffect(target, "isTTY", IsTTY); env->SetMethodNoSideEffect(target, "guessHandleType", GuessHandleType); - target->Set(ttyString, t->GetFunction(env->context()).ToLocalChecked()); + target->Set(env->context(), + ttyString, + t->GetFunction(env->context()).ToLocalChecked()).FromJust(); env->set_tty_constructor_template(t); } @@ -112,8 +114,8 @@ void TTYWrap::GetWindowSize(const FunctionCallbackInfo& args) { if (err == 0) { Local a = args[0].As(); - a->Set(0, Integer::New(env->isolate(), width)); - a->Set(1, Integer::New(env->isolate(), height)); + a->Set(env->context(), 0, Integer::New(env->isolate(), width)).FromJust(); + a->Set(env->context(), 1, Integer::New(env->isolate(), height)).FromJust(); } args.GetReturnValue().Set(err); diff --git a/src/udp_wrap.cc b/src/udp_wrap.cc index aa29f6973e35e0..4c7072f2a2b981 100644 --- a/src/udp_wrap.cc +++ b/src/udp_wrap.cc @@ -133,7 +133,9 @@ void UDPWrap::Initialize(Local target, t->Inherit(HandleWrap::GetConstructorTemplate(env)); - target->Set(udpString, t->GetFunction(env->context()).ToLocalChecked()); + target->Set(env->context(), + udpString, + t->GetFunction(env->context()).ToLocalChecked()).FromJust(); env->set_udp_constructor_function( t->GetFunction(env->context()).ToLocalChecked()); @@ -144,8 +146,9 @@ void UDPWrap::Initialize(Local target, Local sendWrapString = FIXED_ONE_BYTE_STRING(env->isolate(), "SendWrap"); swt->SetClassName(sendWrapString); - target->Set(sendWrapString, - swt->GetFunction(env->context()).ToLocalChecked()); + target->Set(env->context(), + sendWrapString, + swt->GetFunction(env->context()).ToLocalChecked()).FromJust(); } @@ -373,7 +376,7 @@ void UDPWrap::DoSend(const FunctionCallbackInfo& args, int family) { // construct uv_buf_t array for (size_t i = 0; i < count; i++) { - Local chunk = chunks->Get(i); + Local chunk = chunks->Get(env->context(), i).ToLocalChecked(); size_t length = Buffer::Length(chunk); diff --git a/src/uv.cc b/src/uv.cc index 354acee4c01fc6..5628719c784653 100644 --- a/src/uv.cc +++ b/src/uv.cc @@ -63,10 +63,11 @@ void Initialize(Local target, Local context) { Environment* env = Environment::GetCurrent(context); Isolate* isolate = env->isolate(); - target->Set(FIXED_ONE_BYTE_STRING(isolate, "errname"), + target->Set(env->context(), + FIXED_ONE_BYTE_STRING(isolate, "errname"), env->NewFunctionTemplate(ErrName) ->GetFunction(env->context()) - .ToLocalChecked()); + .ToLocalChecked()).FromJust(); #define V(name, _) NODE_DEFINE_CONSTANT(target, UV_##name); UV_ERRNO_MAP(V) @@ -76,8 +77,8 @@ void Initialize(Local target, #define V(name, msg) do { \ Local arr = Array::New(isolate, 2); \ - arr->Set(0, OneByteString(isolate, #name)); \ - arr->Set(1, OneByteString(isolate, msg)); \ + arr->Set(env->context(), 0, OneByteString(isolate, #name)).FromJust(); \ + arr->Set(env->context(), 1, OneByteString(isolate, msg)).FromJust(); \ err_map->Set(context, \ Integer::New(isolate, UV_##name), \ arr).ToLocalChecked(); \