Commit 9ab034ec authored by Ng Zhi An's avatar Ng Zhi An Committed by V8 LUCI CQ

[objects] Fix -Wshadow warnings

Bug: v8:12244,v8:12245
Change-Id: I1ec0d96b645afa9bbda670918ce57be3698f50ef
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3265684
Commit-Queue: Zhi An Ng <zhin@chromium.org>
Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Cr-Commit-Position: refs/heads/main@{#77804}
parent 1d7ba96e
...@@ -218,16 +218,17 @@ Handle<Object> Context::Lookup(Handle<Context> context, Handle<String> name, ...@@ -218,16 +218,17 @@ Handle<Object> Context::Lookup(Handle<Context> context, Handle<String> name,
context->global_object().native_context().script_context_table(); context->global_object().native_context().script_context_table();
VariableLookupResult r; VariableLookupResult r;
if (ScriptContextTable::Lookup(isolate, script_contexts, *name, &r)) { if (ScriptContextTable::Lookup(isolate, script_contexts, *name, &r)) {
Context context = script_contexts.get_context(r.context_index); Context script_context = script_contexts.get_context(r.context_index);
if (FLAG_trace_contexts) { if (FLAG_trace_contexts) {
PrintF("=> found property in script context %d: %p\n", PrintF("=> found property in script context %d: %p\n",
r.context_index, reinterpret_cast<void*>(context.ptr())); r.context_index,
reinterpret_cast<void*>(script_context.ptr()));
} }
*index = r.slot_index; *index = r.slot_index;
*variable_mode = r.mode; *variable_mode = r.mode;
*init_flag = r.init_flag; *init_flag = r.init_flag;
*attributes = GetAttributesForMode(r.mode); *attributes = GetAttributesForMode(r.mode);
return handle(context, isolate); return handle(script_context, isolate);
} }
} }
...@@ -380,9 +381,9 @@ Handle<Object> Context::Lookup(Handle<Context> context, Handle<String> name, ...@@ -380,9 +381,9 @@ Handle<Object> Context::Lookup(Handle<Context> context, Handle<String> name,
// Check the original context, but do not follow its context chain. // Check the original context, but do not follow its context chain.
Object obj = context->get(WRAPPED_CONTEXT_INDEX); Object obj = context->get(WRAPPED_CONTEXT_INDEX);
if (obj.IsContext()) { if (obj.IsContext()) {
Handle<Context> context(Context::cast(obj), isolate); Handle<Context> wrapped_context(Context::cast(obj), isolate);
Handle<Object> result = Handle<Object> result =
Context::Lookup(context, name, DONT_FOLLOW_CHAINS, index, Context::Lookup(wrapped_context, name, DONT_FOLLOW_CHAINS, index,
attributes, init_flag, variable_mode); attributes, init_flag, variable_mode);
if (!result.is_null()) return result; if (!result.is_null()) return result;
} }
......
...@@ -2306,7 +2306,7 @@ class FastElementsAccessor : public ElementsAccessorBase<Subclass, KindTraits> { ...@@ -2306,7 +2306,7 @@ class FastElementsAccessor : public ElementsAccessorBase<Subclass, KindTraits> {
} }
} else { } else {
if (!value.IsNaN()) { if (!value.IsNaN()) {
double search_value = value.Number(); double search_number = value.Number();
if (IsDoubleElementsKind(Subclass::kind())) { if (IsDoubleElementsKind(Subclass::kind())) {
// Search for non-NaN Number in PACKED_DOUBLE_ELEMENTS or // Search for non-NaN Number in PACKED_DOUBLE_ELEMENTS or
// HOLEY_DOUBLE_ELEMENTS --- Skip TheHole, and trust UCOMISD or // HOLEY_DOUBLE_ELEMENTS --- Skip TheHole, and trust UCOMISD or
...@@ -2316,7 +2316,7 @@ class FastElementsAccessor : public ElementsAccessorBase<Subclass, KindTraits> { ...@@ -2316,7 +2316,7 @@ class FastElementsAccessor : public ElementsAccessorBase<Subclass, KindTraits> {
for (size_t k = start_from; k < length; ++k) { for (size_t k = start_from; k < length; ++k) {
if (elements.is_the_hole(static_cast<int>(k))) continue; if (elements.is_the_hole(static_cast<int>(k))) continue;
if (elements.get_scalar(static_cast<int>(k)) == search_value) { if (elements.get_scalar(static_cast<int>(k)) == search_number) {
return Just(true); return Just(true);
} }
} }
...@@ -2329,7 +2329,7 @@ class FastElementsAccessor : public ElementsAccessorBase<Subclass, KindTraits> { ...@@ -2329,7 +2329,7 @@ class FastElementsAccessor : public ElementsAccessorBase<Subclass, KindTraits> {
for (size_t k = start_from; k < length; ++k) { for (size_t k = start_from; k < length; ++k) {
Object element_k = elements.get(static_cast<int>(k)); Object element_k = elements.get(static_cast<int>(k));
if (element_k.IsNumber() && element_k.Number() == search_value) { if (element_k.IsNumber() && element_k.Number() == search_number) {
return Just(true); return Just(true);
} }
} }
......
...@@ -95,7 +95,7 @@ Handle<FeedbackMetadata> FeedbackMetadata::New(IsolateT* isolate, ...@@ -95,7 +95,7 @@ Handle<FeedbackMetadata> FeedbackMetadata::New(IsolateT* isolate,
FeedbackSlotKind kind = spec->GetKind(FeedbackSlot(i)); FeedbackSlotKind kind = spec->GetKind(FeedbackSlot(i));
int entry_size = FeedbackMetadata::GetSlotSize(kind); int entry_size = FeedbackMetadata::GetSlotSize(kind);
for (int j = 1; j < entry_size; j++) { for (int j = 1; j < entry_size; j++) {
FeedbackSlotKind kind = spec->GetKind(FeedbackSlot(i + j)); kind = spec->GetKind(FeedbackSlot(i + j));
DCHECK_EQ(FeedbackSlotKind::kInvalid, kind); DCHECK_EQ(FeedbackSlotKind::kInvalid, kind);
} }
i += entry_size; i += entry_size;
......
...@@ -1582,9 +1582,6 @@ Maybe<Intl::NumberFormatDigitOptions> Intl::SetNumberFormatDigitOptions( ...@@ -1582,9 +1582,6 @@ Maybe<Intl::NumberFormatDigitOptions> Intl::SetNumberFormatDigitOptions(
// 15. Else If mnfd is not undefined or mxfd is not undefined, then // 15. Else If mnfd is not undefined or mxfd is not undefined, then
if (!mnfd_obj->IsUndefined(isolate) || !mxfd_obj->IsUndefined(isolate)) { if (!mnfd_obj->IsUndefined(isolate) || !mxfd_obj->IsUndefined(isolate)) {
Handle<String> mxfd_str = factory->maximumFractionDigits_string();
Handle<String> mnfd_str = factory->minimumFractionDigits_string();
int specified_mnfd; int specified_mnfd;
int specified_mxfd; int specified_mxfd;
......
...@@ -401,9 +401,9 @@ MaybeHandle<JSCollator> JSCollator::New(Isolate* isolate, Handle<Map> map, ...@@ -401,9 +401,9 @@ MaybeHandle<JSCollator> JSCollator::New(Isolate* isolate, Handle<Map> map,
// This will need to be filtered out when creating the // This will need to be filtered out when creating the
// resolvedOptions object. // resolvedOptions object.
if (usage == Usage::SEARCH) { if (usage == Usage::SEARCH) {
UErrorCode status = U_ZERO_ERROR; UErrorCode set_status = U_ZERO_ERROR;
icu_locale.setUnicodeKeywordValue("co", "search", status); icu_locale.setUnicodeKeywordValue("co", "search", set_status);
DCHECK(U_SUCCESS(status)); DCHECK(U_SUCCESS(set_status));
} else { } else {
if (collation_str != nullptr && if (collation_str != nullptr &&
Intl::IsValidCollation(icu_locale, collation_str.get())) { Intl::IsValidCollation(icu_locale, collation_str.get())) {
......
...@@ -1081,7 +1081,7 @@ class CalendarCache { ...@@ -1081,7 +1081,7 @@ class CalendarCache {
icu::GregorianCalendar::getStaticClassID()) { icu::GregorianCalendar::getStaticClassID()) {
icu::GregorianCalendar* gc = icu::GregorianCalendar* gc =
static_cast<icu::GregorianCalendar*>(calendar.get()); static_cast<icu::GregorianCalendar*>(calendar.get());
UErrorCode status = U_ZERO_ERROR; status = U_ZERO_ERROR;
// The beginning of ECMAScript time, namely -(2**53) // The beginning of ECMAScript time, namely -(2**53)
const double start_of_time = -9007199254740992; const double start_of_time = -9007199254740992;
gc->setGregorianChange(start_of_time, status); gc->setGregorianChange(start_of_time, status);
...@@ -1726,7 +1726,6 @@ MaybeHandle<JSDateTimeFormat> JSDateTimeFormat::New( ...@@ -1726,7 +1726,6 @@ MaybeHandle<JSDateTimeFormat> JSDateTimeFormat::New(
// 29. Let matcher be ? GetOption(options, "formatMatcher", "string", « // 29. Let matcher be ? GetOption(options, "formatMatcher", "string", «
// "basic", "best fit" », "best fit"). // "basic", "best fit" », "best fit").
enum FormatMatcherOption { kBestFit, kBasic };
// We implement only best fit algorithm, but still need to check // We implement only best fit algorithm, but still need to check
// if the formatMatcher values are in range. // if the formatMatcher values are in range.
// c. Let matcher be ? GetOption(options, "formatMatcher", "string", // c. Let matcher be ? GetOption(options, "formatMatcher", "string",
...@@ -1870,7 +1869,7 @@ MaybeHandle<JSDateTimeFormat> JSDateTimeFormat::New( ...@@ -1870,7 +1869,7 @@ MaybeHandle<JSDateTimeFormat> JSDateTimeFormat::New(
if (dateTimeFormatHourCycle != if (dateTimeFormatHourCycle !=
ToHourCycle(hc_extension_it->second.c_str())) { ToHourCycle(hc_extension_it->second.c_str())) {
// Remove -hc- if it does not agree with what we used. // Remove -hc- if it does not agree with what we used.
UErrorCode status = U_ZERO_ERROR; status = U_ZERO_ERROR;
resolved_locale.setUnicodeKeywordValue("hc", nullptr, status); resolved_locale.setUnicodeKeywordValue("hc", nullptr, status);
DCHECK(U_SUCCESS(status)); DCHECK(U_SUCCESS(status));
} }
......
...@@ -1132,8 +1132,8 @@ void LookupIterator::WriteDataValueToWasmObject(Handle<Object> value) { ...@@ -1132,8 +1132,8 @@ void LookupIterator::WriteDataValueToWasmObject(Handle<Object> value) {
} else { } else {
// WasmArrays don't have writable properties. // WasmArrays don't have writable properties.
DCHECK(holder->IsWasmStruct()); DCHECK(holder->IsWasmStruct());
Handle<WasmStruct> holder = GetHolder<WasmStruct>(); Handle<WasmStruct> wasm_holder = GetHolder<WasmStruct>();
WasmStruct::SetField(isolate_, holder, property_details_.field_index(), WasmStruct::SetField(isolate_, wasm_holder, property_details_.field_index(),
value); value);
} }
} }
......
...@@ -859,7 +859,6 @@ Handle<DescriptorArray> MapUpdater::BuildDescriptorArray() { ...@@ -859,7 +859,6 @@ Handle<DescriptorArray> MapUpdater::BuildDescriptorArray() {
PropertyLocation next_location = old_details.location(); PropertyLocation next_location = old_details.location();
Representation next_representation = old_details.representation(); Representation next_representation = old_details.representation();
Descriptor d;
if (next_location == PropertyLocation::kField) { if (next_location == PropertyLocation::kField) {
Handle<FieldType> next_field_type = Handle<FieldType> next_field_type =
GetOrComputeFieldType(i, old_details.location(), next_representation); GetOrComputeFieldType(i, old_details.location(), next_representation);
...@@ -889,6 +888,7 @@ Handle<DescriptorArray> MapUpdater::BuildDescriptorArray() { ...@@ -889,6 +888,7 @@ Handle<DescriptorArray> MapUpdater::BuildDescriptorArray() {
DCHECK_EQ(PropertyConstness::kConst, next_constness); DCHECK_EQ(PropertyConstness::kConst, next_constness);
Handle<Object> value(GetValue(i), isolate_); Handle<Object> value(GetValue(i), isolate_);
Descriptor d;
if (next_kind == kData) { if (next_kind == kData) {
d = Descriptor::DataConstant(key, value, next_attributes); d = Descriptor::DataConstant(key, value, next_attributes);
} else { } else {
...@@ -1121,7 +1121,7 @@ void MapUpdater::UpdateFieldType(Isolate* isolate, Handle<Map> map, ...@@ -1121,7 +1121,7 @@ void MapUpdater::UpdateFieldType(Isolate* isolate, Handle<Map> map,
backlog.push(target); backlog.push(target);
} }
DescriptorArray descriptors = current.instance_descriptors(isolate); DescriptorArray descriptors = current.instance_descriptors(isolate);
PropertyDetails details = descriptors.GetDetails(descriptor); details = descriptors.GetDetails(descriptor);
// It is allowed to change representation here only from None // It is allowed to change representation here only from None
// to something or from Smi or HeapObject to Tagged. // to something or from Smi or HeapObject to Tagged.
......
...@@ -2972,7 +2972,7 @@ Maybe<bool> JSProxy::IsArray(Handle<JSProxy> proxy) { ...@@ -2972,7 +2972,7 @@ Maybe<bool> JSProxy::IsArray(Handle<JSProxy> proxy) {
Isolate* isolate = proxy->GetIsolate(); Isolate* isolate = proxy->GetIsolate();
Handle<JSReceiver> object = Handle<JSReceiver>::cast(proxy); Handle<JSReceiver> object = Handle<JSReceiver>::cast(proxy);
for (int i = 0; i < JSProxy::kMaxIterationLimit; i++) { for (int i = 0; i < JSProxy::kMaxIterationLimit; i++) {
Handle<JSProxy> proxy = Handle<JSProxy>::cast(object); proxy = Handle<JSProxy>::cast(object);
if (proxy->IsRevoked()) { if (proxy->IsRevoked()) {
isolate->Throw(*isolate->factory()->NewTypeError( isolate->Throw(*isolate->factory()->NewTypeError(
MessageTemplate::kProxyRevoked, MessageTemplate::kProxyRevoked,
...@@ -3391,9 +3391,9 @@ Maybe<bool> JSArray::ArraySetLength(Isolate* isolate, Handle<JSArray> a, ...@@ -3391,9 +3391,9 @@ Maybe<bool> JSArray::ArraySetLength(Isolate* isolate, Handle<JSArray> a,
if (!new_writable) { if (!new_writable) {
PropertyDescriptor readonly; PropertyDescriptor readonly;
readonly.set_writable(false); readonly.set_writable(false);
Maybe<bool> success = OrdinaryDefineOwnProperty( success = OrdinaryDefineOwnProperty(isolate, a,
isolate, a, isolate->factory()->length_string(), &readonly, isolate->factory()->length_string(),
should_throw); &readonly, should_throw);
DCHECK(success.FromJust()); DCHECK(success.FromJust());
USE(success); USE(success);
} }
...@@ -4376,12 +4376,12 @@ void DescriptorArray::CopyFrom(InternalIndex index, DescriptorArray src) { ...@@ -4376,12 +4376,12 @@ void DescriptorArray::CopyFrom(InternalIndex index, DescriptorArray src) {
void DescriptorArray::Sort() { void DescriptorArray::Sort() {
// In-place heap sort. // In-place heap sort.
int len = number_of_descriptors(); const int len = number_of_descriptors();
// Reset sorting since the descriptor array might contain invalid pointers. // Reset sorting since the descriptor array might contain invalid pointers.
for (int i = 0; i < len; ++i) SetSortedKey(i, i); for (int i = 0; i < len; ++i) SetSortedKey(i, i);
// Bottom-up max-heap construction. // Bottom-up max-heap construction.
// Index of the last node with children. // Index of the last node with children.
const int max_parent_index = (len / 2) - 1; int max_parent_index = (len / 2) - 1;
for (int i = max_parent_index; i >= 0; --i) { for (int i = max_parent_index; i >= 0; --i) {
int parent_index = i; int parent_index = i;
const uint32_t parent_hash = GetSortedKey(i).hash(); const uint32_t parent_hash = GetSortedKey(i).hash();
...@@ -4409,7 +4409,7 @@ void DescriptorArray::Sort() { ...@@ -4409,7 +4409,7 @@ void DescriptorArray::Sort() {
// Shift down the new top element. // Shift down the new top element.
int parent_index = 0; int parent_index = 0;
const uint32_t parent_hash = GetSortedKey(parent_index).hash(); const uint32_t parent_hash = GetSortedKey(parent_index).hash();
const int max_parent_index = (i / 2) - 1; max_parent_index = (i / 2) - 1;
while (parent_index <= max_parent_index) { while (parent_index <= max_parent_index) {
int child_index = parent_index * 2 + 1; int child_index = parent_index * 2 + 1;
uint32_t child_hash = GetSortedKey(child_index).hash(); uint32_t child_hash = GetSortedKey(child_index).hash();
...@@ -5964,15 +5964,15 @@ int BaseNameDictionary<Derived, Shape>::NextEnumerationIndex( ...@@ -5964,15 +5964,15 @@ int BaseNameDictionary<Derived, Shape>::NextEnumerationIndex(
// Iterate over the dictionary using the enumeration order and update // Iterate over the dictionary using the enumeration order and update
// the dictionary with new enumeration indices. // the dictionary with new enumeration indices.
for (int i = 0; i < length; i++) { for (int i = 0; i < length; i++) {
InternalIndex index(Smi::ToInt(iteration_order->get(i))); InternalIndex internal_index(Smi::ToInt(iteration_order->get(i)));
DCHECK(dictionary->IsKey(dictionary->GetReadOnlyRoots(), DCHECK(dictionary->IsKey(dictionary->GetReadOnlyRoots(),
dictionary->KeyAt(isolate, index))); dictionary->KeyAt(isolate, internal_index)));
int enum_index = PropertyDetails::kInitialIndex + i; int enum_index = PropertyDetails::kInitialIndex + i;
PropertyDetails details = dictionary->DetailsAt(index); PropertyDetails details = dictionary->DetailsAt(internal_index);
PropertyDetails new_details = details.set_index(enum_index); PropertyDetails new_details = details.set_index(enum_index);
dictionary->DetailsAtPut(index, new_details); dictionary->DetailsAtPut(internal_index, new_details);
} }
index = PropertyDetails::kInitialIndex + length; index = PropertyDetails::kInitialIndex + length;
......
...@@ -298,8 +298,8 @@ Handle<ScopeInfo> ScopeInfo::Create(IsolateT* isolate, Zone* zone, Scope* scope, ...@@ -298,8 +298,8 @@ Handle<ScopeInfo> ScopeInfo::Create(IsolateT* isolate, Zone* zone, Scope* scope,
for (int i = 0; i < parameter_count; i++) { for (int i = 0; i < parameter_count; i++) {
Variable* parameter = scope->AsDeclarationScope()->parameter(i); Variable* parameter = scope->AsDeclarationScope()->parameter(i);
if (parameter->location() != VariableLocation::CONTEXT) continue; if (parameter->location() != VariableLocation::CONTEXT) continue;
int index = parameter->index() - scope->ContextHeaderLength(); int param_index = parameter->index() - scope->ContextHeaderLength();
int info_index = context_local_info_base + index; int info_index = context_local_info_base + param_index;
int info = Smi::ToInt(scope_info.get(info_index)); int info = Smi::ToInt(scope_info.get(info_index));
info = ParameterNumberBits::update(info, i); info = ParameterNumberBits::update(info, i);
scope_info.set(info_index, Smi::FromInt(info)); scope_info.set(info_index, Smi::FromInt(info));
......
...@@ -576,15 +576,15 @@ void SourceTextModule::FetchStarExports(Isolate* isolate, ...@@ -576,15 +576,15 @@ void SourceTextModule::FetchStarExports(Isolate* isolate,
// the name to undefined instead of a Cell. // the name to undefined instead of a Cell.
Handle<ObjectHashTable> requested_exports(requested_module->exports(), Handle<ObjectHashTable> requested_exports(requested_module->exports(),
isolate); isolate);
for (InternalIndex i : requested_exports->IterateEntries()) { for (InternalIndex index : requested_exports->IterateEntries()) {
Object key; Object key;
if (!requested_exports->ToKey(roots, i, &key)) continue; if (!requested_exports->ToKey(roots, index, &key)) continue;
Handle<String> name(String::cast(key), isolate); Handle<String> name(String::cast(key), isolate);
if (name->Equals(roots.default_string())) continue; if (name->Equals(roots.default_string())) continue;
if (!exports->Lookup(name).IsTheHole(roots)) continue; if (!exports->Lookup(name).IsTheHole(roots)) continue;
Handle<Cell> cell(Cell::cast(requested_exports->ValueAt(i)), isolate); Handle<Cell> cell(Cell::cast(requested_exports->ValueAt(index)), isolate);
auto insert_result = more_exports.insert(std::make_pair(name, cell)); auto insert_result = more_exports.insert(std::make_pair(name, cell));
if (!insert_result.second) { if (!insert_result.second) {
auto it = insert_result.first; auto it = insert_result.first;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment