Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: test/unittests/compiler/load-elimination-unittest.cc

Issue 1994503002: [turbofan] Turn common Guard operator into simplified TypeGuard. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 TypedGraphTest { 15 class LoadEliminationTest : public TypedGraphTest {
16 public: 16 public:
17 LoadEliminationTest() 17 LoadEliminationTest() : TypedGraphTest(3), simplified_(zone()) {}
18 : TypedGraphTest(3), common_(zone()), simplified_(zone()) {}
19 ~LoadEliminationTest() override {} 18 ~LoadEliminationTest() override {}
20 19
21 protected: 20 protected:
22 Reduction Reduce(Node* node) { 21 Reduction Reduce(Node* node) {
23 // TODO(titzer): mock the GraphReducer here for better unit testing. 22 // TODO(titzer): mock the GraphReducer here for better unit testing.
24 GraphReducer graph_reducer(zone(), graph()); 23 GraphReducer graph_reducer(zone(), graph());
25 LoadElimination reducer(&graph_reducer, graph(), common()); 24 LoadElimination reducer(&graph_reducer, graph(), simplified());
26 return reducer.Reduce(node); 25 return reducer.Reduce(node);
27 } 26 }
28 27
29 SimplifiedOperatorBuilder* simplified() { return &simplified_; } 28 SimplifiedOperatorBuilder* simplified() { return &simplified_; }
30 CommonOperatorBuilder* common() { return &common_; }
31 29
32 private: 30 private:
33 CommonOperatorBuilder common_;
34 SimplifiedOperatorBuilder simplified_; 31 SimplifiedOperatorBuilder simplified_;
35 }; 32 };
36 33
37 34
38 TEST_F(LoadEliminationTest, LoadFieldWithStoreField) { 35 TEST_F(LoadEliminationTest, LoadFieldWithStoreField) {
39 Node* object1 = Parameter(Type::Any(), 0); 36 Node* object1 = Parameter(Type::Any(), 0);
40 Node* object2 = Parameter(Type::Any(), 1); 37 Node* object2 = Parameter(Type::Any(), 1);
41 Node* value = Parameter(Type::Any(), 2); 38 Node* value = Parameter(Type::Any(), 2);
42 Node* effect = graph()->start(); 39 Node* effect = graph()->start();
43 Node* control = graph()->start(); 40 Node* control = graph()->start();
(...skipping 24 matching lines...) Expand all
68 65
69 Reduction r4 = Reduce(graph()->NewNode(simplified()->LoadField(access1), 66 Reduction r4 = Reduce(graph()->NewNode(simplified()->LoadField(access1),
70 object1, store3, control)); 67 object1, store3, control));
71 ASSERT_TRUE(r4.Changed()); 68 ASSERT_TRUE(r4.Changed());
72 EXPECT_EQ(value, r4.replacement()); 69 EXPECT_EQ(value, r4.replacement());
73 } 70 }
74 71
75 } // namespace compiler 72 } // namespace compiler
76 } // namespace internal 73 } // namespace internal
77 } // namespace v8 74 } // namespace v8
OLDNEW
« no previous file with comments | « test/unittests/compiler/js-intrinsic-lowering-unittest.cc ('k') | test/unittests/compiler/node-test-utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698