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/graph-inl.h" | 5 #include "src/compiler/graph-inl.h" |
6 #include "src/compiler/js-graph.h" | 6 #include "src/compiler/js-graph.h" |
7 #include "src/compiler/js-typed-lowering.h" | 7 #include "src/compiler/js-typed-lowering.h" |
8 #include "src/compiler/machine-operator.h" | 8 #include "src/compiler/machine-operator.h" |
9 #include "src/compiler/node-properties-inl.h" | 9 #include "src/compiler/node-properties-inl.h" |
10 #include "src/compiler/opcodes.h" | 10 #include "src/compiler/opcodes.h" |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 Node* state_node = | 69 Node* state_node = |
70 graph.NewNode(common.FrameState(JS_FRAME, BailoutId(0), | 70 graph.NewNode(common.FrameState(JS_FRAME, BailoutId(0), |
71 OutputFrameStateCombine::Ignore()), | 71 OutputFrameStateCombine::Ignore()), |
72 parameters, locals, stack, context, UndefinedConstant()); | 72 parameters, locals, stack, context, UndefinedConstant()); |
73 | 73 |
74 return state_node; | 74 return state_node; |
75 } | 75 } |
76 | 76 |
77 Node* reduce(Node* node) { | 77 Node* reduce(Node* node) { |
78 JSGraph jsgraph(&graph, &common, &javascript, &machine); | 78 JSGraph jsgraph(&graph, &common, &javascript, &machine); |
79 JSTypedLowering reducer(&jsgraph); | 79 JSTypedLowering reducer(&jsgraph, main_zone()); |
80 Reduction reduction = reducer.Reduce(node); | 80 Reduction reduction = reducer.Reduce(node); |
81 if (reduction.Changed()) return reduction.replacement(); | 81 if (reduction.Changed()) return reduction.replacement(); |
82 return node; | 82 return node; |
83 } | 83 } |
84 | 84 |
85 Node* start() { return graph.start(); } | 85 Node* start() { return graph.start(); } |
86 | 86 |
87 Node* context() { | 87 Node* context() { |
88 if (context_node == NULL) { | 88 if (context_node == NULL) { |
89 context_node = graph.NewNode(common.Parameter(-1), graph.start()); | 89 context_node = graph.NewNode(common.Parameter(-1), graph.start()); |
(...skipping 893 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
983 JSTypedLoweringTester R; | 983 JSTypedLoweringTester R; |
984 | 984 |
985 const Operator* ops[] = { | 985 const Operator* ops[] = { |
986 R.javascript.Subtract(), R.simplified.NumberSubtract(), | 986 R.javascript.Subtract(), R.simplified.NumberSubtract(), |
987 R.javascript.Multiply(), R.simplified.NumberMultiply(), | 987 R.javascript.Multiply(), R.simplified.NumberMultiply(), |
988 R.javascript.Divide(), R.simplified.NumberDivide(), | 988 R.javascript.Divide(), R.simplified.NumberDivide(), |
989 R.javascript.Modulus(), R.simplified.NumberModulus(), | 989 R.javascript.Modulus(), R.simplified.NumberModulus(), |
990 }; | 990 }; |
991 | 991 |
992 for (size_t j = 0; j < arraysize(ops); j += 2) { | 992 for (size_t j = 0; j < arraysize(ops); j += 2) { |
993 BinopEffectsTester B(ops[j], Type::String(), Type::String()); | 993 BinopEffectsTester B(ops[j], Type::Symbol(), Type::Symbol()); |
994 CHECK_EQ(ops[j + 1]->opcode(), B.result->op()->opcode()); | 994 CHECK_EQ(ops[j + 1]->opcode(), B.result->op()->opcode()); |
995 | 995 |
996 Node* i0 = B.CheckConvertedInput(IrOpcode::kJSToNumber, 0, true); | 996 Node* i0 = B.CheckConvertedInput(IrOpcode::kJSToNumber, 0, true); |
997 Node* i1 = B.CheckConvertedInput(IrOpcode::kJSToNumber, 1, true); | 997 Node* i1 = B.CheckConvertedInput(IrOpcode::kJSToNumber, 1, true); |
998 | 998 |
999 CHECK_EQ(B.p0, i0->InputAt(0)); | 999 CHECK_EQ(B.p0, i0->InputAt(0)); |
1000 CHECK_EQ(B.p1, i1->InputAt(0)); | 1000 CHECK_EQ(B.p1, i1->InputAt(0)); |
1001 | 1001 |
1002 // Effects should be ordered start -> i0 -> i1 -> effect_use | 1002 // Effects should be ordered start -> i0 -> i1 -> effect_use |
1003 B.CheckEffectOrdering(i0, i1); | 1003 B.CheckEffectOrdering(i0, i1); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1056 BinopEffectsTester B(ops[j], Type::Symbol(), Type::String()); | 1056 BinopEffectsTester B(ops[j], Type::Symbol(), Type::String()); |
1057 CHECK_EQ(ops[j + 1]->opcode(), B.result->op()->opcode()); | 1057 CHECK_EQ(ops[j + 1]->opcode(), B.result->op()->opcode()); |
1058 | 1058 |
1059 Node* i0 = B.CheckConvertedInput(IrOpcode::kJSToNumber, 0, true); | 1059 Node* i0 = B.CheckConvertedInput(IrOpcode::kJSToNumber, 0, true); |
1060 Node* i1 = B.CheckConvertedInput(IrOpcode::kJSToNumber, 1, true); | 1060 Node* i1 = B.CheckConvertedInput(IrOpcode::kJSToNumber, 1, true); |
1061 | 1061 |
1062 // Inputs should be commuted. | 1062 // Inputs should be commuted. |
1063 CHECK_EQ(B.p1, i0->InputAt(0)); | 1063 CHECK_EQ(B.p1, i0->InputAt(0)); |
1064 CHECK_EQ(B.p0, i1->InputAt(0)); | 1064 CHECK_EQ(B.p0, i1->InputAt(0)); |
1065 | 1065 |
1066 // But effects should be ordered start -> i1 -> i0 -> effect_use | 1066 // But effects should be ordered start -> i1 -> effect_use |
1067 B.CheckEffectOrdering(i1, i0); | 1067 B.CheckEffectOrdering(i1); |
1068 } | 1068 } |
1069 | 1069 |
1070 for (size_t j = 0; j < arraysize(ops); j += 2) { | 1070 for (size_t j = 0; j < arraysize(ops); j += 2) { |
1071 BinopEffectsTester B(ops[j], Type::Number(), Type::Symbol()); | 1071 BinopEffectsTester B(ops[j], Type::Number(), Type::Symbol()); |
1072 | 1072 |
1073 Node* i0 = B.CheckConvertedInput(IrOpcode::kJSToNumber, 0, true); | 1073 Node* i0 = B.CheckConvertedInput(IrOpcode::kJSToNumber, 0, true); |
1074 Node* i1 = B.result->InputAt(1); | 1074 Node* i1 = B.result->InputAt(1); |
1075 | 1075 |
1076 CHECK_EQ(B.p1, i0->InputAt(0)); // Should be commuted. | 1076 CHECK_EQ(B.p1, i0->InputAt(0)); // Should be commuted. |
1077 CHECK_EQ(B.p0, i1); | 1077 CHECK_EQ(B.p0, i1); |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1298 CHECK_EQ(p1, r->InputAt(0)); | 1298 CHECK_EQ(p1, r->InputAt(0)); |
1299 CHECK_EQ(p0, r->InputAt(1)); | 1299 CHECK_EQ(p0, r->InputAt(1)); |
1300 } else { | 1300 } else { |
1301 CHECK_EQ(p0, r->InputAt(0)); | 1301 CHECK_EQ(p0, r->InputAt(0)); |
1302 CHECK_EQ(p1, r->InputAt(1)); | 1302 CHECK_EQ(p1, r->InputAt(1)); |
1303 } | 1303 } |
1304 } | 1304 } |
1305 } | 1305 } |
1306 } | 1306 } |
1307 } | 1307 } |
OLD | NEW |