OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/compiler/access-builder.h" | 5 #include "src/compiler/access-builder.h" |
6 #include "src/compiler/graph-inl.h" | 6 #include "src/compiler/graph-inl.h" |
7 #include "src/compiler/js-builtin-reducer.h" | 7 #include "src/compiler/js-builtin-reducer.h" |
8 #include "src/compiler/js-typed-lowering.h" | 8 #include "src/compiler/js-typed-lowering.h" |
9 #include "src/compiler/node-aux-data-inl.h" | 9 #include "src/compiler/node-aux-data-inl.h" |
10 #include "src/compiler/node-properties-inl.h" | 10 #include "src/compiler/node-properties-inl.h" |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 Node* l = left(); | 77 Node* l = left(); |
78 Node* r = right(); | 78 Node* r = right(); |
79 node_->ReplaceInput(0, r); | 79 node_->ReplaceInput(0, r); |
80 node_->ReplaceInput(1, l); | 80 node_->ReplaceInput(1, l); |
81 std::swap(left_type_, right_type_); | 81 std::swap(left_type_, right_type_); |
82 } | 82 } |
83 | 83 |
84 // Remove all effect and control inputs and outputs to this node and change | 84 // Remove all effect and control inputs and outputs to this node and change |
85 // to the pure operator {op}, possibly inserting a boolean inversion. | 85 // to the pure operator {op}, possibly inserting a boolean inversion. |
86 Reduction ChangeToPureOperator(const Operator* op, bool invert = false) { | 86 Reduction ChangeToPureOperator(const Operator* op, bool invert = false) { |
87 DCHECK_EQ(0, OperatorProperties::GetEffectInputCount(op)); | 87 DCHECK_EQ(0, op->EffectInputCount()); |
88 DCHECK_EQ(false, OperatorProperties::HasContextInput(op)); | 88 DCHECK_EQ(false, OperatorProperties::HasContextInput(op)); |
89 DCHECK_EQ(0, OperatorProperties::GetControlInputCount(op)); | 89 DCHECK_EQ(0, op->ControlInputCount()); |
90 DCHECK_EQ(2, OperatorProperties::GetValueInputCount(op)); | 90 DCHECK_EQ(2, op->ValueInputCount()); |
91 | 91 |
92 // Remove the effects from the node, if any, and update its effect usages. | 92 // Remove the effects from the node, if any, and update its effect usages. |
93 if (OperatorProperties::GetEffectInputCount(node_->op()) > 0) { | 93 if (node_->op()->EffectInputCount() > 0) { |
94 RelaxEffects(node_); | 94 RelaxEffects(node_); |
95 } | 95 } |
96 // Remove the inputs corresponding to context, effect, and control. | 96 // Remove the inputs corresponding to context, effect, and control. |
97 NodeProperties::RemoveNonValueInputs(node_); | 97 NodeProperties::RemoveNonValueInputs(node_); |
98 // Finally, update the operator to the new one. | 98 // Finally, update the operator to the new one. |
99 node_->set_op(op); | 99 node_->set_op(op); |
100 | 100 |
101 if (invert) { | 101 if (invert) { |
102 // Insert an boolean not to invert the value. | 102 // Insert an boolean not to invert the value. |
103 Node* value = graph()->NewNode(simplified()->BooleanNot(), node_); | 103 Node* value = graph()->NewNode(simplified()->BooleanNot(), node_); |
(...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
670 return Reducer::NoChange(); | 670 return Reducer::NoChange(); |
671 } | 671 } |
672 | 672 |
673 | 673 |
674 Reduction JSTypedLowering::Reduce(Node* node) { | 674 Reduction JSTypedLowering::Reduce(Node* node) { |
675 // Check if the output type is a singleton. In that case we already know the | 675 // Check if the output type is a singleton. In that case we already know the |
676 // result value and can simply replace the node unless there are effects. | 676 // result value and can simply replace the node unless there are effects. |
677 if (NodeProperties::IsTyped(node) && | 677 if (NodeProperties::IsTyped(node) && |
678 NodeProperties::GetBounds(node).upper->IsConstant() && | 678 NodeProperties::GetBounds(node).upper->IsConstant() && |
679 !IrOpcode::IsLeafOpcode(node->opcode()) && | 679 !IrOpcode::IsLeafOpcode(node->opcode()) && |
680 !OperatorProperties::HasEffectOutput(node->op())) { | 680 node->op()->EffectOutputCount() == 0) { |
681 return ReplaceEagerly(node, jsgraph()->Constant( | 681 return ReplaceEagerly(node, jsgraph()->Constant( |
682 NodeProperties::GetBounds(node).upper->AsConstant()->Value())); | 682 NodeProperties::GetBounds(node).upper->AsConstant()->Value())); |
683 // TODO(neis): Extend this to Range(x,x), NaN, MinusZero, ...? | 683 // TODO(neis): Extend this to Range(x,x), NaN, MinusZero, ...? |
684 } | 684 } |
685 switch (node->opcode()) { | 685 switch (node->opcode()) { |
686 case IrOpcode::kJSEqual: | 686 case IrOpcode::kJSEqual: |
687 return ReduceJSEqual(node, false); | 687 return ReduceJSEqual(node, false); |
688 case IrOpcode::kJSNotEqual: | 688 case IrOpcode::kJSNotEqual: |
689 return ReduceJSEqual(node, true); | 689 return ReduceJSEqual(node, true); |
690 case IrOpcode::kJSStrictEqual: | 690 case IrOpcode::kJSStrictEqual: |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
754 return JSBuiltinReducer(jsgraph()).Reduce(node); | 754 return JSBuiltinReducer(jsgraph()).Reduce(node); |
755 default: | 755 default: |
756 break; | 756 break; |
757 } | 757 } |
758 return NoChange(); | 758 return NoChange(); |
759 } | 759 } |
760 | 760 |
761 } // namespace compiler | 761 } // namespace compiler |
762 } // namespace internal | 762 } // namespace internal |
763 } // namespace v8 | 763 } // namespace v8 |
OLD | NEW |