[maglev][cleanup] AssertCondition to use cross-platform conditions

Bug: v8:7700
Change-Id: I7ca0209ae08ed60beb07e98b4699e7b6bab62324
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4198139
Commit-Queue: Darius Mercadier <dmercadier@chromium.org>
Auto-Submit: Victor Gomes <victorgomes@chromium.org>
Reviewed-by: Darius Mercadier <dmercadier@chromium.org>
Cr-Commit-Position: refs/heads/main@{#85510}
This commit is contained in:
Victor Gomes 2023-01-26 17:28:15 +01:00 committed by V8 LUCI CQ
parent 6b9f51e37c
commit d98c971b6e
6 changed files with 25 additions and 64 deletions

View File

@ -673,31 +673,6 @@ inline void MaglevAssembler::MoveRepr(MachineRepresentation repr,
MoveRepr(repr, dst, scratch);
}
inline Condition ToCondition(AssertCondition cond) {
switch (cond) {
case AssertCondition::kLess:
return lt;
case AssertCondition::kLessOrEqual:
return le;
case AssertCondition::kGreater:
return gt;
case AssertCondition::kGeaterOrEqual:
return ge;
case AssertCondition::kBelow:
return lo;
case AssertCondition::kBelowOrEqual:
return ls;
case AssertCondition::kAbove:
return hi;
case AssertCondition::kAboveOrEqual:
return hs;
case AssertCondition::kEqual:
return eq;
case AssertCondition::kNotEqual:
return ne;
}
}
} // namespace maglev
} // namespace internal
} // namespace v8

View File

@ -426,6 +426,16 @@ inline bool AnyMapIsHeapNumber(const ZoneHandleSet<Map>& maps) {
[](Handle<Map> map) { return map->IsHeapNumberMap(); });
}
inline Condition ToCondition(AssertCondition cond) {
switch (cond) {
#define CASE(Name) \
case AssertCondition::k##Name: \
return k##Name;
ASSERT_CONDITION(CASE)
#undef CASE
}
}
} // namespace maglev
} // namespace internal
} // namespace v8

View File

@ -2210,7 +2210,8 @@ bool MaglevGraphBuilder::TryBuildElementAccessOnString(
ValueNode* length = AddNewNode<StringLength>({object});
ValueNode* index = GetInt32ElementIndex(index_object);
AddNewNode<CheckInt32Condition>({index, length}, AssertCondition::kBelow,
AddNewNode<CheckInt32Condition>({index, length},
AssertCondition::kUnsignedLessThan,
DeoptimizeReason::kOutOfBounds);
SetAccumulator(AddNewNode<StringAt>({object, index}));
@ -3098,7 +3099,8 @@ ValueNode* MaglevGraphBuilder::TryReduceStringPrototypeCharCodeAt(
BuildCheckString(receiver);
// And index is below length.
ValueNode* length = AddNewNode<StringLength>({receiver});
AddNewNode<CheckInt32Condition>({index, length}, AssertCondition::kBelow,
AddNewNode<CheckInt32Condition>({index, length},
AssertCondition::kUnsignedLessThan,
DeoptimizeReason::kOutOfBounds);
return AddNewNode<BuiltinStringPrototypeCharCodeAt>({receiver, index});
}
@ -4997,7 +4999,7 @@ void MaglevGraphBuilder::VisitResumeGenerator() {
ValueNode* register_size = GetInt32Constant(
parameter_count_without_receiver() + registers.register_count());
AddNewNode<AssertInt32>(
{register_size, array_length}, AssertCondition::kLessOrEqual,
{register_size, array_length}, AssertCondition::kLessThanEqual,
AbortReason::kInvalidParametersAndRegistersInGenerator);
}

View File

@ -769,8 +769,7 @@ void CheckUint32IsSmi::GenerateCode(MaglevAssembler* masm,
Register reg = ToRegister(input());
// Perform an unsigned comparison against Smi::kMaxValue.
__ Cmp(reg, Smi::kMaxValue);
__ EmitEagerDeoptIf(ToCondition(AssertCondition::kAbove),
DeoptimizeReason::kNotASmi, this);
__ EmitEagerDeoptIf(kUnsignedGreaterThan, DeoptimizeReason::kNotASmi, this);
}
void CheckedSmiUntag::SetValueLocationConstraints() {

View File

@ -3496,16 +3496,16 @@ class CreateClosure : public FixedInputValueNodeT<1, CreateClosure> {
};
#define ASSERT_CONDITION(V) \
V(Less) \
V(LessOrEqual) \
V(Greater) \
V(GeaterOrEqual) \
V(Below) \
V(BelowOrEqual) \
V(Above) \
V(AboveOrEqual) \
V(Equal) \
V(NotEqual)
V(NotEqual) \
V(LessThan) \
V(LessThanEqual) \
V(GreaterThan) \
V(GreaterThanEqual) \
V(UnsignedLessThan) \
V(UnsignedLessThanEqual) \
V(UnsignedGreaterThan) \
V(UnsignedGreaterThanEqual)
enum class AssertCondition {
#define D(Name) k##Name,

View File

@ -537,31 +537,6 @@ inline void MaglevAssembler::MoveRepr(MachineRepresentation repr,
MoveRepr(repr, dst, kScratchRegister);
}
inline Condition ToCondition(AssertCondition cond) {
switch (cond) {
case AssertCondition::kLess:
return less;
case AssertCondition::kLessOrEqual:
return less_equal;
case AssertCondition::kGreater:
return greater;
case AssertCondition::kGeaterOrEqual:
return greater_equal;
case AssertCondition::kBelow:
return below;
case AssertCondition::kBelowOrEqual:
return below_equal;
case AssertCondition::kAbove:
return above;
case AssertCondition::kAboveOrEqual:
return above_equal;
case AssertCondition::kEqual:
return equal;
case AssertCondition::kNotEqual:
return not_equal;
}
}
} // namespace maglev
} // namespace internal
} // namespace v8