src: refactor GetCreationContext calls

PR-URL: https://github.com/nodejs/node/pull/51287
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
This commit is contained in:
Yagiz Nizipli authored and GitHub committed 2023-12-28 11:12:34 +00:00
1 parent c14133503a
commit ff6365b5ef
5 files changed
+12 -14

No files matched your search

+3 -4
View File
@@ -248,8 +248,7 @@ MaybeLocal<Value> MakeCallback(Isolate* isolate,
Local<Value> argv[],
async_context asyncContext) {
// Check can_call_into_js() first because calling Get() might do so.
Environment* env =
Environment::GetCurrent(recv->GetCreationContext().ToLocalChecked());
Environment* env = Environment::GetCurrent(recv->GetCreationContextChecked());
CHECK_NOT_NULL(env);
if (!env->can_call_into_js()) return Local<Value>();
@@ -279,7 +278,7 @@ MaybeLocal<Value> MakeCallback(Isolate* isolate,
// Because of the AssignToContext() call in src/node_contextify.cc,
// the two contexts need not be the same.
Environment* env =
Environment::GetCurrent(callback->GetCreationContext().ToLocalChecked());
Environment::GetCurrent(callback->GetCreationContextChecked());
CHECK_NOT_NULL(env);
Context::Scope context_scope(env->context());
MaybeLocal<Value> ret =
@@ -302,7 +301,7 @@ MaybeLocal<Value> MakeSyncCallback(Isolate* isolate,
int argc,
Local<Value> argv[]) {
Environment* env =
Environment::GetCurrent(callback->GetCreationContext().ToLocalChecked());
Environment::GetCurrent(callback->GetCreationContextChecked());
CHECK_NOT_NULL(env);
if (!env->can_call_into_js()) return Local<Value>();
+1 -2
View File
@@ -55,8 +55,7 @@ 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->GetCreationContext().ToLocalChecked()->GetIsolate(),
isolate);
DCHECK_EQ(handle->GetCreationContextChecked()->GetIsolate(), isolate);
DCHECK_EQ(env()->isolate(), isolate);
return handle;
+1 -1
View File
@@ -89,7 +89,7 @@ Local<Context> ModuleWrap::context() const {
// If this fails, there is likely a bug e.g. ModuleWrap::context() is accessed
// before the ModuleWrap constructor completes.
CHECK(obj->IsObject());
return obj.As<Object>()->GetCreationContext().ToLocalChecked();
return obj.As<Object>()->GetCreationContextChecked();
}
ModuleWrap* ModuleWrap::GetFromModule(Environment* env,
+6 -6
View File
@@ -800,7 +800,7 @@ void MessagePort::OnMessage(MessageProcessingMode mode) {
HandleScope handle_scope(env()->isolate());
Local<Context> context =
object(env()->isolate())->GetCreationContext().ToLocalChecked();
object(env()->isolate())->GetCreationContextChecked();
size_t processing_limit;
if (mode == MessageProcessingMode::kNormalOperation) {
@@ -1057,7 +1057,7 @@ bool GetTransferList(Environment* env,
void MessagePort::PostMessage(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args);
Local<Object> obj = args.This();
Local<Context> context = obj->GetCreationContext().ToLocalChecked();
Local<Context> context = obj->GetCreationContextChecked();
if (args.Length() == 0) {
return THROW_ERR_MISSING_ARGS(env, "Not enough arguments to "
@@ -1143,9 +1143,9 @@ void MessagePort::ReceiveMessage(const FunctionCallbackInfo<Value>& args) {
return;
}
MaybeLocal<Value> payload = port->ReceiveMessage(
port->object()->GetCreationContext().ToLocalChecked(),
MessageProcessingMode::kForceReadMessages);
MaybeLocal<Value> payload =
port->ReceiveMessage(port->object()->GetCreationContextChecked(),
MessageProcessingMode::kForceReadMessages);
if (!payload.IsEmpty())
args.GetReturnValue().Set(payload.ToLocalChecked());
}
@@ -1610,7 +1610,7 @@ static void MessageChannel(const FunctionCallbackInfo<Value>& args) {
return;
}
Local<Context> context = args.This()->GetCreationContext().ToLocalChecked();
Local<Context> context = args.This()->GetCreationContextChecked();
Context::Scope context_scope(context);
MessagePort* port1 = MessagePort::New(env, context);
+1 -1
View File
@@ -907,7 +907,7 @@ 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->GetCreationContext().ToLocalChecked()->GetIsolate(),
CHECK_EQ(port->GetCreationContextChecked()->GetIsolate(),
args.GetIsolate());
args.GetReturnValue().Set(port);
}