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 909 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
920 node->set_op( | 920 node->set_op( |
921 simplified()->StoreField(AccessBuilder::ForContextSlot(access.index()))); | 921 simplified()->StoreField(AccessBuilder::ForContextSlot(access.index()))); |
922 node->RemoveInput(2); | 922 node->RemoveInput(2); |
923 DCHECK_EQ(4, node->InputCount()); | 923 DCHECK_EQ(4, node->InputCount()); |
924 return Changed(node); | 924 return Changed(node); |
925 } | 925 } |
926 | 926 |
927 | 927 |
928 Reduction JSTypedLowering::Reduce(Node* node) { | 928 Reduction JSTypedLowering::Reduce(Node* node) { |
929 // Check if the output type is a singleton. In that case we already know the | 929 // Check if the output type is a singleton. In that case we already know the |
930 // result value and can simply replace the node unless there are effects. | 930 // result value and can simply replace the node if it's eliminatable. |
Jarin
2015/01/05 09:41:21
eliminatable -> eliminable?
Benedikt Meurer
2015/01/05 12:37:12
Done.
| |
931 if (NodeProperties::IsTyped(node) && | 931 if (NodeProperties::IsTyped(node) && |
932 NodeProperties::GetBounds(node).upper->IsConstant() && | |
933 !IrOpcode::IsLeafOpcode(node->opcode()) && | 932 !IrOpcode::IsLeafOpcode(node->opcode()) && |
934 node->op()->EffectOutputCount() == 0) { | 933 node->op()->HasProperty(Operator::kEliminatable)) { |
935 return ReplaceEagerly(node, jsgraph()->Constant( | 934 Type* upper = NodeProperties::GetBounds(node).upper; |
936 NodeProperties::GetBounds(node).upper->AsConstant()->Value())); | 935 if (upper->IsConstant()) { |
937 // TODO(neis): Extend this to Range(x,x), NaN, MinusZero, ...? | 936 Node* replacement = jsgraph()->Constant(upper->AsConstant()->Value()); |
937 NodeProperties::ReplaceWithValue(node, replacement); | |
938 return Changed(replacement); | |
939 } else if (upper->Is(Type::Number()) && | |
940 base::bit_equal_to<double>()(upper->Min(), upper->Max())) { | |
941 Node* replacement = jsgraph()->Constant(upper->Min()); | |
942 NodeProperties::ReplaceWithValue(node, replacement); | |
943 return Changed(replacement); | |
944 } | |
938 } | 945 } |
939 switch (node->opcode()) { | 946 switch (node->opcode()) { |
940 case IrOpcode::kJSEqual: | 947 case IrOpcode::kJSEqual: |
941 return ReduceJSEqual(node, false); | 948 return ReduceJSEqual(node, false); |
942 case IrOpcode::kJSNotEqual: | 949 case IrOpcode::kJSNotEqual: |
943 return ReduceJSEqual(node, true); | 950 return ReduceJSEqual(node, true); |
944 case IrOpcode::kJSStrictEqual: | 951 case IrOpcode::kJSStrictEqual: |
945 return ReduceJSStrictEqual(node, false); | 952 return ReduceJSStrictEqual(node, false); |
946 case IrOpcode::kJSStrictNotEqual: | 953 case IrOpcode::kJSStrictNotEqual: |
947 return ReduceJSStrictEqual(node, true); | 954 return ReduceJSStrictEqual(node, true); |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1076 } | 1083 } |
1077 | 1084 |
1078 | 1085 |
1079 MachineOperatorBuilder* JSTypedLowering::machine() const { | 1086 MachineOperatorBuilder* JSTypedLowering::machine() const { |
1080 return jsgraph()->machine(); | 1087 return jsgraph()->machine(); |
1081 } | 1088 } |
1082 | 1089 |
1083 } // namespace compiler | 1090 } // namespace compiler |
1084 } // namespace internal | 1091 } // namespace internal |
1085 } // namespace v8 | 1092 } // namespace v8 |
OLD | NEW |