Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 840f509

Browse filesBrowse files
backesRafaelGSS
authored andcommitted
src: avoid deprecated FixedArray::Get
Use the method without context parameter; the old API is deprecated. Refs: https://crrev.com/c/7141498 PR-URL: #61898 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Filip Skokan <panva.ip@gmail.com> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com> (cherry picked from commit fafe164)
1 parent a34fe77 commit 840f509
Copy full SHA for 840f509

3 files changed

+21-28Lines changed: 21 additions & 28 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/module_wrap.cc‎

Copy file name to clipboardExpand all lines: src/module_wrap.cc
+18-23Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,7 @@ std::string ModuleCacheKey::ToString() const {
9898
}
9999

100100
template <int elements_per_attribute>
101-
ModuleCacheKey ModuleCacheKey::From(Local<Context> context,
102-
Local<String> specifier,
101+
ModuleCacheKey ModuleCacheKey::From(Local<String> specifier,
103102
Local<FixedArray> import_attributes) {
104103
CHECK_EQ(import_attributes->Length() % elements_per_attribute, 0);
105104
Isolate* isolate = Isolate::GetCurrent();
@@ -112,12 +111,11 @@ ModuleCacheKey ModuleCacheKey::From(Local<Context> context,
112111

113112
for (int i = 0; i < import_attributes->Length();
114113
i += elements_per_attribute) {
115-
DCHECK(DataIsString(import_attributes->Get(context, i)));
116-
DCHECK(DataIsString(import_attributes->Get(context, i + 1)));
114+
DCHECK(DataIsString(import_attributes->Get(i)));
115+
DCHECK(DataIsString(import_attributes->Get(i + 1)));
117116

118-
Local<String> v8_key = import_attributes->Get(context, i).As<String>();
119-
Local<String> v8_value =
120-
import_attributes->Get(context, i + 1).As<String>();
117+
Local<String> v8_key = import_attributes->Get(i).As<String>();
118+
Local<String> v8_value = import_attributes->Get(i + 1).As<String>();
121119
Utf8Value key_utf8(isolate, v8_key);
122120
Utf8Value value_utf8(isolate, v8_value);
123121

@@ -134,10 +132,8 @@ ModuleCacheKey ModuleCacheKey::From(Local<Context> context,
134132
return ModuleCacheKey{utf8_specifier.ToString(), attributes, hash};
135133
}
136134

137-
ModuleCacheKey ModuleCacheKey::From(Local<Context> context,
138-
Local<ModuleRequest> v8_request) {
139-
return From(
140-
context, v8_request->GetSpecifier(), v8_request->GetImportAttributes());
135+
ModuleCacheKey ModuleCacheKey::From(Local<ModuleRequest> v8_request) {
136+
return From(v8_request->GetSpecifier(), v8_request->GetImportAttributes());
141137
}
142138

143139
ModuleWrap::ModuleWrap(Realm* realm,
@@ -577,8 +573,8 @@ static Local<Object> createImportAttributesContainer(
577573
LocalVector<Value> values(isolate, num_attributes);
578574

579575
for (int i = 0; i < raw_attributes->Length(); i += elements_per_attribute) {
580-
Local<Data> key = raw_attributes->Get(realm->context(), i);
581-
Local<Data> value = raw_attributes->Get(realm->context(), i + 1);
576+
Local<Data> key = raw_attributes->Get(i);
577+
Local<Data> value = raw_attributes->Get(i + 1);
582578
DCHECK(DataIsString(key));
583579
DCHECK(DataIsString(value));
584580

@@ -601,9 +597,9 @@ static Local<Array> createModuleRequestsContainer(
601597
LocalVector<Value> requests(isolate, raw_requests->Length());
602598

603599
for (int i = 0; i < raw_requests->Length(); i++) {
604-
DCHECK(raw_requests->Get(context, i)->IsModuleRequest());
600+
DCHECK(raw_requests->Get(i)->IsModuleRequest());
605601
Local<ModuleRequest> module_request =
606-
raw_requests->Get(realm->context(), i).As<ModuleRequest>();
602+
raw_requests->Get(i).As<ModuleRequest>();
607603

608604
Local<String> specifier = module_request->GetSpecifier();
609605

@@ -691,8 +687,8 @@ void ModuleWrap::Link(const FunctionCallbackInfo<Value>& args) {
691687
// TODO(joyeecheung): merge this with the serializeKey() in module_map.js.
692688
// This currently doesn't sort the import attributes.
693689
Local<Value> module_value = modules_vector[i].Get(isolate);
694-
ModuleCacheKey module_cache_key = ModuleCacheKey::From(
695-
context, requests->Get(context, i).As<ModuleRequest>());
690+
ModuleCacheKey module_cache_key =
691+
ModuleCacheKey::From(requests->Get(i).As<ModuleRequest>());
696692
auto it = module_request_map.find(module_cache_key);
697693
if (it == module_request_map.end()) {
698694
// This is the first request with this identity, record it - any mismatch
@@ -1085,12 +1081,11 @@ MaybeLocal<Object> ModuleWrap::ResolveSourceCallback(
10851081
return module_source_object.As<Object>();
10861082
}
10871083

1088-
static std::string GetSpecifierFromModuleRequest(Local<Context> context,
1089-
Local<Module> referrer,
1084+
static std::string GetSpecifierFromModuleRequest(Local<Module> referrer,
10901085
size_t module_request_index) {
10911086
Local<ModuleRequest> raw_request =
10921087
referrer->GetModuleRequests()
1093-
->Get(context, static_cast<int>(module_request_index))
1088+
->Get(static_cast<int>(module_request_index))
10941089
.As<ModuleRequest>();
10951090
Local<String> specifier = raw_request->GetSpecifier();
10961091
Utf8Value specifier_utf8(Isolate::GetCurrent(), specifier);
@@ -1113,14 +1108,14 @@ Maybe<ModuleWrap*> ModuleWrap::ResolveModule(Local<Context> context,
11131108
ModuleWrap* dependent = ModuleWrap::GetFromModule(env, referrer);
11141109
if (dependent == nullptr) {
11151110
std::string specifier =
1116-
GetSpecifierFromModuleRequest(context, referrer, module_request_index);
1111+
GetSpecifierFromModuleRequest(referrer, module_request_index);
11171112
THROW_ERR_VM_MODULE_LINK_FAILURE(
11181113
env, "request for '%s' is from invalid module", specifier);
11191114
return Nothing<ModuleWrap*>();
11201115
}
11211116
if (!dependent->IsLinked()) {
11221117
std::string specifier =
1123-
GetSpecifierFromModuleRequest(context, referrer, module_request_index);
1118+
GetSpecifierFromModuleRequest(referrer, module_request_index);
11241119
THROW_ERR_VM_MODULE_LINK_FAILURE(env,
11251120
"request for '%s' can not be resolved on "
11261121
"module '%s' that is not linked",
@@ -1170,7 +1165,7 @@ static MaybeLocal<Promise> ImportModuleDynamicallyWithPhase(
11701165
// If the host-defined options are empty, get the referrer id symbol
11711166
// from the realm global object.
11721167
if (options->Length() == HostDefinedOptions::kLength) {
1173-
id = options->Get(context, HostDefinedOptions::kID).As<Symbol>();
1168+
id = options->Get(HostDefinedOptions::kID).As<Symbol>();
11741169
} else if (!context->Global()
11751170
->GetPrivate(context, env->host_defined_option_symbol())
11761171
.ToLocal(&id)) {
Collapse file

‎src/module_wrap.h‎

Copy file name to clipboardExpand all lines: src/module_wrap.h
+2-4Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,9 @@ struct ModuleCacheKey : public MemoryRetainer {
6363
std::string ToString() const;
6464

6565
template <int elements_per_attribute = 3>
66-
static ModuleCacheKey From(v8::Local<v8::Context> context,
67-
v8::Local<v8::String> specifier,
66+
static ModuleCacheKey From(v8::Local<v8::String> specifier,
6867
v8::Local<v8::FixedArray> import_attributes);
69-
static ModuleCacheKey From(v8::Local<v8::Context> context,
70-
v8::Local<v8::ModuleRequest> v8_request);
68+
static ModuleCacheKey From(v8::Local<v8::ModuleRequest> v8_request);
7169

7270
struct Hash {
7371
std::size_t operator()(const ModuleCacheKey& request) const {
Collapse file

‎src/node_builtins.cc‎

Copy file name to clipboardExpand all lines: src/node_builtins.cc
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,7 @@ MaybeLocal<Module> BuiltinLoader::LoadBuiltinSourceTextModule(Realm* realm,
744744
// Pre-fetch all dependencies.
745745
if (requests->Length() > 0) {
746746
for (int i = 0; i < requests->Length(); i++) {
747-
Local<ModuleRequest> req = requests->Get(context, i).As<ModuleRequest>();
747+
Local<ModuleRequest> req = requests->Get(i).As<ModuleRequest>();
748748
std::string specifier =
749749
Utf8Value(isolate, req->GetSpecifier()).ToString();
750750
std::string resolved_id = ResolveRequestForBuiltin(specifier);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.