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/load-elimination.h" | 6 #include "src/compiler/load-elimination.h" |
7 #include "src/compiler/simplified-operator.h" | 7 #include "src/compiler/simplified-operator.h" |
8 #include "test/unittests/compiler/graph-unittest.h" | 8 #include "test/unittests/compiler/graph-unittest.h" |
9 #include "test/unittests/compiler/node-test-utils.h" | 9 #include "test/unittests/compiler/node-test-utils.h" |
10 | 10 |
11 namespace v8 { | 11 namespace v8 { |
12 namespace internal { | 12 namespace internal { |
13 namespace compiler { | 13 namespace compiler { |
14 | 14 |
15 class LoadEliminationTest : public GraphTest { | 15 class LoadEliminationTest : public GraphTest { |
16 public: | 16 public: |
17 LoadEliminationTest() : GraphTest(3), simplified_(zone()) {} | 17 LoadEliminationTest() : GraphTest(3), simplified_(zone()) {} |
18 ~LoadEliminationTest() override {} | 18 ~LoadEliminationTest() override {} |
19 | 19 |
20 protected: | 20 protected: |
21 Reduction Reduce(Node* node) { | 21 Reduction Reduce(Node* node) { |
22 LoadElimination reducer; | 22 // TODO(titzer): mock the GraphReducer here for better unit testing. |
| 23 GraphReducer graph_reducer(zone(), graph()); |
| 24 LoadElimination reducer(&graph_reducer); |
23 return reducer.Reduce(node); | 25 return reducer.Reduce(node); |
24 } | 26 } |
25 | 27 |
26 SimplifiedOperatorBuilder* simplified() { return &simplified_; } | 28 SimplifiedOperatorBuilder* simplified() { return &simplified_; } |
27 | 29 |
28 private: | 30 private: |
29 SimplifiedOperatorBuilder simplified_; | 31 SimplifiedOperatorBuilder simplified_; |
30 }; | 32 }; |
31 | 33 |
32 | 34 |
(...skipping 30 matching lines...) Expand all Loading... |
63 | 65 |
64 Reduction r4 = Reduce(graph()->NewNode(simplified()->LoadField(access1), | 66 Reduction r4 = Reduce(graph()->NewNode(simplified()->LoadField(access1), |
65 object1, store3, control)); | 67 object1, store3, control)); |
66 ASSERT_TRUE(r4.Changed()); | 68 ASSERT_TRUE(r4.Changed()); |
67 EXPECT_EQ(value, r4.replacement()); | 69 EXPECT_EQ(value, r4.replacement()); |
68 } | 70 } |
69 | 71 |
70 } // namespace compiler | 72 } // namespace compiler |
71 } // namespace internal | 73 } // namespace internal |
72 } // namespace v8 | 74 } // namespace v8 |
OLD | NEW |