Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/api/environment.cc
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,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();
Expand Down Expand Up @@ -682,7 +682,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
Expand Down Expand Up @@ -761,7 +761,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`
Expand All @@ -786,7 +786,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.
Expand All @@ -804,7 +804,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);

Expand All @@ -828,7 +828,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);

Expand All @@ -854,7 +854,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;

Expand Down
2 changes: 1 addition & 1 deletion src/crypto/crypto_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -948,7 +948,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();

Expand Down
4 changes: 2 additions & 2 deletions src/crypto/crypto_x509.cc
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ MaybeLocal<Value> ToV8Value(Local<Context> context, BIOPointer&& bio) {
return {};
BUF_MEM* mem = bio;
Local<Value> ret;
if (!String::NewFromUtf8(context->GetIsolate(),
if (!String::NewFromUtf8(Isolate::GetCurrent(),
mem->data,
NewStringType::kNormal,
mem->length)
Expand All @@ -119,7 +119,7 @@ MaybeLocal<Value> ToV8Value(Local<Context> context, const BIOPointer& bio) {
return {};
BUF_MEM* mem = bio;
Local<Value> ret;
if (!String::NewFromUtf8(context->GetIsolate(),
if (!String::NewFromUtf8(Isolate::GetCurrent(),
mem->data,
NewStringType::kNormal,
mem->length)
Expand Down
2 changes: 1 addition & 1 deletion src/encoding_binding.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions src/env.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1750,10 +1750,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
Expand Down Expand Up @@ -1793,7 +1793,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;
Expand Down
34 changes: 17 additions & 17 deletions src/inspector/network_agent.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,31 +29,31 @@ using v8::Value;
Maybe<protocol::String> ObjectGetProtocolString(v8::Local<v8::Context> context,
Local<Object> object,
Local<v8::String> property) {
HandleScope handle_scope(context->GetIsolate());
HandleScope handle_scope(v8::Isolate::GetCurrent());
Local<Value> value;
if (!object->Get(context, property).ToLocal(&value) || !value->IsString()) {
return Nothing<protocol::String>();
}
Local<v8::String> str = value.As<v8::String>();
return Just(ToProtocolString(context->GetIsolate(), str));
return Just(ToProtocolString(v8::Isolate::GetCurrent(), str));
}

// Get a protocol string property from the object.
Maybe<protocol::String> ObjectGetProtocolString(v8::Local<v8::Context> context,
Local<Object> 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<double> ObjectGetDouble(v8::Local<v8::Context> context,
Local<Object> object,
const char* property) {
HandleScope handle_scope(context->GetIsolate());
HandleScope handle_scope(v8::Isolate::GetCurrent());
Local<Value> value;
if (!object->Get(context, OneByteString(context->GetIsolate(), property))
if (!object->Get(context, OneByteString(v8::Isolate::GetCurrent(), property))
.ToLocal(&value) ||
!value->IsNumber()) {
return Nothing<double>();
Expand All @@ -65,9 +65,9 @@ Maybe<double> ObjectGetDouble(v8::Local<v8::Context> context,
Maybe<int> ObjectGetInt(v8::Local<v8::Context> context,
Local<Object> object,
const char* property) {
HandleScope handle_scope(context->GetIsolate());
HandleScope handle_scope(v8::Isolate::GetCurrent());
Local<Value> value;
if (!object->Get(context, OneByteString(context->GetIsolate(), property))
if (!object->Get(context, OneByteString(v8::Isolate::GetCurrent(), property))
.ToLocal(&value) ||
!value->IsInt32()) {
return Nothing<int>();
Expand All @@ -79,9 +79,9 @@ Maybe<int> ObjectGetInt(v8::Local<v8::Context> context,
Maybe<bool> ObjectGetBool(v8::Local<v8::Context> context,
Local<Object> object,
const char* property) {
HandleScope handle_scope(context->GetIsolate());
HandleScope handle_scope(v8::Isolate::GetCurrent());
Local<Value> value;
if (!object->Get(context, OneByteString(context->GetIsolate(), property))
if (!object->Get(context, OneByteString(v8::Isolate::GetCurrent(), property))
.ToLocal(&value) ||
!value->IsBoolean()) {
return Nothing<bool>();
Expand All @@ -93,9 +93,9 @@ Maybe<bool> ObjectGetBool(v8::Local<v8::Context> context,
MaybeLocal<v8::Object> ObjectGetObject(v8::Local<v8::Context> context,
Local<Object> object,
const char* property) {
EscapableHandleScope handle_scope(context->GetIsolate());
EscapableHandleScope handle_scope(v8::Isolate::GetCurrent());
Local<Value> value;
if (!object->Get(context, OneByteString(context->GetIsolate(), property))
if (!object->Get(context, OneByteString(v8::Isolate::GetCurrent(), property))
.ToLocal(&value) ||
!value->IsObject()) {
return {};
Expand All @@ -106,7 +106,7 @@ MaybeLocal<v8::Object> ObjectGetObject(v8::Local<v8::Context> context,
// Create a protocol::Network::Headers from the v8 object.
std::unique_ptr<protocol::Network::Headers> createHeadersFromObject(
v8::Local<v8::Context> context, Local<Object> headers_obj) {
HandleScope handle_scope(context->GetIsolate());
HandleScope handle_scope(v8::Isolate::GetCurrent());

std::unique_ptr<protocol::DictionaryValue> dict =
protocol::DictionaryValue::create();
Expand All @@ -127,7 +127,7 @@ std::unique_ptr<protocol::Network::Headers> createHeadersFromObject(
.To(&property_value)) {
return {};
}
dict->setString(ToProtocolString(context->GetIsolate(), property_name),
dict->setString(ToProtocolString(v8::Isolate::GetCurrent(), property_name),
property_value);
}

Expand All @@ -137,7 +137,7 @@ std::unique_ptr<protocol::Network::Headers> createHeadersFromObject(
// Create a protocol::Network::Request from the v8 object.
std::unique_ptr<protocol::Network::Request> createRequestFromObject(
v8::Local<v8::Context> context, Local<Object> request) {
HandleScope handle_scope(context->GetIsolate());
HandleScope handle_scope(v8::Isolate::GetCurrent());
protocol::String url;
if (!ObjectGetProtocolString(context, request, "url").To(&url)) {
return {};
Expand Down Expand Up @@ -169,7 +169,7 @@ std::unique_ptr<protocol::Network::Request> createRequestFromObject(
// Create a protocol::Network::Response from the v8 object.
std::unique_ptr<protocol::Network::Response> createResponseFromObject(
v8::Local<v8::Context> context, Local<Object> response) {
HandleScope handle_scope(context->GetIsolate());
HandleScope handle_scope(v8::Isolate::GetCurrent());
protocol::String url;
if (!ObjectGetProtocolString(context, response, "url").To(&url)) {
return {};
Expand Down Expand Up @@ -210,7 +210,7 @@ std::unique_ptr<protocol::Network::Response> createResponseFromObject(

std::unique_ptr<protocol::Network::WebSocketResponse> createWebSocketResponse(
v8::Local<v8::Context> context, Local<Object> response) {
HandleScope handle_scope(context->GetIsolate());
HandleScope handle_scope(v8::Isolate::GetCurrent());
int status;
if (!ObjectGetInt(context, response, "status").To(&status)) {
return {};
Expand Down
2 changes: 1 addition & 1 deletion src/js_native_api_v8.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
14 changes: 7 additions & 7 deletions src/module_wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,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;
Expand Down Expand Up @@ -178,7 +178,7 @@ ModuleWrap* ModuleWrap::GetLinkedRequest(uint32_t index) {
object()->GetInternalField(kLinkedRequestsSlot);
DCHECK(linked_requests_data->IsValue() &&
linked_requests_data.As<Value>()->IsArray());
Local<Array> requests = linked_requests_data.As<Array>();
Local<Array> requests = linked_requests_data.As<Value>().As<Array>();

CHECK_LT(index, requests->Length());

Expand Down Expand Up @@ -1000,7 +1000,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
Expand All @@ -1024,7 +1024,7 @@ MaybeLocal<Object> ModuleWrap::ResolveSourceCallback(
Local<String> url = resolved_module->object()
->GetInternalField(ModuleWrap::kURLSlot)
.As<String>();
THROW_ERR_SOURCE_PHASE_NOT_DEFINED(context->GetIsolate(), url);
THROW_ERR_SOURCE_PHASE_NOT_DEFINED(Isolate::GetCurrent(), url);
return {};
}
CHECK(module_source_object->IsObject());
Expand All @@ -1037,7 +1037,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);
Expand Down Expand Up @@ -1082,7 +1082,7 @@ static 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);
Expand Down Expand Up @@ -1321,7 +1321,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);
Expand Down
4 changes: 2 additions & 2 deletions src/node.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<v8::Context> context = isolate->GetCurrentContext(); \
v8::Local<v8::String> constant_name = v8::String::NewFromUtf8Literal( \
isolate, #constant, v8::NewStringType::kInternalized); \
Expand All @@ -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<v8::Context> context = isolate->GetCurrentContext(); \
v8::Local<v8::String> constant_name = v8::String::NewFromUtf8Literal( \
isolate, #constant, v8::NewStringType::kInternalized); \
Expand Down
2 changes: 1 addition & 1 deletion src/node_blob.cc
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,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);
Expand Down
12 changes: 6 additions & 6 deletions src/node_builtins.cc
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ MaybeLocal<Function> BuiltinLoader::LookupAndCompileInternal(
const char* id,
LocalVector<String>* parameters,
Realm* optional_realm) {
Isolate* isolate = context->GetIsolate();
Isolate* isolate = Isolate::GetCurrent();
EscapableHandleScope scope(isolate);

Local<String> source;
Expand Down Expand Up @@ -396,7 +396,7 @@ void BuiltinLoader::SaveCodeCache(const char* id, Local<Function> fun) {
MaybeLocal<Function> BuiltinLoader::LookupAndCompile(Local<Context> context,
const char* id,
Realm* optional_realm) {
Isolate* isolate = context->GetIsolate();
Isolate* isolate = Isolate::GetCurrent();
LocalVector<String> parameters(isolate);
// Detects parameters of the scripts based on module ids.
// internal/bootstrap/realm: process, getLinkedBinding,
Expand Down Expand Up @@ -450,7 +450,7 @@ MaybeLocal<Function> BuiltinLoader::LookupAndCompile(Local<Context> context,
MaybeLocal<Value> BuiltinLoader::CompileAndCall(Local<Context> 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
Expand Down Expand Up @@ -506,7 +506,7 @@ MaybeLocal<Value> BuiltinLoader::CompileAndCall(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);
}

Expand Down Expand Up @@ -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.
Expand Down
Loading
Loading