diff --git a/src/node_util.cc b/src/node_util.cc index 601180905d87c9..d72216fa2add62 100644 --- a/src/node_util.cc +++ b/src/node_util.cc @@ -53,8 +53,8 @@ CHAR_TEST(16, IsUnicodeSurrogateTrail, (ch & 0x400) != 0) static void GetOwnNonIndexProperties( const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args); - Local context = env->context(); + Isolate* isolate = args.GetIsolate(); + Local context = isolate->GetCurrentContext(); CHECK(args[0]->IsObject()); CHECK(args[1]->IsUint32()); @@ -168,7 +168,7 @@ static void PreviewEntries(const FunctionCallbackInfo& args) { if (!args[0]->IsObject()) return; - Environment* env = Environment::GetCurrent(args); + Isolate* isolate = args.GetIsolate(); bool is_key_value; Local entries; if (!args[0].As()->PreviewEntries(&is_key_value).ToLocal(&entries)) @@ -177,12 +177,8 @@ static void PreviewEntries(const FunctionCallbackInfo& args) { if (args.Length() == 1) return args.GetReturnValue().Set(entries); - Local ret[] = { - entries, - Boolean::New(env->isolate(), is_key_value) - }; - return args.GetReturnValue().Set( - Array::New(env->isolate(), ret, arraysize(ret))); + Local ret[] = {entries, Boolean::New(isolate, is_key_value)}; + return args.GetReturnValue().Set(Array::New(isolate, ret, arraysize(ret))); } static void Sleep(const FunctionCallbackInfo& args) { @@ -222,9 +218,10 @@ static uint32_t GetUVHandleTypeCode(const uv_handle_type type) { } static void GuessHandleType(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args); + Isolate* isolate = args.GetIsolate(); + Local context = isolate->GetCurrentContext(); int fd; - if (!args[0]->Int32Value(env->context()).To(&fd)) return; + if (!args[0]->Int32Value(context).To(&fd)) return; CHECK_GE(fd, 0); uv_handle_type t = uv_guess_handle(fd); @@ -239,10 +236,12 @@ static uint32_t FastGuessHandleType(Local receiver, const uint32_t fd) { CFunction fast_guess_handle_type_(CFunction::Make(FastGuessHandleType)); static void ParseEnv(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args); + Isolate* isolate = args.GetIsolate(); + Local context = isolate->GetCurrentContext(); + Environment* env = Environment::GetCurrent(context); CHECK_EQ(args.Length(), 1); // content CHECK(args[0]->IsString()); - Utf8Value content(env->isolate(), args[0]); + Utf8Value content(isolate, args[0]); Dotenv dotenv{}; dotenv.ParseContent(content.ToStringView()); Local obj; @@ -252,8 +251,9 @@ static void ParseEnv(const FunctionCallbackInfo& args) { } static void GetCallSites(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args); - Isolate* isolate = env->isolate(); + Isolate* isolate = args.GetIsolate(); + Local context = isolate->GetCurrentContext(); + Environment* env = Environment::GetCurrent(context); CHECK_EQ(args.Length(), 1); CHECK(args[0]->IsNumber()); @@ -306,8 +306,7 @@ static void GetCallSites(const FunctionCallbackInfo& args) { }; Local callsite; - if (!NewDictionaryInstanceNullProto( - env->context(), callsite_template, values) + if (!NewDictionaryInstanceNullProto(context, callsite_template, values) .ToLocal(&callsite)) { return; } diff --git a/src/uv.cc b/src/uv.cc index d4fadfc24e9a17..a005fd05c8f49c 100644 --- a/src/uv.cc +++ b/src/uv.cc @@ -68,7 +68,9 @@ void GetErrMessage(const FunctionCallbackInfo& args) { } void ErrName(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args); + Isolate* isolate = args.GetIsolate(); + Local context = isolate->GetCurrentContext(); + Environment* env = Environment::GetCurrent(context); if (env->options()->pending_deprecation && env->EmitErrNameWarning()) { if (ProcessEmitDeprecationWarning( env, @@ -82,13 +84,12 @@ void ErrName(const FunctionCallbackInfo& args) { CHECK_LT(err, 0); char name[50]; uv_err_name_r(err, name, sizeof(name)); - args.GetReturnValue().Set(OneByteString(env->isolate(), name)); + args.GetReturnValue().Set(OneByteString(isolate, name)); } void GetErrMap(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args); - Isolate* isolate = env->isolate(); - Local context = env->context(); + Isolate* isolate = args.GetIsolate(); + Local context = isolate->GetCurrentContext(); // This can't return a SafeMap, because the uv binding can be referenced // by user code by using `process.binding('uv').getErrorMap()`: