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-graph.h" | 7 #include "src/compiler/js-graph.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-matchers.h" | 10 #include "src/compiler/node-matchers.h" |
(...skipping 819 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
830 node->set_op( | 830 node->set_op( |
831 simplified()->StoreField(AccessBuilder::ForContextSlot(access.index()))); | 831 simplified()->StoreField(AccessBuilder::ForContextSlot(access.index()))); |
832 node->RemoveInput(2); | 832 node->RemoveInput(2); |
833 DCHECK_EQ(4, node->InputCount()); | 833 DCHECK_EQ(4, node->InputCount()); |
834 return Changed(node); | 834 return Changed(node); |
835 } | 835 } |
836 | 836 |
837 | 837 |
838 Reduction JSTypedLowering::Reduce(Node* node) { | 838 Reduction JSTypedLowering::Reduce(Node* node) { |
839 // Check if the output type is a singleton. In that case we already know the | 839 // Check if the output type is a singleton. In that case we already know the |
840 // result value and can simply replace the node unless there are effects. | 840 // result value and can simply replace the node if it's eliminable. |
841 if (NodeProperties::IsTyped(node) && | 841 if (NodeProperties::IsTyped(node) && |
842 NodeProperties::GetBounds(node).upper->IsConstant() && | |
843 !IrOpcode::IsLeafOpcode(node->opcode()) && | 842 !IrOpcode::IsLeafOpcode(node->opcode()) && |
844 node->op()->EffectOutputCount() == 0) { | 843 node->op()->HasProperty(Operator::kEliminatable)) { |
845 return ReplaceEagerly(node, jsgraph()->Constant( | 844 Type* upper = NodeProperties::GetBounds(node).upper; |
846 NodeProperties::GetBounds(node).upper->AsConstant()->Value())); | 845 if (upper->IsConstant()) { |
847 // TODO(neis): Extend this to Range(x,x), NaN, MinusZero, ...? | 846 Node* replacement = jsgraph()->Constant(upper->AsConstant()->Value()); |
| 847 NodeProperties::ReplaceWithValue(node, replacement); |
| 848 return Changed(replacement); |
| 849 } else if (upper->Is(Type::MinusZero())) { |
| 850 Node* replacement = jsgraph()->Constant(factory()->minus_zero_value()); |
| 851 NodeProperties::ReplaceWithValue(node, replacement); |
| 852 return Changed(replacement); |
| 853 } else if (upper->Is(Type::NaN())) { |
| 854 Node* replacement = jsgraph()->NaNConstant(); |
| 855 NodeProperties::ReplaceWithValue(node, replacement); |
| 856 return Changed(replacement); |
| 857 } else if (upper->Is(Type::Null())) { |
| 858 Node* replacement = jsgraph()->NullConstant(); |
| 859 NodeProperties::ReplaceWithValue(node, replacement); |
| 860 return Changed(replacement); |
| 861 } else if (upper->Is(Type::PlainNumber()) && upper->Min() == upper->Max()) { |
| 862 Node* replacement = jsgraph()->Constant(upper->Min()); |
| 863 NodeProperties::ReplaceWithValue(node, replacement); |
| 864 return Changed(replacement); |
| 865 } else if (upper->Is(Type::Undefined())) { |
| 866 Node* replacement = jsgraph()->UndefinedConstant(); |
| 867 NodeProperties::ReplaceWithValue(node, replacement); |
| 868 return Changed(replacement); |
| 869 } |
848 } | 870 } |
849 switch (node->opcode()) { | 871 switch (node->opcode()) { |
850 case IrOpcode::kJSEqual: | 872 case IrOpcode::kJSEqual: |
851 return ReduceJSEqual(node, false); | 873 return ReduceJSEqual(node, false); |
852 case IrOpcode::kJSNotEqual: | 874 case IrOpcode::kJSNotEqual: |
853 return ReduceJSEqual(node, true); | 875 return ReduceJSEqual(node, true); |
854 case IrOpcode::kJSStrictEqual: | 876 case IrOpcode::kJSStrictEqual: |
855 return ReduceJSStrictEqual(node, false); | 877 return ReduceJSStrictEqual(node, false); |
856 case IrOpcode::kJSStrictNotEqual: | 878 case IrOpcode::kJSStrictNotEqual: |
857 return ReduceJSStrictEqual(node, true); | 879 return ReduceJSStrictEqual(node, true); |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
964 } | 986 } |
965 | 987 |
966 | 988 |
967 MachineOperatorBuilder* JSTypedLowering::machine() const { | 989 MachineOperatorBuilder* JSTypedLowering::machine() const { |
968 return jsgraph()->machine(); | 990 return jsgraph()->machine(); |
969 } | 991 } |
970 | 992 |
971 } // namespace compiler | 993 } // namespace compiler |
972 } // namespace internal | 994 } // namespace internal |
973 } // namespace v8 | 995 } // namespace v8 |
OLD | NEW |