[turbofan] Drop the obsolete TypeGuard operator.

The only real use case left for TypeGuard was the renaming inside the
LoadElimination, but this case only occurs in dead code (guarded by a
previous Check), so it's not relevant, and we can drop the TypeGuard
operator completely.

R=jarin@chromium.org

Review-Url: https://codereview.chromium.org/2108793003
Cr-Commit-Position: refs/heads/master@{#37361}
This commit is contained in:
bmeurer 2016-06-28 23:34:04 -07:00 committed by Commit bot
parent 61eb77643e
commit be32c055f1
16 changed files with 9 additions and 164 deletions

View File

@ -395,9 +395,6 @@ bool EffectControlLinearizer::TryWireInStateEffect(Node* node,
Node** control) {
ValueEffectControl state(nullptr, nullptr, nullptr);
switch (node->opcode()) {
case IrOpcode::kTypeGuard:
state = LowerTypeGuard(node, *effect, *control);
break;
case IrOpcode::kChangeBitToTagged:
state = LowerChangeBitToTagged(node, *effect, *control);
break;
@ -509,13 +506,6 @@ bool EffectControlLinearizer::TryWireInStateEffect(Node* node,
return true;
}
EffectControlLinearizer::ValueEffectControl
EffectControlLinearizer::LowerTypeGuard(Node* node, Node* effect,
Node* control) {
Node* value = node->InputAt(0);
return ValueEffectControl(value, effect, control);
}
EffectControlLinearizer::ValueEffectControl
EffectControlLinearizer::LowerChangeFloat64ToTagged(Node* node, Node* effect,
Node* control) {

View File

@ -43,7 +43,6 @@ class EffectControlLinearizer {
bool TryWireInStateEffect(Node* node, Node* frame_state, Node** effect,
Node** control);
ValueEffectControl LowerTypeGuard(Node* node, Node* effect, Node* control);
ValueEffectControl LowerChangeBitToTagged(Node* node, Node* effect,
Node* control);
ValueEffectControl LowerChangeInt31ToTaggedSigned(Node* node, Node* effect,

View File

@ -793,7 +793,6 @@ bool EscapeStatusAnalysis::CheckUsesForEscape(Node* uses, Node* rep,
}
break;
case IrOpcode::kSelect:
case IrOpcode::kTypeGuard:
// TODO(mstarzinger): The following list of operators will eventually be
// handled by the EscapeAnalysisReducer (similar to ObjectIsSmi).
case IrOpcode::kObjectIsCallable:

View File

@ -34,10 +34,6 @@ Reduction JSIntrinsicLowering::Reduce(Node* node) {
return ReduceCreateIterResultObject(node);
case Runtime::kInlineDeoptimizeNow:
return ReduceDeoptimizeNow(node);
case Runtime::kInlineDoubleHi:
return ReduceDoubleHi(node);
case Runtime::kInlineDoubleLo:
return ReduceDoubleLo(node);
case Runtime::kInlineGeneratorClose:
return ReduceGeneratorClose(node);
case Runtime::kInlineGeneratorGetInputOrDebugPos:
@ -125,24 +121,6 @@ Reduction JSIntrinsicLowering::ReduceDeoptimizeNow(Node* node) {
return Changed(node);
}
Reduction JSIntrinsicLowering::ReduceDoubleHi(Node* node) {
// Tell the compiler to assume number input.
Node* renamed = graph()->NewNode(simplified()->TypeGuard(Type::Number()),
node->InputAt(0), graph()->start());
node->ReplaceInput(0, renamed);
return Change(node, machine()->Float64ExtractHighWord32());
}
Reduction JSIntrinsicLowering::ReduceDoubleLo(Node* node) {
// Tell the compiler to assume number input.
Node* renamed = graph()->NewNode(simplified()->TypeGuard(Type::Number()),
node->InputAt(0), graph()->start());
node->ReplaceInput(0, renamed);
return Change(node, machine()->Float64ExtractLowWord32());
}
Reduction JSIntrinsicLowering::ReduceGeneratorClose(Node* node) {
Node* const generator = NodeProperties::GetValueInput(node, 0);
Node* const effect = NodeProperties::GetEffectInput(node);

View File

@ -39,8 +39,6 @@ class JSIntrinsicLowering final : public AdvancedReducer {
private:
Reduction ReduceCreateIterResultObject(Node* node);
Reduction ReduceDeoptimizeNow(Node* node);
Reduction ReduceDoubleHi(Node* node);
Reduction ReduceDoubleLo(Node* node);
Reduction ReduceGeneratorClose(Node* node);
Reduction ReduceGeneratorGetInputOrDebugPos(Node* node);
Reduction ReduceGeneratorGetResumeMode(Node* node);

View File

@ -61,21 +61,20 @@ Reduction LoadElimination::ReduceLoadField(Node* node) {
NodeProperties::GetValueInput(effect, 0));
if (object == value_input) {
Node* const value = NodeProperties::GetValueInput(effect, 1);
Type* stored_value_type = NodeProperties::GetType(value);
Type* load_type = NodeProperties::GetType(node);
Type* value_type = NodeProperties::GetType(value);
Type* node_type = NodeProperties::GetType(node);
// Make sure the replacement's type is a subtype of the node's
// type. Otherwise we could confuse optimizations that were
// based on the original type.
if (stored_value_type->Is(load_type)) {
if (value_type->Is(node_type)) {
ReplaceWithValue(node, value);
return Replace(value);
} else {
Node* renamed = graph()->NewNode(
simplified()->TypeGuard(Type::Intersect(
stored_value_type, load_type, graph()->zone())),
value, NodeProperties::GetControlInput(node));
ReplaceWithValue(node, renamed);
return Replace(renamed);
// This LoadField has stronger guarantees than the stored value
// can give us, which suggests that we are probably in unreachable
// code, guarded by some Check, so don't bother trying to optimize
// this LoadField {node}.
return NoChange();
}
}
// TODO(turbofan): Alias analysis to the rescue?

View File

@ -262,8 +262,7 @@
V(ObjectIsReceiver) \
V(ObjectIsSmi) \
V(ObjectIsString) \
V(ObjectIsUndetectable) \
V(TypeGuard)
V(ObjectIsUndetectable)
// Opcodes for Machine-level operators.
#define MACHINE_COMPARE_BINOP_LIST(V) \

View File

@ -175,8 +175,6 @@ Reduction SimplifiedOperatorReducer::Reduce(Node* node) {
}
case IrOpcode::kReferenceEqual:
return ReduceReferenceEqual(node);
case IrOpcode::kTypeGuard:
return ReduceTypeGuard(node);
default:
break;
}
@ -199,15 +197,6 @@ Reduction SimplifiedOperatorReducer::ReduceReferenceEqual(Node* node) {
return NoChange();
}
Reduction SimplifiedOperatorReducer::ReduceTypeGuard(Node* node) {
DCHECK_EQ(IrOpcode::kTypeGuard, node->opcode());
Node* const input = NodeProperties::GetValueInput(node, 0);
Type* const input_type = NodeProperties::GetTypeOrAny(input);
Type* const guard_type = TypeOf(node->op());
if (input_type->Is(guard_type)) return Replace(input);
return NoChange();
}
Reduction SimplifiedOperatorReducer::Change(Node* node, const Operator* op,
Node* a) {
DCHECK_EQ(node->InputCount(), OperatorProperties::GetTotalInputCount(op));

View File

@ -29,7 +29,6 @@ class SimplifiedOperatorReducer final : public AdvancedReducer {
private:
Reduction ReduceReferenceEqual(Node* node);
Reduction ReduceTypeGuard(Node* node);
Reduction Change(Node* node, const Operator* op, Node* a);
Reduction ReplaceBoolean(bool value);

View File

@ -212,11 +212,6 @@ CheckTaggedHoleMode CheckTaggedHoleModeOf(const Operator* op) {
return OpParameter<CheckTaggedHoleMode>(op);
}
Type* TypeOf(const Operator* op) {
DCHECK_EQ(IrOpcode::kTypeGuard, op->opcode());
return OpParameter<Type*>(op);
}
BinaryOperationHints::Hint BinaryOperationHintOf(const Operator* op) {
DCHECK(op->opcode() == IrOpcode::kSpeculativeNumberAdd ||
op->opcode() == IrOpcode::kSpeculativeNumberSubtract ||
@ -459,23 +454,6 @@ const Operator* SimplifiedOperatorBuilder::CheckBounds() {
"CheckBounds", 2, 1, 1, 1, 1, 0);
}
const Operator* SimplifiedOperatorBuilder::TypeGuard(Type* type) {
class TypeGuardOperator final : public Operator1<Type*> {
public:
explicit TypeGuardOperator(Type* type)
: Operator1<Type*>( // --
IrOpcode::kTypeGuard, Operator::kPure, // opcode
"TypeGuard", // name
1, 0, 1, 1, 0, 0, // counts
type) {} // parameter
void PrintParameter(std::ostream& os) const final {
parameter()->PrintTo(os);
}
};
return new (zone()) TypeGuardOperator(type);
}
const Operator* SimplifiedOperatorBuilder::Allocate(PretenureFlag pretenure) {
switch (pretenure) {
case NOT_TENURED:

View File

@ -260,8 +260,6 @@ class SimplifiedOperatorBuilder final : public ZoneObject {
const Operator* ObjectIsString();
const Operator* ObjectIsUndetectable();
const Operator* TypeGuard(Type* type);
const Operator* Allocate(PretenureFlag pretenure = NOT_TENURED);
const Operator* LoadField(FieldAccess const&);

View File

@ -703,12 +703,6 @@ Type* Typer::Visitor::TypeEffectPhi(Node* node) {
return nullptr;
}
Type* Typer::Visitor::TypeTypeGuard(Node* node) {
Type* input_type = Operand(node, 0);
Type* guard_type = TypeOf(node->op());
return Type::Intersect(input_type, guard_type, zone());
}
Type* Typer::Visitor::TypeCheckpoint(Node* node) {
UNREACHABLE();
return nullptr;

View File

@ -417,9 +417,6 @@ void Verifier::Visitor::Check(Node* node) {
CHECK_EQ(input_count, 1 + effect_count);
break;
}
case IrOpcode::kTypeGuard:
// TODO(bmeurer): what are the constraints on these?
break;
case IrOpcode::kCheckpoint:
// Type is empty.
CheckNotTyped(node);

View File

@ -50,42 +50,6 @@ class JSIntrinsicLoweringTest : public GraphTest {
};
// -----------------------------------------------------------------------------
// %_DoubleLo
TEST_F(JSIntrinsicLoweringTest, InlineOptimizedDoubleLo) {
Node* const input = Parameter(0);
Node* const context = Parameter(1);
Node* const effect = graph()->start();
Node* const control = graph()->start();
Reduction const r = Reduce(
graph()->NewNode(javascript()->CallRuntime(Runtime::kInlineDoubleLo, 1),
input, context, effect, control));
ASSERT_TRUE(r.Changed());
EXPECT_THAT(r.replacement(),
IsFloat64ExtractLowWord32(IsTypeGuard(Type::Number(), input, _)));
}
// -----------------------------------------------------------------------------
// %_DoubleHi
TEST_F(JSIntrinsicLoweringTest, InlineOptimizedDoubleHi) {
Node* const input = Parameter(0);
Node* const context = Parameter(1);
Node* const effect = graph()->start();
Node* const control = graph()->start();
Reduction const r = Reduce(
graph()->NewNode(javascript()->CallRuntime(Runtime::kInlineDoubleHi, 1),
input, context, effect, control));
ASSERT_TRUE(r.Changed());
EXPECT_THAT(r.replacement(), IsFloat64ExtractHighWord32(
IsTypeGuard(Type::Number(), input, _)));
}
// -----------------------------------------------------------------------------
// %_IsSmi

View File

@ -1343,32 +1343,6 @@ class IsStackSlotMatcher final : public NodeMatcher {
const Matcher<MachineRepresentation> rep_matcher_;
};
class IsTypeGuardMatcher final : public NodeMatcher {
public:
IsTypeGuardMatcher(const Matcher<Type*>& type_matcher,
const Matcher<Node*>& value_matcher,
const Matcher<Node*>& control_matcher)
: NodeMatcher(IrOpcode::kTypeGuard),
type_matcher_(type_matcher),
value_matcher_(value_matcher),
control_matcher_(control_matcher) {}
bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
return (NodeMatcher::MatchAndExplain(node, listener) &&
PrintMatchAndExplain(OpParameter<Type*>(node->op()), "type",
type_matcher_, listener) &&
PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0),
"value", value_matcher_, listener) &&
PrintMatchAndExplain(NodeProperties::GetControlInput(node, 0),
"control", control_matcher_, listener));
}
private:
const Matcher<Type*> type_matcher_;
const Matcher<Node*> value_matcher_;
const Matcher<Node*> control_matcher_;
};
class IsToNumberMatcher final : public NodeMatcher {
public:
IsToNumberMatcher(const Matcher<Node*>& base_matcher,
@ -2049,13 +2023,6 @@ Matcher<Node*> IsTailCall(
effect_matcher, control_matcher));
}
Matcher<Node*> IsTypeGuard(const Matcher<Type*>& type_matcher,
const Matcher<Node*>& value_matcher,
const Matcher<Node*>& control_matcher) {
return MakeMatcher(
new IsTypeGuardMatcher(type_matcher, value_matcher, control_matcher));
}
Matcher<Node*> IsReferenceEqual(const Matcher<Type*>& type_matcher,
const Matcher<Node*>& lhs_matcher,
const Matcher<Node*>& rhs_matcher) {

View File

@ -426,9 +426,6 @@ Matcher<Node*> IsWord32PairSar(const Matcher<Node*>& lhs_matcher,
const Matcher<Node*>& rhs_matcher);
Matcher<Node*> IsStackSlot();
Matcher<Node*> IsTypeGuard(const Matcher<Type*>& type_matcher,
const Matcher<Node*>& value_matcher,
const Matcher<Node*>& control_matcher);
} // namespace compiler
} // namespace internal