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,
context->global_object().native_context().script_context_table();
VariableLookupResult 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) {
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;
*variable_mode = r.mode;
*init_flag = r.init_flag;
*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,
// Check the original context, but do not follow its context chain.
Object obj = context->get(WRAPPED_CONTEXT_INDEX);
if (obj.IsContext()) {
Handle<Context> context(Context::cast(obj), isolate);
Handle<Context> wrapped_context(Context::cast(obj), isolate);
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);
if (!result.is_null()) return result;
}
......
......@@ -2306,7 +2306,7 @@ class FastElementsAccessor : public ElementsAccessorBase<Subclass, KindTraits> {
}
} else {
if (!value.IsNaN()) {
double search_value = value.Number();
double search_number = value.Number();
if (IsDoubleElementsKind(Subclass::kind())) {
// Search for non-NaN Number in PACKED_DOUBLE_ELEMENTS or
// HOLEY_DOUBLE_ELEMENTS --- Skip TheHole, and trust UCOMISD or
......@@ -2316,7 +2316,7 @@ class FastElementsAccessor : public ElementsAccessorBase<Subclass, KindTraits> {
for (size_t k = start_from; k < length; ++k) {
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);
}
}
......@@ -2329,7 +2329,7 @@ class FastElementsAccessor : public ElementsAccessorBase<Subclass, KindTraits> {
for (size_t k = start_from; k < length; ++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);
}
}
......
......@@ -95,7 +95,7 @@ Handle<FeedbackMetadata> FeedbackMetadata::New(IsolateT* isolate,
FeedbackSlotKind kind = spec->GetKind(FeedbackSlot(i));
int entry_size = FeedbackMetadata::GetSlotSize(kind);
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);
}
i += entry_size;
......
......@@ -1582,9 +1582,6 @@ Maybe<Intl::NumberFormatDigitOptions> Intl::SetNumberFormatDigitOptions(
// 15. Else If mnfd is not undefined or mxfd is not undefined, then
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_mxfd;
......
......@@ -401,9 +401,9 @@ MaybeHandle<JSCollator> JSCollator::New(Isolate* isolate, Handle<Map> map,
// This will need to be filtered out when creating the
// resolvedOptions object.
if (usage == Usage::SEARCH) {
UErrorCode status = U_ZERO_ERROR;
icu_locale.setUnicodeKeywordValue("co", "search", status);
DCHECK(U_SUCCESS(status));
UErrorCode set_status = U_ZERO_ERROR;
icu_locale.setUnicodeKeywordValue("co", "search", set_status);
DCHECK(U_SUCCESS(set_status));
} else {
if (collation_str != nullptr &&
Intl::IsValidCollation(icu_locale, collation_str.get())) {
......
......@@ -1081,7 +1081,7 @@ class CalendarCache {
icu::GregorianCalendar::getStaticClassID()) {
icu::GregorianCalendar* gc =
static_cast<icu::GregorianCalendar*>(calendar.get());
UErrorCode status = U_ZERO_ERROR;
status = U_ZERO_ERROR;
// The beginning of ECMAScript time, namely -(2**53)
const double start_of_time = -9007199254740992;
gc->setGregorianChange(start_of_time, status);
......@@ -1726,7 +1726,6 @@ MaybeHandle<JSDateTimeFormat> JSDateTimeFormat::New(
// 29. Let matcher be ? GetOption(options, "formatMatcher", "string", «
// "basic", "best fit" », "best fit").
enum FormatMatcherOption { kBestFit, kBasic };
// We implement only best fit algorithm, but still need to check
// if the formatMatcher values are in range.
// c. Let matcher be ? GetOption(options, "formatMatcher", "string",
......@@ -1870,7 +1869,7 @@ MaybeHandle<JSDateTimeFormat> JSDateTimeFormat::New(
if (dateTimeFormatHourCycle !=
ToHourCycle(hc_extension_it->second.c_str())) {
// 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);
DCHECK(U_SUCCESS(status));
}
......
......@@ -1132,8 +1132,8 @@ void LookupIterator::WriteDataValueToWasmObject(Handle<Object> value) {
} else {
// WasmArrays don't have writable properties.
DCHECK(holder->IsWasmStruct());
Handle<WasmStruct> holder = GetHolder<WasmStruct>();
WasmStruct::SetField(isolate_, holder, property_details_.field_index(),
Handle<WasmStruct> wasm_holder = GetHolder<WasmStruct>();
WasmStruct::SetField(isolate_, wasm_holder, property_details_.field_index(),
value);
}
}
......
......@@ -859,7 +859,6 @@ Handle<DescriptorArray> MapUpdater::BuildDescriptorArray() {
PropertyLocation next_location = old_details.location();
Representation next_representation = old_details.representation();
Descriptor d;
if (next_location == PropertyLocation::kField) {
Handle<FieldType> next_field_type =
GetOrComputeFieldType(i, old_details.location(), next_representation);
......@@ -889,6 +888,7 @@ Handle<DescriptorArray> MapUpdater::BuildDescriptorArray() {
DCHECK_EQ(PropertyConstness::kConst, next_constness);
Handle<Object> value(GetValue(i), isolate_);
Descriptor d;
if (next_kind == kData) {
d = Descriptor::DataConstant(key, value, next_attributes);
} else {
......@@ -1121,7 +1121,7 @@ void MapUpdater::UpdateFieldType(Isolate* isolate, Handle<Map> map,
backlog.push(target);
}
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
// to something or from Smi or HeapObject to Tagged.
......
......@@ -2972,7 +2972,7 @@ Maybe<bool> JSProxy::IsArray(Handle<JSProxy> proxy) {
Isolate* isolate = proxy->GetIsolate();
Handle<JSReceiver> object = Handle<JSReceiver>::cast(proxy);
for (int i = 0; i < JSProxy::kMaxIterationLimit; i++) {
Handle<JSProxy> proxy = Handle<JSProxy>::cast(object);
proxy = Handle<JSProxy>::cast(object);
if (proxy->IsRevoked()) {
isolate->Throw(*isolate->factory()->NewTypeError(
MessageTemplate::kProxyRevoked,
......@@ -3391,9 +3391,9 @@ Maybe<bool> JSArray::ArraySetLength(Isolate* isolate, Handle<JSArray> a,
if (!new_writable) {
PropertyDescriptor readonly;
readonly.set_writable(false);
Maybe<bool> success = OrdinaryDefineOwnProperty(
isolate, a, isolate->factory()->length_string(), &readonly,
should_throw);
success = OrdinaryDefineOwnProperty(isolate, a,
isolate->factory()->length_string(),
&readonly, should_throw);
DCHECK(success.FromJust());
USE(success);
}
......@@ -4376,12 +4376,12 @@ void DescriptorArray::CopyFrom(InternalIndex index, DescriptorArray src) {
void DescriptorArray::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.
for (int i = 0; i < len; ++i) SetSortedKey(i, i);
// Bottom-up max-heap construction.
// 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) {
int parent_index = i;
const uint32_t parent_hash = GetSortedKey(i).hash();
......@@ -4409,7 +4409,7 @@ void DescriptorArray::Sort() {
// Shift down the new top element.
int parent_index = 0;
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) {
int child_index = parent_index * 2 + 1;
uint32_t child_hash = GetSortedKey(child_index).hash();
......@@ -5964,15 +5964,15 @@ int BaseNameDictionary<Derived, Shape>::NextEnumerationIndex(
// Iterate over the dictionary using the enumeration order and update
// the dictionary with new enumeration indices.
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(),
dictionary->KeyAt(isolate, index)));
dictionary->KeyAt(isolate, internal_index)));
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);
dictionary->DetailsAtPut(index, new_details);
dictionary->DetailsAtPut(internal_index, new_details);
}
index = PropertyDetails::kInitialIndex + length;
......
......@@ -298,8 +298,8 @@ Handle<ScopeInfo> ScopeInfo::Create(IsolateT* isolate, Zone* zone, Scope* scope,
for (int i = 0; i < parameter_count; i++) {
Variable* parameter = scope->AsDeclarationScope()->parameter(i);
if (parameter->location() != VariableLocation::CONTEXT) continue;
int index = parameter->index() - scope->ContextHeaderLength();
int info_index = context_local_info_base + index;
int param_index = parameter->index() - scope->ContextHeaderLength();
int info_index = context_local_info_base + param_index;
int info = Smi::ToInt(scope_info.get(info_index));
info = ParameterNumberBits::update(info, i);
scope_info.set(info_index, Smi::FromInt(info));
......
......@@ -576,15 +576,15 @@ void SourceTextModule::FetchStarExports(Isolate* isolate,
// the name to undefined instead of a Cell.
Handle<ObjectHashTable> requested_exports(requested_module->exports(),
isolate);
for (InternalIndex i : requested_exports->IterateEntries()) {
for (InternalIndex index : requested_exports->IterateEntries()) {
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);
if (name->Equals(roots.default_string())) 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));
if (!insert_result.second) {
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