Commit ed3834db authored by bmeurer's avatar bmeurer Committed by Commit bot

[turbofan] Guard invariant that Branch/Select condition must be Boolean.

This introduces additional verification logic to ensure that the
condition passed to Branch/Select operators is always of type
Boolean.

CQ_INCLUDE_TRYBOTS=master.tryserver.v8:v8_win64_dbg
TBR=jarin@chromium.org
BUG=v8:5267

Review-Url: https://codereview.chromium.org/2672713002
Cr-Commit-Position: refs/heads/master@{#42875}
parent faa0ab66
......@@ -894,6 +894,7 @@ class RepresentationSelector {
// Helper for handling selects.
void VisitSelect(Node* node, Truncation truncation,
SimplifiedLowering* lowering) {
DCHECK(TypeOf(node->InputAt(0))->Is(Type::Boolean()));
ProcessInput(node, 0, UseInfo::Bool());
MachineRepresentation output =
......@@ -1424,10 +1425,12 @@ class RepresentationSelector {
return;
}
case IrOpcode::kBranch:
case IrOpcode::kBranch: {
DCHECK(TypeOf(node->InputAt(0))->Is(Type::Boolean()));
ProcessInput(node, 0, UseInfo::Bool());
EnqueueInput(node, NodeProperties::FirstControlIndex(node));
return;
}
case IrOpcode::kSwitch:
ProcessInput(node, 0, UseInfo::TruncatingWord32());
EnqueueInput(node, NodeProperties::FirstControlIndex(node));
......
......@@ -207,6 +207,8 @@ void Verifier::Visitor::Check(Node* node) {
}
CHECK_EQ(1, count_true);
CHECK_EQ(1, count_false);
// The condition must be a Boolean.
CheckValueInputIs(node, 0, Type::Boolean());
// Type is empty.
CheckNotTyped(node);
break;
......@@ -408,6 +410,10 @@ void Verifier::Visitor::Check(Node* node) {
CHECK_EQ(0, effect_count);
CHECK_EQ(0, control_count);
CHECK_EQ(3, value_count);
// The condition must be a Boolean.
CheckValueInputIs(node, 0, Type::Boolean());
// Type can be anything.
CheckTypeIs(node, Type::Any());
break;
}
case IrOpcode::kPhi: {
......
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