From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: deepak1556 Date: Mon, 1 Sep 2025 03:13:53 +0900 Subject: Remove deprecated `GetIsolate` https://chromium-review.googlesource.com/c/v8/v8/+/6905244 diff --git a/src/api/environment.cc b/src/api/environment.cc index 8e227ddd1be50c046a8cf2895a31d607eb7d31de..82f53bba29613de212f64be440ca20d7c630fddf 100644 --- a/src/api/environment.cc +++ b/src/api/environment.cc @@ -654,7 +654,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(); @@ -700,7 +700,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 @@ -779,7 +779,7 @@ Maybe InitializeContextRuntime(Local context) { } Maybe InitializeBaseContextForSnapshot(Local context) { - Isolate* isolate = context->GetIsolate(); + Isolate* isolate = Isolate::GetCurrent(); HandleScope handle_scope(isolate); // Delete `Intl.v8BreakIterator` @@ -804,7 +804,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. @@ -822,7 +822,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); @@ -846,7 +846,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); @@ -872,7 +872,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/base_object-inl.h b/src/base_object-inl.h index 6f731b17fe0b84dd3d2c9bc9cfef1f8062a2c5f7..71a1072ed2decbee08d40eda7c47456be5093bc2 100644 --- a/src/base_object-inl.h +++ b/src/base_object-inl.h @@ -55,7 +55,6 @@ v8::Local BaseObject::object() const { v8::Local BaseObject::object(v8::Isolate* isolate) const { v8::Local handle = object(); - DCHECK_EQ(handle->GetCreationContextChecked()->GetIsolate(), isolate); DCHECK_EQ(env()->isolate(), isolate); return handle; diff --git a/src/crypto/crypto_context.cc b/src/crypto/crypto_context.cc index a3d309d832c73ddc79564b9644d825bec7459e7f..580cbaf3858961f375ca2f53c48a07bcba82ef46 100644 --- a/src/crypto/crypto_context.cc +++ b/src/crypto/crypto_context.cc @@ -967,7 +967,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 eb6dad44a49d997097c8fb5009eeb60a7305da27..fd29d17de195017970856ce30d7a9c5785b0b8ee 100644 --- a/src/crypto/crypto_x509.cc +++ b/src/crypto/crypto_x509.cc @@ -97,7 +97,7 @@ MaybeLocal ToV8Value(Local context, BIOPointer&& bio) { if (!bio) return {}; BUF_MEM* mem = bio; Local ret; - if (!String::NewFromUtf8(context->GetIsolate(), + if (!String::NewFromUtf8(Isolate::GetCurrent(), mem->data, NewStringType::kNormal, mem->length) @@ -121,7 +121,7 @@ MaybeLocal ToV8Value(Local context, const ASN1_OBJECT* obj) { } Local result; - if (!String::NewFromUtf8(context->GetIsolate(), str).ToLocal(&result)) { + if (!String::NewFromUtf8(Isolate::GetCurrent(), str).ToLocal(&result)) { return {}; } return result; @@ -136,12 +136,12 @@ MaybeLocal ToV8Value(Local context, const ASN1_STRING* str) { unsigned char* value_str; int value_str_size = ASN1_STRING_to_UTF8(&value_str, str); if (value_str_size < 0) { - return Undefined(context->GetIsolate()); + return Undefined(Isolate::GetCurrent()); } DataPointer free_value_str(value_str, value_str_size); Local result; - if (!String::NewFromUtf8(context->GetIsolate(), + if (!String::NewFromUtf8(Isolate::GetCurrent(), reinterpret_cast(value_str), NewStringType::kNormal, value_str_size) @@ -155,7 +155,7 @@ MaybeLocal ToV8Value(Local context, const BIOPointer& bio) { if (!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 31ed995714bb99ab534f26ba9ebc6051c258a1c9..5ace688bb7ffc86eedf5aff11ab0ab487ad9440e 100644 --- a/src/encoding_binding.cc +++ b/src/encoding_binding.cc @@ -73,7 +73,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/env.cc b/src/env.cc index c6209cc7cf317de1bb9217e39dd760e5a83303e2..161d577e0ea6a251c83ba1903b1ec9a582a5317c 100644 --- a/src/env.cc +++ b/src/env.cc @@ -1748,10 +1748,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 @@ -1791,7 +1791,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 3b5d9615021101ad03d9dfef83e0c56b462b59ad..823e7b8d3d07eb2afa1cc62d3d9e2af20f4e2e89 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 {}; diff --git a/src/js_native_api_v8.h b/src/js_native_api_v8.h index 27aeac589b19cd681923fb848ce5f36c66fc05e2..5f2900869763f40cac54e3cb3fe2e24eda615410 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 cbb3e7f4df72f83cb8a1afc25a7429218792e964..ffccac5589bfe12eaf7861364cc6f2e403d26679 100644 --- a/src/module_wrap.cc +++ b/src/module_wrap.cc @@ -865,7 +865,7 @@ MaybeLocal ModuleWrap::ResolveModuleCallback( 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); @@ -907,7 +907,7 @@ MaybeLocal ImportModuleDynamically( Local resource_name, Local specifier, 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); @@ -1131,7 +1131,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 16a0c71aef949b0ddd27def9dc843298f9a6b75f..28fa4cb3e7a621480a5ff11c48666c0de1363375 100644 --- a/src/node.h +++ b/src/node.h @@ -1050,7 +1050,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); \ @@ -1066,7 +1066,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 9b9956f5ee3150a80f040cd0dbb9ef6589295600..14de0dad25fbf854ea23eb25abd6f9f2179e0dad 100644 --- a/src/node_blob.cc +++ b/src/node_blob.cc @@ -554,7 +554,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 4b288e0f89e0156cb5b0555c0259b2c1150770db..bc87057c8473d4731de55b909c58106217b32d1b 100644 --- a/src/node_builtins.cc +++ b/src/node_builtins.cc @@ -275,7 +275,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; @@ -397,7 +397,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, @@ -451,7 +451,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 @@ -507,7 +507,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); } @@ -546,14 +546,14 @@ bool BuiltinLoader::CompileAllBuiltinsAndCopyCodeCache( to_eager_compile_.emplace(id); } - v8::TryCatch bootstrapCatch(context->GetIsolate()); + v8::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 cbcecfba33070b820aca0e2814982160a97a6378..b1ee513fc0873a51b4885f612dbf7b950b5cf2ca 100644 --- a/src/node_constants.cc +++ b/src/node_constants.cc @@ -1264,7 +1264,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(target->SetPrototype(env->context(), Null(env->isolate())).FromJust()); diff --git a/src/node_contextify.cc b/src/node_contextify.cc index 21a08a738e5c3506d27e402762a4a267e9278588..475b5628f9b82a2b9b86343f25759c1e6814f816 100644 --- a/src/node_contextify.cc +++ b/src/node_contextify.cc @@ -111,7 +111,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 @@ -682,7 +682,7 @@ Intercepted ContextifyContext::PropertyDefinerCallback( } Local context = ctx->context(); - Isolate* isolate = context->GetIsolate(); + Isolate* isolate = Isolate::GetCurrent(); PropertyAttribute attributes = PropertyAttribute::None; bool is_declared = @@ -1657,7 +1657,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 492d5f455f45a5c8a957ecdabed38709a633f640..48f9917113555c7ed87e37750c45d152fa4b68f8 100644 --- a/src/node_env_var.cc +++ b/src/node_env_var.cc @@ -295,7 +295,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 befb642f1effa3c4139e4cd99ff64d9c5175fd72..9c068afd1c4c3fadeee4ba035e67ec4ae72c7f73 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) { @@ -1000,7 +1000,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); @@ -1118,7 +1118,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 d7009937b31729f33d9c45cbda7f5440fbdac2aa..e57a3140cd90d7e7852a0c6892091e50b850ae64 100644 --- a/src/node_file.cc +++ b/src/node_file.cc @@ -3753,7 +3753,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 1eff9399ff87510164390a1dfea84158a8856b86..e912562d768308906286890b7015cf2c462bac49 100644 --- a/src/node_messaging.cc +++ b/src/node_messaging.cc @@ -253,7 +253,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) @@ -268,7 +268,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) || @@ -283,7 +283,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; @@ -1464,7 +1464,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 6204986dc97686a248d6ae483f3a413ee5c51e47..c0108310df81c9bd1756a6fb92466a7f84e53f7c 100644 --- a/src/node_modules.cc +++ b/src/node_modules.cc @@ -64,7 +64,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); @@ -706,7 +706,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 1cb08b715865f8337e0292fc8e2a26488ba21694..2bd20fc173d4110282ee736e49b49ce0859088f3 100644 --- a/src/node_process_methods.cc +++ b/src/node_process_methods.cc @@ -736,7 +736,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 cd2b4c0107594a8ba9bf671669e4c82326719908..d18945085ff1860bbe3796e0b47904210aafd941 100644 --- a/src/node_realm.cc +++ b/src/node_realm.cc @@ -19,7 +19,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_(v8::Isolate::GetCurrent()), kind_(kind) { context_.Reset(isolate_, context); env->AssignToContext(context, this, ContextInfo("")); } diff --git a/src/node_report.cc b/src/node_report.cc index df73a8204bc0917073a70ca68d019ceab3159b08..d7bb94db78b3a729f25ceaf66d193032056b36ff 100644 --- a/src/node_report.cc +++ b/src/node_report.cc @@ -399,7 +399,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 69d8d15d8989ed31a19489e68588e730760c8ffb..d342a5ff91bbd9cb73c02c26ae3a36b9d0dc7b47 100644 --- a/src/node_snapshotable.cc +++ b/src/node_snapshotable.cc @@ -1613,7 +1613,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 8b6fe36e1fece112269ebf193d6322a4d1dacc0a..96101167016573e80fff520256ebb78c71d83302 100644 --- a/src/node_sqlite.cc +++ b/src/node_sqlite.cc @@ -1858,7 +1858,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 c4257110d8b52017fccd8e1e746b557a0b7084df..6f00da0b515397d300e387f03f4a2bf71155cfe0 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 09589e85e8bc131811204833d9a76f98c7b2a102..1154b452151b6b597aed67effbb3796c635d236b 100644 --- a/src/node_url.cc +++ b/src/node_url.cc @@ -69,7 +69,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 430d5dd4f808af7b1790bd62f06d47b86100d4e9..08a741216d88c95d580e9281e174550001ff2b21 100644 --- a/src/node_v8.cc +++ b/src/node_v8.cc @@ -157,7 +157,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 3f91b651b83a20e70d5b368e012f5ee4b9d16092..40c601acd752b559f7ffbc00c15728fbb5275ac5 100644 --- a/src/node_wasi.cc +++ b/src/node_wasi.cc @@ -49,7 +49,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); @@ -275,7 +275,7 @@ R WASI::WasiFunction::FastCallback( return EinvalError(); } - v8::Isolate* isolate = receiver->GetIsolate(); + v8::Isolate* isolate = v8::Isolate::GetCurrent(); v8::HandleScope handle_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 74ece724e207a69e2457598a199c12f1cebcfd4a..1705e430099c5a363e02010f83d729b0aa54f8e5 100644 --- a/src/node_webstorage.cc +++ b/src/node_webstorage.cc @@ -58,7 +58,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 = @@ -434,7 +434,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 8555ab556b5b74a1cf9cf30747f1f417bfe4e4d9..1a2532337504444d59098304b87e0d65f16e838c 100644 --- a/src/node_worker.cc +++ b/src/node_worker.cc @@ -1289,8 +1289,6 @@ 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(), - args.GetIsolate()); args.GetReturnValue().Set(port); } } diff --git a/src/timers.cc b/src/timers.cc index bf90e68479da141265f748775acacab513b8d437..5f0d07b4ac1d9b8df6c8bb059e5d07ac1a882b36 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-inl.h b/src/util-inl.h index b21f7a8260ca6a4701f8904b9cb641428db80772..16fe55f3054fd20544babd63ff204330cb47c1a7 100644 --- a/src/util-inl.h +++ b/src/util-inl.h @@ -326,14 +326,14 @@ v8::Maybe FromV8Array(v8::Local context, std::vector>* out) { uint32_t count = js_array->Length(); out->reserve(count); - ArrayIterationData data{out, context->GetIsolate()}; + ArrayIterationData data{out, v8::Isolate::GetCurrent()}; return js_array->Iterate(context, PushItemToVector, &data); } v8::MaybeLocal ToV8Value(v8::Local context, std::string_view str, v8::Isolate* isolate) { - if (isolate == nullptr) isolate = context->GetIsolate(); + if (isolate == nullptr) isolate = v8::Isolate::GetCurrent(); if (str.size() >= static_cast(v8::String::kMaxLength)) [[unlikely]] { // V8 only has a TODO comment about adding an exception when the maximum // string size is exceeded. @@ -349,7 +349,7 @@ v8::MaybeLocal ToV8Value(v8::Local context, v8::MaybeLocal ToV8Value(v8::Local context, v8_inspector::StringView str, v8::Isolate* isolate) { - if (isolate == nullptr) isolate = context->GetIsolate(); + if (isolate == nullptr) isolate = v8::Isolate::GetCurrent(); if (str.length() >= static_cast(v8::String::kMaxLength)) [[unlikely]] { // V8 only has a TODO comment about adding an exception when the maximum @@ -376,7 +376,7 @@ template v8::MaybeLocal ToV8Value(v8::Local context, const std::vector& vec, v8::Isolate* isolate) { - if (isolate == nullptr) isolate = context->GetIsolate(); + if (isolate == nullptr) isolate = v8::Isolate::GetCurrent(); v8::EscapableHandleScope handle_scope(isolate); MaybeStackBuffer, 128> arr(vec.size()); @@ -393,7 +393,7 @@ template v8::MaybeLocal ToV8Value(v8::Local context, const std::set& set, v8::Isolate* isolate) { - if (isolate == nullptr) isolate = context->GetIsolate(); + if (isolate == nullptr) isolate = v8::Isolate::GetCurrent(); v8::Local set_js = v8::Set::New(isolate); v8::HandleScope handle_scope(isolate); @@ -412,7 +412,7 @@ template v8::MaybeLocal ToV8Value(v8::Local context, const std::unordered_map& map, v8::Isolate* isolate) { - if (isolate == nullptr) isolate = context->GetIsolate(); + if (isolate == nullptr) isolate = v8::Isolate::GetCurrent(); v8::EscapableHandleScope handle_scope(isolate); v8::Local ret = v8::Map::New(isolate); @@ -455,7 +455,7 @@ template v8::MaybeLocal ToV8Value(v8::Local context, const T& number, v8::Isolate* isolate) { - if (isolate == nullptr) isolate = context->GetIsolate(); + if (isolate == nullptr) isolate = v8::Isolate::GetCurrent(); return ConvertNumberToV8Value(isolate, number); } @@ -468,7 +468,7 @@ v8::Local ToV8ValuePrimitiveArray(v8::Local context, std::is_floating_point_v, "Only primitive types (bool, integral, floating-point) are supported."); - if (isolate == nullptr) isolate = context->GetIsolate(); + if (isolate == nullptr) isolate = v8::Isolate::GetCurrent(); v8::EscapableHandleScope handle_scope(isolate); v8::LocalVector elements(isolate); diff --git a/src/util.cc b/src/util.cc index 5ca32f026f9f001ddadc14965705fe005600eddd..1b38f22b930b77d80aa53f9b12299d3cc469a46d 100644 --- a/src/util.cc +++ b/src/util.cc @@ -393,7 +393,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, @@ -454,7 +454,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, @@ -476,7 +476,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, @@ -564,7 +564,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, @@ -665,7 +665,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 7c98de621ca4d53cbaaa5bd4488aab20c7b033a7..329d2397c87ac37d157e3325e2ab62907d7286b4 100644 --- a/src/util.h +++ b/src/util.h @@ -756,7 +756,7 @@ inline v8::MaybeLocal ToV8Value(v8::Local context, // 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 = \