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 <limits> | 5 #include <limits> |
6 | 6 |
7 #include "src/v8.h" | 7 #include "src/v8.h" |
8 #include "test/cctest/cctest.h" | 8 #include "test/cctest/cctest.h" |
9 #include "test/cctest/compiler/graph-builder-tester.h" | 9 #include "test/cctest/compiler/graph-builder-tester.h" |
10 | 10 |
11 #include "src/compiler/node-matchers.h" | 11 #include "src/compiler/node-matchers.h" |
12 #include "src/compiler/representation-change.h" | 12 #include "src/compiler/representation-change.h" |
13 #include "src/compiler/typer.h" | 13 #include "src/compiler/typer.h" |
14 | 14 |
15 using namespace v8::internal; | 15 using namespace v8::internal; |
16 using namespace v8::internal::compiler; | 16 using namespace v8::internal::compiler; |
17 | 17 |
18 namespace v8 { // for friendiness. | 18 namespace v8 { // for friendiness. |
19 namespace internal { | 19 namespace internal { |
20 namespace compiler { | 20 namespace compiler { |
21 | 21 |
22 class RepresentationChangerTester : public HandleAndZoneScope, | 22 class RepresentationChangerTester : public HandleAndZoneScope, |
23 public GraphAndBuilders { | 23 public GraphAndBuilders { |
24 public: | 24 public: |
25 RepresentationChangerTester() | 25 explicit RepresentationChangerTester(int num_parameters = 0) |
26 : GraphAndBuilders(main_zone()), | 26 : GraphAndBuilders(main_zone()), |
27 typer_(main_zone()), | 27 typer_(main_zone()), |
28 jsgraph_(main_graph_, &main_common_, &typer_), | 28 jsgraph_(main_graph_, &main_common_, &typer_), |
29 changer_(&jsgraph_, &main_simplified_, &main_machine_, main_isolate()) { | 29 changer_(&jsgraph_, &main_simplified_, &main_machine_, main_isolate()) { |
| 30 Node* s = graph()->NewNode(common()->Start(num_parameters)); |
| 31 graph()->SetStart(s); |
30 } | 32 } |
31 | 33 |
32 Typer typer_; | 34 Typer typer_; |
33 JSGraph jsgraph_; | 35 JSGraph jsgraph_; |
34 RepresentationChanger changer_; | 36 RepresentationChanger changer_; |
35 | 37 |
36 Isolate* isolate() { return main_isolate(); } | 38 Isolate* isolate() { return main_isolate(); } |
37 Graph* graph() { return main_graph_; } | 39 Graph* graph() { return main_graph_; } |
38 CommonOperatorBuilder* common() { return &main_common_; } | 40 CommonOperatorBuilder* common() { return &main_common_; } |
39 JSGraph* jsgraph() { return &jsgraph_; } | 41 JSGraph* jsgraph() { return &jsgraph_; } |
(...skipping 13 matching lines...) Expand all Loading... |
53 } | 55 } |
54 | 56 |
55 void CheckNumberConstant(Node* n, double expected) { | 57 void CheckNumberConstant(Node* n, double expected) { |
56 ValueMatcher<double> m(n); | 58 ValueMatcher<double> m(n); |
57 CHECK_EQ(IrOpcode::kNumberConstant, n->opcode()); | 59 CHECK_EQ(IrOpcode::kNumberConstant, n->opcode()); |
58 CHECK(m.HasValue()); | 60 CHECK(m.HasValue()); |
59 CHECK_EQ(expected, m.Value()); | 61 CHECK_EQ(expected, m.Value()); |
60 } | 62 } |
61 | 63 |
62 Node* Parameter(int index = 0) { | 64 Node* Parameter(int index = 0) { |
63 return graph()->NewNode(common()->Parameter(index)); | 65 return graph()->NewNode(common()->Parameter(index), graph()->start()); |
64 } | 66 } |
65 | 67 |
66 void CheckTypeError(RepTypeUnion from, RepTypeUnion to) { | 68 void CheckTypeError(RepTypeUnion from, RepTypeUnion to) { |
67 changer()->testing_type_errors_ = true; | 69 changer()->testing_type_errors_ = true; |
68 changer()->type_error_ = false; | 70 changer()->type_error_ = false; |
69 Node* n = Parameter(0); | 71 Node* n = Parameter(0); |
70 Node* c = changer()->GetRepresentationFor(n, from, to); | 72 Node* c = changer()->GetRepresentationFor(n, from, to); |
71 CHECK_EQ(n, c); | 73 CHECK_EQ(n, c); |
72 CHECK(changer()->type_error_); | 74 CHECK(changer()->type_error_); |
73 } | 75 } |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 // rW64 | 274 // rW64 |
273 // tIrW64 | 275 // tIrW64 |
274 // tUrW64 | 276 // tUrW64 |
275 // rF64 | 277 // rF64 |
276 // tIrF64 | 278 // tIrF64 |
277 // tUrF64 | 279 // tUrF64 |
278 // tArF64 | 280 // tArF64 |
279 // rT | 281 // rT |
280 // tArT | 282 // tArT |
281 } | 283 } |
OLD | NEW |