diff --git a/src/api/environment.cc b/src/api/environment.cc index fdc7da857f3714..53862f399b972d 100644 --- a/src/api/environment.cc +++ b/src/api/environment.cc @@ -636,7 +636,7 @@ std::unique_ptr MultiIsolatePlatform::Create( MaybeLocal GetPerContextExports(Local context, IsolateData* isolate_data) { - Isolate* isolate = context->GetIsolate(); + Isolate* isolate = Isolate::GetCurrent(); EscapableHandleScope handle_scope(isolate); Local global = context->Global(); @@ -682,7 +682,7 @@ void ProtoThrower(const FunctionCallbackInfo& info) { // This runs at runtime, regardless of whether the context // is created from a snapshot. Maybe InitializeContextRuntime(Local context) { - Isolate* isolate = context->GetIsolate(); + Isolate* isolate = Isolate::GetCurrent(); HandleScope handle_scope(isolate); // When `IsCodeGenerationFromStringsAllowed` is true, V8 takes the fast path @@ -761,7 +761,7 @@ Maybe InitializeContextRuntime(Local context) { } Maybe InitializeBaseContextForSnapshot(Local context) { - Isolate* isolate = context->GetIsolate(); + Isolate* isolate = Isolate::GetCurrent(); HandleScope handle_scope(isolate); // Delete `Intl.v8BreakIterator` @@ -786,7 +786,7 @@ Maybe InitializeBaseContextForSnapshot(Local context) { } Maybe InitializeMainContextForSnapshot(Local context) { - Isolate* isolate = context->GetIsolate(); + Isolate* isolate = Isolate::GetCurrent(); HandleScope handle_scope(isolate); // Initialize the default values. @@ -804,7 +804,7 @@ Maybe InitializeMainContextForSnapshot(Local context) { MaybeLocal InitializePrivateSymbols(Local context, IsolateData* isolate_data) { CHECK(isolate_data); - Isolate* isolate = context->GetIsolate(); + Isolate* isolate = Isolate::GetCurrent(); EscapableHandleScope scope(isolate); Context::Scope context_scope(context); @@ -828,7 +828,7 @@ MaybeLocal InitializePrivateSymbols(Local context, MaybeLocal InitializePerIsolateSymbols(Local context, IsolateData* isolate_data) { CHECK(isolate_data); - Isolate* isolate = context->GetIsolate(); + Isolate* isolate = Isolate::GetCurrent(); EscapableHandleScope scope(isolate); Context::Scope context_scope(context); @@ -854,7 +854,7 @@ MaybeLocal InitializePerIsolateSymbols(Local context, Maybe InitializePrimordials(Local context, IsolateData* isolate_data) { // Run per-context JS files. - Isolate* isolate = context->GetIsolate(); + Isolate* isolate = Isolate::GetCurrent(); Context::Scope context_scope(context); Local exports; diff --git a/src/crypto/crypto_context.cc b/src/crypto/crypto_context.cc index f59603891f289e..fe97d55e6c077b 100644 --- a/src/crypto/crypto_context.cc +++ b/src/crypto/crypto_context.cc @@ -948,7 +948,7 @@ bool ArrayOfStringsToX509s(Local context, Local cert_array, std::vector* certs) { ClearErrorOnReturn clear_error_on_return; - Isolate* isolate = context->GetIsolate(); + Isolate* isolate = Isolate::GetCurrent(); Environment* env = Environment::GetCurrent(context); uint32_t array_length = cert_array->Length(); diff --git a/src/crypto/crypto_x509.cc b/src/crypto/crypto_x509.cc index 7d46e09be3e2c0..2e791a229165ce 100644 --- a/src/crypto/crypto_x509.cc +++ b/src/crypto/crypto_x509.cc @@ -105,7 +105,7 @@ MaybeLocal ToV8Value(Local context, BIOPointer&& bio) { return {}; BUF_MEM* mem = bio; Local ret; - if (!String::NewFromUtf8(context->GetIsolate(), + if (!String::NewFromUtf8(Isolate::GetCurrent(), mem->data, NewStringType::kNormal, mem->length) @@ -119,7 +119,7 @@ MaybeLocal ToV8Value(Local context, const BIOPointer& bio) { return {}; BUF_MEM* mem = bio; Local ret; - if (!String::NewFromUtf8(context->GetIsolate(), + if (!String::NewFromUtf8(Isolate::GetCurrent(), mem->data, NewStringType::kNormal, mem->length) diff --git a/src/encoding_binding.cc b/src/encoding_binding.cc index 69a34500b4590a..e8a0adc07da29a 100644 --- a/src/encoding_binding.cc +++ b/src/encoding_binding.cc @@ -76,7 +76,7 @@ void BindingData::Deserialize(Local context, int index, InternalFieldInfoBase* info) { DCHECK_IS_SNAPSHOT_SLOT(index); - HandleScope scope(context->GetIsolate()); + HandleScope scope(Isolate::GetCurrent()); Realm* realm = Realm::GetCurrent(context); // Recreate the buffer in the constructor. InternalFieldInfo* casted_info = static_cast(info); diff --git a/src/env.cc b/src/env.cc index a8115bdb5b43d8..837f8e1ce0b98a 100644 --- a/src/env.cc +++ b/src/env.cc @@ -1750,10 +1750,10 @@ void AsyncHooks::Deserialize(Local context) { context->GetDataFromSnapshotOnce( info_->js_execution_async_resources).ToLocalChecked(); } else { - js_execution_async_resources = Array::New(context->GetIsolate()); + js_execution_async_resources = Array::New(Isolate::GetCurrent()); } js_execution_async_resources_.Reset( - context->GetIsolate(), js_execution_async_resources); + Isolate::GetCurrent(), js_execution_async_resources); // The native_execution_async_resources_ field requires v8::Local<> instances // for async calls whose resources were on the stack as JS objects when they @@ -1793,7 +1793,7 @@ AsyncHooks::SerializeInfo AsyncHooks::Serialize(Local context, info.async_id_fields = async_id_fields_.Serialize(context, creator); if (!js_execution_async_resources_.IsEmpty()) { info.js_execution_async_resources = creator->AddData( - context, js_execution_async_resources_.Get(context->GetIsolate())); + context, js_execution_async_resources_.Get(Isolate::GetCurrent())); CHECK_NE(info.js_execution_async_resources, 0); } else { info.js_execution_async_resources = 0; diff --git a/src/inspector/network_agent.cc b/src/inspector/network_agent.cc index d136b72e598d07..649008aafc8d68 100644 --- a/src/inspector/network_agent.cc +++ b/src/inspector/network_agent.cc @@ -29,31 +29,31 @@ using v8::Value; Maybe ObjectGetProtocolString(v8::Local context, Local object, Local property) { - HandleScope handle_scope(context->GetIsolate()); + HandleScope handle_scope(v8::Isolate::GetCurrent()); Local value; if (!object->Get(context, property).ToLocal(&value) || !value->IsString()) { return Nothing(); } Local str = value.As(); - return Just(ToProtocolString(context->GetIsolate(), str)); + return Just(ToProtocolString(v8::Isolate::GetCurrent(), str)); } // Get a protocol string property from the object. Maybe ObjectGetProtocolString(v8::Local context, Local object, const char* property) { - HandleScope handle_scope(context->GetIsolate()); + HandleScope handle_scope(v8::Isolate::GetCurrent()); return ObjectGetProtocolString( - context, object, OneByteString(context->GetIsolate(), property)); + context, object, OneByteString(v8::Isolate::GetCurrent(), property)); } // Get a protocol double property from the object. Maybe ObjectGetDouble(v8::Local context, Local object, const char* property) { - HandleScope handle_scope(context->GetIsolate()); + HandleScope handle_scope(v8::Isolate::GetCurrent()); Local value; - if (!object->Get(context, OneByteString(context->GetIsolate(), property)) + if (!object->Get(context, OneByteString(v8::Isolate::GetCurrent(), property)) .ToLocal(&value) || !value->IsNumber()) { return Nothing(); @@ -65,9 +65,9 @@ Maybe ObjectGetDouble(v8::Local context, Maybe ObjectGetInt(v8::Local context, Local object, const char* property) { - HandleScope handle_scope(context->GetIsolate()); + HandleScope handle_scope(v8::Isolate::GetCurrent()); Local value; - if (!object->Get(context, OneByteString(context->GetIsolate(), property)) + if (!object->Get(context, OneByteString(v8::Isolate::GetCurrent(), property)) .ToLocal(&value) || !value->IsInt32()) { return Nothing(); @@ -79,9 +79,9 @@ Maybe ObjectGetInt(v8::Local context, Maybe ObjectGetBool(v8::Local context, Local object, const char* property) { - HandleScope handle_scope(context->GetIsolate()); + HandleScope handle_scope(v8::Isolate::GetCurrent()); Local value; - if (!object->Get(context, OneByteString(context->GetIsolate(), property)) + if (!object->Get(context, OneByteString(v8::Isolate::GetCurrent(), property)) .ToLocal(&value) || !value->IsBoolean()) { return Nothing(); @@ -93,9 +93,9 @@ Maybe ObjectGetBool(v8::Local context, MaybeLocal ObjectGetObject(v8::Local context, Local object, const char* property) { - EscapableHandleScope handle_scope(context->GetIsolate()); + EscapableHandleScope handle_scope(v8::Isolate::GetCurrent()); Local value; - if (!object->Get(context, OneByteString(context->GetIsolate(), property)) + if (!object->Get(context, OneByteString(v8::Isolate::GetCurrent(), property)) .ToLocal(&value) || !value->IsObject()) { return {}; @@ -106,7 +106,7 @@ MaybeLocal ObjectGetObject(v8::Local context, // Create a protocol::Network::Headers from the v8 object. std::unique_ptr createHeadersFromObject( v8::Local context, Local headers_obj) { - HandleScope handle_scope(context->GetIsolate()); + HandleScope handle_scope(v8::Isolate::GetCurrent()); std::unique_ptr dict = protocol::DictionaryValue::create(); @@ -127,7 +127,7 @@ std::unique_ptr createHeadersFromObject( .To(&property_value)) { return {}; } - dict->setString(ToProtocolString(context->GetIsolate(), property_name), + dict->setString(ToProtocolString(v8::Isolate::GetCurrent(), property_name), property_value); } @@ -137,7 +137,7 @@ std::unique_ptr createHeadersFromObject( // Create a protocol::Network::Request from the v8 object. std::unique_ptr createRequestFromObject( v8::Local context, Local request) { - HandleScope handle_scope(context->GetIsolate()); + HandleScope handle_scope(v8::Isolate::GetCurrent()); protocol::String url; if (!ObjectGetProtocolString(context, request, "url").To(&url)) { return {}; @@ -169,7 +169,7 @@ std::unique_ptr createRequestFromObject( // Create a protocol::Network::Response from the v8 object. std::unique_ptr createResponseFromObject( v8::Local context, Local response) { - HandleScope handle_scope(context->GetIsolate()); + HandleScope handle_scope(v8::Isolate::GetCurrent()); protocol::String url; if (!ObjectGetProtocolString(context, response, "url").To(&url)) { return {}; @@ -210,7 +210,7 @@ std::unique_ptr createResponseFromObject( std::unique_ptr createWebSocketResponse( v8::Local context, Local response) { - HandleScope handle_scope(context->GetIsolate()); + HandleScope handle_scope(v8::Isolate::GetCurrent()); int status; if (!ObjectGetInt(context, response, "status").To(&status)) { return {}; diff --git a/src/js_native_api_v8.h b/src/js_native_api_v8.h index 27aeac589b19cd..5f2900869763f4 100644 --- a/src/js_native_api_v8.h +++ b/src/js_native_api_v8.h @@ -53,7 +53,7 @@ class RefTracker { struct napi_env__ { explicit napi_env__(v8::Local context, int32_t module_api_version) - : isolate(context->GetIsolate()), + : isolate(v8::Isolate::GetCurrent()), context_persistent(isolate, context), module_api_version(module_api_version) { napi_clear_last_error(this); diff --git a/src/module_wrap.cc b/src/module_wrap.cc index 28843f6206e62a..c72d0a31233833 100644 --- a/src/module_wrap.cc +++ b/src/module_wrap.cc @@ -77,7 +77,7 @@ ModuleCacheKey ModuleCacheKey::From(Local context, Local specifier, Local import_attributes) { CHECK_EQ(import_attributes->Length() % elements_per_attribute, 0); - Isolate* isolate = context->GetIsolate(); + Isolate* isolate = Isolate::GetCurrent(); std::size_t h1 = specifier->GetIdentityHash(); size_t num_attributes = import_attributes->Length() / elements_per_attribute; ImportAttributeVector attributes; @@ -178,7 +178,7 @@ ModuleWrap* ModuleWrap::GetLinkedRequest(uint32_t index) { object()->GetInternalField(kLinkedRequestsSlot); DCHECK(linked_requests_data->IsValue() && linked_requests_data.As()->IsArray()); - Local requests = linked_requests_data.As(); + Local requests = linked_requests_data.As().As(); CHECK_LT(index, requests->Length()); @@ -1000,7 +1000,7 @@ MaybeLocal ModuleWrap::ResolveModuleCallback( return {}; } DCHECK_NOT_NULL(resolved_module); - return resolved_module->module_.Get(context->GetIsolate()); + return resolved_module->module_.Get(Isolate::GetCurrent()); } // static @@ -1024,7 +1024,7 @@ MaybeLocal ModuleWrap::ResolveSourceCallback( Local url = resolved_module->object() ->GetInternalField(ModuleWrap::kURLSlot) .As(); - THROW_ERR_SOURCE_PHASE_NOT_DEFINED(context->GetIsolate(), url); + THROW_ERR_SOURCE_PHASE_NOT_DEFINED(Isolate::GetCurrent(), url); return {}; } CHECK(module_source_object->IsObject()); @@ -1037,7 +1037,7 @@ Maybe ModuleWrap::ResolveModule( Local specifier, Local import_attributes, Local referrer) { - Isolate* isolate = context->GetIsolate(); + Isolate* isolate = Isolate::GetCurrent(); Environment* env = Environment::GetCurrent(context); if (env == nullptr) { THROW_ERR_EXECUTION_ENVIRONMENT_NOT_AVAILABLE(isolate); @@ -1082,7 +1082,7 @@ static MaybeLocal ImportModuleDynamicallyWithPhase( Local specifier, ModuleImportPhase phase, Local import_attributes) { - Isolate* isolate = context->GetIsolate(); + Isolate* isolate = Isolate::GetCurrent(); Environment* env = Environment::GetCurrent(context); if (env == nullptr) { THROW_ERR_EXECUTION_ENVIRONMENT_NOT_AVAILABLE(isolate); @@ -1321,7 +1321,7 @@ MaybeLocal LinkRequireFacadeWithOriginal( Local import_attributes, Local referrer) { Environment* env = Environment::GetCurrent(context); - Isolate* isolate = context->GetIsolate(); + Isolate* isolate = Isolate::GetCurrent(); CHECK(specifier->Equals(context, env->original_string()).ToChecked()); CHECK(!env->temporary_required_module_facade_original.IsEmpty()); return env->temporary_required_module_facade_original.Get(isolate); diff --git a/src/node.h b/src/node.h index 8618e9625018c5..6bfe281912feb9 100644 --- a/src/node.h +++ b/src/node.h @@ -1002,7 +1002,7 @@ NODE_DEPRECATED("Use v8::Date::ValueOf() directly", #define NODE_DEFINE_CONSTANT(target, constant) \ do { \ - v8::Isolate* isolate = target->GetIsolate(); \ + v8::Isolate* isolate = v8::Isolate::GetCurrent(); \ v8::Local context = isolate->GetCurrentContext(); \ v8::Local constant_name = v8::String::NewFromUtf8Literal( \ isolate, #constant, v8::NewStringType::kInternalized); \ @@ -1018,7 +1018,7 @@ NODE_DEPRECATED("Use v8::Date::ValueOf() directly", #define NODE_DEFINE_HIDDEN_CONSTANT(target, constant) \ do { \ - v8::Isolate* isolate = target->GetIsolate(); \ + v8::Isolate* isolate = v8::Isolate::GetCurrent(); \ v8::Local context = isolate->GetCurrentContext(); \ v8::Local constant_name = v8::String::NewFromUtf8Literal( \ isolate, #constant, v8::NewStringType::kInternalized); \ diff --git a/src/node_blob.cc b/src/node_blob.cc index eceddfbba39144..c3bdae7b3aa99b 100644 --- a/src/node_blob.cc +++ b/src/node_blob.cc @@ -557,7 +557,7 @@ void BlobBindingData::Deserialize(Local context, int index, InternalFieldInfoBase* info) { DCHECK_IS_SNAPSHOT_SLOT(index); - HandleScope scope(context->GetIsolate()); + HandleScope scope(Isolate::GetCurrent()); Realm* realm = Realm::GetCurrent(context); BlobBindingData* binding = realm->AddBindingData(holder); CHECK_NOT_NULL(binding); diff --git a/src/node_builtins.cc b/src/node_builtins.cc index d9d23531c7153b..520bcc5b1b3b7c 100644 --- a/src/node_builtins.cc +++ b/src/node_builtins.cc @@ -274,7 +274,7 @@ MaybeLocal BuiltinLoader::LookupAndCompileInternal( const char* id, LocalVector* parameters, Realm* optional_realm) { - Isolate* isolate = context->GetIsolate(); + Isolate* isolate = Isolate::GetCurrent(); EscapableHandleScope scope(isolate); Local source; @@ -396,7 +396,7 @@ void BuiltinLoader::SaveCodeCache(const char* id, Local fun) { MaybeLocal BuiltinLoader::LookupAndCompile(Local context, const char* id, Realm* optional_realm) { - Isolate* isolate = context->GetIsolate(); + Isolate* isolate = Isolate::GetCurrent(); LocalVector parameters(isolate); // Detects parameters of the scripts based on module ids. // internal/bootstrap/realm: process, getLinkedBinding, @@ -450,7 +450,7 @@ MaybeLocal BuiltinLoader::LookupAndCompile(Local context, MaybeLocal BuiltinLoader::CompileAndCall(Local context, const char* id, Realm* realm) { - Isolate* isolate = context->GetIsolate(); + Isolate* isolate = Isolate::GetCurrent(); // Detects parameters of the scripts based on module ids. // internal/bootstrap/realm: process, getLinkedBinding, // getInternalBinding, primordials @@ -506,7 +506,7 @@ MaybeLocal BuiltinLoader::CompileAndCall(Local context, if (!maybe_fn.ToLocal(&fn)) { return MaybeLocal(); } - Local undefined = Undefined(context->GetIsolate()); + Local undefined = Undefined(Isolate::GetCurrent()); return fn->Call(context, undefined, argc, argv); } @@ -544,14 +544,14 @@ bool BuiltinLoader::CompileAllBuiltinsAndCopyCodeCache( to_eager_compile_.emplace(id); } - TryCatch bootstrapCatch(context->GetIsolate()); + TryCatch bootstrapCatch(Isolate::GetCurrent()); auto fn = LookupAndCompile(context, id.data(), nullptr); if (bootstrapCatch.HasCaught()) { per_process::Debug(DebugCategory::CODE_CACHE, "Failed to compile code cache for %s\n", id.data()); all_succeeded = false; - PrintCaughtException(context->GetIsolate(), context, bootstrapCatch); + PrintCaughtException(Isolate::GetCurrent(), context, bootstrapCatch); } else { // This is used by the snapshot builder, so save the code cache // unconditionally. diff --git a/src/node_constants.cc b/src/node_constants.cc index fd28e0904d05e2..f6be4d5b074c52 100644 --- a/src/node_constants.cc +++ b/src/node_constants.cc @@ -1281,7 +1281,7 @@ void CreatePerContextProperties(Local target, Local unused, Local context, void* priv) { - Isolate* isolate = context->GetIsolate(); + Isolate* isolate = Isolate::GetCurrent(); Environment* env = Environment::GetCurrent(context); CHECK( diff --git a/src/node_contextify.cc b/src/node_contextify.cc index ef4bc0085404b7..2703f992171dc0 100644 --- a/src/node_contextify.cc +++ b/src/node_contextify.cc @@ -112,7 +112,7 @@ namespace { // Convert an int to a V8 Name (String or Symbol). MaybeLocal Uint32ToName(Local context, uint32_t index) { - return Uint32::New(context->GetIsolate(), index)->ToString(context); + return Uint32::New(Isolate::GetCurrent(), index)->ToString(context); } } // anonymous namespace @@ -676,7 +676,7 @@ Intercepted ContextifyContext::PropertyDefinerCallback( } Local context = ctx->context(); - Isolate* isolate = context->GetIsolate(); + Isolate* isolate = Isolate::GetCurrent(); PropertyAttribute attributes = PropertyAttribute::None; bool is_declared = @@ -1663,7 +1663,7 @@ static MaybeLocal CompileFunctionForCJSLoader( bool* cache_rejected, bool is_cjs_scope, ScriptCompiler::CachedData* cached_data) { - Isolate* isolate = context->GetIsolate(); + Isolate* isolate = Isolate::GetCurrent(); EscapableHandleScope scope(isolate); Local symbol = env->vm_dynamic_import_default_internal(); diff --git a/src/node_env_var.cc b/src/node_env_var.cc index 6aad252eb5681b..5f7ef8cc58f589 100644 --- a/src/node_env_var.cc +++ b/src/node_env_var.cc @@ -311,7 +311,7 @@ std::shared_ptr KVStore::CreateMapKVStore() { Maybe KVStore::AssignFromObject(Local context, Local entries) { - Isolate* isolate = context->GetIsolate(); + Isolate* isolate = Isolate::GetCurrent(); HandleScope handle_scope(isolate); Local keys; if (!entries->GetOwnPropertyNames(context).ToLocal(&keys)) diff --git a/src/node_errors.cc b/src/node_errors.cc index 5f51add4cdf68a..75bbe9cd539880 100644 --- a/src/node_errors.cc +++ b/src/node_errors.cc @@ -633,7 +633,7 @@ v8::ModifyCodeGenerationFromStringsResult ModifyCodeGenerationFromStrings( v8::Local context, v8::Local source, bool is_code_like) { - HandleScope scope(context->GetIsolate()); + HandleScope scope(Isolate::GetCurrent()); if (context->GetNumberOfEmbedderDataFields() <= ContextEmbedderIndex::kAllowCodeGenerationFromStrings) { @@ -1016,7 +1016,7 @@ const char* errno_string(int errorno) { } void PerIsolateMessageListener(Local message, Local error) { - Isolate* isolate = message->GetIsolate(); + Isolate* isolate = Isolate::GetCurrent(); switch (message->ErrorLevel()) { case Isolate::MessageErrorLevel::kMessageWarning: { Environment* env = Environment::GetCurrent(isolate); @@ -1134,7 +1134,7 @@ void Initialize(Local target, SetMethod( context, target, "triggerUncaughtException", TriggerUncaughtException); - Isolate* isolate = context->GetIsolate(); + Isolate* isolate = Isolate::GetCurrent(); Local exit_codes = Object::New(isolate); READONLY_PROPERTY(target, "exitCodes", exit_codes); diff --git a/src/node_file.cc b/src/node_file.cc index 44b4d4595e4455..ba191f3da4bafc 100644 --- a/src/node_file.cc +++ b/src/node_file.cc @@ -3849,7 +3849,7 @@ void BindingData::Deserialize(Local context, int index, InternalFieldInfoBase* info) { DCHECK_IS_SNAPSHOT_SLOT(index); - HandleScope scope(context->GetIsolate()); + HandleScope scope(Isolate::GetCurrent()); Realm* realm = Realm::GetCurrent(context); InternalFieldInfo* casted_info = static_cast(info); BindingData* binding = diff --git a/src/node_messaging.cc b/src/node_messaging.cc index 084ff03dbe8124..9834a4fd916ffa 100644 --- a/src/node_messaging.cc +++ b/src/node_messaging.cc @@ -254,7 +254,7 @@ namespace { MaybeLocal GetEmitMessageFunction(Local context, IsolateData* isolate_data) { - Isolate* isolate = context->GetIsolate(); + Isolate* isolate = Isolate::GetCurrent(); Local per_context_bindings; Local emit_message_val; if (!GetPerContextExports(context, isolate_data) @@ -269,7 +269,7 @@ MaybeLocal GetEmitMessageFunction(Local context, } MaybeLocal GetDOMException(Local context) { - Isolate* isolate = context->GetIsolate(); + Isolate* isolate = Isolate::GetCurrent(); Local per_context_bindings; Local domexception_ctor_val; if (!GetPerContextExports(context).ToLocal(&per_context_bindings) || @@ -284,7 +284,7 @@ MaybeLocal GetDOMException(Local context) { } void ThrowDataCloneException(Local context, Local message) { - Isolate* isolate = context->GetIsolate(); + Isolate* isolate = Isolate::GetCurrent(); Local argv[] = {message, FIXED_ONE_BYTE_STRING(isolate, "DataCloneError")}; Local exception; @@ -1462,7 +1462,7 @@ BaseObjectPtr JSTransferable::Data::Deserialize( Maybe JSTransferable::Data::FinalizeTransferWrite( Local context, ValueSerializer* serializer) { - HandleScope handle_scope(context->GetIsolate()); + HandleScope handle_scope(Isolate::GetCurrent()); auto ret = serializer->WriteValue(context, PersistentToLocal::Strong(data_)); data_.Reset(); return ret; diff --git a/src/node_modules.cc b/src/node_modules.cc index 9de75dda832d70..d6b02b04694a84 100644 --- a/src/node_modules.cc +++ b/src/node_modules.cc @@ -68,7 +68,7 @@ void BindingData::Deserialize(v8::Local context, int index, InternalFieldInfoBase* info) { DCHECK_IS_SNAPSHOT_SLOT(index); - HandleScope scope(context->GetIsolate()); + HandleScope scope(Isolate::GetCurrent()); Realm* realm = Realm::GetCurrent(context); BindingData* binding = realm->AddBindingData(holder); CHECK_NOT_NULL(binding); @@ -696,7 +696,7 @@ void BindingData::CreatePerContextProperties(Local target, Realm* realm = Realm::GetCurrent(context); realm->AddBindingData(target); - Isolate* isolate = context->GetIsolate(); + Isolate* isolate = Isolate::GetCurrent(); LocalVector compile_cache_status_values(isolate); #define V(status) \ diff --git a/src/node_process_methods.cc b/src/node_process_methods.cc index dbba228e09e93b..d524df4d880d0c 100644 --- a/src/node_process_methods.cc +++ b/src/node_process_methods.cc @@ -743,7 +743,7 @@ void BindingData::Deserialize(Local context, int index, InternalFieldInfoBase* info) { DCHECK_IS_SNAPSHOT_SLOT(index); - v8::HandleScope scope(context->GetIsolate()); + v8::HandleScope scope(Isolate::GetCurrent()); Realm* realm = Realm::GetCurrent(context); // Recreate the buffer in the constructor. InternalFieldInfo* casted_info = static_cast(info); diff --git a/src/node_realm.cc b/src/node_realm.cc index b7ac5d74c3b7cc..67fbb7f2bc6967 100644 --- a/src/node_realm.cc +++ b/src/node_realm.cc @@ -22,7 +22,7 @@ using v8::String; using v8::Value; Realm::Realm(Environment* env, v8::Local context, Kind kind) - : env_(env), isolate_(context->GetIsolate()), kind_(kind) { + : env_(env), isolate_(Isolate::GetCurrent()), kind_(kind) { context_.Reset(isolate_, context); env->AssignToContext(context, this, ContextInfo("")); // The environment can also purge empty wrappers in the check callback, diff --git a/src/node_report.cc b/src/node_report.cc index 904c52edb4b634..eca3bb0520c601 100644 --- a/src/node_report.cc +++ b/src/node_report.cc @@ -402,7 +402,7 @@ static void PrintJavaScriptErrorProperties(JSONWriter* writer, if (!error.IsEmpty() && error->IsObject()) { TryCatch try_catch(isolate); Local error_obj = error.As(); - Local context = error_obj->GetIsolate()->GetCurrentContext(); + Local context = Isolate::GetCurrent()->GetCurrentContext(); Local keys; if (!error_obj->GetOwnPropertyNames(context).ToLocal(&keys)) { return writer->json_objectend(); // the end of 'errorProperties' diff --git a/src/node_snapshotable.cc b/src/node_snapshotable.cc index 9bdef1032e4dc9..46f886b12090a4 100644 --- a/src/node_snapshotable.cc +++ b/src/node_snapshotable.cc @@ -1585,7 +1585,7 @@ void BindingData::Deserialize(Local context, int index, InternalFieldInfoBase* info) { DCHECK_IS_SNAPSHOT_SLOT(index); - v8::HandleScope scope(context->GetIsolate()); + v8::HandleScope scope(Isolate::GetCurrent()); Realm* realm = Realm::GetCurrent(context); // Recreate the buffer in the constructor. InternalFieldInfo* casted_info = static_cast(info); diff --git a/src/node_sqlite.cc b/src/node_sqlite.cc index 58eecd3168ef09..ba622991390bf2 100644 --- a/src/node_sqlite.cc +++ b/src/node_sqlite.cc @@ -1864,7 +1864,7 @@ bool StatementSync::BindParams(const FunctionCallbackInfo& args) { if (args[0]->IsObject() && !args[0]->IsArrayBufferView()) { Local obj = args[0].As(); - Local context = obj->GetIsolate()->GetCurrentContext(); + Local context = Isolate::GetCurrent()->GetCurrentContext(); Local keys; if (!obj->GetOwnPropertyNames(context).ToLocal(&keys)) { return false; diff --git a/src/node_task_queue.cc b/src/node_task_queue.cc index 0a5aba6e31fa79..794c802ec09f5e 100644 --- a/src/node_task_queue.cc +++ b/src/node_task_queue.cc @@ -48,7 +48,7 @@ void PromiseRejectCallback(PromiseRejectMessage message) { static std::atomic rejectionsHandledAfter{0}; Local promise = message.GetPromise(); - Isolate* isolate = promise->GetIsolate(); + Isolate* isolate = Isolate::GetCurrent(); PromiseRejectEvent event = message.GetEvent(); Environment* env = Environment::GetCurrent(isolate); diff --git a/src/node_url.cc b/src/node_url.cc index 9d1e8ec0516157..9b91f83d879ea0 100644 --- a/src/node_url.cc +++ b/src/node_url.cc @@ -70,7 +70,7 @@ void BindingData::Deserialize(Local context, int index, InternalFieldInfoBase* info) { DCHECK_IS_SNAPSHOT_SLOT(index); - HandleScope scope(context->GetIsolate()); + HandleScope scope(Isolate::GetCurrent()); Realm* realm = Realm::GetCurrent(context); BindingData* binding = realm->AddBindingData(holder); CHECK_NOT_NULL(binding); diff --git a/src/node_v8.cc b/src/node_v8.cc index 9f3c721680fabf..ffc273d9d2ce10 100644 --- a/src/node_v8.cc +++ b/src/node_v8.cc @@ -158,7 +158,7 @@ void BindingData::Deserialize(Local context, int index, InternalFieldInfoBase* info) { DCHECK_IS_SNAPSHOT_SLOT(index); - HandleScope scope(context->GetIsolate()); + HandleScope scope(Isolate::GetCurrent()); Realm* realm = Realm::GetCurrent(context); // Recreate the buffer in the constructor. InternalFieldInfo* casted_info = static_cast(info); diff --git a/src/node_wasi.cc b/src/node_wasi.cc index 5f133bac216220..51264dcdfd431d 100644 --- a/src/node_wasi.cc +++ b/src/node_wasi.cc @@ -50,7 +50,7 @@ using v8::WasmMemoryObject; static MaybeLocal WASIException(Local context, int errorno, const char* syscall) { - Isolate* isolate = context->GetIsolate(); + Isolate* isolate = Isolate::GetCurrent(); Environment* env = Environment::GetCurrent(context); CHECK_NOT_NULL(env); const char* err_name = uvwasi_embedder_err_code_to_string(errorno); @@ -276,7 +276,7 @@ R WASI::WasiFunction::FastCallback( return EinvalError(); } - Isolate* isolate = receiver->GetIsolate(); + Isolate* isolate = Isolate::GetCurrent(); HandleScope scope(isolate); if (wasi->memory_.IsEmpty()) { THROW_ERR_WASI_NOT_STARTED(isolate); diff --git a/src/node_webstorage.cc b/src/node_webstorage.cc index 4d796e6df90c58..e598da835f4d4d 100644 --- a/src/node_webstorage.cc +++ b/src/node_webstorage.cc @@ -57,7 +57,7 @@ using v8::Value; } while (0) static void ThrowQuotaExceededException(Local context) { - Isolate* isolate = context->GetIsolate(); + Isolate* isolate = Isolate::GetCurrent(); auto dom_exception_str = FIXED_ONE_BYTE_STRING(isolate, "DOMException"); auto err_name = FIXED_ONE_BYTE_STRING(isolate, "QuotaExceededError"); auto err_message = @@ -433,7 +433,7 @@ Maybe Storage::Store(Local key, Local value) { } static MaybeLocal Uint32ToName(Local context, uint32_t index) { - return Uint32::New(context->GetIsolate(), index)->ToString(context); + return Uint32::New(Isolate::GetCurrent(), index)->ToString(context); } static void Clear(const FunctionCallbackInfo& info) { diff --git a/src/node_worker.cc b/src/node_worker.cc index c28e77ce977e96..735a9181ef7723 100644 --- a/src/node_worker.cc +++ b/src/node_worker.cc @@ -1164,7 +1164,7 @@ void GetEnvMessagePort(const FunctionCallbackInfo& args) { Local port = env->message_port(); CHECK_IMPLIES(!env->is_main_thread(), !port.IsEmpty()); if (!port.IsEmpty()) { - CHECK_EQ(port->GetCreationContextChecked()->GetIsolate(), + CHECK_EQ(Isolate::GetCurrent(), args.GetIsolate()); args.GetReturnValue().Set(port); } diff --git a/src/timers.cc b/src/timers.cc index bf90e68479da14..5f0d07b4ac1d9b 100644 --- a/src/timers.cc +++ b/src/timers.cc @@ -117,7 +117,7 @@ void BindingData::Deserialize(Local context, int index, InternalFieldInfoBase* info) { DCHECK_IS_SNAPSHOT_SLOT(index); - v8::HandleScope scope(context->GetIsolate()); + v8::HandleScope scope(Isolate::GetCurrent()); Realm* realm = Realm::GetCurrent(context); // Recreate the buffer in the constructor. BindingData* binding = realm->AddBindingData(holder); diff --git a/src/util.cc b/src/util.cc index 660cfff6b8a0c5..c4b39450c5b7f9 100644 --- a/src/util.cc +++ b/src/util.cc @@ -391,7 +391,7 @@ void SetMethod(Local context, Local that, const std::string_view name, v8::FunctionCallback callback) { - Isolate* isolate = context->GetIsolate(); + Isolate* isolate = Isolate::GetCurrent(); Local function = NewFunctionTemplate(isolate, callback, @@ -452,7 +452,7 @@ void SetFastMethod(Local context, const std::string_view name, v8::FunctionCallback slow_callback, const v8::CFunction* c_function) { - Isolate* isolate = context->GetIsolate(); + Isolate* isolate = Isolate::GetCurrent(); Local function = NewFunctionTemplate(isolate, slow_callback, @@ -474,7 +474,7 @@ void SetFastMethodNoSideEffect(Local context, const std::string_view name, v8::FunctionCallback slow_callback, const v8::CFunction* c_function) { - Isolate* isolate = context->GetIsolate(); + Isolate* isolate = Isolate::GetCurrent(); Local function = NewFunctionTemplate(isolate, slow_callback, @@ -562,7 +562,7 @@ void SetMethodNoSideEffect(Local context, Local that, const std::string_view name, v8::FunctionCallback callback) { - Isolate* isolate = context->GetIsolate(); + Isolate* isolate = Isolate::GetCurrent(); Local function = NewFunctionTemplate(isolate, callback, @@ -689,7 +689,7 @@ void SetConstructorFunction(Local context, const char* name, Local tmpl, SetConstructorFunctionFlag flag) { - Isolate* isolate = context->GetIsolate(); + Isolate* isolate = Isolate::GetCurrent(); SetConstructorFunction( context, that, OneByteString(isolate, name), tmpl, flag); } diff --git a/src/util.h b/src/util.h index 0719f7370fe64a..bdefe056760a2b 100644 --- a/src/util.h +++ b/src/util.h @@ -746,7 +746,7 @@ inline v8::MaybeLocal ToV8Value( // Variation on NODE_DEFINE_CONSTANT that sets a String value. #define NODE_DEFINE_STRING_CONSTANT(target, name, constant) \ do { \ - v8::Isolate* isolate = target->GetIsolate(); \ + v8::Isolate* isolate = v8::Isolate::GetCurrent(); \ v8::Local constant_name = \ v8::String::NewFromUtf8(isolate, name).ToLocalChecked(); \ v8::Local constant_value = \ diff --git a/test/addons/async-cleanup-hook/binding.cc b/test/addons/async-cleanup-hook/binding.cc index 0a11220850fca2..1bae59afca9993 100644 --- a/test/addons/async-cleanup-hook/binding.cc +++ b/test/addons/async-cleanup-hook/binding.cc @@ -42,15 +42,15 @@ void Initialize(v8::Local exports, v8::Local module, v8::Local context) { AsyncData* data = new AsyncData(); - data->isolate = context->GetIsolate(); + data->isolate = v8::Isolate::GetCurrent(); auto handle = node::AddEnvironmentCleanupHook( - context->GetIsolate(), + v8::Isolate::GetCurrent(), AsyncCleanupHook, data); data->handle = std::move(handle); auto must_not_call_handle = node::AddEnvironmentCleanupHook( - context->GetIsolate(), + v8::Isolate::GetCurrent(), MustNotCall, nullptr); node::RemoveEnvironmentCleanupHook(std::move(must_not_call_handle)); diff --git a/test/addons/cppgc-object/binding.cc b/test/addons/cppgc-object/binding.cc index 63fb1dbdc96d4f..90be1614748303 100644 --- a/test/addons/cppgc-object/binding.cc +++ b/test/addons/cppgc-object/binding.cc @@ -27,7 +27,7 @@ class CppGCed : public v8::Object::Wrappable { static v8::Local GetConstructor( v8::Local context) { - auto ft = v8::FunctionTemplate::New(context->GetIsolate(), New); + auto ft = v8::FunctionTemplate::New(v8::Isolate::GetCurrent(), New); return ft->GetFunction(context).ToLocalChecked(); } diff --git a/test/addons/esm-export/binding-export-primitive.cc b/test/addons/esm-export/binding-export-primitive.cc index b4dd1ddeda993a..7f91a15659f82a 100644 --- a/test/addons/esm-export/binding-export-primitive.cc +++ b/test/addons/esm-export/binding-export-primitive.cc @@ -5,7 +5,7 @@ static void InitModule(v8::Local exports, v8::Local module_val, v8::Local context) { - v8::Isolate* isolate = context->GetIsolate(); + v8::Isolate* isolate = v8::Isolate::GetCurrent(); v8::Local module = module_val.As(); module ->Set(context, diff --git a/test/addons/heap-profiler/binding.cc b/test/addons/heap-profiler/binding.cc index 98156d5548960e..a6dd50933f97a7 100644 --- a/test/addons/heap-profiler/binding.cc +++ b/test/addons/heap-profiler/binding.cc @@ -17,7 +17,7 @@ inline void Test(const v8::FunctionCallbackInfo& args) { } inline void Initialize(v8::Local binding) { - v8::Isolate* const isolate = binding->GetIsolate(); + v8::Isolate* const isolate = v8::Isolate::GetCurrent(); v8::Local context = isolate->GetCurrentContext(); binding->Set(context, v8::String::NewFromUtf8( isolate, "test").ToLocalChecked(), diff --git a/test/addons/hello-world/binding.cc b/test/addons/hello-world/binding.cc index 77de6c45a3a8f1..199882935ec2f9 100644 --- a/test/addons/hello-world/binding.cc +++ b/test/addons/hello-world/binding.cc @@ -19,7 +19,7 @@ NODE_MODULE_INITIALIZER(v8::Local exports, static void FakeInit(v8::Local exports, v8::Local module, v8::Local context) { - auto isolate = context->GetIsolate(); + auto isolate = v8::Isolate::GetCurrent(); auto exception = v8::Exception::Error(v8::String::NewFromUtf8(isolate, "FakeInit should never run!").ToLocalChecked()); isolate->ThrowException(exception); diff --git a/test/addons/new-target/binding.cc b/test/addons/new-target/binding.cc index ba747fbbe87ea7..b19d03b99151b6 100644 --- a/test/addons/new-target/binding.cc +++ b/test/addons/new-target/binding.cc @@ -10,7 +10,7 @@ inline void NewClass(const v8::FunctionCallbackInfo& args) { } inline void Initialize(v8::Local binding) { - auto isolate = binding->GetIsolate(); + auto isolate = v8::Isolate::GetCurrent(); auto context = isolate->GetCurrentContext(); binding->Set(context, v8::String::NewFromUtf8( isolate, "Class").ToLocalChecked(), diff --git a/test/addons/openssl-binding/binding.cc b/test/addons/openssl-binding/binding.cc index 06402022f4da66..fbb96fd3b20c56 100644 --- a/test/addons/openssl-binding/binding.cc +++ b/test/addons/openssl-binding/binding.cc @@ -38,7 +38,7 @@ inline void Hash(const v8::FunctionCallbackInfo& info) { inline void Initialize(v8::Local exports, v8::Local module, v8::Local context) { - auto isolate = context->GetIsolate(); + auto isolate = v8::Isolate::GetCurrent(); auto key = v8::String::NewFromUtf8( isolate, "randomBytes").ToLocalChecked(); auto value = v8::FunctionTemplate::New(isolate, RandomBytes) diff --git a/test/addons/worker-addon/binding.cc b/test/addons/worker-addon/binding.cc index a5f9d8b3f835d8..ccb892684d3f99 100644 --- a/test/addons/worker-addon/binding.cc +++ b/test/addons/worker-addon/binding.cc @@ -52,18 +52,18 @@ void Initialize(Local exports, Local module, Local context) { node::AddEnvironmentCleanupHook( - context->GetIsolate(), + v8::Isolate::GetCurrent(), Cleanup, const_cast(static_cast("cleanup"))); - node::AddEnvironmentCleanupHook(context->GetIsolate(), Dummy, nullptr); - node::RemoveEnvironmentCleanupHook(context->GetIsolate(), Dummy, nullptr); + node::AddEnvironmentCleanupHook(v8::Isolate::GetCurrent(), Dummy, nullptr); + node::RemoveEnvironmentCleanupHook(v8::Isolate::GetCurrent(), Dummy, nullptr); if (getenv("addExtraItemToEventLoop") != nullptr) { // Add an item to the event loop that we do not clean up in order to make // sure that for the main thread, this addon's memory persists even after // the Environment instance has been destroyed. static uv_async_t extra_async; - uv_loop_t* loop = node::GetCurrentEventLoop(context->GetIsolate()); + uv_loop_t* loop = node::GetCurrentEventLoop(v8::Isolate::GetCurrent()); int err = uv_async_init(loop, &extra_async, [](uv_async_t*) {}); assert(err == 0); uv_unref(reinterpret_cast(&extra_async)); diff --git a/test/addons/worker-buffer-callback/binding.cc b/test/addons/worker-buffer-callback/binding.cc index 9cacc6996243bd..29ee2e6fa09c1f 100644 --- a/test/addons/worker-buffer-callback/binding.cc +++ b/test/addons/worker-buffer-callback/binding.cc @@ -18,7 +18,7 @@ void GetFreeCallCount(const FunctionCallbackInfo& args) { void Initialize(Local exports, Local module, Local context) { - Isolate* isolate = context->GetIsolate(); + Isolate* isolate = v8::Isolate::GetCurrent(); NODE_SET_METHOD(exports, "getFreeCallCount", GetFreeCallCount); char* data = new char; diff --git a/test/addons/zlib-binding/binding.cc b/test/addons/zlib-binding/binding.cc index 3a958f26af1ac6..859b54564b63a7 100644 --- a/test/addons/zlib-binding/binding.cc +++ b/test/addons/zlib-binding/binding.cc @@ -44,7 +44,7 @@ inline void CompressBytes(const v8::FunctionCallbackInfo& info) { inline void Initialize(v8::Local exports, v8::Local module, v8::Local context) { - auto isolate = context->GetIsolate(); + auto isolate = v8::Isolate::GetCurrent(); auto key = v8::String::NewFromUtf8( isolate, "compressBytes").ToLocalChecked(); auto value = v8::FunctionTemplate::New(isolate, CompressBytes) diff --git a/test/cctest/test_cppgc.cc b/test/cctest/test_cppgc.cc index 5bbe6495bf0cb7..2f586617bd6cf7 100644 --- a/test/cctest/test_cppgc.cc +++ b/test/cctest/test_cppgc.cc @@ -30,7 +30,7 @@ class CppGCed : public v8::Object::Wrappable { static v8::Local GetConstructor( v8::Local context) { - auto ft = v8::FunctionTemplate::New(context->GetIsolate(), New); + auto ft = v8::FunctionTemplate::New(v8::Isolate::GetCurrent(), New); return ft->GetFunction(context).ToLocalChecked(); } diff --git a/test/cctest/test_linked_binding.cc b/test/cctest/test_linked_binding.cc index 19ea2b8f228ebb..bcfc5050c9a3ec 100644 --- a/test/cctest/test_linked_binding.cc +++ b/test/cctest/test_linked_binding.cc @@ -9,7 +9,7 @@ void InitializeBinding(v8::Local exports, v8::Local module, v8::Local context, void* priv) { - v8::Isolate* isolate = context->GetIsolate(); + v8::Isolate* isolate = v8::Isolate::GetCurrent(); exports ->Set(context, v8::String::NewFromOneByte(isolate, @@ -51,7 +51,7 @@ void InitializeLocalBinding(v8::Local exports, v8::Local context, void* priv) { ++*static_cast(priv); - v8::Isolate* isolate = context->GetIsolate(); + v8::Isolate* isolate = v8::Isolate::GetCurrent(); exports ->Set(context, v8::String::NewFromOneByte(isolate,