Commit bf4b542a authored by Marja Hölttä's avatar Marja Hölttä Committed by V8 LUCI CQ

[cleanup] Make builtins Wshadow compatible

Bug: v8:12244, v8:12245
Change-Id: Icd54ac767542ec2344c34b8dde674b41079180af
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3181525Reviewed-by: 's avatarToon Verwaest <verwaest@chromium.org>
Commit-Queue: Marja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/main@{#77036}
parent c5c5b6cb
......@@ -369,8 +369,8 @@ TF_BUILTIN(ArrayPrototypePush, CodeStubAssembler) {
Increment(&arg_index);
// The runtime SetProperty call could have converted the array to dictionary
// mode, which must be detected to abort the fast-path.
TNode<Int32T> kind = LoadElementsKind(array_receiver);
GotoIf(Word32Equal(kind, Int32Constant(DICTIONARY_ELEMENTS)),
TNode<Int32T> elements_kind = LoadElementsKind(array_receiver);
GotoIf(Word32Equal(elements_kind, Int32Constant(DICTIONARY_ELEMENTS)),
&default_label);
GotoIfNotNumber(arg, &object_push);
......@@ -413,8 +413,8 @@ TF_BUILTIN(ArrayPrototypePush, CodeStubAssembler) {
Increment(&arg_index);
// The runtime SetProperty call could have converted the array to dictionary
// mode, which must be detected to abort the fast-path.
TNode<Int32T> kind = LoadElementsKind(array_receiver);
GotoIf(Word32Equal(kind, Int32Constant(DICTIONARY_ELEMENTS)),
TNode<Int32T> elements_kind = LoadElementsKind(array_receiver);
GotoIf(Word32Equal(elements_kind, Int32Constant(DICTIONARY_ELEMENTS)),
&default_label);
Goto(&object_push);
}
......@@ -806,16 +806,16 @@ void ArrayIncludesIndexofAssembler::GenerateSmiOrObject(
BIND(&not_nan_loop);
{
Label continue_loop(this), not_smi(this);
Label continue_loop(this), element_k_not_smi(this);
GotoIfNot(UintPtrLessThan(index_var.value(), array_length_untagged),
&return_not_found);
TNode<Object> element_k =
UnsafeLoadFixedArrayElement(elements, index_var.value());
GotoIfNot(TaggedIsSmi(element_k), &not_smi);
GotoIfNot(TaggedIsSmi(element_k), &element_k_not_smi);
Branch(Float64Equal(search_num.value(), SmiToFloat64(CAST(element_k))),
&return_found, &continue_loop);
BIND(&not_smi);
BIND(&element_k_not_smi);
GotoIfNot(IsHeapNumber(CAST(element_k)), &continue_loop);
Branch(Float64Equal(search_num.value(),
LoadHeapNumberValue(CAST(element_k))),
......
......@@ -1338,8 +1338,8 @@ Object Slow_ArrayConcat(BuiltinArguments* args, Handle<Object> species,
if (length == 0) break;
FixedDoubleArray elements =
FixedDoubleArray::cast(array.elements());
for (uint32_t i = 0; i < length; i++) {
if (elements.is_the_hole(i)) {
for (uint32_t k = 0; k < length; k++) {
if (elements.is_the_hole(k)) {
// TODO(jkummerow/verwaest): We could be a bit more clever
// here: Check if there are no elements/getters on the
// prototype chain, and if so, allow creation of a holey
......@@ -1348,7 +1348,7 @@ Object Slow_ArrayConcat(BuiltinArguments* args, Handle<Object> species,
failure = true;
break;
}
double double_value = elements.get_scalar(i);
double double_value = elements.get_scalar(k);
double_storage->set(j, double_value);
j++;
}
......@@ -1358,8 +1358,8 @@ Object Slow_ArrayConcat(BuiltinArguments* args, Handle<Object> species,
case PACKED_SMI_ELEMENTS: {
Object the_hole = ReadOnlyRoots(isolate).the_hole_value();
FixedArray elements(FixedArray::cast(array.elements()));
for (uint32_t i = 0; i < length; i++) {
Object element = elements.get(i);
for (uint32_t k = 0; k < length; k++) {
Object element = elements.get(k);
if (element == the_hole) {
failure = true;
break;
......
......@@ -228,16 +228,16 @@ AsyncFromSyncBuiltinsAssembler::LoadIteratorResult(
// Let nextDone be IteratorComplete(nextResult).
// IfAbruptRejectPromise(nextDone, promiseCapability).
const TNode<Object> done =
const TNode<Object> iter_result_done =
GetProperty(context, iter_result, factory()->done_string());
// Let nextValue be IteratorValue(nextResult).
// IfAbruptRejectPromise(nextValue, promiseCapability).
const TNode<Object> value =
const TNode<Object> iter_result_value =
GetProperty(context, iter_result, factory()->value_string());
var_value = value;
var_done = done;
var_value = iter_result_value;
var_done = iter_result_done;
Goto(&merge);
}
......
......@@ -1481,17 +1481,17 @@ CollectionsBuiltinsAssembler::Transition(
Goto(&loop);
BIND(&loop);
{
TNode<TableType> table = var_table.value();
TNode<IntPtrT> index = var_index.value();
TNode<TableType> current_table = var_table.value();
TNode<IntPtrT> current_index = var_index.value();
TNode<Object> next_table =
LoadObjectField(table, TableType::NextTableOffset());
LoadObjectField(current_table, TableType::NextTableOffset());
GotoIf(TaggedIsSmi(next_table), &done_loop);
var_table = CAST(next_table);
var_index = SmiUntag(
CAST(CallBuiltin(Builtin::kOrderedHashTableHealIndex,
NoContextConstant(), table, SmiTag(index))));
var_index = SmiUntag(CAST(CallBuiltin(Builtin::kOrderedHashTableHealIndex,
NoContextConstant(), current_table,
SmiTag(current_index))));
Goto(&loop);
}
BIND(&done_loop);
......
......@@ -315,31 +315,33 @@ BUILTIN(DatePrototypeSetFullYear) {
Handle<Object> year = args.atOrUndefined(isolate, 1);
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, year,
Object::ToNumber(isolate, year));
double y = year->Number(), m = 0.0, dt = 1.0;
double year_double = year->Number(), month_double = 0.0, day_double = 1.0;
int time_within_day = 0;
if (!std::isnan(date->value().Number())) {
int64_t const time_ms = static_cast<int64_t>(date->value().Number());
int64_t local_time_ms = isolate->date_cache()->ToLocal(time_ms);
int const days = isolate->date_cache()->DaysFromTime(local_time_ms);
time_within_day = isolate->date_cache()->TimeInDay(local_time_ms, days);
int year, month, day;
isolate->date_cache()->YearMonthDayFromDays(days, &year, &month, &day);
m = month;
dt = day;
int year_int, month_int, day_int;
isolate->date_cache()->YearMonthDayFromDays(days, &year_int, &month_int,
&day_int);
month_double = month_int;
day_double = day_int;
}
if (argc >= 2) {
Handle<Object> month = args.at(2);
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, month,
Object::ToNumber(isolate, month));
m = month->Number();
month_double = month->Number();
if (argc >= 3) {
Handle<Object> date = args.at(3);
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, date,
Object::ToNumber(isolate, date));
dt = date->Number();
Handle<Object> day = args.at(3);
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, day,
Object::ToNumber(isolate, day));
day_double = day->Number();
}
}
double time_val = MakeDate(MakeDay(y, m, dt), time_within_day);
double time_val =
MakeDate(MakeDay(year_double, month_double, day_double), time_within_day);
return SetLocalDateValue(isolate, date, time_val);
}
......@@ -534,30 +536,32 @@ BUILTIN(DatePrototypeSetUTCFullYear) {
Handle<Object> year = args.atOrUndefined(isolate, 1);
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, year,
Object::ToNumber(isolate, year));
double y = year->Number(), m = 0.0, dt = 1.0;
double year_double = year->Number(), month_double = 0.0, day_double = 1.0;
int time_within_day = 0;
if (!std::isnan(date->value().Number())) {
int64_t const time_ms = static_cast<int64_t>(date->value().Number());
int const days = isolate->date_cache()->DaysFromTime(time_ms);
time_within_day = isolate->date_cache()->TimeInDay(time_ms, days);
int year, month, day;
isolate->date_cache()->YearMonthDayFromDays(days, &year, &month, &day);
m = month;
dt = day;
int year_int, month_int, day_int;
isolate->date_cache()->YearMonthDayFromDays(days, &year_int, &month_int,
&day_int);
month_double = month_int;
day_double = day_int;
}
if (argc >= 2) {
Handle<Object> month = args.at(2);
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, month,
Object::ToNumber(isolate, month));
m = month->Number();
month_double = month->Number();
if (argc >= 3) {
Handle<Object> date = args.at(3);
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, date,
Object::ToNumber(isolate, date));
dt = date->Number();
Handle<Object> day = args.at(3);
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, day,
Object::ToNumber(isolate, day));
day_double = day->Number();
}
}
double const time_val = MakeDate(MakeDay(y, m, dt), time_within_day);
double const time_val =
MakeDate(MakeDay(year_double, month_double, day_double), time_within_day);
return *JSDate::SetValue(date, DateCache::TimeClip(time_val));
}
......@@ -872,11 +876,11 @@ BUILTIN(DatePrototypeSetYear) {
Handle<Object> year = args.atOrUndefined(isolate, 1);
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, year,
Object::ToNumber(isolate, year));
double m = 0.0, dt = 1.0, y = year->Number();
if (!std::isnan(y)) {
double y_int = DoubleToInteger(y);
if (0.0 <= y_int && y_int <= 99.0) {
y = 1900.0 + y_int;
double month_double = 0.0, day_double = 1.0, year_double = year->Number();
if (!std::isnan(year_double)) {
double year_int = DoubleToInteger(year_double);
if (0.0 <= year_int && year_int <= 99.0) {
year_double = 1900.0 + year_int;
}
}
int time_within_day = 0;
......@@ -885,12 +889,14 @@ BUILTIN(DatePrototypeSetYear) {
int64_t local_time_ms = isolate->date_cache()->ToLocal(time_ms);
int const days = isolate->date_cache()->DaysFromTime(local_time_ms);
time_within_day = isolate->date_cache()->TimeInDay(local_time_ms, days);
int year, month, day;
isolate->date_cache()->YearMonthDayFromDays(days, &year, &month, &day);
m = month;
dt = day;
}
double time_val = MakeDate(MakeDay(y, m, dt), time_within_day);
int year_int, month_int, day_int;
isolate->date_cache()->YearMonthDayFromDays(days, &year_int, &month_int,
&day_int);
month_double = month_int;
day_double = day_int;
}
double time_val =
MakeDate(MakeDay(year_double, month_double, day_double), time_within_day);
return SetLocalDateValue(isolate, date, time_val);
}
......
......@@ -94,21 +94,21 @@ void GeneratorBuiltinsAssembler::InnerResume(
BIND(&if_receiverisclosed);
{
// The {receiver} is closed already.
TNode<Object> result;
TNode<Object> builtin_result;
switch (resume_mode) {
case JSGeneratorObject::kNext:
result = CallBuiltin(Builtin::kCreateIterResultObject, context,
builtin_result = CallBuiltin(Builtin::kCreateIterResultObject, context,
UndefinedConstant(), TrueConstant());
break;
case JSGeneratorObject::kReturn:
result = CallBuiltin(Builtin::kCreateIterResultObject, context, value,
TrueConstant());
builtin_result = CallBuiltin(Builtin::kCreateIterResultObject, context,
value, TrueConstant());
break;
case JSGeneratorObject::kThrow:
result = CallRuntime(Runtime::kThrow, context, value);
builtin_result = CallRuntime(Runtime::kThrow, context, value);
break;
}
args->PopAndReturn(result);
args->PopAndReturn(builtin_result);
}
BIND(&if_receiverisrunning);
......
......@@ -323,12 +323,13 @@ class WriteBarrierCodeStubAssembler : public CodeStubAssembler {
GotoIfNot(IsPageFlagSet(value, MemoryChunk::kEvacuationCandidateMask),
&next);
{
TNode<IntPtrT> object = BitcastTaggedToWord(
UncheckedParameter<Object>(WriteBarrierDescriptor::kObject));
Branch(
IsPageFlagSet(object, MemoryChunk::kSkipEvacuationSlotsRecordingMask),
&next, &call_incremental_wb);
}
BIND(&call_incremental_wb);
{
TNode<ExternalReference> function = ExternalConstant(
......
......@@ -1096,7 +1096,7 @@ TF_BUILTIN(ObjectCreate, ObjectBuiltinsAssembler) {
BIND(&no_properties);
{
TVARIABLE(Map, map);
TVARIABLE(HeapObject, properties);
TVARIABLE(HeapObject, new_properties);
Label null_proto(this), non_null_proto(this), instantiate_map(this);
Branch(IsNull(prototype), &null_proto, &non_null_proto);
......@@ -1105,17 +1105,18 @@ TF_BUILTIN(ObjectCreate, ObjectBuiltinsAssembler) {
{
map = LoadSlowObjectWithNullPrototypeMap(native_context);
if (V8_ENABLE_SWISS_NAME_DICTIONARY_BOOL) {
properties =
new_properties =
AllocateSwissNameDictionary(SwissNameDictionary::kInitialCapacity);
} else {
properties = AllocateNameDictionary(NameDictionary::kInitialCapacity);
new_properties =
AllocateNameDictionary(NameDictionary::kInitialCapacity);
}
Goto(&instantiate_map);
}
BIND(&non_null_proto);
{
properties = EmptyFixedArrayConstant();
new_properties = EmptyFixedArrayConstant();
map = LoadObjectFunctionInitialMap(native_context);
GotoIf(TaggedEqual(prototype, LoadMapPrototype(map.value())),
&instantiate_map);
......@@ -1133,7 +1134,7 @@ TF_BUILTIN(ObjectCreate, ObjectBuiltinsAssembler) {
BIND(&instantiate_map);
{
TNode<JSObject> instance =
AllocateJSObjectFromMap(map.value(), properties.value());
AllocateJSObjectFromMap(map.value(), new_properties.value());
args.PopAndReturn(instance);
}
}
......
......@@ -260,19 +260,19 @@ TNode<JSRegExpResult> RegExpBuiltinsAssembler::ConstructNewResultFromMatchInfo(
{
TNode<IntPtrT> from_cursor = var_from_cursor.value();
TNode<IntPtrT> to_cursor = var_to_cursor.value();
TNode<Smi> start =
TNode<Smi> start_cursor =
CAST(UnsafeLoadFixedArrayElement(match_info, from_cursor));
Label next_iter(this);
GotoIf(SmiEqual(start, SmiConstant(-1)), &next_iter);
GotoIf(SmiEqual(start_cursor, SmiConstant(-1)), &next_iter);
TNode<IntPtrT> from_cursor_plus1 =
IntPtrAdd(from_cursor, IntPtrConstant(1));
TNode<Smi> end =
TNode<Smi> end_cursor =
CAST(UnsafeLoadFixedArrayElement(match_info, from_cursor_plus1));
TNode<String> capture =
CAST(CallBuiltin(Builtin::kSubString, context, string, start, end));
TNode<String> capture = CAST(CallBuiltin(Builtin::kSubString, context,
string, start_cursor, end_cursor));
UnsafeStoreFixedArrayElement(result_elements, to_cursor, capture);
Goto(&next_iter);
......@@ -338,10 +338,10 @@ TNode<JSRegExpResult> RegExpBuiltinsAssembler::ConstructNewResultFromMatchInfo(
TVARIABLE(IntPtrT, var_i, IntPtrZero());
Label loop(this, &var_i);
Label inner_loop(this, &var_i);
Goto(&loop);
BIND(&loop);
Goto(&inner_loop);
BIND(&inner_loop);
{
TNode<IntPtrT> i = var_i.value();
TNode<IntPtrT> i_plus_1 = IntPtrAdd(i, IntPtrConstant(1));
......@@ -371,7 +371,7 @@ TNode<JSRegExpResult> RegExpBuiltinsAssembler::ConstructNewResultFromMatchInfo(
var_i = i_plus_2;
Branch(IntPtrGreaterThanOrEqual(var_i.value(), names_length),
&maybe_build_indices, &loop);
&maybe_build_indices, &inner_loop);
BIND(&add_dictionary_property_slow);
// If the dictionary needs resizing, the above Add call will jump here
......@@ -1310,12 +1310,12 @@ TF_BUILTIN(RegExpPrototypeCompile, RegExpBuiltinsAssembler) {
// {maybe_flags} must be undefined in this case, otherwise throw.
{
Label next(this);
GotoIf(IsUndefined(maybe_flags), &next);
Label maybe_flags_is_undefined(this);
GotoIf(IsUndefined(maybe_flags), &maybe_flags_is_undefined);
ThrowTypeError(context, MessageTemplate::kRegExpFlags);
BIND(&next);
BIND(&maybe_flags_is_undefined);
}
const TNode<JSRegExp> pattern = CAST(maybe_pattern);
......
......@@ -1434,9 +1434,10 @@ TF_BUILTIN(StringPrototypeSplit, StringBuiltinsAssembler) {
TNode<Smi> length = smi_zero;
TNode<IntPtrT> capacity = IntPtrConstant(0);
TNode<JSArray> result = AllocateJSArray(kind, array_map, capacity, length);
TNode<JSArray> result_array =
AllocateJSArray(kind, array_map, capacity, length);
args.PopAndReturn(result);
args.PopAndReturn(result_array);
}
}
......
......@@ -112,9 +112,9 @@ const char* Builtins::Lookup(Address pc) {
// May be called during initialization (disassembler).
if (!initialized_) return nullptr;
for (Builtin builtin = Builtins::kFirst; builtin <= Builtins::kLast;
++builtin) {
if (code(builtin).contains(isolate_, pc)) return name(builtin);
for (Builtin builtin_ix = Builtins::kFirst; builtin_ix <= Builtins::kLast;
++builtin_ix) {
if (code(builtin_ix).contains(isolate_, pc)) return name(builtin_ix);
}
return nullptr;
}
......
......@@ -66,7 +66,7 @@ Handle<Code> BuildPlaceholder(Isolate* isolate, Builtin builtin) {
ExternalAssemblerBuffer(buffer, kBufferSize));
DCHECK(!masm.has_frame());
{
FrameScope scope(&masm, StackFrame::NONE);
FrameScope frame_scope(&masm, StackFrame::NONE);
// The contents of placeholder don't matter, as long as they don't create
// embedded constants or external references.
masm.Move(kJavaScriptCallCodeStartRegister, Smi::zero());
......
......@@ -1828,7 +1828,7 @@ void Builtins::Generate_BaselineOutOfLinePrologue(MacroAssembler* masm) {
// Push the baseline code return address now, as if it had been pushed by
// the call to this builtin.
__ PushReturnAddressFrom(return_address);
FrameScope frame_scope(masm, StackFrame::INTERNAL);
FrameScope inner_frame_scope(masm, StackFrame::INTERNAL);
// Save incoming new target or generator
__ Push(new_target);
__ SmiTag(frame_size);
......
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