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 // TODO(jochen): Remove this after the setting is turned on globally. | 5 // TODO(jochen): Remove this after the setting is turned on globally. |
6 #define V8_IMMINENT_DEPRECATION_WARNINGS | 6 #define V8_IMMINENT_DEPRECATION_WARNINGS |
7 | 7 |
8 #include "src/compiler/js-graph.h" | 8 #include "src/compiler/js-graph.h" |
9 #include "src/compiler/js-typed-lowering.h" | 9 #include "src/compiler/js-typed-lowering.h" |
10 #include "src/compiler/machine-operator.h" | 10 #include "src/compiler/machine-operator.h" |
11 #include "src/compiler/node-properties.h" | 11 #include "src/compiler/node-properties.h" |
12 #include "src/compiler/opcodes.h" | 12 #include "src/compiler/opcodes.h" |
13 #include "src/compiler/operator-properties.h" | 13 #include "src/compiler/operator-properties.h" |
14 #include "src/compiler/simplified-operator.h" | 14 #include "src/compiler/simplified-operator.h" |
15 #include "src/compiler/typer.h" | 15 #include "src/compiler/typer.h" |
16 #include "test/cctest/cctest.h" | 16 #include "test/cctest/cctest.h" |
17 #include "test/cctest/compiler/function-tester.h" | |
Michael Starzinger
2015/11/10 09:48:48
nit: Include no longer needed.
sigurds
2015/11/10 10:01:24
Done.
| |
17 | 18 |
18 namespace v8 { | 19 namespace v8 { |
19 namespace internal { | 20 namespace internal { |
20 namespace compiler { | 21 namespace compiler { |
21 | 22 |
22 #ifndef TEST_WITH_STRONG | 23 #ifndef TEST_WITH_STRONG |
23 #define TEST_WITH_STRONG(Name) \ | 24 #define TEST_WITH_STRONG(Name) \ |
24 static void Test##Name(); \ | 25 static void Test##Name(); \ |
25 static void TestWithStrong##Name(LanguageMode language_mode); \ | 26 static void TestWithStrong##Name(LanguageMode language_mode); \ |
26 CcTest register_test_##Name(Test##Name, __FILE__, #Name, NULL, true, true); \ | 27 CcTest register_test_##Name(Test##Name, __FILE__, #Name, NULL, true, true); \ |
27 static void Test##Name() { \ | 28 static void Test##Name() { \ |
28 TestWithStrong##Name(LanguageMode::SLOPPY); \ | 29 TestWithStrong##Name(LanguageMode::SLOPPY); \ |
29 TestWithStrong##Name(LanguageMode::STRONG); \ | 30 TestWithStrong##Name(LanguageMode::STRONG); \ |
30 } \ | 31 } \ |
31 static void TestWithStrong##Name(LanguageMode language_mode) | 32 static void TestWithStrong##Name(LanguageMode language_mode) |
32 #endif | 33 #endif |
33 | 34 |
34 | 35 |
35 class JSTypedLoweringTester : public HandleAndZoneScope { | 36 class JSTypedLoweringTester : public HandleAndZoneScope { |
36 public: | 37 public: |
37 explicit JSTypedLoweringTester(int num_parameters = 0) | 38 explicit JSTypedLoweringTester(int num_parameters = 0) |
38 : isolate(main_isolate()), | 39 : isolate(main_isolate()), |
39 binop(NULL), | 40 binop(NULL), |
40 unop(NULL), | 41 unop(NULL), |
41 javascript(main_zone()), | 42 javascript(main_zone()), |
42 machine(main_zone()), | 43 machine(main_zone()), |
43 simplified(main_zone()), | 44 simplified(main_zone()), |
44 common(main_zone()), | 45 common(main_zone()), |
46 deps(main_isolate(), main_zone()), | |
45 graph(main_zone()), | 47 graph(main_zone()), |
46 typer(main_isolate(), &graph), | 48 typer(main_isolate(), &graph), |
47 context_node(NULL) { | 49 context_node(NULL) { |
48 graph.SetStart(graph.NewNode(common.Start(num_parameters))); | 50 graph.SetStart(graph.NewNode(common.Start(num_parameters))); |
49 graph.SetEnd(graph.NewNode(common.End(1), graph.start())); | 51 graph.SetEnd(graph.NewNode(common.End(1), graph.start())); |
50 typer.Run(); | 52 typer.Run(); |
51 } | 53 } |
52 | 54 |
53 Isolate* isolate; | 55 Isolate* isolate; |
54 const Operator* binop; | 56 const Operator* binop; |
55 const Operator* unop; | 57 const Operator* unop; |
56 JSOperatorBuilder javascript; | 58 JSOperatorBuilder javascript; |
57 MachineOperatorBuilder machine; | 59 MachineOperatorBuilder machine; |
58 SimplifiedOperatorBuilder simplified; | 60 SimplifiedOperatorBuilder simplified; |
59 CommonOperatorBuilder common; | 61 CommonOperatorBuilder common; |
62 CompilationDependencies deps; | |
60 Graph graph; | 63 Graph graph; |
61 Typer typer; | 64 Typer typer; |
62 Node* context_node; | 65 Node* context_node; |
63 | 66 |
64 Node* Parameter(Type* t, int32_t index = 0) { | 67 Node* Parameter(Type* t, int32_t index = 0) { |
65 Node* n = graph.NewNode(common.Parameter(index), graph.start()); | 68 Node* n = graph.NewNode(common.Parameter(index), graph.start()); |
66 NodeProperties::SetType(n, t); | 69 NodeProperties::SetType(n, t); |
67 return n; | 70 return n; |
68 } | 71 } |
69 | 72 |
(...skipping 17 matching lines...) Expand all Loading... | |
87 parameters, locals, stack, context, UndefinedConstant(), graph.start()); | 90 parameters, locals, stack, context, UndefinedConstant(), graph.start()); |
88 | 91 |
89 return state_node; | 92 return state_node; |
90 } | 93 } |
91 | 94 |
92 Node* reduce(Node* node) { | 95 Node* reduce(Node* node) { |
93 JSGraph jsgraph(main_isolate(), &graph, &common, &javascript, &simplified, | 96 JSGraph jsgraph(main_isolate(), &graph, &common, &javascript, &simplified, |
94 &machine); | 97 &machine); |
95 // TODO(titzer): mock the GraphReducer here for better unit testing. | 98 // TODO(titzer): mock the GraphReducer here for better unit testing. |
96 GraphReducer graph_reducer(main_zone(), &graph); | 99 GraphReducer graph_reducer(main_zone(), &graph); |
97 JSTypedLowering reducer(&graph_reducer, &jsgraph, main_zone()); | 100 JSTypedLowering reducer(&graph_reducer, &deps, |
101 JSTypedLowering::kDeoptimizationEnabled, &jsgraph, | |
102 main_zone()); | |
98 Reduction reduction = reducer.Reduce(node); | 103 Reduction reduction = reducer.Reduce(node); |
99 if (reduction.Changed()) return reduction.replacement(); | 104 if (reduction.Changed()) return reduction.replacement(); |
100 return node; | 105 return node; |
101 } | 106 } |
102 | 107 |
103 Node* start() { return graph.start(); } | 108 Node* start() { return graph.start(); } |
104 | 109 |
105 Node* context() { | 110 Node* context() { |
106 if (context_node == NULL) { | 111 if (context_node == NULL) { |
107 context_node = graph.NewNode(common.Parameter(-1), graph.start()); | 112 context_node = graph.NewNode(common.Parameter(-1), graph.start()); |
(...skipping 14 matching lines...) Expand all Loading... | |
122 Node* ReduceUnop(const Operator* op, Type* input_type) { | 127 Node* ReduceUnop(const Operator* op, Type* input_type) { |
123 return reduce(Unop(op, Parameter(input_type))); | 128 return reduce(Unop(op, Parameter(input_type))); |
124 } | 129 } |
125 | 130 |
126 Node* ReduceBinop(const Operator* op, Type* left_type, Type* right_type) { | 131 Node* ReduceBinop(const Operator* op, Type* left_type, Type* right_type) { |
127 return reduce(Binop(op, Parameter(left_type, 0), Parameter(right_type, 1))); | 132 return reduce(Binop(op, Parameter(left_type, 0), Parameter(right_type, 1))); |
128 } | 133 } |
129 | 134 |
130 Node* Binop(const Operator* op, Node* left, Node* right) { | 135 Node* Binop(const Operator* op, Node* left, Node* right) { |
131 // JS binops also require context, effect, and control | 136 // JS binops also require context, effect, and control |
137 DCHECK_EQ(op->ValueInputCount(), 2); | |
Michael Starzinger
2015/11/10 09:48:48
nit: Change no longer needed, let's drop it.
sigurds
2015/11/10 10:01:24
Done.
| |
132 std::vector<Node*> inputs; | 138 std::vector<Node*> inputs; |
133 inputs.push_back(left); | 139 inputs.push_back(left); |
134 inputs.push_back(right); | 140 inputs.push_back(right); |
135 if (OperatorProperties::HasContextInput(op)) { | 141 if (OperatorProperties::HasContextInput(op)) { |
136 inputs.push_back(context()); | 142 inputs.push_back(context()); |
137 } | 143 } |
138 for (int i = 0; i < OperatorProperties::GetFrameStateInputCount(op); i++) { | 144 for (int i = 0; i < OperatorProperties::GetFrameStateInputCount(op); i++) { |
139 inputs.push_back(EmptyFrameState(context())); | 145 inputs.push_back(EmptyFrameState(context())); |
140 } | 146 } |
141 if (op->EffectInputCount() > 0) { | 147 if (op->EffectInputCount() > 0) { |
(...skipping 1118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1260 CHECK_EQ(p1, r->InputAt(1)); | 1266 CHECK_EQ(p1, r->InputAt(1)); |
1261 } | 1267 } |
1262 } | 1268 } |
1263 } | 1269 } |
1264 } | 1270 } |
1265 } | 1271 } |
1266 | 1272 |
1267 } // namespace compiler | 1273 } // namespace compiler |
1268 } // namespace internal | 1274 } // namespace internal |
1269 } // namespace v8 | 1275 } // namespace v8 |
OLD | NEW |