mirror of
https://github.com/zebrajr/node.git
synced 2025-12-06 12:20:27 +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.
|
// Initialize this addon to be context-aware.
|
||||||
NODE_MODULE_INIT(/* exports, module, context */) {
|
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
|
// Create a new instance of `AddonData` for this instance of the addon and
|
||||||
// tie its life cycle to that of the Node.js environment.
|
// 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.
|
// Initialize this addon to be context-aware.
|
||||||
NODE_MODULE_INIT(/* exports, module, context */) {
|
NODE_MODULE_INIT(/* exports, module, context */) {
|
||||||
Isolate* isolate = context->GetIsolate();
|
Isolate* isolate = Isolate::GetCurrent();
|
||||||
|
|
||||||
AddEnvironmentCleanupHook(isolate, sanity_check, nullptr);
|
AddEnvironmentCleanupHook(isolate, sanity_check, nullptr);
|
||||||
AddEnvironmentCleanupHook(isolate, cleanup_cb2, cookie);
|
AddEnvironmentCleanupHook(isolate, cleanup_cb2, cookie);
|
||||||
|
|
@ -879,7 +879,7 @@ MyObject::~MyObject() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyObject::Init(Local<Object> exports) {
|
void MyObject::Init(Local<Object> exports) {
|
||||||
Isolate* isolate = exports->GetIsolate();
|
Isolate* isolate = Isolate::GetCurrent();
|
||||||
Local<Context> context = isolate->GetCurrentContext();
|
Local<Context> context = isolate->GetCurrentContext();
|
||||||
|
|
||||||
Local<ObjectTemplate> addon_data_tpl = ObjectTemplate::New(isolate);
|
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) {
|
void InitAll(Local<Object> exports, Local<Object> module) {
|
||||||
MyObject::Init(exports->GetIsolate());
|
MyObject::Init();
|
||||||
|
|
||||||
NODE_SET_METHOD(module, "exports", CreateObject);
|
NODE_SET_METHOD(module, "exports", CreateObject);
|
||||||
}
|
}
|
||||||
|
|
@ -1039,7 +1039,7 @@ namespace demo {
|
||||||
|
|
||||||
class MyObject : public node::ObjectWrap {
|
class MyObject : public node::ObjectWrap {
|
||||||
public:
|
public:
|
||||||
static void Init(v8::Isolate* isolate);
|
static void Init();
|
||||||
static void NewInstance(const v8::FunctionCallbackInfo<v8::Value>& args);
|
static void NewInstance(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
@ -1089,7 +1089,8 @@ MyObject::MyObject(double value) : value_(value) {
|
||||||
MyObject::~MyObject() {
|
MyObject::~MyObject() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyObject::Init(Isolate* isolate) {
|
void MyObject::Init() {
|
||||||
|
Isolate* isolate = Isolate::GetCurrent();
|
||||||
// Prepare constructor template
|
// Prepare constructor template
|
||||||
Local<FunctionTemplate> tpl = FunctionTemplate::New(isolate, New);
|
Local<FunctionTemplate> tpl = FunctionTemplate::New(isolate, New);
|
||||||
tpl->SetClassName(String::NewFromUtf8(isolate, "MyObject").ToLocalChecked());
|
tpl->SetClassName(String::NewFromUtf8(isolate, "MyObject").ToLocalChecked());
|
||||||
|
|
@ -1235,7 +1236,7 @@ void Add(const FunctionCallbackInfo<Value>& args) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void InitAll(Local<Object> exports) {
|
void InitAll(Local<Object> exports) {
|
||||||
MyObject::Init(exports->GetIsolate());
|
MyObject::Init();
|
||||||
|
|
||||||
NODE_SET_METHOD(exports, "createObject", CreateObject);
|
NODE_SET_METHOD(exports, "createObject", CreateObject);
|
||||||
NODE_SET_METHOD(exports, "add", Add);
|
NODE_SET_METHOD(exports, "add", Add);
|
||||||
|
|
@ -1261,7 +1262,7 @@ namespace demo {
|
||||||
|
|
||||||
class MyObject : public node::ObjectWrap {
|
class MyObject : public node::ObjectWrap {
|
||||||
public:
|
public:
|
||||||
static void Init(v8::Isolate* isolate);
|
static void Init();
|
||||||
static void NewInstance(const v8::FunctionCallbackInfo<v8::Value>& args);
|
static void NewInstance(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||||
inline double value() const { return value_; }
|
inline double value() const { return value_; }
|
||||||
|
|
||||||
|
|
@ -1310,7 +1311,8 @@ MyObject::MyObject(double value) : value_(value) {
|
||||||
MyObject::~MyObject() {
|
MyObject::~MyObject() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyObject::Init(Isolate* isolate) {
|
void MyObject::Init() {
|
||||||
|
Isolate* isolate = Isolate::GetCurrent();
|
||||||
// Prepare constructor template
|
// Prepare constructor template
|
||||||
Local<FunctionTemplate> tpl = FunctionTemplate::New(isolate, New);
|
Local<FunctionTemplate> tpl = FunctionTemplate::New(isolate, New);
|
||||||
tpl->SetClassName(String::NewFromUtf8(isolate, "MyObject").ToLocalChecked());
|
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][],
|
* Given a `FunctionCallbackInfo` for a [binding function][],
|
||||||
using `args.GetIsolate()`.
|
using `args.GetIsolate()`.
|
||||||
* Given a [`Context`][], using `context->GetIsolate()`.
|
|
||||||
* Given a [`Environment`][], using `env->isolate()`.
|
* Given a [`Environment`][], using `env->isolate()`.
|
||||||
* Given a [`Realm`][], using `realm->isolate()`.
|
* Given a [`Realm`][], using `realm->isolate()`.
|
||||||
|
* Calling `Isolate::GetCurrent()`.
|
||||||
|
|
||||||
### V8 JavaScript values
|
### V8 JavaScript values
|
||||||
|
|
||||||
|
|
@ -191,7 +191,7 @@ function getFoo(obj) {
|
||||||
```cpp
|
```cpp
|
||||||
v8::Local<v8::Value> GetFoo(v8::Local<v8::Context> context,
|
v8::Local<v8::Value> GetFoo(v8::Local<v8::Context> context,
|
||||||
v8::Local<v8::Object> obj) {
|
v8::Local<v8::Object> obj) {
|
||||||
v8::Isolate* isolate = context->GetIsolate();
|
v8::Isolate* isolate = Isolate::GetCurrent();
|
||||||
v8::EscapableHandleScope handle_scope(isolate);
|
v8::EscapableHandleScope handle_scope(isolate);
|
||||||
|
|
||||||
// The 'foo_string' handle cannot be returned from this function because
|
// 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.
|
// This could also return a v8::MaybeLocal<v8::Number>, for example.
|
||||||
v8::Maybe<double> SumNumbers(v8::Local<v8::Context> context,
|
v8::Maybe<double> SumNumbers(v8::Local<v8::Context> context,
|
||||||
v8::Local<v8::Array> array_of_integers) {
|
v8::Local<v8::Array> array_of_integers) {
|
||||||
v8::Isolate* isolate = context->GetIsolate();
|
v8::Isolate* isolate = Isolate::GetCurrent();
|
||||||
v8::HandleScope handle_scope(isolate);
|
v8::HandleScope handle_scope(isolate);
|
||||||
|
|
||||||
double sum = 0;
|
double sum = 0;
|
||||||
|
|
|
||||||
|
|
@ -628,7 +628,7 @@ std::unique_ptr<MultiIsolatePlatform> MultiIsolatePlatform::Create(
|
||||||
|
|
||||||
MaybeLocal<Object> GetPerContextExports(Local<Context> context,
|
MaybeLocal<Object> GetPerContextExports(Local<Context> context,
|
||||||
IsolateData* isolate_data) {
|
IsolateData* isolate_data) {
|
||||||
Isolate* isolate = context->GetIsolate();
|
Isolate* isolate = Isolate::GetCurrent();
|
||||||
EscapableHandleScope handle_scope(isolate);
|
EscapableHandleScope handle_scope(isolate);
|
||||||
|
|
||||||
Local<Object> global = context->Global();
|
Local<Object> global = context->Global();
|
||||||
|
|
@ -674,7 +674,7 @@ void ProtoThrower(const FunctionCallbackInfo<Value>& info) {
|
||||||
// This runs at runtime, regardless of whether the context
|
// This runs at runtime, regardless of whether the context
|
||||||
// is created from a snapshot.
|
// is created from a snapshot.
|
||||||
Maybe<void> InitializeContextRuntime(Local<Context> context) {
|
Maybe<void> InitializeContextRuntime(Local<Context> context) {
|
||||||
Isolate* isolate = context->GetIsolate();
|
Isolate* isolate = Isolate::GetCurrent();
|
||||||
HandleScope handle_scope(isolate);
|
HandleScope handle_scope(isolate);
|
||||||
|
|
||||||
// When `IsCodeGenerationFromStringsAllowed` is true, V8 takes the fast path
|
// 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) {
|
Maybe<void> InitializeBaseContextForSnapshot(Local<Context> context) {
|
||||||
Isolate* isolate = context->GetIsolate();
|
Isolate* isolate = Isolate::GetCurrent();
|
||||||
HandleScope handle_scope(isolate);
|
HandleScope handle_scope(isolate);
|
||||||
|
|
||||||
// Delete `Intl.v8BreakIterator`
|
// Delete `Intl.v8BreakIterator`
|
||||||
|
|
@ -778,7 +778,7 @@ Maybe<void> InitializeBaseContextForSnapshot(Local<Context> context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Maybe<void> InitializeMainContextForSnapshot(Local<Context> context) {
|
Maybe<void> InitializeMainContextForSnapshot(Local<Context> context) {
|
||||||
Isolate* isolate = context->GetIsolate();
|
Isolate* isolate = Isolate::GetCurrent();
|
||||||
HandleScope handle_scope(isolate);
|
HandleScope handle_scope(isolate);
|
||||||
|
|
||||||
// Initialize the default values.
|
// Initialize the default values.
|
||||||
|
|
@ -796,7 +796,7 @@ Maybe<void> InitializeMainContextForSnapshot(Local<Context> context) {
|
||||||
MaybeLocal<Object> InitializePrivateSymbols(Local<Context> context,
|
MaybeLocal<Object> InitializePrivateSymbols(Local<Context> context,
|
||||||
IsolateData* isolate_data) {
|
IsolateData* isolate_data) {
|
||||||
CHECK(isolate_data);
|
CHECK(isolate_data);
|
||||||
Isolate* isolate = context->GetIsolate();
|
Isolate* isolate = Isolate::GetCurrent();
|
||||||
EscapableHandleScope scope(isolate);
|
EscapableHandleScope scope(isolate);
|
||||||
Context::Scope context_scope(context);
|
Context::Scope context_scope(context);
|
||||||
|
|
||||||
|
|
@ -820,7 +820,7 @@ MaybeLocal<Object> InitializePrivateSymbols(Local<Context> context,
|
||||||
MaybeLocal<Object> InitializePerIsolateSymbols(Local<Context> context,
|
MaybeLocal<Object> InitializePerIsolateSymbols(Local<Context> context,
|
||||||
IsolateData* isolate_data) {
|
IsolateData* isolate_data) {
|
||||||
CHECK(isolate_data);
|
CHECK(isolate_data);
|
||||||
Isolate* isolate = context->GetIsolate();
|
Isolate* isolate = Isolate::GetCurrent();
|
||||||
EscapableHandleScope scope(isolate);
|
EscapableHandleScope scope(isolate);
|
||||||
Context::Scope context_scope(context);
|
Context::Scope context_scope(context);
|
||||||
|
|
||||||
|
|
@ -846,7 +846,7 @@ MaybeLocal<Object> InitializePerIsolateSymbols(Local<Context> context,
|
||||||
Maybe<void> InitializePrimordials(Local<Context> context,
|
Maybe<void> InitializePrimordials(Local<Context> context,
|
||||||
IsolateData* isolate_data) {
|
IsolateData* isolate_data) {
|
||||||
// Run per-context JS files.
|
// Run per-context JS files.
|
||||||
Isolate* isolate = context->GetIsolate();
|
Isolate* isolate = Isolate::GetCurrent();
|
||||||
Context::Scope context_scope(context);
|
Context::Scope context_scope(context);
|
||||||
Local<Object> exports;
|
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> BaseObject::object(v8::Isolate* isolate) const {
|
||||||
v8::Local<v8::Object> handle = object();
|
v8::Local<v8::Object> handle = object();
|
||||||
|
|
||||||
DCHECK_EQ(handle->GetCreationContextChecked()->GetIsolate(), isolate);
|
|
||||||
DCHECK_EQ(env()->isolate(), isolate);
|
DCHECK_EQ(env()->isolate(), isolate);
|
||||||
|
|
||||||
return handle;
|
return handle;
|
||||||
|
|
|
||||||
|
|
@ -1022,7 +1022,7 @@ bool ArrayOfStringsToX509s(Local<Context> context,
|
||||||
Local<Array> cert_array,
|
Local<Array> cert_array,
|
||||||
std::vector<X509*>* certs) {
|
std::vector<X509*>* certs) {
|
||||||
ClearErrorOnReturn clear_error_on_return;
|
ClearErrorOnReturn clear_error_on_return;
|
||||||
Isolate* isolate = context->GetIsolate();
|
Isolate* isolate = Isolate::GetCurrent();
|
||||||
Environment* env = Environment::GetCurrent(context);
|
Environment* env = Environment::GetCurrent(context);
|
||||||
uint32_t array_length = cert_array->Length();
|
uint32_t array_length = cert_array->Length();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -107,7 +107,7 @@ MaybeLocal<Value> ToV8Value(Local<Context> context, BIOPointer&& bio) {
|
||||||
return {};
|
return {};
|
||||||
BUF_MEM* mem = bio;
|
BUF_MEM* mem = bio;
|
||||||
Local<Value> ret;
|
Local<Value> ret;
|
||||||
if (!String::NewFromUtf8(context->GetIsolate(),
|
if (!String::NewFromUtf8(Isolate::GetCurrent(),
|
||||||
mem->data,
|
mem->data,
|
||||||
NewStringType::kNormal,
|
NewStringType::kNormal,
|
||||||
mem->length)
|
mem->length)
|
||||||
|
|
@ -121,7 +121,7 @@ MaybeLocal<Value> ToV8Value(Local<Context> context, const BIOPointer& bio) {
|
||||||
return {};
|
return {};
|
||||||
BUF_MEM* mem = bio;
|
BUF_MEM* mem = bio;
|
||||||
Local<Value> ret;
|
Local<Value> ret;
|
||||||
if (!String::NewFromUtf8(context->GetIsolate(),
|
if (!String::NewFromUtf8(Isolate::GetCurrent(),
|
||||||
mem->data,
|
mem->data,
|
||||||
NewStringType::kNormal,
|
NewStringType::kNormal,
|
||||||
mem->length)
|
mem->length)
|
||||||
|
|
|
||||||
|
|
@ -76,7 +76,7 @@ void BindingData::Deserialize(Local<Context> context,
|
||||||
int index,
|
int index,
|
||||||
InternalFieldInfoBase* info) {
|
InternalFieldInfoBase* info) {
|
||||||
DCHECK_IS_SNAPSHOT_SLOT(index);
|
DCHECK_IS_SNAPSHOT_SLOT(index);
|
||||||
HandleScope scope(context->GetIsolate());
|
HandleScope scope(Isolate::GetCurrent());
|
||||||
Realm* realm = Realm::GetCurrent(context);
|
Realm* realm = Realm::GetCurrent(context);
|
||||||
// Recreate the buffer in the constructor.
|
// Recreate the buffer in the constructor.
|
||||||
InternalFieldInfo* casted_info = static_cast<InternalFieldInfo*>(info);
|
InternalFieldInfo* casted_info = static_cast<InternalFieldInfo*>(info);
|
||||||
|
|
|
||||||
|
|
@ -1775,10 +1775,10 @@ void AsyncHooks::Deserialize(Local<Context> context) {
|
||||||
context->GetDataFromSnapshotOnce<Array>(
|
context->GetDataFromSnapshotOnce<Array>(
|
||||||
info_->js_execution_async_resources).ToLocalChecked();
|
info_->js_execution_async_resources).ToLocalChecked();
|
||||||
} else {
|
} else {
|
||||||
js_execution_async_resources = Array::New(context->GetIsolate());
|
js_execution_async_resources = Array::New(Isolate::GetCurrent());
|
||||||
}
|
}
|
||||||
js_execution_async_resources_.Reset(
|
js_execution_async_resources_.Reset(Isolate::GetCurrent(),
|
||||||
context->GetIsolate(), js_execution_async_resources);
|
js_execution_async_resources);
|
||||||
|
|
||||||
// The native_execution_async_resources_ field requires v8::Local<> instances
|
// The native_execution_async_resources_ field requires v8::Local<> instances
|
||||||
// for async calls whose resources were on the stack as JS objects when they
|
// 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);
|
info.async_id_fields = async_id_fields_.Serialize(context, creator);
|
||||||
if (!js_execution_async_resources_.IsEmpty()) {
|
if (!js_execution_async_resources_.IsEmpty()) {
|
||||||
info.js_execution_async_resources = creator->AddData(
|
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);
|
CHECK_NE(info.js_execution_async_resources, 0);
|
||||||
} else {
|
} else {
|
||||||
info.js_execution_async_resources = 0;
|
info.js_execution_async_resources = 0;
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ namespace inspector {
|
||||||
|
|
||||||
using v8::EscapableHandleScope;
|
using v8::EscapableHandleScope;
|
||||||
using v8::HandleScope;
|
using v8::HandleScope;
|
||||||
|
using v8::Isolate;
|
||||||
using v8::Just;
|
using v8::Just;
|
||||||
using v8::Local;
|
using v8::Local;
|
||||||
using v8::Maybe;
|
using v8::Maybe;
|
||||||
|
|
@ -29,31 +30,31 @@ using v8::Value;
|
||||||
Maybe<protocol::String> ObjectGetProtocolString(v8::Local<v8::Context> context,
|
Maybe<protocol::String> ObjectGetProtocolString(v8::Local<v8::Context> context,
|
||||||
Local<Object> object,
|
Local<Object> object,
|
||||||
Local<v8::String> property) {
|
Local<v8::String> property) {
|
||||||
HandleScope handle_scope(context->GetIsolate());
|
HandleScope handle_scope(Isolate::GetCurrent());
|
||||||
Local<Value> value;
|
Local<Value> value;
|
||||||
if (!object->Get(context, property).ToLocal(&value) || !value->IsString()) {
|
if (!object->Get(context, property).ToLocal(&value) || !value->IsString()) {
|
||||||
return Nothing<protocol::String>();
|
return Nothing<protocol::String>();
|
||||||
}
|
}
|
||||||
Local<v8::String> str = value.As<v8::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.
|
// Get a protocol string property from the object.
|
||||||
Maybe<protocol::String> ObjectGetProtocolString(v8::Local<v8::Context> context,
|
Maybe<protocol::String> ObjectGetProtocolString(v8::Local<v8::Context> context,
|
||||||
Local<Object> object,
|
Local<Object> object,
|
||||||
const char* property) {
|
const char* property) {
|
||||||
HandleScope handle_scope(context->GetIsolate());
|
HandleScope handle_scope(Isolate::GetCurrent());
|
||||||
return ObjectGetProtocolString(
|
return ObjectGetProtocolString(
|
||||||
context, object, OneByteString(context->GetIsolate(), property));
|
context, object, OneByteString(Isolate::GetCurrent(), property));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get a protocol double property from the object.
|
// Get a protocol double property from the object.
|
||||||
Maybe<double> ObjectGetDouble(v8::Local<v8::Context> context,
|
Maybe<double> ObjectGetDouble(v8::Local<v8::Context> context,
|
||||||
Local<Object> object,
|
Local<Object> object,
|
||||||
const char* property) {
|
const char* property) {
|
||||||
HandleScope handle_scope(context->GetIsolate());
|
HandleScope handle_scope(Isolate::GetCurrent());
|
||||||
Local<Value> value;
|
Local<Value> value;
|
||||||
if (!object->Get(context, OneByteString(context->GetIsolate(), property))
|
if (!object->Get(context, OneByteString(Isolate::GetCurrent(), property))
|
||||||
.ToLocal(&value) ||
|
.ToLocal(&value) ||
|
||||||
!value->IsNumber()) {
|
!value->IsNumber()) {
|
||||||
return Nothing<double>();
|
return Nothing<double>();
|
||||||
|
|
@ -65,9 +66,9 @@ Maybe<double> ObjectGetDouble(v8::Local<v8::Context> context,
|
||||||
Maybe<int> ObjectGetInt(v8::Local<v8::Context> context,
|
Maybe<int> ObjectGetInt(v8::Local<v8::Context> context,
|
||||||
Local<Object> object,
|
Local<Object> object,
|
||||||
const char* property) {
|
const char* property) {
|
||||||
HandleScope handle_scope(context->GetIsolate());
|
HandleScope handle_scope(Isolate::GetCurrent());
|
||||||
Local<Value> value;
|
Local<Value> value;
|
||||||
if (!object->Get(context, OneByteString(context->GetIsolate(), property))
|
if (!object->Get(context, OneByteString(Isolate::GetCurrent(), property))
|
||||||
.ToLocal(&value) ||
|
.ToLocal(&value) ||
|
||||||
!value->IsInt32()) {
|
!value->IsInt32()) {
|
||||||
return Nothing<int>();
|
return Nothing<int>();
|
||||||
|
|
@ -79,9 +80,9 @@ Maybe<int> ObjectGetInt(v8::Local<v8::Context> context,
|
||||||
Maybe<bool> ObjectGetBool(v8::Local<v8::Context> context,
|
Maybe<bool> ObjectGetBool(v8::Local<v8::Context> context,
|
||||||
Local<Object> object,
|
Local<Object> object,
|
||||||
const char* property) {
|
const char* property) {
|
||||||
HandleScope handle_scope(context->GetIsolate());
|
HandleScope handle_scope(Isolate::GetCurrent());
|
||||||
Local<Value> value;
|
Local<Value> value;
|
||||||
if (!object->Get(context, OneByteString(context->GetIsolate(), property))
|
if (!object->Get(context, OneByteString(Isolate::GetCurrent(), property))
|
||||||
.ToLocal(&value) ||
|
.ToLocal(&value) ||
|
||||||
!value->IsBoolean()) {
|
!value->IsBoolean()) {
|
||||||
return Nothing<bool>();
|
return Nothing<bool>();
|
||||||
|
|
@ -93,9 +94,9 @@ Maybe<bool> ObjectGetBool(v8::Local<v8::Context> context,
|
||||||
MaybeLocal<v8::Object> ObjectGetObject(v8::Local<v8::Context> context,
|
MaybeLocal<v8::Object> ObjectGetObject(v8::Local<v8::Context> context,
|
||||||
Local<Object> object,
|
Local<Object> object,
|
||||||
const char* property) {
|
const char* property) {
|
||||||
EscapableHandleScope handle_scope(context->GetIsolate());
|
EscapableHandleScope handle_scope(Isolate::GetCurrent());
|
||||||
Local<Value> value;
|
Local<Value> value;
|
||||||
if (!object->Get(context, OneByteString(context->GetIsolate(), property))
|
if (!object->Get(context, OneByteString(Isolate::GetCurrent(), property))
|
||||||
.ToLocal(&value) ||
|
.ToLocal(&value) ||
|
||||||
!value->IsObject()) {
|
!value->IsObject()) {
|
||||||
return {};
|
return {};
|
||||||
|
|
@ -106,7 +107,7 @@ MaybeLocal<v8::Object> ObjectGetObject(v8::Local<v8::Context> context,
|
||||||
// Create a protocol::Network::Headers from the v8 object.
|
// Create a protocol::Network::Headers from the v8 object.
|
||||||
std::unique_ptr<protocol::Network::Headers> createHeadersFromObject(
|
std::unique_ptr<protocol::Network::Headers> createHeadersFromObject(
|
||||||
v8::Local<v8::Context> context, Local<Object> headers_obj) {
|
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 =
|
std::unique_ptr<protocol::DictionaryValue> dict =
|
||||||
protocol::DictionaryValue::create();
|
protocol::DictionaryValue::create();
|
||||||
|
|
@ -127,7 +128,7 @@ std::unique_ptr<protocol::Network::Headers> createHeadersFromObject(
|
||||||
.To(&property_value)) {
|
.To(&property_value)) {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
dict->setString(ToProtocolString(context->GetIsolate(), property_name),
|
dict->setString(ToProtocolString(Isolate::GetCurrent(), property_name),
|
||||||
property_value);
|
property_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -137,7 +138,7 @@ std::unique_ptr<protocol::Network::Headers> createHeadersFromObject(
|
||||||
// Create a protocol::Network::Request from the v8 object.
|
// Create a protocol::Network::Request from the v8 object.
|
||||||
std::unique_ptr<protocol::Network::Request> createRequestFromObject(
|
std::unique_ptr<protocol::Network::Request> createRequestFromObject(
|
||||||
v8::Local<v8::Context> context, Local<Object> request) {
|
v8::Local<v8::Context> context, Local<Object> request) {
|
||||||
HandleScope handle_scope(context->GetIsolate());
|
HandleScope handle_scope(Isolate::GetCurrent());
|
||||||
protocol::String url;
|
protocol::String url;
|
||||||
if (!ObjectGetProtocolString(context, request, "url").To(&url)) {
|
if (!ObjectGetProtocolString(context, request, "url").To(&url)) {
|
||||||
return {};
|
return {};
|
||||||
|
|
@ -169,7 +170,7 @@ std::unique_ptr<protocol::Network::Request> createRequestFromObject(
|
||||||
// Create a protocol::Network::Response from the v8 object.
|
// Create a protocol::Network::Response from the v8 object.
|
||||||
std::unique_ptr<protocol::Network::Response> createResponseFromObject(
|
std::unique_ptr<protocol::Network::Response> createResponseFromObject(
|
||||||
v8::Local<v8::Context> context, Local<Object> response) {
|
v8::Local<v8::Context> context, Local<Object> response) {
|
||||||
HandleScope handle_scope(context->GetIsolate());
|
HandleScope handle_scope(Isolate::GetCurrent());
|
||||||
protocol::String url;
|
protocol::String url;
|
||||||
if (!ObjectGetProtocolString(context, response, "url").To(&url)) {
|
if (!ObjectGetProtocolString(context, response, "url").To(&url)) {
|
||||||
return {};
|
return {};
|
||||||
|
|
@ -210,7 +211,7 @@ std::unique_ptr<protocol::Network::Response> createResponseFromObject(
|
||||||
|
|
||||||
std::unique_ptr<protocol::Network::WebSocketResponse> createWebSocketResponse(
|
std::unique_ptr<protocol::Network::WebSocketResponse> createWebSocketResponse(
|
||||||
v8::Local<v8::Context> context, Local<Object> response) {
|
v8::Local<v8::Context> context, Local<Object> response) {
|
||||||
HandleScope handle_scope(context->GetIsolate());
|
HandleScope handle_scope(Isolate::GetCurrent());
|
||||||
int status;
|
int status;
|
||||||
if (!ObjectGetInt(context, response, "status").To(&status)) {
|
if (!ObjectGetInt(context, response, "status").To(&status)) {
|
||||||
return {};
|
return {};
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ class RefTracker {
|
||||||
struct napi_env__ {
|
struct napi_env__ {
|
||||||
explicit napi_env__(v8::Local<v8::Context> context,
|
explicit napi_env__(v8::Local<v8::Context> context,
|
||||||
int32_t module_api_version)
|
int32_t module_api_version)
|
||||||
: isolate(context->GetIsolate()),
|
: isolate(v8::Isolate::GetCurrent()),
|
||||||
context_persistent(isolate, context),
|
context_persistent(isolate, context),
|
||||||
module_api_version(module_api_version) {
|
module_api_version(module_api_version) {
|
||||||
napi_clear_last_error(this);
|
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::Context> context_persistent;
|
||||||
|
|
||||||
v8impl::Persistent<v8::Value> last_exception;
|
v8impl::Persistent<v8::Value> last_exception;
|
||||||
|
|
|
||||||
|
|
@ -99,7 +99,7 @@ ModuleCacheKey ModuleCacheKey::From(Local<Context> context,
|
||||||
Local<String> specifier,
|
Local<String> specifier,
|
||||||
Local<FixedArray> import_attributes) {
|
Local<FixedArray> import_attributes) {
|
||||||
CHECK_EQ(import_attributes->Length() % elements_per_attribute, 0);
|
CHECK_EQ(import_attributes->Length() % elements_per_attribute, 0);
|
||||||
Isolate* isolate = context->GetIsolate();
|
Isolate* isolate = Isolate::GetCurrent();
|
||||||
std::size_t h1 = specifier->GetIdentityHash();
|
std::size_t h1 = specifier->GetIdentityHash();
|
||||||
size_t num_attributes = import_attributes->Length() / elements_per_attribute;
|
size_t num_attributes = import_attributes->Length() / elements_per_attribute;
|
||||||
ImportAttributeVector attributes;
|
ImportAttributeVector attributes;
|
||||||
|
|
@ -1022,7 +1022,7 @@ MaybeLocal<Module> ModuleWrap::ResolveModuleCallback(
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
DCHECK_NOT_NULL(resolved_module);
|
DCHECK_NOT_NULL(resolved_module);
|
||||||
return resolved_module->module_.Get(context->GetIsolate());
|
return resolved_module->module_.Get(Isolate::GetCurrent());
|
||||||
}
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
|
|
@ -1046,7 +1046,7 @@ MaybeLocal<Object> ModuleWrap::ResolveSourceCallback(
|
||||||
Local<String> url = resolved_module->object()
|
Local<String> url = resolved_module->object()
|
||||||
->GetInternalField(ModuleWrap::kURLSlot)
|
->GetInternalField(ModuleWrap::kURLSlot)
|
||||||
.As<String>();
|
.As<String>();
|
||||||
THROW_ERR_SOURCE_PHASE_NOT_DEFINED(context->GetIsolate(), url);
|
THROW_ERR_SOURCE_PHASE_NOT_DEFINED(Isolate::GetCurrent(), url);
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
CHECK(module_source_object->IsObject());
|
CHECK(module_source_object->IsObject());
|
||||||
|
|
@ -1059,7 +1059,7 @@ Maybe<ModuleWrap*> ModuleWrap::ResolveModule(
|
||||||
Local<String> specifier,
|
Local<String> specifier,
|
||||||
Local<FixedArray> import_attributes,
|
Local<FixedArray> import_attributes,
|
||||||
Local<Module> referrer) {
|
Local<Module> referrer) {
|
||||||
Isolate* isolate = context->GetIsolate();
|
Isolate* isolate = Isolate::GetCurrent();
|
||||||
Environment* env = Environment::GetCurrent(context);
|
Environment* env = Environment::GetCurrent(context);
|
||||||
if (env == nullptr) {
|
if (env == nullptr) {
|
||||||
THROW_ERR_EXECUTION_ENVIRONMENT_NOT_AVAILABLE(isolate);
|
THROW_ERR_EXECUTION_ENVIRONMENT_NOT_AVAILABLE(isolate);
|
||||||
|
|
@ -1104,7 +1104,7 @@ static MaybeLocal<Promise> ImportModuleDynamicallyWithPhase(
|
||||||
Local<String> specifier,
|
Local<String> specifier,
|
||||||
ModuleImportPhase phase,
|
ModuleImportPhase phase,
|
||||||
Local<FixedArray> import_attributes) {
|
Local<FixedArray> import_attributes) {
|
||||||
Isolate* isolate = context->GetIsolate();
|
Isolate* isolate = Isolate::GetCurrent();
|
||||||
Environment* env = Environment::GetCurrent(context);
|
Environment* env = Environment::GetCurrent(context);
|
||||||
if (env == nullptr) {
|
if (env == nullptr) {
|
||||||
THROW_ERR_EXECUTION_ENVIRONMENT_NOT_AVAILABLE(isolate);
|
THROW_ERR_EXECUTION_ENVIRONMENT_NOT_AVAILABLE(isolate);
|
||||||
|
|
@ -1343,7 +1343,7 @@ MaybeLocal<Module> LinkRequireFacadeWithOriginal(
|
||||||
Local<FixedArray> import_attributes,
|
Local<FixedArray> import_attributes,
|
||||||
Local<Module> referrer) {
|
Local<Module> referrer) {
|
||||||
Environment* env = Environment::GetCurrent(context);
|
Environment* env = Environment::GetCurrent(context);
|
||||||
Isolate* isolate = context->GetIsolate();
|
Isolate* isolate = Isolate::GetCurrent();
|
||||||
CHECK(specifier->Equals(context, env->original_string()).ToChecked());
|
CHECK(specifier->Equals(context, env->original_string()).ToChecked());
|
||||||
CHECK(!env->temporary_required_module_facade_original.IsEmpty());
|
CHECK(!env->temporary_required_module_facade_original.IsEmpty());
|
||||||
return env->temporary_required_module_facade_original.Get(isolate);
|
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) \
|
#define NODE_DEFINE_CONSTANT(target, constant) \
|
||||||
do { \
|
do { \
|
||||||
v8::Isolate* isolate = target->GetIsolate(); \
|
v8::Isolate* isolate = v8::Isolate::GetCurrent(); \
|
||||||
v8::Local<v8::Context> context = isolate->GetCurrentContext(); \
|
v8::Local<v8::Context> context = isolate->GetCurrentContext(); \
|
||||||
v8::Local<v8::String> constant_name = v8::String::NewFromUtf8Literal( \
|
v8::Local<v8::String> constant_name = v8::String::NewFromUtf8Literal( \
|
||||||
isolate, #constant, v8::NewStringType::kInternalized); \
|
isolate, #constant, v8::NewStringType::kInternalized); \
|
||||||
|
|
@ -1017,7 +1017,7 @@ NODE_DEPRECATED("Use v8::Date::ValueOf() directly",
|
||||||
|
|
||||||
#define NODE_DEFINE_HIDDEN_CONSTANT(target, constant) \
|
#define NODE_DEFINE_HIDDEN_CONSTANT(target, constant) \
|
||||||
do { \
|
do { \
|
||||||
v8::Isolate* isolate = target->GetIsolate(); \
|
v8::Isolate* isolate = v8::Isolate::GetCurrent(); \
|
||||||
v8::Local<v8::Context> context = isolate->GetCurrentContext(); \
|
v8::Local<v8::Context> context = isolate->GetCurrentContext(); \
|
||||||
v8::Local<v8::String> constant_name = v8::String::NewFromUtf8Literal( \
|
v8::Local<v8::String> constant_name = v8::String::NewFromUtf8Literal( \
|
||||||
isolate, #constant, v8::NewStringType::kInternalized); \
|
isolate, #constant, v8::NewStringType::kInternalized); \
|
||||||
|
|
|
||||||
|
|
@ -554,7 +554,7 @@ void BlobBindingData::Deserialize(Local<Context> context,
|
||||||
int index,
|
int index,
|
||||||
InternalFieldInfoBase* info) {
|
InternalFieldInfoBase* info) {
|
||||||
DCHECK_IS_SNAPSHOT_SLOT(index);
|
DCHECK_IS_SNAPSHOT_SLOT(index);
|
||||||
HandleScope scope(context->GetIsolate());
|
HandleScope scope(Isolate::GetCurrent());
|
||||||
Realm* realm = Realm::GetCurrent(context);
|
Realm* realm = Realm::GetCurrent(context);
|
||||||
BlobBindingData* binding = realm->AddBindingData<BlobBindingData>(holder);
|
BlobBindingData* binding = realm->AddBindingData<BlobBindingData>(holder);
|
||||||
CHECK_NOT_NULL(binding);
|
CHECK_NOT_NULL(binding);
|
||||||
|
|
|
||||||
|
|
@ -275,7 +275,7 @@ MaybeLocal<Function> BuiltinLoader::LookupAndCompileInternal(
|
||||||
const char* id,
|
const char* id,
|
||||||
LocalVector<String>* parameters,
|
LocalVector<String>* parameters,
|
||||||
Realm* optional_realm) {
|
Realm* optional_realm) {
|
||||||
Isolate* isolate = context->GetIsolate();
|
Isolate* isolate = Isolate::GetCurrent();
|
||||||
EscapableHandleScope scope(isolate);
|
EscapableHandleScope scope(isolate);
|
||||||
|
|
||||||
Local<String> source;
|
Local<String> source;
|
||||||
|
|
@ -397,7 +397,7 @@ void BuiltinLoader::SaveCodeCache(const char* id, Local<Function> fun) {
|
||||||
MaybeLocal<Function> BuiltinLoader::LookupAndCompile(Local<Context> context,
|
MaybeLocal<Function> BuiltinLoader::LookupAndCompile(Local<Context> context,
|
||||||
const char* id,
|
const char* id,
|
||||||
Realm* optional_realm) {
|
Realm* optional_realm) {
|
||||||
Isolate* isolate = context->GetIsolate();
|
Isolate* isolate = Isolate::GetCurrent();
|
||||||
LocalVector<String> parameters(isolate);
|
LocalVector<String> parameters(isolate);
|
||||||
// Detects parameters of the scripts based on module ids.
|
// Detects parameters of the scripts based on module ids.
|
||||||
// internal/bootstrap/realm: process, getLinkedBinding,
|
// internal/bootstrap/realm: process, getLinkedBinding,
|
||||||
|
|
@ -451,7 +451,7 @@ MaybeLocal<Function> BuiltinLoader::LookupAndCompile(Local<Context> context,
|
||||||
MaybeLocal<Value> BuiltinLoader::CompileAndCall(Local<Context> context,
|
MaybeLocal<Value> BuiltinLoader::CompileAndCall(Local<Context> context,
|
||||||
const char* id,
|
const char* id,
|
||||||
Realm* realm) {
|
Realm* realm) {
|
||||||
Isolate* isolate = context->GetIsolate();
|
Isolate* isolate = Isolate::GetCurrent();
|
||||||
// Detects parameters of the scripts based on module ids.
|
// Detects parameters of the scripts based on module ids.
|
||||||
// internal/bootstrap/realm: process, getLinkedBinding,
|
// internal/bootstrap/realm: process, getLinkedBinding,
|
||||||
// getInternalBinding, primordials
|
// getInternalBinding, primordials
|
||||||
|
|
@ -507,7 +507,7 @@ MaybeLocal<Value> BuiltinLoader::CompileAndCall(Local<Context> context,
|
||||||
if (!maybe_fn.ToLocal(&fn)) {
|
if (!maybe_fn.ToLocal(&fn)) {
|
||||||
return MaybeLocal<Value>();
|
return MaybeLocal<Value>();
|
||||||
}
|
}
|
||||||
Local<Value> undefined = Undefined(context->GetIsolate());
|
Local<Value> undefined = Undefined(Isolate::GetCurrent());
|
||||||
return fn->Call(context, undefined, argc, argv);
|
return fn->Call(context, undefined, argc, argv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -545,14 +545,14 @@ bool BuiltinLoader::CompileAllBuiltinsAndCopyCodeCache(
|
||||||
to_eager_compile_.emplace(id);
|
to_eager_compile_.emplace(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
TryCatch bootstrapCatch(context->GetIsolate());
|
TryCatch bootstrapCatch(Isolate::GetCurrent());
|
||||||
auto fn = LookupAndCompile(context, id.data(), nullptr);
|
auto fn = LookupAndCompile(context, id.data(), nullptr);
|
||||||
if (bootstrapCatch.HasCaught()) {
|
if (bootstrapCatch.HasCaught()) {
|
||||||
per_process::Debug(DebugCategory::CODE_CACHE,
|
per_process::Debug(DebugCategory::CODE_CACHE,
|
||||||
"Failed to compile code cache for %s\n",
|
"Failed to compile code cache for %s\n",
|
||||||
id.data());
|
id.data());
|
||||||
all_succeeded = false;
|
all_succeeded = false;
|
||||||
PrintCaughtException(context->GetIsolate(), context, bootstrapCatch);
|
PrintCaughtException(Isolate::GetCurrent(), context, bootstrapCatch);
|
||||||
} else {
|
} else {
|
||||||
// This is used by the snapshot builder, so save the code cache
|
// This is used by the snapshot builder, so save the code cache
|
||||||
// unconditionally.
|
// unconditionally.
|
||||||
|
|
|
||||||
|
|
@ -1281,11 +1281,10 @@ void CreatePerContextProperties(Local<Object> target,
|
||||||
Local<Value> unused,
|
Local<Value> unused,
|
||||||
Local<Context> context,
|
Local<Context> context,
|
||||||
void* priv) {
|
void* priv) {
|
||||||
Isolate* isolate = context->GetIsolate();
|
Isolate* isolate = Isolate::GetCurrent();
|
||||||
Environment* env = Environment::GetCurrent(context);
|
Environment* env = Environment::GetCurrent(context);
|
||||||
|
|
||||||
CHECK(
|
CHECK(target->SetPrototypeV2(env->context(), Null(isolate)).FromJust());
|
||||||
target->SetPrototypeV2(env->context(), Null(env->isolate())).FromJust());
|
|
||||||
|
|
||||||
Local<Object> os_constants =
|
Local<Object> os_constants =
|
||||||
Object::New(isolate, Null(isolate), nullptr, nullptr, 0);
|
Object::New(isolate, Null(isolate), nullptr, nullptr, 0);
|
||||||
|
|
|
||||||
|
|
@ -112,7 +112,7 @@ namespace {
|
||||||
|
|
||||||
// Convert an int to a V8 Name (String or Symbol).
|
// Convert an int to a V8 Name (String or Symbol).
|
||||||
MaybeLocal<String> Uint32ToName(Local<Context> context, uint32_t index) {
|
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
|
} // anonymous namespace
|
||||||
|
|
@ -676,7 +676,7 @@ Intercepted ContextifyContext::PropertyDefinerCallback(
|
||||||
}
|
}
|
||||||
|
|
||||||
Local<Context> context = ctx->context();
|
Local<Context> context = ctx->context();
|
||||||
Isolate* isolate = context->GetIsolate();
|
Isolate* isolate = Isolate::GetCurrent();
|
||||||
|
|
||||||
PropertyAttribute attributes = PropertyAttribute::None;
|
PropertyAttribute attributes = PropertyAttribute::None;
|
||||||
bool is_declared =
|
bool is_declared =
|
||||||
|
|
@ -1656,7 +1656,7 @@ static MaybeLocal<Function> CompileFunctionForCJSLoader(
|
||||||
bool* cache_rejected,
|
bool* cache_rejected,
|
||||||
bool is_cjs_scope,
|
bool is_cjs_scope,
|
||||||
ScriptCompiler::CachedData* cached_data) {
|
ScriptCompiler::CachedData* cached_data) {
|
||||||
Isolate* isolate = context->GetIsolate();
|
Isolate* isolate = Isolate::GetCurrent();
|
||||||
EscapableHandleScope scope(isolate);
|
EscapableHandleScope scope(isolate);
|
||||||
|
|
||||||
Local<Symbol> symbol = env->vm_dynamic_import_default_internal();
|
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,
|
Maybe<void> KVStore::AssignFromObject(Local<Context> context,
|
||||||
Local<Object> entries) {
|
Local<Object> entries) {
|
||||||
Isolate* isolate = context->GetIsolate();
|
Isolate* isolate = Isolate::GetCurrent();
|
||||||
HandleScope handle_scope(isolate);
|
HandleScope handle_scope(isolate);
|
||||||
Local<Array> keys;
|
Local<Array> keys;
|
||||||
if (!entries->GetOwnPropertyNames(context).ToLocal(&keys))
|
if (!entries->GetOwnPropertyNames(context).ToLocal(&keys))
|
||||||
|
|
|
||||||
|
|
@ -633,7 +633,7 @@ v8::ModifyCodeGenerationFromStringsResult ModifyCodeGenerationFromStrings(
|
||||||
v8::Local<v8::Context> context,
|
v8::Local<v8::Context> context,
|
||||||
v8::Local<v8::Value> source,
|
v8::Local<v8::Value> source,
|
||||||
bool is_code_like) {
|
bool is_code_like) {
|
||||||
HandleScope scope(context->GetIsolate());
|
HandleScope scope(Isolate::GetCurrent());
|
||||||
|
|
||||||
if (context->GetNumberOfEmbedderDataFields() <=
|
if (context->GetNumberOfEmbedderDataFields() <=
|
||||||
ContextEmbedderIndex::kAllowCodeGenerationFromStrings) {
|
ContextEmbedderIndex::kAllowCodeGenerationFromStrings) {
|
||||||
|
|
@ -1016,7 +1016,7 @@ const char* errno_string(int errorno) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void PerIsolateMessageListener(Local<Message> message, Local<Value> error) {
|
void PerIsolateMessageListener(Local<Message> message, Local<Value> error) {
|
||||||
Isolate* isolate = message->GetIsolate();
|
Isolate* isolate = Isolate::GetCurrent();
|
||||||
switch (message->ErrorLevel()) {
|
switch (message->ErrorLevel()) {
|
||||||
case Isolate::MessageErrorLevel::kMessageWarning: {
|
case Isolate::MessageErrorLevel::kMessageWarning: {
|
||||||
Environment* env = Environment::GetCurrent(isolate);
|
Environment* env = Environment::GetCurrent(isolate);
|
||||||
|
|
@ -1177,7 +1177,7 @@ void Initialize(Local<Object> target,
|
||||||
SetMethod(
|
SetMethod(
|
||||||
context, target, "getErrorSourcePositions", GetErrorSourcePositions);
|
context, target, "getErrorSourcePositions", GetErrorSourcePositions);
|
||||||
|
|
||||||
Isolate* isolate = context->GetIsolate();
|
Isolate* isolate = Isolate::GetCurrent();
|
||||||
Local<Object> exit_codes = Object::New(isolate);
|
Local<Object> exit_codes = Object::New(isolate);
|
||||||
READONLY_PROPERTY(target, "exitCodes", exit_codes);
|
READONLY_PROPERTY(target, "exitCodes", exit_codes);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3851,7 +3851,7 @@ void BindingData::Deserialize(Local<Context> context,
|
||||||
int index,
|
int index,
|
||||||
InternalFieldInfoBase* info) {
|
InternalFieldInfoBase* info) {
|
||||||
DCHECK_IS_SNAPSHOT_SLOT(index);
|
DCHECK_IS_SNAPSHOT_SLOT(index);
|
||||||
HandleScope scope(context->GetIsolate());
|
HandleScope scope(Isolate::GetCurrent());
|
||||||
Realm* realm = Realm::GetCurrent(context);
|
Realm* realm = Realm::GetCurrent(context);
|
||||||
InternalFieldInfo* casted_info = static_cast<InternalFieldInfo*>(info);
|
InternalFieldInfo* casted_info = static_cast<InternalFieldInfo*>(info);
|
||||||
BindingData* binding =
|
BindingData* binding =
|
||||||
|
|
|
||||||
|
|
@ -254,7 +254,7 @@ namespace {
|
||||||
|
|
||||||
MaybeLocal<Function> GetEmitMessageFunction(Local<Context> context,
|
MaybeLocal<Function> GetEmitMessageFunction(Local<Context> context,
|
||||||
IsolateData* isolate_data) {
|
IsolateData* isolate_data) {
|
||||||
Isolate* isolate = context->GetIsolate();
|
Isolate* isolate = Isolate::GetCurrent();
|
||||||
Local<Object> per_context_bindings;
|
Local<Object> per_context_bindings;
|
||||||
Local<Value> emit_message_val;
|
Local<Value> emit_message_val;
|
||||||
if (!GetPerContextExports(context, isolate_data)
|
if (!GetPerContextExports(context, isolate_data)
|
||||||
|
|
@ -269,7 +269,7 @@ MaybeLocal<Function> GetEmitMessageFunction(Local<Context> context,
|
||||||
}
|
}
|
||||||
|
|
||||||
MaybeLocal<Function> GetDOMException(Local<Context> context) {
|
MaybeLocal<Function> GetDOMException(Local<Context> context) {
|
||||||
Isolate* isolate = context->GetIsolate();
|
Isolate* isolate = Isolate::GetCurrent();
|
||||||
Local<Object> per_context_bindings;
|
Local<Object> per_context_bindings;
|
||||||
Local<Value> domexception_ctor_val;
|
Local<Value> domexception_ctor_val;
|
||||||
if (!GetPerContextExports(context).ToLocal(&per_context_bindings) ||
|
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) {
|
void ThrowDataCloneException(Local<Context> context, Local<String> message) {
|
||||||
Isolate* isolate = context->GetIsolate();
|
Isolate* isolate = Isolate::GetCurrent();
|
||||||
Local<Value> argv[] = {message,
|
Local<Value> argv[] = {message,
|
||||||
FIXED_ONE_BYTE_STRING(isolate, "DataCloneError")};
|
FIXED_ONE_BYTE_STRING(isolate, "DataCloneError")};
|
||||||
Local<Value> exception;
|
Local<Value> exception;
|
||||||
|
|
@ -1477,7 +1477,7 @@ BaseObjectPtr<BaseObject> JSTransferable::Data::Deserialize(
|
||||||
|
|
||||||
Maybe<bool> JSTransferable::Data::FinalizeTransferWrite(
|
Maybe<bool> JSTransferable::Data::FinalizeTransferWrite(
|
||||||
Local<Context> context, ValueSerializer* serializer) {
|
Local<Context> context, ValueSerializer* serializer) {
|
||||||
HandleScope handle_scope(context->GetIsolate());
|
HandleScope handle_scope(Isolate::GetCurrent());
|
||||||
auto ret = serializer->WriteValue(context, PersistentToLocal::Strong(data_));
|
auto ret = serializer->WriteValue(context, PersistentToLocal::Strong(data_));
|
||||||
data_.Reset();
|
data_.Reset();
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
||||||
|
|
@ -68,7 +68,7 @@ void BindingData::Deserialize(v8::Local<v8::Context> context,
|
||||||
int index,
|
int index,
|
||||||
InternalFieldInfoBase* info) {
|
InternalFieldInfoBase* info) {
|
||||||
DCHECK_IS_SNAPSHOT_SLOT(index);
|
DCHECK_IS_SNAPSHOT_SLOT(index);
|
||||||
HandleScope scope(context->GetIsolate());
|
HandleScope scope(Isolate::GetCurrent());
|
||||||
Realm* realm = Realm::GetCurrent(context);
|
Realm* realm = Realm::GetCurrent(context);
|
||||||
BindingData* binding = realm->AddBindingData<BindingData>(holder);
|
BindingData* binding = realm->AddBindingData<BindingData>(holder);
|
||||||
CHECK_NOT_NULL(binding);
|
CHECK_NOT_NULL(binding);
|
||||||
|
|
@ -664,7 +664,7 @@ void BindingData::CreatePerContextProperties(Local<Object> target,
|
||||||
Realm* realm = Realm::GetCurrent(context);
|
Realm* realm = Realm::GetCurrent(context);
|
||||||
realm->AddBindingData<BindingData>(target);
|
realm->AddBindingData<BindingData>(target);
|
||||||
|
|
||||||
Isolate* isolate = context->GetIsolate();
|
Isolate* isolate = Isolate::GetCurrent();
|
||||||
LocalVector<Value> compile_cache_status_values(isolate);
|
LocalVector<Value> compile_cache_status_values(isolate);
|
||||||
|
|
||||||
#define V(status) \
|
#define V(status) \
|
||||||
|
|
|
||||||
|
|
@ -737,7 +737,7 @@ void BindingData::Deserialize(Local<Context> context,
|
||||||
int index,
|
int index,
|
||||||
InternalFieldInfoBase* info) {
|
InternalFieldInfoBase* info) {
|
||||||
DCHECK_IS_SNAPSHOT_SLOT(index);
|
DCHECK_IS_SNAPSHOT_SLOT(index);
|
||||||
v8::HandleScope scope(context->GetIsolate());
|
v8::HandleScope scope(Isolate::GetCurrent());
|
||||||
Realm* realm = Realm::GetCurrent(context);
|
Realm* realm = Realm::GetCurrent(context);
|
||||||
// Recreate the buffer in the constructor.
|
// Recreate the buffer in the constructor.
|
||||||
InternalFieldInfo* casted_info = static_cast<InternalFieldInfo*>(info);
|
InternalFieldInfo* casted_info = static_cast<InternalFieldInfo*>(info);
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ using v8::String;
|
||||||
using v8::Value;
|
using v8::Value;
|
||||||
|
|
||||||
Realm::Realm(Environment* env, v8::Local<v8::Context> context, Kind kind)
|
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);
|
context_.Reset(isolate_, context);
|
||||||
env->AssignToContext(context, this, ContextInfo(""));
|
env->AssignToContext(context, this, ContextInfo(""));
|
||||||
// The environment can also purge empty wrappers in the check callback,
|
// 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()) {
|
if (!error.IsEmpty() && error->IsObject()) {
|
||||||
TryCatch try_catch(isolate);
|
TryCatch try_catch(isolate);
|
||||||
Local<Object> error_obj = error.As<Object>();
|
Local<Object> error_obj = error.As<Object>();
|
||||||
Local<Context> context = error_obj->GetIsolate()->GetCurrentContext();
|
Local<Context> context = Isolate::GetCurrent()->GetCurrentContext();
|
||||||
Local<Array> keys;
|
Local<Array> keys;
|
||||||
if (!error_obj->GetOwnPropertyNames(context).ToLocal(&keys)) {
|
if (!error_obj->GetOwnPropertyNames(context).ToLocal(&keys)) {
|
||||||
return writer->json_objectend(); // the end of 'errorProperties'
|
return writer->json_objectend(); // the end of 'errorProperties'
|
||||||
|
|
|
||||||
|
|
@ -1614,7 +1614,7 @@ void BindingData::Deserialize(Local<Context> context,
|
||||||
int index,
|
int index,
|
||||||
InternalFieldInfoBase* info) {
|
InternalFieldInfoBase* info) {
|
||||||
DCHECK_IS_SNAPSHOT_SLOT(index);
|
DCHECK_IS_SNAPSHOT_SLOT(index);
|
||||||
v8::HandleScope scope(context->GetIsolate());
|
v8::HandleScope scope(Isolate::GetCurrent());
|
||||||
Realm* realm = Realm::GetCurrent(context);
|
Realm* realm = Realm::GetCurrent(context);
|
||||||
// Recreate the buffer in the constructor.
|
// Recreate the buffer in the constructor.
|
||||||
InternalFieldInfo* casted_info = static_cast<InternalFieldInfo*>(info);
|
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()) {
|
if (args[0]->IsObject() && !args[0]->IsArrayBufferView()) {
|
||||||
Local<Object> obj = args[0].As<Object>();
|
Local<Object> obj = args[0].As<Object>();
|
||||||
Local<Context> context = obj->GetIsolate()->GetCurrentContext();
|
Local<Context> context = Isolate::GetCurrent()->GetCurrentContext();
|
||||||
Local<Array> keys;
|
Local<Array> keys;
|
||||||
if (!obj->GetOwnPropertyNames(context).ToLocal(&keys)) {
|
if (!obj->GetOwnPropertyNames(context).ToLocal(&keys)) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ void PromiseRejectCallback(PromiseRejectMessage message) {
|
||||||
static std::atomic<uint64_t> rejectionsHandledAfter{0};
|
static std::atomic<uint64_t> rejectionsHandledAfter{0};
|
||||||
|
|
||||||
Local<Promise> promise = message.GetPromise();
|
Local<Promise> promise = message.GetPromise();
|
||||||
Isolate* isolate = promise->GetIsolate();
|
Isolate* isolate = Isolate::GetCurrent();
|
||||||
PromiseRejectEvent event = message.GetEvent();
|
PromiseRejectEvent event = message.GetEvent();
|
||||||
|
|
||||||
Environment* env = Environment::GetCurrent(isolate);
|
Environment* env = Environment::GetCurrent(isolate);
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,7 @@ void BindingData::Deserialize(Local<Context> context,
|
||||||
int index,
|
int index,
|
||||||
InternalFieldInfoBase* info) {
|
InternalFieldInfoBase* info) {
|
||||||
DCHECK_IS_SNAPSHOT_SLOT(index);
|
DCHECK_IS_SNAPSHOT_SLOT(index);
|
||||||
HandleScope scope(context->GetIsolate());
|
HandleScope scope(Isolate::GetCurrent());
|
||||||
Realm* realm = Realm::GetCurrent(context);
|
Realm* realm = Realm::GetCurrent(context);
|
||||||
BindingData* binding = realm->AddBindingData<BindingData>(holder);
|
BindingData* binding = realm->AddBindingData<BindingData>(holder);
|
||||||
CHECK_NOT_NULL(binding);
|
CHECK_NOT_NULL(binding);
|
||||||
|
|
|
||||||
|
|
@ -158,7 +158,7 @@ void BindingData::Deserialize(Local<Context> context,
|
||||||
int index,
|
int index,
|
||||||
InternalFieldInfoBase* info) {
|
InternalFieldInfoBase* info) {
|
||||||
DCHECK_IS_SNAPSHOT_SLOT(index);
|
DCHECK_IS_SNAPSHOT_SLOT(index);
|
||||||
HandleScope scope(context->GetIsolate());
|
HandleScope scope(Isolate::GetCurrent());
|
||||||
Realm* realm = Realm::GetCurrent(context);
|
Realm* realm = Realm::GetCurrent(context);
|
||||||
// Recreate the buffer in the constructor.
|
// Recreate the buffer in the constructor.
|
||||||
InternalFieldInfo* casted_info = static_cast<InternalFieldInfo*>(info);
|
InternalFieldInfo* casted_info = static_cast<InternalFieldInfo*>(info);
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ using v8::WasmMemoryObject;
|
||||||
static MaybeLocal<Value> WASIException(Local<Context> context,
|
static MaybeLocal<Value> WASIException(Local<Context> context,
|
||||||
int errorno,
|
int errorno,
|
||||||
const char* syscall) {
|
const char* syscall) {
|
||||||
Isolate* isolate = context->GetIsolate();
|
Isolate* isolate = Isolate::GetCurrent();
|
||||||
Environment* env = Environment::GetCurrent(context);
|
Environment* env = Environment::GetCurrent(context);
|
||||||
CHECK_NOT_NULL(env);
|
CHECK_NOT_NULL(env);
|
||||||
const char* err_name = uvwasi_embedder_err_code_to_string(errorno);
|
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>();
|
return EinvalError<R>();
|
||||||
}
|
}
|
||||||
|
|
||||||
Isolate* isolate = receiver->GetIsolate();
|
Isolate* isolate = Isolate::GetCurrent();
|
||||||
HandleScope scope(isolate);
|
HandleScope scope(isolate);
|
||||||
if (wasi->memory_.IsEmpty()) {
|
if (wasi->memory_.IsEmpty()) {
|
||||||
THROW_ERR_WASI_NOT_STARTED(isolate);
|
THROW_ERR_WASI_NOT_STARTED(isolate);
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ using v8::Value;
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
static void ThrowQuotaExceededException(Local<Context> context) {
|
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 dom_exception_str = FIXED_ONE_BYTE_STRING(isolate, "DOMException");
|
||||||
auto err_name = FIXED_ONE_BYTE_STRING(isolate, "QuotaExceededError");
|
auto err_name = FIXED_ONE_BYTE_STRING(isolate, "QuotaExceededError");
|
||||||
auto err_message =
|
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) {
|
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) {
|
static void Clear(const FunctionCallbackInfo<Value>& info) {
|
||||||
|
|
|
||||||
|
|
@ -1463,8 +1463,6 @@ void GetEnvMessagePort(const FunctionCallbackInfo<Value>& args) {
|
||||||
Local<Object> port = env->message_port();
|
Local<Object> port = env->message_port();
|
||||||
CHECK_IMPLIES(!env->is_main_thread(), !port.IsEmpty());
|
CHECK_IMPLIES(!env->is_main_thread(), !port.IsEmpty());
|
||||||
if (!port.IsEmpty()) {
|
if (!port.IsEmpty()) {
|
||||||
CHECK_EQ(port->GetCreationContextChecked()->GetIsolate(),
|
|
||||||
args.GetIsolate());
|
|
||||||
args.GetReturnValue().Set(port);
|
args.GetReturnValue().Set(port);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -114,7 +114,7 @@ void BindingData::Deserialize(Local<Context> context,
|
||||||
int index,
|
int index,
|
||||||
InternalFieldInfoBase* info) {
|
InternalFieldInfoBase* info) {
|
||||||
DCHECK_IS_SNAPSHOT_SLOT(index);
|
DCHECK_IS_SNAPSHOT_SLOT(index);
|
||||||
v8::HandleScope scope(context->GetIsolate());
|
v8::HandleScope scope(Isolate::GetCurrent());
|
||||||
Realm* realm = Realm::GetCurrent(context);
|
Realm* realm = Realm::GetCurrent(context);
|
||||||
// Recreate the buffer in the constructor.
|
// Recreate the buffer in the constructor.
|
||||||
BindingData* binding = realm->AddBindingData<BindingData>(holder);
|
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) {
|
std::vector<v8::Global<v8::Value>>* out) {
|
||||||
uint32_t count = js_array->Length();
|
uint32_t count = js_array->Length();
|
||||||
out->reserve(count);
|
out->reserve(count);
|
||||||
ArrayIterationData data{out, context->GetIsolate()};
|
ArrayIterationData data{out, v8::Isolate::GetCurrent()};
|
||||||
return js_array->Iterate(context, PushItemToVector, &data);
|
return js_array->Iterate(context, PushItemToVector, &data);
|
||||||
}
|
}
|
||||||
|
|
||||||
v8::MaybeLocal<v8::Value> ToV8Value(v8::Local<v8::Context> context,
|
v8::MaybeLocal<v8::Value> ToV8Value(v8::Local<v8::Context> context,
|
||||||
std::string_view str,
|
std::string_view str,
|
||||||
v8::Isolate* isolate) {
|
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]] {
|
if (str.size() >= static_cast<size_t>(v8::String::kMaxLength)) [[unlikely]] {
|
||||||
// V8 only has a TODO comment about adding an exception when the maximum
|
// V8 only has a TODO comment about adding an exception when the maximum
|
||||||
// string size is exceeded.
|
// 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::MaybeLocal<v8::Value> ToV8Value(v8::Local<v8::Context> context,
|
||||||
v8_inspector::StringView str,
|
v8_inspector::StringView str,
|
||||||
v8::Isolate* isolate) {
|
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))
|
if (str.length() >= static_cast<size_t>(v8::String::kMaxLength))
|
||||||
[[unlikely]] {
|
[[unlikely]] {
|
||||||
// V8 only has a TODO comment about adding an exception when the maximum
|
// 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,
|
v8::MaybeLocal<v8::Value> ToV8Value(v8::Local<v8::Context> context,
|
||||||
const std::vector<T>& vec,
|
const std::vector<T>& vec,
|
||||||
v8::Isolate* isolate) {
|
v8::Isolate* isolate) {
|
||||||
if (isolate == nullptr) isolate = context->GetIsolate();
|
if (isolate == nullptr) isolate = v8::Isolate::GetCurrent();
|
||||||
v8::EscapableHandleScope handle_scope(isolate);
|
v8::EscapableHandleScope handle_scope(isolate);
|
||||||
|
|
||||||
MaybeStackBuffer<v8::Local<v8::Value>, 128> arr(vec.size());
|
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,
|
v8::MaybeLocal<v8::Value> ToV8Value(v8::Local<v8::Context> context,
|
||||||
const std::set<T>& set,
|
const std::set<T>& set,
|
||||||
v8::Isolate* isolate) {
|
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::Local<v8::Set> set_js = v8::Set::New(isolate);
|
||||||
v8::HandleScope handle_scope(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,
|
v8::MaybeLocal<v8::Value> ToV8Value(v8::Local<v8::Context> context,
|
||||||
const std::ranges::elements_view<T, U>& vec,
|
const std::ranges::elements_view<T, U>& vec,
|
||||||
v8::Isolate* isolate) {
|
v8::Isolate* isolate) {
|
||||||
if (isolate == nullptr) isolate = context->GetIsolate();
|
if (isolate == nullptr) isolate = v8::Isolate::GetCurrent();
|
||||||
v8::EscapableHandleScope handle_scope(isolate);
|
v8::EscapableHandleScope handle_scope(isolate);
|
||||||
|
|
||||||
MaybeStackBuffer<v8::Local<v8::Value>, 128> arr(vec.size());
|
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,
|
v8::MaybeLocal<v8::Value> ToV8Value(v8::Local<v8::Context> context,
|
||||||
const std::unordered_map<T, U>& map,
|
const std::unordered_map<T, U>& map,
|
||||||
v8::Isolate* isolate) {
|
v8::Isolate* isolate) {
|
||||||
if (isolate == nullptr) isolate = context->GetIsolate();
|
if (isolate == nullptr) isolate = v8::Isolate::GetCurrent();
|
||||||
v8::EscapableHandleScope handle_scope(isolate);
|
v8::EscapableHandleScope handle_scope(isolate);
|
||||||
|
|
||||||
v8::Local<v8::Map> ret = v8::Map::New(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,
|
v8::MaybeLocal<v8::Value> ToV8Value(v8::Local<v8::Context> context,
|
||||||
const T& number,
|
const T& number,
|
||||||
v8::Isolate* isolate) {
|
v8::Isolate* isolate) {
|
||||||
if (isolate == nullptr) isolate = context->GetIsolate();
|
if (isolate == nullptr) isolate = v8::Isolate::GetCurrent();
|
||||||
return ConvertNumberToV8Value(isolate, number);
|
return ConvertNumberToV8Value(isolate, number);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -497,7 +497,7 @@ v8::Local<v8::Array> ToV8ValuePrimitiveArray(v8::Local<v8::Context> context,
|
||||||
std::is_floating_point_v<T>,
|
std::is_floating_point_v<T>,
|
||||||
"Only primitive types (bool, integral, floating-point) are supported.");
|
"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::EscapableHandleScope handle_scope(isolate);
|
||||||
|
|
||||||
v8::LocalVector<v8::Value> elements(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>();
|
if (value.IsEmpty()) return v8::MaybeLocal<v8::Object>();
|
||||||
}
|
}
|
||||||
v8::Local<v8::Object> obj = tmpl->NewInstance(context, property_values);
|
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()) {
|
.IsNothing()) {
|
||||||
return v8::MaybeLocal<v8::Object>();
|
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,
|
Local<v8::Object> that,
|
||||||
const std::string_view name,
|
const std::string_view name,
|
||||||
v8::FunctionCallback callback) {
|
v8::FunctionCallback callback) {
|
||||||
Isolate* isolate = context->GetIsolate();
|
Isolate* isolate = Isolate::GetCurrent();
|
||||||
Local<v8::Function> function =
|
Local<v8::Function> function =
|
||||||
NewFunctionTemplate(isolate,
|
NewFunctionTemplate(isolate,
|
||||||
callback,
|
callback,
|
||||||
|
|
@ -452,7 +452,7 @@ void SetFastMethod(Local<v8::Context> context,
|
||||||
const std::string_view name,
|
const std::string_view name,
|
||||||
v8::FunctionCallback slow_callback,
|
v8::FunctionCallback slow_callback,
|
||||||
const v8::CFunction* c_function) {
|
const v8::CFunction* c_function) {
|
||||||
Isolate* isolate = context->GetIsolate();
|
Isolate* isolate = Isolate::GetCurrent();
|
||||||
Local<v8::Function> function =
|
Local<v8::Function> function =
|
||||||
NewFunctionTemplate(isolate,
|
NewFunctionTemplate(isolate,
|
||||||
slow_callback,
|
slow_callback,
|
||||||
|
|
@ -474,7 +474,7 @@ void SetFastMethodNoSideEffect(Local<v8::Context> context,
|
||||||
const std::string_view name,
|
const std::string_view name,
|
||||||
v8::FunctionCallback slow_callback,
|
v8::FunctionCallback slow_callback,
|
||||||
const v8::CFunction* c_function) {
|
const v8::CFunction* c_function) {
|
||||||
Isolate* isolate = context->GetIsolate();
|
Isolate* isolate = Isolate::GetCurrent();
|
||||||
Local<v8::Function> function =
|
Local<v8::Function> function =
|
||||||
NewFunctionTemplate(isolate,
|
NewFunctionTemplate(isolate,
|
||||||
slow_callback,
|
slow_callback,
|
||||||
|
|
@ -562,7 +562,7 @@ void SetMethodNoSideEffect(Local<v8::Context> context,
|
||||||
Local<v8::Object> that,
|
Local<v8::Object> that,
|
||||||
const std::string_view name,
|
const std::string_view name,
|
||||||
v8::FunctionCallback callback) {
|
v8::FunctionCallback callback) {
|
||||||
Isolate* isolate = context->GetIsolate();
|
Isolate* isolate = Isolate::GetCurrent();
|
||||||
Local<v8::Function> function =
|
Local<v8::Function> function =
|
||||||
NewFunctionTemplate(isolate,
|
NewFunctionTemplate(isolate,
|
||||||
callback,
|
callback,
|
||||||
|
|
@ -689,7 +689,7 @@ void SetConstructorFunction(Local<v8::Context> context,
|
||||||
const char* name,
|
const char* name,
|
||||||
Local<v8::FunctionTemplate> tmpl,
|
Local<v8::FunctionTemplate> tmpl,
|
||||||
SetConstructorFunctionFlag flag) {
|
SetConstructorFunctionFlag flag) {
|
||||||
Isolate* isolate = context->GetIsolate();
|
Isolate* isolate = Isolate::GetCurrent();
|
||||||
SetConstructorFunction(
|
SetConstructorFunction(
|
||||||
context, that, OneByteString(isolate, name), tmpl, flag);
|
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.
|
// Variation on NODE_DEFINE_CONSTANT that sets a String value.
|
||||||
#define NODE_DEFINE_STRING_CONSTANT(target, name, constant) \
|
#define NODE_DEFINE_STRING_CONSTANT(target, name, constant) \
|
||||||
do { \
|
do { \
|
||||||
v8::Isolate* isolate = target->GetIsolate(); \
|
v8::Isolate* isolate = v8::Isolate::GetCurrent(); \
|
||||||
v8::Local<v8::String> constant_name = \
|
v8::Local<v8::String> constant_name = \
|
||||||
v8::String::NewFromUtf8(isolate, name).ToLocalChecked(); \
|
v8::String::NewFromUtf8(isolate, name).ToLocalChecked(); \
|
||||||
v8::Local<v8::String> constant_value = \
|
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::Value> module,
|
||||||
v8::Local<v8::Context> context) {
|
v8::Local<v8::Context> context) {
|
||||||
AsyncData* data = new AsyncData();
|
AsyncData* data = new AsyncData();
|
||||||
data->isolate = context->GetIsolate();
|
v8::Isolate* isolate = v8::Isolate::GetCurrent();
|
||||||
auto handle = node::AddEnvironmentCleanupHook(
|
data->isolate = isolate;
|
||||||
context->GetIsolate(),
|
auto handle =
|
||||||
AsyncCleanupHook,
|
node::AddEnvironmentCleanupHook(isolate, AsyncCleanupHook, data);
|
||||||
data);
|
|
||||||
data->handle = std::move(handle);
|
data->handle = std::move(handle);
|
||||||
|
|
||||||
auto must_not_call_handle = node::AddEnvironmentCleanupHook(
|
auto must_not_call_handle =
|
||||||
context->GetIsolate(),
|
node::AddEnvironmentCleanupHook(isolate, MustNotCall, nullptr);
|
||||||
MustNotCall,
|
|
||||||
nullptr);
|
|
||||||
node::RemoveEnvironmentCleanupHook(std::move(must_not_call_handle));
|
node::RemoveEnvironmentCleanupHook(std::move(must_not_call_handle));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ class CppGCed : public v8::Object::Wrappable {
|
||||||
|
|
||||||
static v8::Local<v8::Function> GetConstructor(
|
static v8::Local<v8::Function> GetConstructor(
|
||||||
v8::Local<v8::Context> context) {
|
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();
|
return ft->GetFunction(context).ToLocalChecked();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
static void InitModule(v8::Local<v8::Object> exports,
|
static void InitModule(v8::Local<v8::Object> exports,
|
||||||
v8::Local<v8::Value> module_val,
|
v8::Local<v8::Value> module_val,
|
||||||
v8::Local<v8::Context> context) {
|
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>();
|
v8::Local<v8::Object> module = module_val.As<v8::Object>();
|
||||||
module
|
module
|
||||||
->Set(context,
|
->Set(context,
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ inline void Test(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void Initialize(v8::Local<v8::Object> binding) {
|
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();
|
v8::Local<v8::Context> context = isolate->GetCurrentContext();
|
||||||
binding->Set(context, v8::String::NewFromUtf8(
|
binding->Set(context, v8::String::NewFromUtf8(
|
||||||
isolate, "test").ToLocalChecked(),
|
isolate, "test").ToLocalChecked(),
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ NODE_MODULE_INITIALIZER(v8::Local<v8::Object> exports,
|
||||||
static void FakeInit(v8::Local<v8::Object> exports,
|
static void FakeInit(v8::Local<v8::Object> exports,
|
||||||
v8::Local<v8::Value> module,
|
v8::Local<v8::Value> module,
|
||||||
v8::Local<v8::Context> context) {
|
v8::Local<v8::Context> context) {
|
||||||
auto isolate = context->GetIsolate();
|
auto isolate = v8::Isolate::GetCurrent();
|
||||||
auto exception = v8::Exception::Error(v8::String::NewFromUtf8(isolate,
|
auto exception = v8::Exception::Error(v8::String::NewFromUtf8(isolate,
|
||||||
"FakeInit should never run!").ToLocalChecked());
|
"FakeInit should never run!").ToLocalChecked());
|
||||||
isolate->ThrowException(exception);
|
isolate->ThrowException(exception);
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ inline void NewClass(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void Initialize(v8::Local<v8::Object> binding) {
|
inline void Initialize(v8::Local<v8::Object> binding) {
|
||||||
auto isolate = binding->GetIsolate();
|
auto isolate = v8::Isolate::GetCurrent();
|
||||||
auto context = isolate->GetCurrentContext();
|
auto context = isolate->GetCurrentContext();
|
||||||
binding->Set(context, v8::String::NewFromUtf8(
|
binding->Set(context, v8::String::NewFromUtf8(
|
||||||
isolate, "Class").ToLocalChecked(),
|
isolate, "Class").ToLocalChecked(),
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ inline void Hash(const v8::FunctionCallbackInfo<v8::Value>& info) {
|
||||||
inline void Initialize(v8::Local<v8::Object> exports,
|
inline void Initialize(v8::Local<v8::Object> exports,
|
||||||
v8::Local<v8::Value> module,
|
v8::Local<v8::Value> module,
|
||||||
v8::Local<v8::Context> context) {
|
v8::Local<v8::Context> context) {
|
||||||
auto isolate = context->GetIsolate();
|
auto isolate = v8::Isolate::GetCurrent();
|
||||||
auto key = v8::String::NewFromUtf8(
|
auto key = v8::String::NewFromUtf8(
|
||||||
isolate, "randomBytes").ToLocalChecked();
|
isolate, "randomBytes").ToLocalChecked();
|
||||||
auto value = v8::FunctionTemplate::New(isolate, RandomBytes)
|
auto value = v8::FunctionTemplate::New(isolate, RandomBytes)
|
||||||
|
|
|
||||||
|
|
@ -51,19 +51,18 @@ void Cleanup(void* str) {
|
||||||
void Initialize(Local<Object> exports,
|
void Initialize(Local<Object> exports,
|
||||||
Local<Value> module,
|
Local<Value> module,
|
||||||
Local<Context> context) {
|
Local<Context> context) {
|
||||||
|
Isolate* isolate = Isolate::GetCurrent();
|
||||||
node::AddEnvironmentCleanupHook(
|
node::AddEnvironmentCleanupHook(
|
||||||
context->GetIsolate(),
|
isolate, Cleanup, const_cast<void*>(static_cast<const void*>("cleanup")));
|
||||||
Cleanup,
|
node::AddEnvironmentCleanupHook(isolate, Dummy, nullptr);
|
||||||
const_cast<void*>(static_cast<const void*>("cleanup")));
|
node::RemoveEnvironmentCleanupHook(isolate, Dummy, nullptr);
|
||||||
node::AddEnvironmentCleanupHook(context->GetIsolate(), Dummy, nullptr);
|
|
||||||
node::RemoveEnvironmentCleanupHook(context->GetIsolate(), Dummy, nullptr);
|
|
||||||
|
|
||||||
if (getenv("addExtraItemToEventLoop") != nullptr) {
|
if (getenv("addExtraItemToEventLoop") != nullptr) {
|
||||||
// Add an item to the event loop that we do not clean up in order to make
|
// 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
|
// sure that for the main thread, this addon's memory persists even after
|
||||||
// the Environment instance has been destroyed.
|
// the Environment instance has been destroyed.
|
||||||
static uv_async_t extra_async;
|
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*) {});
|
int err = uv_async_init(loop, &extra_async, [](uv_async_t*) {});
|
||||||
assert(err == 0);
|
assert(err == 0);
|
||||||
uv_unref(reinterpret_cast<uv_handle_t*>(&extra_async));
|
uv_unref(reinterpret_cast<uv_handle_t*>(&extra_async));
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ void GetFreeCallCount(const FunctionCallbackInfo<Value>& args) {
|
||||||
void Initialize(Local<Object> exports,
|
void Initialize(Local<Object> exports,
|
||||||
Local<Value> module,
|
Local<Value> module,
|
||||||
Local<Context> context) {
|
Local<Context> context) {
|
||||||
Isolate* isolate = context->GetIsolate();
|
Isolate* isolate = Isolate::GetCurrent();
|
||||||
NODE_SET_METHOD(exports, "getFreeCallCount", GetFreeCallCount);
|
NODE_SET_METHOD(exports, "getFreeCallCount", GetFreeCallCount);
|
||||||
|
|
||||||
char* data = new char;
|
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,
|
inline void Initialize(v8::Local<v8::Object> exports,
|
||||||
v8::Local<v8::Value> module,
|
v8::Local<v8::Value> module,
|
||||||
v8::Local<v8::Context> context) {
|
v8::Local<v8::Context> context) {
|
||||||
auto isolate = context->GetIsolate();
|
auto isolate = v8::Isolate::GetCurrent();
|
||||||
auto key = v8::String::NewFromUtf8(
|
auto key = v8::String::NewFromUtf8(
|
||||||
isolate, "compressBytes").ToLocalChecked();
|
isolate, "compressBytes").ToLocalChecked();
|
||||||
auto value = v8::FunctionTemplate::New(isolate, CompressBytes)
|
auto value = v8::FunctionTemplate::New(isolate, CompressBytes)
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ class CppGCed : public v8::Object::Wrappable {
|
||||||
|
|
||||||
static v8::Local<v8::Function> GetConstructor(
|
static v8::Local<v8::Function> GetConstructor(
|
||||||
v8::Local<v8::Context> context) {
|
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();
|
return ft->GetFunction(context).ToLocalChecked();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ void InitializeBinding(v8::Local<v8::Object> exports,
|
||||||
v8::Local<v8::Value> module,
|
v8::Local<v8::Value> module,
|
||||||
v8::Local<v8::Context> context,
|
v8::Local<v8::Context> context,
|
||||||
void* priv) {
|
void* priv) {
|
||||||
v8::Isolate* isolate = context->GetIsolate();
|
v8::Isolate* isolate = v8::Isolate::GetCurrent();
|
||||||
exports
|
exports
|
||||||
->Set(context,
|
->Set(context,
|
||||||
v8::String::NewFromOneByte(isolate,
|
v8::String::NewFromOneByte(isolate,
|
||||||
|
|
@ -51,7 +51,7 @@ void InitializeLocalBinding(v8::Local<v8::Object> exports,
|
||||||
v8::Local<v8::Context> context,
|
v8::Local<v8::Context> context,
|
||||||
void* priv) {
|
void* priv) {
|
||||||
++*static_cast<int*>(priv);
|
++*static_cast<int*>(priv);
|
||||||
v8::Isolate* isolate = context->GetIsolate();
|
v8::Isolate* isolate = v8::Isolate::GetCurrent();
|
||||||
exports
|
exports
|
||||||
->Set(context,
|
->Set(context,
|
||||||
v8::String::NewFromOneByte(isolate,
|
v8::String::NewFromOneByte(isolate,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user