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/v8.h" | 5 #include "src/v8.h" |
6 #include "test/cctest/cctest.h" | 6 #include "test/cctest/cctest.h" |
7 | 7 |
8 #include "src/compiler/graph-inl.h" | 8 #include "src/compiler/graph-inl.h" |
9 #include "src/compiler/js-typed-lowering.h" | 9 #include "src/compiler/js-typed-lowering.h" |
10 #include "src/compiler/node-properties-inl.h" | 10 #include "src/compiler/node-properties-inl.h" |
11 #include "src/compiler/opcodes.h" | 11 #include "src/compiler/opcodes.h" |
12 #include "src/compiler/typer.h" | 12 #include "src/compiler/typer.h" |
13 | 13 |
14 using namespace v8::internal; | 14 using namespace v8::internal; |
15 using namespace v8::internal::compiler; | 15 using namespace v8::internal::compiler; |
16 | 16 |
17 class JSTypedLoweringTester : public HandleAndZoneScope { | 17 class JSTypedLoweringTester : public HandleAndZoneScope { |
18 public: | 18 public: |
19 explicit JSTypedLoweringTester(int num_parameters = 0) | 19 explicit JSTypedLoweringTester(int num_parameters = 0) |
20 : isolate(main_isolate()), | 20 : isolate(main_isolate()), |
21 binop(NULL), | 21 binop(NULL), |
22 unop(NULL), | 22 unop(NULL), |
23 javascript(main_zone()), | 23 javascript(main_zone()), |
24 machine(main_zone()), | 24 machine(main_zone()), |
25 simplified(main_zone()), | 25 simplified(main_zone()), |
26 common(main_zone()), | 26 common(main_zone()), |
27 graph(main_zone()), | 27 graph(main_zone()), |
28 typer(main_zone()), | 28 typer(main_zone()), |
29 source_positions(&graph), | |
30 context_node(NULL) { | 29 context_node(NULL) { |
31 typer.DecorateGraph(&graph); | 30 typer.DecorateGraph(&graph); |
32 Node* s = graph.NewNode(common.Start(num_parameters)); | 31 Node* s = graph.NewNode(common.Start(num_parameters)); |
33 graph.SetStart(s); | 32 graph.SetStart(s); |
34 } | 33 } |
35 | 34 |
36 Isolate* isolate; | 35 Isolate* isolate; |
37 Operator* binop; | 36 Operator* binop; |
38 Operator* unop; | 37 Operator* unop; |
39 JSOperatorBuilder javascript; | 38 JSOperatorBuilder javascript; |
40 MachineOperatorBuilder machine; | 39 MachineOperatorBuilder machine; |
41 SimplifiedOperatorBuilder simplified; | 40 SimplifiedOperatorBuilder simplified; |
42 CommonOperatorBuilder common; | 41 CommonOperatorBuilder common; |
43 Graph graph; | 42 Graph graph; |
44 Typer typer; | 43 Typer typer; |
45 SourcePositionTable source_positions; | |
46 Node* context_node; | 44 Node* context_node; |
47 | 45 |
48 Node* Parameter(Type* t, int32_t index = 0) { | 46 Node* Parameter(Type* t, int32_t index = 0) { |
49 Node* n = graph.NewNode(common.Parameter(index), graph.start()); | 47 Node* n = graph.NewNode(common.Parameter(index), graph.start()); |
50 NodeProperties::SetBounds(n, Bounds(Type::None(), t)); | 48 NodeProperties::SetBounds(n, Bounds(Type::None(), t)); |
51 return n; | 49 return n; |
52 } | 50 } |
53 | 51 |
54 Node* reduce(Node* node) { | 52 Node* reduce(Node* node) { |
55 JSGraph jsgraph(&graph, &common, &typer); | 53 JSGraph jsgraph(&graph, &common, &typer); |
56 JSTypedLowering reducer(&jsgraph, &source_positions); | 54 JSTypedLowering reducer(&jsgraph); |
57 Reduction reduction = reducer.Reduce(node); | 55 Reduction reduction = reducer.Reduce(node); |
58 if (reduction.Changed()) return reduction.replacement(); | 56 if (reduction.Changed()) return reduction.replacement(); |
59 return node; | 57 return node; |
60 } | 58 } |
61 | 59 |
62 Node* start() { return graph.start(); } | 60 Node* start() { return graph.start(); } |
63 | 61 |
64 Node* context() { | 62 Node* context() { |
65 if (context_node == NULL) { | 63 if (context_node == NULL) { |
66 context_node = graph.NewNode(common.Parameter(-1), graph.start()); | 64 context_node = graph.NewNode(common.Parameter(-1), graph.start()); |
(...skipping 1266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1333 CHECK_EQ(p1, r->InputAt(0)); | 1331 CHECK_EQ(p1, r->InputAt(0)); |
1334 CHECK_EQ(p0, r->InputAt(1)); | 1332 CHECK_EQ(p0, r->InputAt(1)); |
1335 } else { | 1333 } else { |
1336 CHECK_EQ(p0, r->InputAt(0)); | 1334 CHECK_EQ(p0, r->InputAt(0)); |
1337 CHECK_EQ(p1, r->InputAt(1)); | 1335 CHECK_EQ(p1, r->InputAt(1)); |
1338 } | 1336 } |
1339 } | 1337 } |
1340 } | 1338 } |
1341 } | 1339 } |
1342 } | 1340 } |
OLD | NEW |