Commit fd9e54a9 authored by Georg Neis's avatar Georg Neis Committed by Commit Bot

[turbofan] Preserve CheckBounds's kAbortOnOutOfBounds mode

A previous CL made the mode an explicit argument but failed to
keep SimplifiedLowering from overriding it.

Moreover, CheckedUint64Bounds so far didn't support the two modes.

Change-Id: I01d8bf90fca77940fbeb428da57608a59f812c75
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2124833
Commit-Queue: Georg Neis <neis@chromium.org>
Reviewed-by: 's avatarTobias Tebbi <tebbi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#66921}
parent 1340412a
......@@ -2416,13 +2416,31 @@ Node* EffectControlLinearizer::LowerCheckedUint32ToTaggedSigned(
Node* EffectControlLinearizer::LowerCheckedUint64Bounds(Node* node,
Node* frame_state) {
CheckParameters const& params = CheckParametersOf(node->op());
Node* const index = node->InputAt(0);
Node* const limit = node->InputAt(1);
const CheckBoundsParameters& params = CheckBoundsParametersOf(node->op());
Node* check = __ Uint64LessThan(index, limit);
__ DeoptimizeIfNot(DeoptimizeReason::kOutOfBounds, params.feedback(), check,
frame_state, IsSafetyCheck::kCriticalSafetyCheck);
switch (params.mode()) {
case CheckBoundsParameters::kDeoptOnOutOfBounds:
__ DeoptimizeIfNot(DeoptimizeReason::kOutOfBounds,
params.check_parameters().feedback(), check,
frame_state, IsSafetyCheck::kCriticalSafetyCheck);
break;
case CheckBoundsParameters::kAbortOnOutOfBounds: {
auto if_abort = __ MakeDeferredLabel();
auto done = __ MakeLabel();
__ Branch(check, &done, &if_abort);
__ Bind(&if_abort);
__ Unreachable();
__ Goto(&done);
__ Bind(&done);
break;
}
}
return index;
}
......
......@@ -1646,7 +1646,8 @@ class RepresentationSelector {
}
void VisitCheckBounds(Node* node, SimplifiedLowering* lowering) {
CheckParameters const& p = CheckParametersOf(node->op());
CheckBoundsParameters const& p = CheckBoundsParametersOf(node->op());
FeedbackSource const& feedback = p.check_parameters().feedback();
Type const index_type = TypeOf(node->InputAt(0));
Type const length_type = TypeOf(node->InputAt(1));
if (length_type.Is(Type::Unsigned31())) {
......@@ -1657,8 +1658,7 @@ class RepresentationSelector {
VisitBinop(node, UseInfo::TruncatingWord32(),
MachineRepresentation::kWord32);
if (lower()) {
CheckBoundsParameters::Mode mode =
CheckBoundsParameters::kDeoptOnOutOfBounds;
CheckBoundsParameters::Mode mode = p.mode();
if (lowering->poisoning_level_ ==
PoisoningMitigationLevel::kDontPoison &&
(index_type.IsNone() || length_type.IsNone() ||
......@@ -1669,31 +1669,29 @@ class RepresentationSelector {
mode = CheckBoundsParameters::kAbortOnOutOfBounds;
}
NodeProperties::ChangeOp(
node, simplified()->CheckedUint32Bounds(p.feedback(), mode));
node, simplified()->CheckedUint32Bounds(feedback, mode));
}
} else {
VisitBinop(node, UseInfo::CheckedTaggedAsArrayIndex(p.feedback()),
VisitBinop(node, UseInfo::CheckedTaggedAsArrayIndex(feedback),
UseInfo::Word(), MachineType::PointerRepresentation());
if (lower()) {
if (jsgraph_->machine()->Is64()) {
NodeProperties::ChangeOp(
node, simplified()->CheckedUint64Bounds(p.feedback()));
node, simplified()->CheckedUint64Bounds(feedback, p.mode()));
} else {
NodeProperties::ChangeOp(
node,
simplified()->CheckedUint32Bounds(
p.feedback(), CheckBoundsParameters::kDeoptOnOutOfBounds));
node, simplified()->CheckedUint32Bounds(feedback, p.mode()));
}
}
}
} else {
CHECK(length_type.Is(type_cache_->kPositiveSafeInteger));
VisitBinop(node,
UseInfo::CheckedSigned64AsWord64(kIdentifyZeros, p.feedback()),
UseInfo::CheckedSigned64AsWord64(kIdentifyZeros, feedback),
UseInfo::Word64(), MachineRepresentation::kWord64);
if (lower()) {
NodeProperties::ChangeOp(
node, simplified()->CheckedUint64Bounds(p.feedback()));
node, simplified()->CheckedUint64Bounds(feedback, p.mode()));
}
}
}
......
......@@ -835,13 +835,13 @@ bool operator==(CheckMinusZeroParameters const& lhs,
V(CheckedTaggedToTaggedSigned, 1, 1) \
V(CheckedUint32ToInt32, 1, 1) \
V(CheckedUint32ToTaggedSigned, 1, 1) \
V(CheckedUint64Bounds, 2, 1) \
V(CheckedUint64ToInt32, 1, 1) \
V(CheckedUint64ToTaggedSigned, 1, 1)
#define CHECKED_BOUNDS_OP_LIST(V) \
V(CheckBounds) \
V(CheckedUint32Bounds)
V(CheckedUint32Bounds) \
V(CheckedUint64Bounds)
struct SimplifiedOperatorGlobalCache final {
#define PURE(Name, properties, value_input_count, control_input_count) \
......@@ -1615,7 +1615,8 @@ std::ostream& operator<<(std::ostream& os, CheckParameters const& p) {
CheckParameters const& CheckParametersOf(Operator const* op) {
if (op->opcode() == IrOpcode::kCheckBounds ||
op->opcode() == IrOpcode::kCheckedUint32Bounds) {
op->opcode() == IrOpcode::kCheckedUint32Bounds ||
op->opcode() == IrOpcode::kCheckedUint64Bounds) {
return OpParameter<CheckBoundsParameters>(op).check_parameters();
}
#define MAKE_OR(name, arg2, arg3) op->opcode() == IrOpcode::k##name ||
......@@ -1648,7 +1649,9 @@ std::ostream& operator<<(std::ostream& os, CheckBoundsParameters const& p) {
}
CheckBoundsParameters const& CheckBoundsParametersOf(Operator const* op) {
CHECK_EQ(op->opcode(), IrOpcode::kCheckedUint32Bounds);
DCHECK(op->opcode() == IrOpcode::kCheckBounds ||
op->opcode() == IrOpcode::kCheckedUint32Bounds ||
op->opcode() == IrOpcode::kCheckedUint64Bounds);
return OpParameter<CheckBoundsParameters>(op);
}
......
......@@ -786,6 +786,11 @@ class V8_EXPORT_PRIVATE SimplifiedOperatorBuilder final
const Operator* CheckBounds(const FeedbackSource& feedback,
CheckBoundsParameters::Mode mode =
CheckBoundsParameters::kDeoptOnOutOfBounds);
const Operator* CheckedUint32Bounds(const FeedbackSource& feedback,
CheckBoundsParameters::Mode mode);
const Operator* CheckedUint64Bounds(const FeedbackSource& feedback,
CheckBoundsParameters::Mode mode);
const Operator* CheckClosure(const Handle<FeedbackCell>& feedback_cell);
const Operator* CheckEqualsInternalizedString();
const Operator* CheckEqualsSymbol();
......@@ -831,11 +836,8 @@ class V8_EXPORT_PRIVATE SimplifiedOperatorBuilder final
const FeedbackSource& feedback);
const Operator* CheckedUint32Div();
const Operator* CheckedUint32Mod();
const Operator* CheckedUint32Bounds(const FeedbackSource& feedback,
CheckBoundsParameters::Mode mode);
const Operator* CheckedUint32ToInt32(const FeedbackSource& feedback);
const Operator* CheckedUint32ToTaggedSigned(const FeedbackSource& feedback);
const Operator* CheckedUint64Bounds(const FeedbackSource& feedback);
const Operator* CheckedUint64ToInt32(const FeedbackSource& feedback);
const Operator* CheckedUint64ToTaggedSigned(const FeedbackSource& feedback);
......
......@@ -754,16 +754,18 @@ TEST_F(RedundancyEliminationTest, CheckedUint64Bounds) {
Node* effect = graph()->start();
Node* control = graph()->start();
Node* check1 = effect =
graph()->NewNode(simplified()->CheckedUint64Bounds(feedback1), index,
length, effect, control);
Node* check1 = effect = graph()->NewNode(
simplified()->CheckedUint64Bounds(
feedback1, CheckBoundsParameters::kDeoptOnOutOfBounds),
index, length, effect, control);
Reduction r1 = Reduce(check1);
ASSERT_TRUE(r1.Changed());
EXPECT_EQ(r1.replacement(), check1);
Node* check2 = effect =
graph()->NewNode(simplified()->CheckedUint64Bounds(feedback2), index,
length, effect, control);
Node* check2 = effect = graph()->NewNode(
simplified()->CheckedUint64Bounds(
feedback2, CheckBoundsParameters::kDeoptOnOutOfBounds),
index, length, effect, control);
Reduction r2 = Reduce(check2);
ASSERT_TRUE(r2.Changed());
EXPECT_EQ(r2.replacement(), check1);
......
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