mirror of
https://github.com/zebrajr/node.git
synced 2025-12-06 00:20:08 +01:00
doc,src,test: replace use of deprecated GetIsolate
`Isolate::GetCurrent()` should be used instead as it returns the same
thing.
Refs: 5c4a937aaf
PR-URL: https://github.com/nodejs/node/pull/59805
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Richard Lau <richard.lau@ibm.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This commit is contained in:
parent
496f12dec6
commit
5623194a6b
|
|
@ -223,7 +223,7 @@ static void Method(const v8::FunctionCallbackInfo<v8::Value>& info) {
|
|||
|
||||
// Initialize this addon to be context-aware.
|
||||
NODE_MODULE_INIT(/* exports, module, context */) {
|
||||
Isolate* isolate = context->GetIsolate();
|
||||
Isolate* isolate = Isolate::GetCurrent();
|
||||
|
||||
// Create a new instance of `AddonData` for this instance of the addon and
|
||||
// tie its life cycle to that of the Node.js environment.
|
||||
|
|
@ -320,7 +320,7 @@ static void sanity_check(void*) {
|
|||
|
||||
// Initialize this addon to be context-aware.
|
||||
NODE_MODULE_INIT(/* exports, module, context */) {
|
||||
Isolate* isolate = context->GetIsolate();
|
||||
Isolate* isolate = Isolate::GetCurrent();
|
||||
|
||||
AddEnvironmentCleanupHook(isolate, sanity_check, nullptr);
|
||||
AddEnvironmentCleanupHook(isolate, cleanup_cb2, cookie);
|
||||
|
|
@ -879,7 +879,7 @@ MyObject::~MyObject() {
|
|||
}
|
||||
|
||||
void MyObject::Init(Local<Object> exports) {
|
||||
Isolate* isolate = exports->GetIsolate();
|
||||
Isolate* isolate = Isolate::GetCurrent();
|
||||
Local<Context> context = isolate->GetCurrentContext();
|
||||
|
||||
Local<ObjectTemplate> addon_data_tpl = ObjectTemplate::New(isolate);
|
||||
|
|
@ -1013,7 +1013,7 @@ void CreateObject(const FunctionCallbackInfo<Value>& args) {
|
|||
}
|
||||
|
||||
void InitAll(Local<Object> exports, Local<Object> module) {
|
||||
MyObject::Init(exports->GetIsolate());
|
||||
MyObject::Init();
|
||||
|
||||
NODE_SET_METHOD(module, "exports", CreateObject);
|
||||
}
|
||||
|
|
@ -1039,7 +1039,7 @@ namespace demo {
|
|||
|
||||
class MyObject : public node::ObjectWrap {
|
||||
public:
|
||||
static void Init(v8::Isolate* isolate);
|
||||
static void Init();
|
||||
static void NewInstance(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
|
||||
private:
|
||||
|
|
@ -1089,7 +1089,8 @@ MyObject::MyObject(double value) : value_(value) {
|
|||
MyObject::~MyObject() {
|
||||
}
|
||||
|
||||
void MyObject::Init(Isolate* isolate) {
|
||||
void MyObject::Init() {
|
||||
Isolate* isolate = Isolate::GetCurrent();
|
||||
// Prepare constructor template
|
||||
Local<FunctionTemplate> tpl = FunctionTemplate::New(isolate, New);
|
||||
tpl->SetClassName(String::NewFromUtf8(isolate, "MyObject").ToLocalChecked());
|
||||
|
|
@ -1235,7 +1236,7 @@ void Add(const FunctionCallbackInfo<Value>& args) {
|
|||
}
|
||||
|
||||
void InitAll(Local<Object> exports) {
|
||||
MyObject::Init(exports->GetIsolate());
|
||||
MyObject::Init();
|
||||
|
||||
NODE_SET_METHOD(exports, "createObject", CreateObject);
|
||||
NODE_SET_METHOD(exports, "add", Add);
|
||||
|
|
@ -1261,7 +1262,7 @@ namespace demo {
|
|||
|
||||
class MyObject : public node::ObjectWrap {
|
||||
public:
|
||||
static void Init(v8::Isolate* isolate);
|
||||
static void Init();
|
||||
static void NewInstance(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
inline double value() const { return value_; }
|
||||
|
||||
|
|
@ -1310,7 +1311,8 @@ MyObject::MyObject(double value) : value_(value) {
|
|||
MyObject::~MyObject() {
|
||||
}
|
||||
|
||||
void MyObject::Init(Isolate* isolate) {
|
||||
void MyObject::Init() {
|
||||
Isolate* isolate = Isolate::GetCurrent();
|
||||
// Prepare constructor template
|
||||
Local<FunctionTemplate> tpl = FunctionTemplate::New(isolate, New);
|
||||
tpl->SetClassName(String::NewFromUtf8(isolate, "MyObject").ToLocalChecked());
|
||||
|
|
|
|||
|
|
@ -94,9 +94,9 @@ Typical ways of accessing the current `Isolate` in the Node.js code are:
|
|||
|
||||
* Given a `FunctionCallbackInfo` for a [binding function][],
|
||||
using `args.GetIsolate()`.
|
||||
* Given a [`Context`][], using `context->GetIsolate()`.
|
||||
* Given a [`Environment`][], using `env->isolate()`.
|
||||
* Given a [`Realm`][], using `realm->isolate()`.
|
||||
* Calling `Isolate::GetCurrent()`.
|
||||
|
||||
### V8 JavaScript values
|
||||
|
||||
|
|
@ -191,7 +191,7 @@ function getFoo(obj) {
|
|||
```cpp
|
||||
v8::Local<v8::Value> GetFoo(v8::Local<v8::Context> context,
|
||||
v8::Local<v8::Object> obj) {
|
||||
v8::Isolate* isolate = context->GetIsolate();
|
||||
v8::Isolate* isolate = Isolate::GetCurrent();
|
||||
v8::EscapableHandleScope handle_scope(isolate);
|
||||
|
||||
// The 'foo_string' handle cannot be returned from this function because
|
||||
|
|
@ -753,7 +753,7 @@ using `.ToLocal()` and `.To()` and returning early in case there is an error:
|
|||
// This could also return a v8::MaybeLocal<v8::Number>, for example.
|
||||
v8::Maybe<double> SumNumbers(v8::Local<v8::Context> context,
|
||||
v8::Local<v8::Array> array_of_integers) {
|
||||
v8::Isolate* isolate = context->GetIsolate();
|
||||
v8::Isolate* isolate = Isolate::GetCurrent();
|
||||
v8::HandleScope handle_scope(isolate);
|
||||
|
||||
double sum = 0;
|
||||
|
|
|
|||
|
|
@ -628,7 +628,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();
|
||||
|
|
@ -674,7 +674,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
|
||||
|
|
@ -753,7 +753,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`
|
||||
|
|
@ -778,7 +778,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.
|
||||
|
|
@ -796,7 +796,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);
|
||||
|
||||
|
|
@ -820,7 +820,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);
|
||||
|
||||
|
|
@ -846,7 +846,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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -1022,7 +1022,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();
|
||||
|
||||
|
|
|
|||
|
|
@ -107,7 +107,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)
|
||||
|
|
@ -121,7 +121,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)
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -1775,10 +1775,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);
|
||||
js_execution_async_resources_.Reset(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
|
||||
|
|
@ -1818,7 +1818,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;
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ namespace inspector {
|
|||
|
||||
using v8::EscapableHandleScope;
|
||||
using v8::HandleScope;
|
||||
using v8::Isolate;
|
||||
using v8::Just;
|
||||
using v8::Local;
|
||||
using v8::Maybe;
|
||||
|
|
@ -29,31 +30,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(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(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(Isolate::GetCurrent());
|
||||
return ObjectGetProtocolString(
|
||||
context, object, OneByteString(context->GetIsolate(), property));
|
||||
context, object, OneByteString(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(Isolate::GetCurrent());
|
||||
Local<Value> value;
|
||||
if (!object->Get(context, OneByteString(context->GetIsolate(), property))
|
||||
if (!object->Get(context, OneByteString(Isolate::GetCurrent(), property))
|
||||
.ToLocal(&value) ||
|
||||
!value->IsNumber()) {
|
||||
return Nothing<double>();
|
||||
|
|
@ -65,9 +66,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(Isolate::GetCurrent());
|
||||
Local<Value> value;
|
||||
if (!object->Get(context, OneByteString(context->GetIsolate(), property))
|
||||
if (!object->Get(context, OneByteString(Isolate::GetCurrent(), property))
|
||||
.ToLocal(&value) ||
|
||||
!value->IsInt32()) {
|
||||
return Nothing<int>();
|
||||
|
|
@ -79,9 +80,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(Isolate::GetCurrent());
|
||||
Local<Value> value;
|
||||
if (!object->Get(context, OneByteString(context->GetIsolate(), property))
|
||||
if (!object->Get(context, OneByteString(Isolate::GetCurrent(), property))
|
||||
.ToLocal(&value) ||
|
||||
!value->IsBoolean()) {
|
||||
return Nothing<bool>();
|
||||
|
|
@ -93,9 +94,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(Isolate::GetCurrent());
|
||||
Local<Value> value;
|
||||
if (!object->Get(context, OneByteString(context->GetIsolate(), property))
|
||||
if (!object->Get(context, OneByteString(Isolate::GetCurrent(), property))
|
||||
.ToLocal(&value) ||
|
||||
!value->IsObject()) {
|
||||
return {};
|
||||
|
|
@ -106,7 +107,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(Isolate::GetCurrent());
|
||||
|
||||
std::unique_ptr<protocol::DictionaryValue> dict =
|
||||
protocol::DictionaryValue::create();
|
||||
|
|
@ -127,7 +128,7 @@ std::unique_ptr<protocol::Network::Headers> createHeadersFromObject(
|
|||
.To(&property_value)) {
|
||||
return {};
|
||||
}
|
||||
dict->setString(ToProtocolString(context->GetIsolate(), property_name),
|
||||
dict->setString(ToProtocolString(Isolate::GetCurrent(), property_name),
|
||||
property_value);
|
||||
}
|
||||
|
||||
|
|
@ -137,7 +138,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(Isolate::GetCurrent());
|
||||
protocol::String url;
|
||||
if (!ObjectGetProtocolString(context, request, "url").To(&url)) {
|
||||
return {};
|
||||
|
|
@ -169,7 +170,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(Isolate::GetCurrent());
|
||||
protocol::String url;
|
||||
if (!ObjectGetProtocolString(context, response, "url").To(&url)) {
|
||||
return {};
|
||||
|
|
@ -210,7 +211,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(Isolate::GetCurrent());
|
||||
int status;
|
||||
if (!ObjectGetInt(context, response, "status").To(&status)) {
|
||||
return {};
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
@ -142,7 +142,7 @@ struct napi_env__ {
|
|||
}
|
||||
}
|
||||
|
||||
v8::Isolate* const isolate; // Shortcut for context()->GetIsolate()
|
||||
v8::Isolate* const isolate; // Shortcut for Isolate::GetCurrent()
|
||||
v8impl::Persistent<v8::Context> context_persistent;
|
||||
|
||||
v8impl::Persistent<v8::Value> last_exception;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
@ -1022,7 +1022,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
|
||||
|
|
@ -1046,7 +1046,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());
|
||||
|
|
@ -1059,7 +1059,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);
|
||||
|
|
@ -1104,7 +1104,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);
|
||||
|
|
@ -1343,7 +1343,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);
|
||||
|
|
|
|||
|
|
@ -1001,7 +1001,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); \
|
||||
|
|
@ -1017,7 +1017,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); \
|
||||
|
|
|
|||
|
|
@ -554,7 +554,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);
|
||||
|
|
|
|||
|
|
@ -275,7 +275,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;
|
||||
|
|
@ -397,7 +397,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,
|
||||
|
|
@ -451,7 +451,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
|
||||
|
|
@ -507,7 +507,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);
|
||||
}
|
||||
|
||||
|
|
@ -545,14 +545,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.
|
||||
|
|
|
|||
|
|
@ -1281,11 +1281,10 @@ 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(
|
||||
target->SetPrototypeV2(env->context(), Null(env->isolate())).FromJust());
|
||||
CHECK(target->SetPrototypeV2(env->context(), Null(isolate)).FromJust());
|
||||
|
||||
Local<Object> os_constants =
|
||||
Object::New(isolate, Null(isolate), nullptr, nullptr, 0);
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ namespace {
|
|||
|
||||
// Convert an int to a V8 Name (String or Symbol).
|
||||
MaybeLocal<String> Uint32ToName(Local<Context> context, uint32_t index) {
|
||||
return Uint32::New(context->GetIsolate(), index)->ToString(context);
|
||||
return Uint32::New(Isolate::GetCurrent(), index)->ToString(context);
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
|
@ -676,7 +676,7 @@ Intercepted ContextifyContext::PropertyDefinerCallback(
|
|||
}
|
||||
|
||||
Local<Context> context = ctx->context();
|
||||
Isolate* isolate = context->GetIsolate();
|
||||
Isolate* isolate = Isolate::GetCurrent();
|
||||
|
||||
PropertyAttribute attributes = PropertyAttribute::None;
|
||||
bool is_declared =
|
||||
|
|
@ -1656,7 +1656,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();
|
||||
|
|
|
|||
|
|
@ -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))
|
||||
|
|
|
|||
|
|
@ -633,7 +633,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) {
|
||||
|
|
@ -1016,7 +1016,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);
|
||||
|
|
@ -1177,7 +1177,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);
|
||||
|
||||
|
|
|
|||
|
|
@ -3851,7 +3851,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 =
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
@ -1477,7 +1477,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;
|
||||
|
|
|
|||
|
|
@ -68,7 +68,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);
|
||||
|
|
@ -664,7 +664,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) \
|
||||
|
|
|
|||
|
|
@ -737,7 +737,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);
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ using v8::String;
|
|||
using v8::Value;
|
||||
|
||||
Realm::Realm(Environment* env, v8::Local<v8::Context> context, Kind kind)
|
||||
: env_(env), isolate_(context->GetIsolate()), kind_(kind) {
|
||||
: env_(env), isolate_(Isolate::GetCurrent()), kind_(kind) {
|
||||
context_.Reset(isolate_, context);
|
||||
env->AssignToContext(context, this, ContextInfo(""));
|
||||
// The environment can also purge empty wrappers in the check callback,
|
||||
|
|
|
|||
|
|
@ -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'
|
||||
|
|
|
|||
|
|
@ -1614,7 +1614,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);
|
||||
|
|
|
|||
|
|
@ -2019,7 +2019,7 @@ bool StatementSync::BindParams(const FunctionCallbackInfo<Value>& args) {
|
|||
|
||||
if (args[0]->IsObject() && !args[0]->IsArrayBufferView()) {
|
||||
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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -70,7 +70,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);
|
||||
|
|
|
|||
|
|
@ -158,7 +158,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);
|
||||
|
|
|
|||
|
|
@ -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,7 +275,7 @@ R WASI::WasiFunction<FT, F, R, Args...>::FastCallback(
|
|||
return EinvalError<R>();
|
||||
}
|
||||
|
||||
Isolate* isolate = receiver->GetIsolate();
|
||||
Isolate* isolate = Isolate::GetCurrent();
|
||||
HandleScope scope(isolate);
|
||||
if (wasi->memory_.IsEmpty()) {
|
||||
THROW_ERR_WASI_NOT_STARTED(isolate);
|
||||
|
|
|
|||
|
|
@ -57,7 +57,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 =
|
||||
|
|
@ -433,7 +433,7 @@ Maybe<void> Storage::Store(Local<Name> key, Local<Value> value) {
|
|||
}
|
||||
|
||||
static MaybeLocal<String> Uint32ToName(Local<Context> 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<Value>& info) {
|
||||
|
|
|
|||
|
|
@ -1463,8 +1463,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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -336,14 +336,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.
|
||||
|
|
@ -359,7 +359,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
|
||||
|
|
@ -386,7 +386,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());
|
||||
|
|
@ -403,7 +403,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);
|
||||
|
||||
|
|
@ -422,7 +422,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());
|
||||
|
|
@ -441,7 +441,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);
|
||||
|
|
@ -484,7 +484,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);
|
||||
}
|
||||
|
||||
|
|
@ -497,7 +497,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);
|
||||
|
|
@ -731,7 +731,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>();
|
||||
}
|
||||
|
|
|
|||
10
src/util.cc
10
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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -739,7 +739,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 = \
|
||||
|
|
|
|||
|
|
@ -42,17 +42,14 @@ void Initialize(v8::Local<v8::Object> exports,
|
|||
v8::Local<v8::Value> module,
|
||||
v8::Local<v8::Context> context) {
|
||||
AsyncData* data = new AsyncData();
|
||||
data->isolate = context->GetIsolate();
|
||||
auto handle = node::AddEnvironmentCleanupHook(
|
||||
context->GetIsolate(),
|
||||
AsyncCleanupHook,
|
||||
data);
|
||||
v8::Isolate* isolate = v8::Isolate::GetCurrent();
|
||||
data->isolate = isolate;
|
||||
auto handle =
|
||||
node::AddEnvironmentCleanupHook(isolate, AsyncCleanupHook, data);
|
||||
data->handle = std::move(handle);
|
||||
|
||||
auto must_not_call_handle = node::AddEnvironmentCleanupHook(
|
||||
context->GetIsolate(),
|
||||
MustNotCall,
|
||||
nullptr);
|
||||
auto must_not_call_handle =
|
||||
node::AddEnvironmentCleanupHook(isolate, MustNotCall, nullptr);
|
||||
node::RemoveEnvironmentCleanupHook(std::move(must_not_call_handle));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ class CppGCed : public v8::Object::Wrappable {
|
|||
|
||||
static v8::Local<v8::Function> GetConstructor(
|
||||
v8::Local<v8::Context> context) {
|
||||
auto ft = v8::FunctionTemplate::New(context->GetIsolate(), New);
|
||||
auto ft = v8::FunctionTemplate::New(v8::Isolate::GetCurrent(), New);
|
||||
return ft->GetFunction(context).ToLocalChecked();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
static void InitModule(v8::Local<v8::Object> exports,
|
||||
v8::Local<v8::Value> module_val,
|
||||
v8::Local<v8::Context> context) {
|
||||
v8::Isolate* isolate = context->GetIsolate();
|
||||
v8::Isolate* isolate = v8::Isolate::GetCurrent();
|
||||
v8::Local<v8::Object> module = module_val.As<v8::Object>();
|
||||
module
|
||||
->Set(context,
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ inline void Test(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
|||
}
|
||||
|
||||
inline void Initialize(v8::Local<v8::Object> binding) {
|
||||
v8::Isolate* const isolate = binding->GetIsolate();
|
||||
v8::Isolate* const isolate = v8::Isolate::GetCurrent();
|
||||
v8::Local<v8::Context> context = isolate->GetCurrentContext();
|
||||
binding->Set(context, v8::String::NewFromUtf8(
|
||||
isolate, "test").ToLocalChecked(),
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ NODE_MODULE_INITIALIZER(v8::Local<v8::Object> exports,
|
|||
static void FakeInit(v8::Local<v8::Object> exports,
|
||||
v8::Local<v8::Value> module,
|
||||
v8::Local<v8::Context> context) {
|
||||
auto isolate = context->GetIsolate();
|
||||
auto isolate = v8::Isolate::GetCurrent();
|
||||
auto exception = v8::Exception::Error(v8::String::NewFromUtf8(isolate,
|
||||
"FakeInit should never run!").ToLocalChecked());
|
||||
isolate->ThrowException(exception);
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ inline void NewClass(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
|||
}
|
||||
|
||||
inline void Initialize(v8::Local<v8::Object> binding) {
|
||||
auto isolate = binding->GetIsolate();
|
||||
auto isolate = v8::Isolate::GetCurrent();
|
||||
auto context = isolate->GetCurrentContext();
|
||||
binding->Set(context, v8::String::NewFromUtf8(
|
||||
isolate, "Class").ToLocalChecked(),
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ inline void Hash(const v8::FunctionCallbackInfo<v8::Value>& info) {
|
|||
inline void Initialize(v8::Local<v8::Object> exports,
|
||||
v8::Local<v8::Value> module,
|
||||
v8::Local<v8::Context> context) {
|
||||
auto isolate = context->GetIsolate();
|
||||
auto isolate = v8::Isolate::GetCurrent();
|
||||
auto key = v8::String::NewFromUtf8(
|
||||
isolate, "randomBytes").ToLocalChecked();
|
||||
auto value = v8::FunctionTemplate::New(isolate, RandomBytes)
|
||||
|
|
|
|||
|
|
@ -51,19 +51,18 @@ void Cleanup(void* str) {
|
|||
void Initialize(Local<Object> exports,
|
||||
Local<Value> module,
|
||||
Local<Context> context) {
|
||||
Isolate* isolate = Isolate::GetCurrent();
|
||||
node::AddEnvironmentCleanupHook(
|
||||
context->GetIsolate(),
|
||||
Cleanup,
|
||||
const_cast<void*>(static_cast<const void*>("cleanup")));
|
||||
node::AddEnvironmentCleanupHook(context->GetIsolate(), Dummy, nullptr);
|
||||
node::RemoveEnvironmentCleanupHook(context->GetIsolate(), Dummy, nullptr);
|
||||
isolate, Cleanup, const_cast<void*>(static_cast<const void*>("cleanup")));
|
||||
node::AddEnvironmentCleanupHook(isolate, Dummy, nullptr);
|
||||
node::RemoveEnvironmentCleanupHook(isolate, Dummy, nullptr);
|
||||
|
||||
if (getenv("addExtraItemToEventLoop") != nullptr) {
|
||||
// Add an item to the event loop that we do not clean up in order to make
|
||||
// sure that for the main thread, this addon's memory persists even after
|
||||
// the Environment instance has been destroyed.
|
||||
static uv_async_t extra_async;
|
||||
uv_loop_t* loop = node::GetCurrentEventLoop(context->GetIsolate());
|
||||
uv_loop_t* loop = node::GetCurrentEventLoop(isolate);
|
||||
int err = uv_async_init(loop, &extra_async, [](uv_async_t*) {});
|
||||
assert(err == 0);
|
||||
uv_unref(reinterpret_cast<uv_handle_t*>(&extra_async));
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ void GetFreeCallCount(const FunctionCallbackInfo<Value>& args) {
|
|||
void Initialize(Local<Object> exports,
|
||||
Local<Value> module,
|
||||
Local<Context> context) {
|
||||
Isolate* isolate = context->GetIsolate();
|
||||
Isolate* isolate = Isolate::GetCurrent();
|
||||
NODE_SET_METHOD(exports, "getFreeCallCount", GetFreeCallCount);
|
||||
|
||||
char* data = new char;
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ inline void CompressBytes(const v8::FunctionCallbackInfo<v8::Value>& info) {
|
|||
inline void Initialize(v8::Local<v8::Object> exports,
|
||||
v8::Local<v8::Value> module,
|
||||
v8::Local<v8::Context> context) {
|
||||
auto isolate = context->GetIsolate();
|
||||
auto isolate = v8::Isolate::GetCurrent();
|
||||
auto key = v8::String::NewFromUtf8(
|
||||
isolate, "compressBytes").ToLocalChecked();
|
||||
auto value = v8::FunctionTemplate::New(isolate, CompressBytes)
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ class CppGCed : public v8::Object::Wrappable {
|
|||
|
||||
static v8::Local<v8::Function> GetConstructor(
|
||||
v8::Local<v8::Context> context) {
|
||||
auto ft = v8::FunctionTemplate::New(context->GetIsolate(), New);
|
||||
auto ft = v8::FunctionTemplate::New(v8::Isolate::GetCurrent(), New);
|
||||
return ft->GetFunction(context).ToLocalChecked();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ void InitializeBinding(v8::Local<v8::Object> exports,
|
|||
v8::Local<v8::Value> module,
|
||||
v8::Local<v8::Context> context,
|
||||
void* priv) {
|
||||
v8::Isolate* isolate = context->GetIsolate();
|
||||
v8::Isolate* isolate = v8::Isolate::GetCurrent();
|
||||
exports
|
||||
->Set(context,
|
||||
v8::String::NewFromOneByte(isolate,
|
||||
|
|
@ -51,7 +51,7 @@ void InitializeLocalBinding(v8::Local<v8::Object> exports,
|
|||
v8::Local<v8::Context> context,
|
||||
void* priv) {
|
||||
++*static_cast<int*>(priv);
|
||||
v8::Isolate* isolate = context->GetIsolate();
|
||||
v8::Isolate* isolate = v8::Isolate::GetCurrent();
|
||||
exports
|
||||
->Set(context,
|
||||
v8::String::NewFromOneByte(isolate,
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user