diff --git a/src/module_wrap.cc b/src/module_wrap.cc index ef69fe133fa..7bf8351e7e0 100644 --- a/src/module_wrap.cc +++ b/src/module_wrap.cc @@ -98,8 +98,7 @@ std::string ModuleCacheKey::ToString() const { } template -ModuleCacheKey ModuleCacheKey::From(Local context, - Local specifier, +ModuleCacheKey ModuleCacheKey::From(Local specifier, Local import_attributes) { CHECK_EQ(import_attributes->Length() % elements_per_attribute, 0); Isolate* isolate = Isolate::GetCurrent(); @@ -112,12 +111,11 @@ ModuleCacheKey ModuleCacheKey::From(Local context, for (int i = 0; i < import_attributes->Length(); i += elements_per_attribute) { - DCHECK(DataIsString(import_attributes->Get(context, i))); - DCHECK(DataIsString(import_attributes->Get(context, i + 1))); + DCHECK(DataIsString(import_attributes->Get(i))); + DCHECK(DataIsString(import_attributes->Get(i + 1))); - Local v8_key = import_attributes->Get(context, i).As(); - Local v8_value = - import_attributes->Get(context, i + 1).As(); + Local v8_key = import_attributes->Get(i).As(); + Local v8_value = import_attributes->Get(i + 1).As(); Utf8Value key_utf8(isolate, v8_key); Utf8Value value_utf8(isolate, v8_value); @@ -134,10 +132,8 @@ ModuleCacheKey ModuleCacheKey::From(Local context, return ModuleCacheKey{utf8_specifier.ToString(), attributes, hash}; } -ModuleCacheKey ModuleCacheKey::From(Local context, - Local v8_request) { - return From( - context, v8_request->GetSpecifier(), v8_request->GetImportAttributes()); +ModuleCacheKey ModuleCacheKey::From(Local v8_request) { + return From(v8_request->GetSpecifier(), v8_request->GetImportAttributes()); } ModuleWrap::ModuleWrap(Realm* realm, @@ -577,8 +573,8 @@ static Local createImportAttributesContainer( LocalVector values(isolate, num_attributes); for (int i = 0; i < raw_attributes->Length(); i += elements_per_attribute) { - Local key = raw_attributes->Get(realm->context(), i); - Local value = raw_attributes->Get(realm->context(), i + 1); + Local key = raw_attributes->Get(i); + Local value = raw_attributes->Get(i + 1); DCHECK(DataIsString(key)); DCHECK(DataIsString(value)); @@ -601,9 +597,9 @@ static Local createModuleRequestsContainer( LocalVector requests(isolate, raw_requests->Length()); for (int i = 0; i < raw_requests->Length(); i++) { - DCHECK(raw_requests->Get(context, i)->IsModuleRequest()); + DCHECK(raw_requests->Get(i)->IsModuleRequest()); Local module_request = - raw_requests->Get(realm->context(), i).As(); + raw_requests->Get(i).As(); Local specifier = module_request->GetSpecifier(); @@ -691,8 +687,8 @@ void ModuleWrap::Link(const FunctionCallbackInfo& args) { // TODO(joyeecheung): merge this with the serializeKey() in module_map.js. // This currently doesn't sort the import attributes. Local module_value = modules_vector[i].Get(isolate); - ModuleCacheKey module_cache_key = ModuleCacheKey::From( - context, requests->Get(context, i).As()); + ModuleCacheKey module_cache_key = + ModuleCacheKey::From(requests->Get(i).As()); auto it = module_request_map.find(module_cache_key); if (it == module_request_map.end()) { // This is the first request with this identity, record it - any mismatch @@ -1085,12 +1081,11 @@ MaybeLocal ModuleWrap::ResolveSourceCallback( return module_source_object.As(); } -static std::string GetSpecifierFromModuleRequest(Local context, - Local referrer, +static std::string GetSpecifierFromModuleRequest(Local referrer, size_t module_request_index) { Local raw_request = referrer->GetModuleRequests() - ->Get(context, static_cast(module_request_index)) + ->Get(static_cast(module_request_index)) .As(); Local specifier = raw_request->GetSpecifier(); Utf8Value specifier_utf8(Isolate::GetCurrent(), specifier); @@ -1113,14 +1108,14 @@ Maybe ModuleWrap::ResolveModule(Local context, ModuleWrap* dependent = ModuleWrap::GetFromModule(env, referrer); if (dependent == nullptr) { std::string specifier = - GetSpecifierFromModuleRequest(context, referrer, module_request_index); + GetSpecifierFromModuleRequest(referrer, module_request_index); THROW_ERR_VM_MODULE_LINK_FAILURE( env, "request for '%s' is from invalid module", specifier); return Nothing(); } if (!dependent->IsLinked()) { std::string specifier = - GetSpecifierFromModuleRequest(context, referrer, module_request_index); + GetSpecifierFromModuleRequest(referrer, module_request_index); THROW_ERR_VM_MODULE_LINK_FAILURE(env, "request for '%s' can not be resolved on " "module '%s' that is not linked", @@ -1170,7 +1165,7 @@ static MaybeLocal ImportModuleDynamicallyWithPhase( // If the host-defined options are empty, get the referrer id symbol // from the realm global object. if (options->Length() == HostDefinedOptions::kLength) { - id = options->Get(context, HostDefinedOptions::kID).As(); + id = options->Get(HostDefinedOptions::kID).As(); } else if (!context->Global() ->GetPrivate(context, env->host_defined_option_symbol()) .ToLocal(&id)) { diff --git a/src/module_wrap.h b/src/module_wrap.h index 4c18eef502b..a91a7cb6573 100644 --- a/src/module_wrap.h +++ b/src/module_wrap.h @@ -63,11 +63,9 @@ struct ModuleCacheKey : public MemoryRetainer { std::string ToString() const; template - static ModuleCacheKey From(v8::Local context, - v8::Local specifier, + static ModuleCacheKey From(v8::Local specifier, v8::Local import_attributes); - static ModuleCacheKey From(v8::Local context, - v8::Local v8_request); + static ModuleCacheKey From(v8::Local v8_request); struct Hash { std::size_t operator()(const ModuleCacheKey& request) const { diff --git a/src/node_builtins.cc b/src/node_builtins.cc index 81503ae2a1f..a0046afc499 100644 --- a/src/node_builtins.cc +++ b/src/node_builtins.cc @@ -744,7 +744,7 @@ MaybeLocal BuiltinLoader::LoadBuiltinSourceTextModule(Realm* realm, // Pre-fetch all dependencies. if (requests->Length() > 0) { for (int i = 0; i < requests->Length(); i++) { - Local req = requests->Get(context, i).As(); + Local req = requests->Get(i).As(); std::string specifier = Utf8Value(isolate, req->GetSpecifier()).ToString(); std::string resolved_id = ResolveRequestForBuiltin(specifier);