mirror of
https://github.com/electron/electron.git
synced 2026-10-28 11:44:46 +08:00
* chore: bump node in DEPS to v24.22.0 * fix(patch): enable the V8 sandbox in shared-cage builds Upstream now enables the V8 sandbox only for shared-cage builds. Keep Electron's behaviour of enabling it whenever pointer compression is on, matching Chromium's V8. The unofficial.gni x86 hunk landed upstream. Ref: https://github.com/nodejs/node/pull/62237 Ref: https://github.com/nodejs/node/pull/65491 * fix(patch): use names for asymmetric key algorithms Upstream dropped the BoringSSL guard in DhKeyGenTraits::Setup(), removed ReadASN1Element() from ncrypto, and no longer includes <openssl/evp.h> from env.h, so those hunks are no longer needed. Ref: https://github.com/nodejs/node/pull/65966 Ref: https://github.com/nodejs/node/pull/66108 Ref: https://github.com/nodejs/node/pull/65484 * fix(patch): skip RSA-PSS keygen deprecation tests with BoringSSL The skip is now upstream. Ref: https://github.com/nodejs/node/pull/65808 * fix(patch): detach cppgc wrappers from their Realm before it is freed Upstream's CppgcWrapperList::Cleanup() now pops nodes itself and the wrapper owns and frees its list node, so the local PopFront/delete hunk is dropped. Ref: https://github.com/nodejs/node/pull/65778 * fix(patch): gate jspi flag on V8_ENABLE_WEBASSEMBLY Ref: https://github.com/nodejs/node/pull/66082 * chore: remove upstreamed patches - https://github.com/nodejs/node/pull/63985 - https://github.com/nodejs/node/pull/65630 - https://github.com/nodejs/node/pull/64453 - https://github.com/nodejs/node/pull/65778 * chore: update patches (trivial only) * chore: update filenames.auto.gni * fix(patch): discover hashes from OpenSSL providers ncrypto's DigestCache::aliases() now has a function-local static, so ncrypto needs the no_exit_time_destructors config too. Ref: https://github.com/nodejs/node/pull/65484 * fix(patch): read the peer certificate chain without consuming it sk_X509_num() returns size_t in BoringSSL. Ref: https://github.com/nodejs/node/pull/65602 * fix(patch): fix shared buffer growability validation Ref: https://github.com/nodejs/node/pull/65845 * chore: update patches (trivial only) * node#65820: src: fix null pointer call when running without a startup snapshot SnapshotData::AsEmbedderWrapper() was removed. Both call sites wrap the embedded snapshot, so use EmbedderSnapshotData::BuiltinSnapshotData(). Ref: https://github.com/nodejs/node/pull/65820 * node#65407: src: apply IsolateSettings when using a snapshot node::CreateEnvironment() no longer installs the per-isolate message listener when it builds the environment from a snapshot, so stop compensating for that and let SetIsolateUpForNode() add it. Ref: https://github.com/nodejs/node/pull/65407 * test: drop removed wasm rab integration flag from webidl buffer source test Chromium's V8 removed --experimental-wasm-rab-integration after shipping it; the new test-internal-webidl-buffer-source.js passes it. Ref: https://github.com/nodejs/node/pull/65845 Ref: https://chromium-review.googlesource.com/c/v8/v8/+/7708297 * test: skip new rmSync permission error test when the Node suite runs as root test-fs-rmSync-special-char-additional-error.js is new in v24.22.0 and relies on a read-only directory blocking removal, which root bypasses; the Linux Node.js test job runs as root. Ref: https://github.com/nodejs/node/pull/64453 --------- Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com> Co-authored-by: Sam Attard <sattard@anthropic.com>
880 lines
42 KiB
Diff
880 lines
42 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: deepak1556 <hop2deep@gmail.com>
|
|
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 312a857537867e408fe2bd1b1a0d1061c41ccf3b..51b7607854b77ceeb3f9e977ce15594cdb4eaeca 100644
|
|
--- a/src/api/environment.cc
|
|
+++ b/src/api/environment.cc
|
|
@@ -810,7 +810,7 @@ std::unique_ptr<MultiIsolatePlatform> MultiIsolatePlatform::Create(
|
|
|
|
MaybeLocal<Object> GetPerContextExports(Local<Context> context,
|
|
IsolateData* isolate_data) {
|
|
- Isolate* isolate = context->GetIsolate();
|
|
+ Isolate* isolate = Isolate::GetCurrent();
|
|
EscapableHandleScope handle_scope(isolate);
|
|
|
|
Local<Object> global = context->Global();
|
|
@@ -856,7 +856,7 @@ void ProtoThrower(const FunctionCallbackInfo<Value>& info) {
|
|
// This runs at runtime, regardless of whether the context
|
|
// is created from a snapshot.
|
|
Maybe<void> InitializeContextRuntime(Local<Context> context) {
|
|
- Isolate* isolate = context->GetIsolate();
|
|
+ Isolate* isolate = Isolate::GetCurrent();
|
|
HandleScope handle_scope(isolate);
|
|
|
|
// When `IsCodeGenerationFromStringsAllowed` is true, V8 takes the fast path
|
|
@@ -935,7 +935,7 @@ Maybe<void> InitializeContextRuntime(Local<Context> context) {
|
|
}
|
|
|
|
Maybe<void> InitializeBaseContextForSnapshot(Local<Context> context) {
|
|
- Isolate* isolate = context->GetIsolate();
|
|
+ Isolate* isolate = Isolate::GetCurrent();
|
|
HandleScope handle_scope(isolate);
|
|
|
|
// Delete `Intl.v8BreakIterator`
|
|
@@ -960,7 +960,7 @@ Maybe<void> InitializeBaseContextForSnapshot(Local<Context> context) {
|
|
}
|
|
|
|
Maybe<void> InitializeMainContextForSnapshot(Local<Context> context) {
|
|
- Isolate* isolate = context->GetIsolate();
|
|
+ Isolate* isolate = Isolate::GetCurrent();
|
|
HandleScope handle_scope(isolate);
|
|
|
|
// Initialize the default values.
|
|
@@ -978,7 +978,7 @@ Maybe<void> InitializeMainContextForSnapshot(Local<Context> context) {
|
|
MaybeLocal<Object> InitializePrivateSymbols(Local<Context> context,
|
|
IsolateData* isolate_data) {
|
|
CHECK(isolate_data);
|
|
- Isolate* isolate = context->GetIsolate();
|
|
+ Isolate* isolate = Isolate::GetCurrent();
|
|
EscapableHandleScope scope(isolate);
|
|
Context::Scope context_scope(context);
|
|
|
|
@@ -1002,7 +1002,7 @@ MaybeLocal<Object> InitializePrivateSymbols(Local<Context> context,
|
|
MaybeLocal<Object> InitializePerIsolateSymbols(Local<Context> context,
|
|
IsolateData* isolate_data) {
|
|
CHECK(isolate_data);
|
|
- Isolate* isolate = context->GetIsolate();
|
|
+ Isolate* isolate = Isolate::GetCurrent();
|
|
EscapableHandleScope scope(isolate);
|
|
Context::Scope context_scope(context);
|
|
|
|
@@ -1028,7 +1028,7 @@ MaybeLocal<Object> InitializePerIsolateSymbols(Local<Context> context,
|
|
Maybe<void> InitializePrimordials(Local<Context> context,
|
|
IsolateData* isolate_data) {
|
|
// Run per-context JS files.
|
|
- Isolate* isolate = context->GetIsolate();
|
|
+ Isolate* isolate = Isolate::GetCurrent();
|
|
Context::Scope context_scope(context);
|
|
Local<Object> exports;
|
|
|
|
diff --git a/src/base_object-inl.h b/src/base_object-inl.h
|
|
index cc60ddddb037e0279615bbe24821eb20fd8da677..37d83e41b618a07aca98118260abe9618f11256d 100644
|
|
--- a/src/base_object-inl.h
|
|
+++ b/src/base_object-inl.h
|
|
@@ -55,7 +55,6 @@ v8::Local<v8::Object> BaseObject::object() const {
|
|
v8::Local<v8::Object> BaseObject::object(v8::Isolate* isolate) const {
|
|
v8::Local<v8::Object> 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 114b0c920882dd267f057c6414563c57e91eb236..ec217aadc4a34ce09742c3b9490634727f387c1d 100644
|
|
--- a/src/crypto/crypto_context.cc
|
|
+++ b/src/crypto/crypto_context.cc
|
|
@@ -1174,7 +1174,7 @@ bool ArrayOfStringsToX509s(Local<Context> context,
|
|
Local<Array> cert_array,
|
|
std::vector<X509*>* 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 1bf003f830812664ad903dbdfe30366835767c0b..337cd5899f9ced88e9d2eda61ba194b7f70b910a 100644
|
|
--- a/src/crypto/crypto_x509.cc
|
|
+++ b/src/crypto/crypto_x509.cc
|
|
@@ -109,7 +109,7 @@ MaybeLocal<Value> ToV8Value(Local<Context> context, BIOPointer&& bio) {
|
|
if (!mem) [[unlikely]]
|
|
return {};
|
|
Local<Value> ret;
|
|
- if (!String::NewFromUtf8(context->GetIsolate(),
|
|
+ if (!String::NewFromUtf8(Isolate::GetCurrent(),
|
|
mem->data,
|
|
NewStringType::kNormal,
|
|
mem->length)
|
|
@@ -125,7 +125,7 @@ MaybeLocal<Value> ToV8Value(Local<Context> context, const BIOPointer& bio) {
|
|
if (!mem) [[unlikely]]
|
|
return {};
|
|
Local<Value> 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 31277621e92b4d3583a67140f4ab8a74a9c6df3b..caa109871b71926f3355491767b8064b50cb7e19 100644
|
|
--- a/src/encoding_binding.cc
|
|
+++ b/src/encoding_binding.cc
|
|
@@ -76,7 +76,7 @@ void BindingData::Deserialize(Local<Context> 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<InternalFieldInfo*>(info);
|
|
diff --git a/src/env.cc b/src/env.cc
|
|
index 7674b06f7018020f87c32316a66eebc04720ab5e..efda30eb1fb1c18bafd64eed46a6fc72e806a02b 100644
|
|
--- a/src/env.cc
|
|
+++ b/src/env.cc
|
|
@@ -1935,10 +1935,10 @@ void AsyncHooks::Deserialize(Local<Context> context) {
|
|
context->GetDataFromSnapshotOnce<Array>(
|
|
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
|
|
@@ -1978,7 +1978,7 @@ AsyncHooks::SerializeInfo AsyncHooks::Serialize(Local<Context> 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 a19c9ec16375ced6569ed5973b9cd72ff5d14171..036c21f0eb50d0da3027e2c7bb2fd00c55ab67df 100644
|
|
--- a/src/inspector/network_agent.cc
|
|
+++ b/src/inspector/network_agent.cc
|
|
@@ -33,8 +33,8 @@ static void ThrowEventError(v8::Isolate* isolate, const std::string& message) {
|
|
std::unique_ptr<protocol::Network::Headers>
|
|
NetworkAgent::createHeadersFromObject(v8::Local<v8::Context> context,
|
|
Local<Object> headers_obj) {
|
|
- HandleScope handle_scope(context->GetIsolate());
|
|
Isolate* isolate = env_->isolate();
|
|
+ HandleScope handle_scope(isolate);
|
|
|
|
std::unique_ptr<protocol::DictionaryValue> dict =
|
|
protocol::DictionaryValue::create();
|
|
@@ -58,7 +58,7 @@ NetworkAgent::createHeadersFromObject(v8::Local<v8::Context> context,
|
|
ThrowEventError(isolate, "Invalid header value in event");
|
|
return {};
|
|
}
|
|
- dict->setString(ToProtocolString(context->GetIsolate(), property_name),
|
|
+ dict->setString(ToProtocolString(v8::Isolate::GetCurrent(), property_name),
|
|
property_value);
|
|
}
|
|
|
|
@@ -69,8 +69,8 @@ NetworkAgent::createHeadersFromObject(v8::Local<v8::Context> context,
|
|
std::unique_ptr<protocol::Network::Request>
|
|
NetworkAgent::createRequestFromObject(v8::Local<v8::Context> context,
|
|
Local<Object> request) {
|
|
- HandleScope handle_scope(context->GetIsolate());
|
|
Isolate* isolate = env_->isolate();
|
|
+ HandleScope handle_scope(isolate);
|
|
protocol::String url;
|
|
if (!ObjectGetProtocolString(context, request, "url").To(&url)) {
|
|
ThrowEventError(isolate, "Missing request.url in event");
|
|
@@ -106,8 +106,8 @@ NetworkAgent::createRequestFromObject(v8::Local<v8::Context> context,
|
|
std::unique_ptr<protocol::Network::Response>
|
|
NetworkAgent::createResponseFromObject(v8::Local<v8::Context> context,
|
|
Local<Object> response) {
|
|
- HandleScope handle_scope(context->GetIsolate());
|
|
Isolate* isolate = env_->isolate();
|
|
+ HandleScope handle_scope(isolate);
|
|
protocol::String url;
|
|
if (!ObjectGetProtocolString(context, response, "url").To(&url)) {
|
|
ThrowEventError(isolate, "Missing response.url in event");
|
|
@@ -153,8 +153,8 @@ NetworkAgent::createResponseFromObject(v8::Local<v8::Context> context,
|
|
std::unique_ptr<protocol::Network::WebSocketResponse>
|
|
NetworkAgent::createWebSocketResponse(v8::Local<v8::Context> context,
|
|
Local<Object> response) {
|
|
- HandleScope handle_scope(context->GetIsolate());
|
|
Isolate* isolate = env_->isolate();
|
|
+ HandleScope handle_scope(isolate);
|
|
int status;
|
|
if (!ObjectGetInt(context, response, "status").To(&status)) {
|
|
ThrowEventError(isolate, "Missing response.status in event");
|
|
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<v8::Context> 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 fbcf8f0f99ccaac583040e1ecebcbf65bd03cfa6..6934e3ca3751091e6ebc7802dabf8b50fd9f6355 100644
|
|
--- a/src/module_wrap.cc
|
|
+++ b/src/module_wrap.cc
|
|
@@ -99,7 +99,7 @@ ModuleCacheKey ModuleCacheKey::From(Local<Context> context,
|
|
Local<String> specifier,
|
|
Local<FixedArray> 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;
|
|
@@ -1008,7 +1008,7 @@ MaybeLocal<Module> ModuleWrap::ResolveModuleCallback(
|
|
return {};
|
|
}
|
|
DCHECK_NOT_NULL(resolved_module);
|
|
- return resolved_module->module_.Get(context->GetIsolate());
|
|
+ return resolved_module->module_.Get(Isolate::GetCurrent());
|
|
}
|
|
|
|
// static
|
|
@@ -1029,7 +1029,7 @@ MaybeLocal<Object> ModuleWrap::ResolveSourceCallback(
|
|
->GetInternalField(ModuleWrap::kModuleSourceObjectSlot)
|
|
.As<Value>();
|
|
if (module_source_object->IsUndefined()) {
|
|
- THROW_ERR_SOURCE_PHASE_NOT_DEFINED(context->GetIsolate(),
|
|
+ THROW_ERR_SOURCE_PHASE_NOT_DEFINED(Isolate::GetCurrent(),
|
|
resolved_module->url_);
|
|
return {};
|
|
}
|
|
@@ -1043,7 +1043,7 @@ Maybe<ModuleWrap*> ModuleWrap::ResolveModule(
|
|
Local<String> specifier,
|
|
Local<FixedArray> import_attributes,
|
|
Local<Module> referrer) {
|
|
- Isolate* isolate = context->GetIsolate();
|
|
+ Isolate* isolate = Isolate::GetCurrent();
|
|
Environment* env = Environment::GetCurrent(context);
|
|
if (env == nullptr) {
|
|
THROW_ERR_EXECUTION_ENVIRONMENT_NOT_AVAILABLE(isolate);
|
|
@@ -1092,7 +1092,7 @@ MaybeLocal<Promise> ImportModuleDynamicallyWithPhase(
|
|
Local<String> specifier,
|
|
ModuleImportPhase phase,
|
|
Local<FixedArray> 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);
|
|
@@ -1334,7 +1334,7 @@ MaybeLocal<Module> LinkRequireFacadeWithOriginal(
|
|
Local<FixedArray> import_attributes,
|
|
Local<Module> 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 564ba432f023ea0575bba72e1a17816faf4d830c..ff11c2ef06a720df01bbdd784746066a7c23ee5b 100644
|
|
--- a/src/node.h
|
|
+++ b/src/node.h
|
|
@@ -1168,7 +1168,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<v8::Context> context = isolate->GetCurrentContext(); \
|
|
v8::Local<v8::String> constant_name = v8::String::NewFromUtf8Literal( \
|
|
isolate, #constant, v8::NewStringType::kInternalized); \
|
|
@@ -1184,7 +1184,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<v8::Context> context = isolate->GetCurrentContext(); \
|
|
v8::Local<v8::String> constant_name = v8::String::NewFromUtf8Literal( \
|
|
isolate, #constant, v8::NewStringType::kInternalized); \
|
|
diff --git a/src/node_blob.cc b/src/node_blob.cc
|
|
index ef148203713880ed3f56698613f9cd9c78ff1fb0..a04bc2be0ef5ab65ac39062de0549bb3e4b168c1 100644
|
|
--- a/src/node_blob.cc
|
|
+++ b/src/node_blob.cc
|
|
@@ -579,7 +579,7 @@ void BlobBindingData::Deserialize(Local<Context> 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<BlobBindingData>(holder);
|
|
CHECK_NOT_NULL(binding);
|
|
diff --git a/src/node_builtins.cc b/src/node_builtins.cc
|
|
index ab9f14174e7a16b2da17a9d5a00aa82318aac9b6..a4c62510ad9f8c2c77986ead1e17afd319adc496 100644
|
|
--- a/src/node_builtins.cc
|
|
+++ b/src/node_builtins.cc
|
|
@@ -279,7 +279,7 @@ MaybeLocal<Data> BuiltinLoader::LookupAndCompile(
|
|
Local<Context> context,
|
|
const BuiltinSource* builtin_source,
|
|
Realm* optional_realm) {
|
|
- Isolate* isolate = context->GetIsolate();
|
|
+ Isolate* isolate = Isolate::GetCurrent();
|
|
EscapableHandleScope scope(isolate);
|
|
|
|
BuiltinCodeCacheData cached_data{};
|
|
@@ -447,7 +447,7 @@ void BuiltinLoader::SaveCodeCache(const std::string& id, Local<Data> data) {
|
|
|
|
MaybeLocal<Function> BuiltinLoader::LookupAndCompileFunction(
|
|
Local<Context> context, const char* id, Realm* optional_realm) {
|
|
- Isolate* isolate = context->GetIsolate();
|
|
+ Isolate* isolate = Isolate::GetCurrent();
|
|
LocalVector<String> parameters(isolate);
|
|
|
|
Local<Data> data;
|
|
@@ -488,7 +488,7 @@ MaybeLocal<Function> BuiltinLoader::LookupAndCompileFunction(
|
|
MaybeLocal<Value> BuiltinLoader::CompileAndCall(Local<Context> context,
|
|
const char* id,
|
|
Realm* realm) {
|
|
- Isolate* isolate = context->GetIsolate();
|
|
+ Isolate* isolate = Isolate::GetCurrent();
|
|
const BuiltinSource* builtin_source = LoadBuiltinSource(isolate, id);
|
|
if (builtin_source == nullptr) {
|
|
THROW_ERR_MODULE_NOT_FOUND(isolate, "Cannot find module %s", id);
|
|
@@ -560,7 +560,7 @@ MaybeLocal<Value> BuiltinLoader::CompileAndCallWith(Local<Context> context,
|
|
if (!maybe_fn.ToLocal(&fn)) {
|
|
return MaybeLocal<Value>();
|
|
}
|
|
- Local<Value> undefined = Undefined(context->GetIsolate());
|
|
+ Local<Value> undefined = Undefined(Isolate::GetCurrent());
|
|
return fn->Call(context, undefined, argc, argv);
|
|
}
|
|
|
|
@@ -584,14 +584,14 @@ bool BuiltinLoader::CompileAllBuiltinsAndCopyCodeCache(
|
|
to_eager_compile_.emplace(id);
|
|
}
|
|
|
|
- TryCatch bootstrapCatch(context->GetIsolate());
|
|
+ TryCatch bootstrapCatch(Isolate::GetCurrent());
|
|
auto data = LookupAndCompile(context, id.data(), nullptr);
|
|
if (bootstrapCatch.HasCaught()) {
|
|
per_process::Debug(DebugCategory::CODE_CACHE,
|
|
"Failed to compile code cache for %s\n",
|
|
id);
|
|
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 9abb643cc955a5f45b1edcd9340d4c25b3103ef2..7055aa4c367adc8724f1a51ff3c09a9b6beeac9e 100644
|
|
--- a/src/node_constants.cc
|
|
+++ b/src/node_constants.cc
|
|
@@ -1336,7 +1336,7 @@ void CreatePerContextProperties(Local<Object> target,
|
|
Local<Value> unused,
|
|
Local<Context> 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 211bc074161b5fd4ac6f2d9a23b201d79ae362ef..469c85642e995024b354abaa67dd865933867fc7 100644
|
|
--- a/src/node_contextify.cc
|
|
+++ b/src/node_contextify.cc
|
|
@@ -109,6 +109,8 @@ using v8::Value;
|
|
// For every `set` of a global property, the interceptor callback defines or
|
|
// changes the property both on the sandbox and the global proxy.
|
|
|
|
+
|
|
+
|
|
ContextifyContext* ContextifyContext::New(Environment* env,
|
|
Local<Object> sandbox_obj,
|
|
ContextOptions* options) {
|
|
@@ -686,7 +688,7 @@ Intercepted ContextifyContext::PropertyDefinerCallback(
|
|
DebugCategory::CONTEXTIFY, "PropertyDefiner(name: %s)\n", property);
|
|
|
|
Local<Context> context = ctx->context();
|
|
- Isolate* isolate = context->GetIsolate();
|
|
+ Isolate* isolate = Isolate::GetCurrent();
|
|
|
|
PropertyAttribute attributes = PropertyAttribute::None;
|
|
bool is_declared =
|
|
@@ -1668,7 +1670,7 @@ static MaybeLocal<Function> 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> symbol = env->vm_dynamic_import_default_internal();
|
|
diff --git a/src/node_env_var.cc b/src/node_env_var.cc
|
|
index 5550a4bee3ce9ec8759d216335a9b2b96e20c96e..b38c2f75a92f2d6c1b9c6e7b7aca924653f7494d 100644
|
|
--- a/src/node_env_var.cc
|
|
+++ b/src/node_env_var.cc
|
|
@@ -311,7 +311,7 @@ std::shared_ptr<KVStore> KVStore::CreateMapKVStore() {
|
|
|
|
Maybe<void> KVStore::AssignFromObject(Local<Context> context,
|
|
Local<Object> entries) {
|
|
- Isolate* isolate = context->GetIsolate();
|
|
+ Isolate* isolate = Isolate::GetCurrent();
|
|
HandleScope handle_scope(isolate);
|
|
Local<Array> keys;
|
|
if (!entries->GetOwnPropertyNames(context).ToLocal(&keys))
|
|
diff --git a/src/node_errors.cc b/src/node_errors.cc
|
|
index 9a7c89b22fe358808fbd9570c7239b4e040ab450..026ee86b455c327fbd5be3472cd504097bf0258b 100644
|
|
--- a/src/node_errors.cc
|
|
+++ b/src/node_errors.cc
|
|
@@ -654,7 +654,7 @@ v8::ModifyCodeGenerationFromStringsResult ModifyCodeGenerationFromStrings(
|
|
v8::Local<v8::Context> context,
|
|
v8::Local<v8::Value> source,
|
|
bool is_code_like) {
|
|
- HandleScope scope(context->GetIsolate());
|
|
+ HandleScope scope(Isolate::GetCurrent());
|
|
|
|
if (context->GetNumberOfEmbedderDataFields() <=
|
|
ContextEmbedderIndex::kAllowCodeGenerationFromStrings) {
|
|
@@ -1076,7 +1076,7 @@ const char* errno_string(int errorno) {
|
|
}
|
|
|
|
void PerIsolateMessageListener(Local<Message> message, Local<Value> error) {
|
|
- Isolate* isolate = message->GetIsolate();
|
|
+ Isolate* isolate = Isolate::GetCurrent();
|
|
switch (message->ErrorLevel()) {
|
|
case Isolate::MessageErrorLevel::kMessageWarning: {
|
|
Environment* env = Environment::GetCurrent(isolate);
|
|
@@ -1241,7 +1241,7 @@ void Initialize(Local<Object> target,
|
|
SetMethod(
|
|
context, target, "getErrorSourcePositions", GetErrorSourcePositions);
|
|
|
|
- Isolate* isolate = context->GetIsolate();
|
|
+ Isolate* isolate = Isolate::GetCurrent();
|
|
Local<Object> exit_codes = Object::New(isolate);
|
|
READONLY_PROPERTY(target, "exitCodes", exit_codes);
|
|
|
|
diff --git a/src/node_file.cc b/src/node_file.cc
|
|
index 78d98080323698dc619ebdffda7cb3849d4414bc..fb5aaa3ab08923bf9c1c4e767bad2881510633e8 100644
|
|
--- a/src/node_file.cc
|
|
+++ b/src/node_file.cc
|
|
@@ -4272,7 +4272,7 @@ void BindingData::Deserialize(Local<Context> 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<InternalFieldInfo*>(info);
|
|
BindingData* binding =
|
|
diff --git a/src/node_messaging.cc b/src/node_messaging.cc
|
|
index be7bbc85add91e730e3edc3cf19b73b27715b4c7..ea379c5200ed4c8c6358efd184682a8fab523977 100644
|
|
--- a/src/node_messaging.cc
|
|
+++ b/src/node_messaging.cc
|
|
@@ -254,7 +254,7 @@ namespace {
|
|
|
|
MaybeLocal<Function> GetEmitMessageFunction(Local<Context> context,
|
|
IsolateData* isolate_data) {
|
|
- Isolate* isolate = context->GetIsolate();
|
|
+ Isolate* isolate = Isolate::GetCurrent();
|
|
Local<Object> per_context_bindings;
|
|
Local<Value> emit_message_val;
|
|
if (!GetPerContextExports(context, isolate_data)
|
|
@@ -269,7 +269,7 @@ MaybeLocal<Function> GetEmitMessageFunction(Local<Context> context,
|
|
}
|
|
|
|
MaybeLocal<Function> GetDOMException(Local<Context> context) {
|
|
- Isolate* isolate = context->GetIsolate();
|
|
+ Isolate* isolate = Isolate::GetCurrent();
|
|
Local<Object> per_context_bindings;
|
|
Local<Value> domexception_ctor_val;
|
|
if (!GetPerContextExports(context).ToLocal(&per_context_bindings) ||
|
|
@@ -284,7 +284,7 @@ MaybeLocal<Function> GetDOMException(Local<Context> context) {
|
|
}
|
|
|
|
void ThrowDataCloneException(Local<Context> context, Local<String> message) {
|
|
- Isolate* isolate = context->GetIsolate();
|
|
+ Isolate* isolate = Isolate::GetCurrent();
|
|
Local<Value> argv[] = {message,
|
|
FIXED_ONE_BYTE_STRING(isolate, "DataCloneError")};
|
|
Local<Value> exception;
|
|
@@ -1482,7 +1482,7 @@ BaseObjectPtr<BaseObject> JSTransferable::Data::Deserialize(
|
|
|
|
Maybe<bool> JSTransferable::Data::FinalizeTransferWrite(
|
|
Local<Context> 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 fa5f5a7c0eed19a7d88bd9d0e7862dfe68303c5e..cc3880fc811f89dc97529be886df27809c7de85b 100644
|
|
--- a/src/node_modules.cc
|
|
+++ b/src/node_modules.cc
|
|
@@ -70,7 +70,7 @@ void BindingData::Deserialize(v8::Local<v8::Context> 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<BindingData>(holder);
|
|
CHECK_NOT_NULL(binding);
|
|
@@ -773,7 +773,7 @@ void BindingData::CreatePerContextProperties(Local<Object> target,
|
|
Realm* realm = Realm::GetCurrent(context);
|
|
realm->AddBindingData<BindingData>(target);
|
|
|
|
- Isolate* isolate = context->GetIsolate();
|
|
+ Isolate* isolate = Isolate::GetCurrent();
|
|
LocalVector<Value> compile_cache_status_values(isolate);
|
|
|
|
#define V(status) \
|
|
diff --git a/src/node_process_methods.cc b/src/node_process_methods.cc
|
|
index a33748d360c96368fa623b31ef0711eaaa04267f..d4dd93d084d5e58f0c18ef82a51d25be4643ba7a 100644
|
|
--- a/src/node_process_methods.cc
|
|
+++ b/src/node_process_methods.cc
|
|
@@ -746,7 +746,7 @@ void BindingData::Deserialize(Local<Context> 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<InternalFieldInfo*>(info);
|
|
diff --git a/src/node_realm.cc b/src/node_realm.cc
|
|
index 05c37067124898c306ae4eadb986cf038284730c..4444b7d6c52dff2d5ea4c5509df7d932789c8e3a 100644
|
|
--- a/src/node_realm.cc
|
|
+++ b/src/node_realm.cc
|
|
@@ -20,7 +20,7 @@ using v8::TryCatch;
|
|
using v8::Value;
|
|
|
|
Realm::Realm(Environment* env, v8::Local<v8::Context> 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 04c5d415c3c67ef9eba962bc15e738f0df6a005a..b8bb41e88888e426689298a611fc87cb3d8e0caf 100644
|
|
--- a/src/node_report.cc
|
|
+++ b/src/node_report.cc
|
|
@@ -400,7 +400,7 @@ static void PrintJavaScriptErrorProperties(JSONWriter* writer,
|
|
if (!error.IsEmpty() && error->IsObject()) {
|
|
TryCatch try_catch(isolate);
|
|
Local<Object> error_obj = error.As<Object>();
|
|
- Local<Context> context = error_obj->GetIsolate()->GetCurrentContext();
|
|
+ Local<Context> context = Isolate::GetCurrent()->GetCurrentContext();
|
|
Local<Array> 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 1d0702ba59be0653b417afc8729306b307ca6272..e773fb1ed4e777667fa677b402b20d676e9af4a2 100644
|
|
--- a/src/node_snapshotable.cc
|
|
+++ b/src/node_snapshotable.cc
|
|
@@ -1675,7 +1675,7 @@ void BindingData::Deserialize(Local<Context> 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<InternalFieldInfo*>(info);
|
|
diff --git a/src/node_sqlite.cc b/src/node_sqlite.cc
|
|
index a0a13c3537e7ae95ae1bf535ec9b50b2469e78a5..f21c7deea5edd85198bb4c015af0d38b42e7d8c9 100644
|
|
--- a/src/node_sqlite.cc
|
|
+++ b/src/node_sqlite.cc
|
|
@@ -2886,7 +2886,7 @@ bool StatementSync::BindParams(const FunctionCallbackInfo<Value>& args) {
|
|
if (args[0]->IsObject() && !args[0]->IsArrayBufferView() &&
|
|
!args[0]->IsArrayBuffer() && !args[0]->IsSharedArrayBuffer()) {
|
|
Local<Object> obj = args[0].As<Object>();
|
|
- Local<Context> context = obj->GetIsolate()->GetCurrentContext();
|
|
+ Local<Context> context = Isolate::GetCurrent()->GetCurrentContext();
|
|
Local<Array> keys;
|
|
if (!obj->GetOwnPropertyNames(context).ToLocal(&keys)) {
|
|
return false;
|
|
diff --git a/src/node_task_queue.cc b/src/node_task_queue.cc
|
|
index d33ee3c26c111e53edf27e6368ca8f64ff30a349..f1c53c44f201b295888e7932c5e3e2b19cb9c319 100644
|
|
--- a/src/node_task_queue.cc
|
|
+++ b/src/node_task_queue.cc
|
|
@@ -48,7 +48,7 @@ void PromiseRejectCallback(PromiseRejectMessage message) {
|
|
static std::atomic<uint64_t> rejectionsHandledAfter{0};
|
|
|
|
Local<Promise> 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 7f32a83177f47af84edbdc981aea7445fe84958e..0c5c9e65136a9090ed4b2d817c81e2a900fe2958 100644
|
|
--- a/src/node_url.cc
|
|
+++ b/src/node_url.cc
|
|
@@ -107,7 +107,7 @@ void BindingData::Deserialize(Local<Context> 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<BindingData>(holder);
|
|
CHECK_NOT_NULL(binding);
|
|
diff --git a/src/node_v8.cc b/src/node_v8.cc
|
|
index 06164d7792f8a7450bf3283d57aa344937546ece..7e7fd72645e8f534623d3dd0cb832b933dce2b45 100644
|
|
--- a/src/node_v8.cc
|
|
+++ b/src/node_v8.cc
|
|
@@ -165,7 +165,7 @@ void BindingData::Deserialize(Local<Context> 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<InternalFieldInfo*>(info);
|
|
diff --git a/src/node_wasi.cc b/src/node_wasi.cc
|
|
index 370221d3cddc201180260ecb3a222bc831c91093..f5aff2f65fe6b9f48cf970ab3e7c57cfe4885f85 100644
|
|
--- a/src/node_wasi.cc
|
|
+++ b/src/node_wasi.cc
|
|
@@ -50,7 +50,7 @@ using v8::WasmMemoryObject;
|
|
static MaybeLocal<Value> WASIException(Local<Context> 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,8 +275,8 @@ R WASI::WasiFunction<FT, F, R, Args...>::FastCallback(
|
|
return EinvalError<R>();
|
|
}
|
|
|
|
- Isolate* isolate = receiver->GetIsolate();
|
|
- HandleScope scope(isolate);
|
|
+ Isolate* isolate = Isolate::GetCurrent();
|
|
+ HandleScope handle_scope(isolate);
|
|
if (wasi->memory_.IsEmpty()) {
|
|
THROW_ERR_WASI_NOT_STARTED(isolate);
|
|
return EinvalError<R>();
|
|
diff --git a/src/node_webstorage.cc b/src/node_webstorage.cc
|
|
index 9bebd4fb1b86b97df59aa2a04106c1916ca658bc..afd17511610cc0977874190aeca9e5e63e1db4e7 100644
|
|
--- a/src/node_webstorage.cc
|
|
+++ b/src/node_webstorage.cc
|
|
@@ -60,7 +60,7 @@ using v8::Value;
|
|
} while (0)
|
|
|
|
static void ThrowQuotaExceededException(Local<Context> 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 =
|
|
@@ -468,6 +468,8 @@ Maybe<void> Storage::Store(Local<Name> key, Local<Value> value) {
|
|
return JustVoid();
|
|
}
|
|
|
|
+
|
|
+
|
|
static void Clear(const FunctionCallbackInfo<Value>& info) {
|
|
Storage* storage;
|
|
ASSIGN_OR_RETURN_UNWRAP(&storage, info.This());
|
|
diff --git a/src/node_worker.cc b/src/node_worker.cc
|
|
index b45ee62d0e13d24c013102ca2b463a2517d92907..91949db98400298ae7a770a76c387fcf2b388571 100644
|
|
--- a/src/node_worker.cc
|
|
+++ b/src/node_worker.cc
|
|
@@ -1459,8 +1459,6 @@ void GetEnvMessagePort(const FunctionCallbackInfo<Value>& args) {
|
|
Local<Object> 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 da4206187f7c7d2becb8a101c1ff5346a10e13f4..03f0910926f3d403121e227cee32a546b2394e04 100644
|
|
--- a/src/timers.cc
|
|
+++ b/src/timers.cc
|
|
@@ -114,7 +114,7 @@ void BindingData::Deserialize(Local<Context> 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<BindingData>(holder);
|
|
diff --git a/src/util-inl.h b/src/util-inl.h
|
|
index f42c7b1250d1eb2e4d9f8e10c5ea9a9ca310924b..d59e30a635b08b97d255ed2e5540a66db54b068f 100644
|
|
--- a/src/util-inl.h
|
|
+++ b/src/util-inl.h
|
|
@@ -337,14 +337,14 @@ v8::Maybe<void> FromV8Array(v8::Local<v8::Context> context,
|
|
std::vector<v8::Global<v8::Value>>* 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<v8::Value> ToV8Value(v8::Local<v8::Context> 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<size_t>(v8::String::kMaxLength)) [[unlikely]] {
|
|
// V8 only has a TODO comment about adding an exception when the maximum
|
|
// string size is exceeded.
|
|
@@ -360,7 +360,7 @@ v8::MaybeLocal<v8::Value> ToV8Value(v8::Local<v8::Context> context,
|
|
v8::MaybeLocal<v8::Value> ToV8Value(v8::Local<v8::Context> context,
|
|
std::u16string_view str,
|
|
v8::Isolate* isolate) {
|
|
- if (isolate == nullptr) isolate = context->GetIsolate();
|
|
+ if (isolate == nullptr) isolate = v8::Isolate::GetCurrent();
|
|
if (str.length() >= static_cast<size_t>(v8::String::kMaxLength))
|
|
[[unlikely]] {
|
|
// V8 only has a TODO comment about adding an exception when the maximum
|
|
@@ -380,7 +380,7 @@ v8::MaybeLocal<v8::Value> ToV8Value(v8::Local<v8::Context> context,
|
|
v8::MaybeLocal<v8::Value> ToV8Value(v8::Local<v8::Context> 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<size_t>(v8::String::kMaxLength))
|
|
[[unlikely]] {
|
|
// V8 only has a TODO comment about adding an exception when the maximum
|
|
@@ -407,7 +407,7 @@ template <typename T>
|
|
v8::MaybeLocal<v8::Value> ToV8Value(v8::Local<v8::Context> context,
|
|
const std::vector<T>& vec,
|
|
v8::Isolate* isolate) {
|
|
- if (isolate == nullptr) isolate = context->GetIsolate();
|
|
+ if (isolate == nullptr) isolate = v8::Isolate::GetCurrent();
|
|
v8::EscapableHandleScope handle_scope(isolate);
|
|
|
|
MaybeStackBuffer<v8::Local<v8::Value>, 128> arr(vec.size());
|
|
@@ -424,7 +424,7 @@ template <typename T>
|
|
v8::MaybeLocal<v8::Value> ToV8Value(v8::Local<v8::Context> context,
|
|
const std::set<T>& set,
|
|
v8::Isolate* isolate) {
|
|
- if (isolate == nullptr) isolate = context->GetIsolate();
|
|
+ if (isolate == nullptr) isolate = v8::Isolate::GetCurrent();
|
|
v8::Local<v8::Set> set_js = v8::Set::New(isolate);
|
|
v8::HandleScope handle_scope(isolate);
|
|
|
|
@@ -443,7 +443,7 @@ template <typename T, std::size_t U>
|
|
v8::MaybeLocal<v8::Value> ToV8Value(v8::Local<v8::Context> context,
|
|
const std::ranges::elements_view<T, U>& vec,
|
|
v8::Isolate* isolate) {
|
|
- if (isolate == nullptr) isolate = context->GetIsolate();
|
|
+ if (isolate == nullptr) isolate = v8::Isolate::GetCurrent();
|
|
v8::EscapableHandleScope handle_scope(isolate);
|
|
|
|
MaybeStackBuffer<v8::Local<v8::Value>, 128> arr(vec.size());
|
|
@@ -462,7 +462,7 @@ template <typename T, typename U>
|
|
v8::MaybeLocal<v8::Value> ToV8Value(v8::Local<v8::Context> context,
|
|
const std::unordered_map<T, U>& map,
|
|
v8::Isolate* isolate) {
|
|
- if (isolate == nullptr) isolate = context->GetIsolate();
|
|
+ if (isolate == nullptr) isolate = v8::Isolate::GetCurrent();
|
|
v8::EscapableHandleScope handle_scope(isolate);
|
|
|
|
v8::Local<v8::Map> ret = v8::Map::New(isolate);
|
|
@@ -505,7 +505,7 @@ template <typename T, typename>
|
|
v8::MaybeLocal<v8::Value> ToV8Value(v8::Local<v8::Context> context,
|
|
const T& number,
|
|
v8::Isolate* isolate) {
|
|
- if (isolate == nullptr) isolate = context->GetIsolate();
|
|
+ if (isolate == nullptr) isolate = v8::Isolate::GetCurrent();
|
|
return ConvertNumberToV8Value(isolate, number);
|
|
}
|
|
|
|
@@ -518,7 +518,7 @@ v8::Local<v8::Array> ToV8ValuePrimitiveArray(v8::Local<v8::Context> context,
|
|
std::is_floating_point_v<T>,
|
|
"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<v8::Value> elements(isolate);
|
|
@@ -811,7 +811,7 @@ inline v8::MaybeLocal<v8::Object> NewDictionaryInstanceNullProto(
|
|
if (value.IsEmpty()) return v8::MaybeLocal<v8::Object>();
|
|
}
|
|
v8::Local<v8::Object> obj = tmpl->NewInstance(context, property_values);
|
|
- if (obj->SetPrototypeV2(context, v8::Null(context->GetIsolate()))
|
|
+ if (obj->SetPrototypeV2(context, v8::Null(v8::Isolate::GetCurrent()))
|
|
.IsNothing()) {
|
|
return v8::MaybeLocal<v8::Object>();
|
|
}
|
|
diff --git a/src/util.cc b/src/util.cc
|
|
index 660cfff6b8a0c583be843e555e7a06cd09e0d279..c4b39450c5b7f91c46f7027db367c30db34927bb 100644
|
|
--- a/src/util.cc
|
|
+++ b/src/util.cc
|
|
@@ -391,7 +391,7 @@ void SetMethod(Local<v8::Context> context,
|
|
Local<v8::Object> that,
|
|
const std::string_view name,
|
|
v8::FunctionCallback callback) {
|
|
- Isolate* isolate = context->GetIsolate();
|
|
+ Isolate* isolate = Isolate::GetCurrent();
|
|
Local<v8::Function> function =
|
|
NewFunctionTemplate(isolate,
|
|
callback,
|
|
@@ -452,7 +452,7 @@ void SetFastMethod(Local<v8::Context> context,
|
|
const std::string_view name,
|
|
v8::FunctionCallback slow_callback,
|
|
const v8::CFunction* c_function) {
|
|
- Isolate* isolate = context->GetIsolate();
|
|
+ Isolate* isolate = Isolate::GetCurrent();
|
|
Local<v8::Function> function =
|
|
NewFunctionTemplate(isolate,
|
|
slow_callback,
|
|
@@ -474,7 +474,7 @@ void SetFastMethodNoSideEffect(Local<v8::Context> context,
|
|
const std::string_view name,
|
|
v8::FunctionCallback slow_callback,
|
|
const v8::CFunction* c_function) {
|
|
- Isolate* isolate = context->GetIsolate();
|
|
+ Isolate* isolate = Isolate::GetCurrent();
|
|
Local<v8::Function> function =
|
|
NewFunctionTemplate(isolate,
|
|
slow_callback,
|
|
@@ -562,7 +562,7 @@ void SetMethodNoSideEffect(Local<v8::Context> context,
|
|
Local<v8::Object> that,
|
|
const std::string_view name,
|
|
v8::FunctionCallback callback) {
|
|
- Isolate* isolate = context->GetIsolate();
|
|
+ Isolate* isolate = Isolate::GetCurrent();
|
|
Local<v8::Function> function =
|
|
NewFunctionTemplate(isolate,
|
|
callback,
|
|
@@ -689,7 +689,7 @@ void SetConstructorFunction(Local<v8::Context> context,
|
|
const char* name,
|
|
Local<v8::FunctionTemplate> 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 b61d98fd7669def0a378e2f7adc8d88428f18119..f59862fed6c02c209ad63f1a31bbae66ca9533dd 100644
|
|
--- a/src/util.h
|
|
+++ b/src/util.h
|
|
@@ -767,7 +767,7 @@ inline v8::MaybeLocal<v8::Value> 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<v8::String> constant_name = \
|
|
v8::String::NewFromUtf8(isolate, name).ToLocalChecked(); \
|
|
v8::Local<v8::String> constant_value = \
|