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

Side by Side Diff: test/unittests/compiler/state-values-utils-unittest.cc

Issue 1015423002: [turbofan] Remember types for deoptimization during simplified lowering. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Address review comments Created 5 years, 9 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
« no previous file with comments | « test/unittests/compiler/liveness-analyzer-unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/state-values-utils.h" 5 #include "src/compiler/state-values-utils.h"
6 #include "test/unittests/compiler/graph-unittest.h" 6 #include "test/unittests/compiler/graph-unittest.h"
7 #include "test/unittests/compiler/node-test-utils.h" 7 #include "test/unittests/compiler/node-test-utils.h"
8 #include "test/unittests/test-utils.h" 8 #include "test/unittests/test-utils.h"
9 #include "testing/gmock/include/gmock/gmock.h" 9 #include "testing/gmock/include/gmock/gmock.h"
10 10
(...skipping 14 matching lines...) Expand all
25 25
26 26
27 TEST_F(StateValuesIteratorTest, SimpleIteration) { 27 TEST_F(StateValuesIteratorTest, SimpleIteration) {
28 NodeVector inputs(zone()); 28 NodeVector inputs(zone());
29 const int count = 10; 29 const int count = 10;
30 for (int i = 0; i < count; i++) { 30 for (int i = 0; i < count; i++) {
31 inputs.push_back(Int32Constant(i)); 31 inputs.push_back(Int32Constant(i));
32 } 32 }
33 Node* state_values = StateValuesFromVector(&inputs); 33 Node* state_values = StateValuesFromVector(&inputs);
34 int i = 0; 34 int i = 0;
35 for (Node* node : StateValuesAccess(state_values)) { 35 for (StateValuesAccess::TypedNode node : StateValuesAccess(state_values)) {
36 EXPECT_THAT(node, IsInt32Constant(i)); 36 EXPECT_THAT(node.node, IsInt32Constant(i));
37 i++; 37 i++;
38 } 38 }
39 EXPECT_EQ(count, i); 39 EXPECT_EQ(count, i);
40 } 40 }
41 41
42 42
43 TEST_F(StateValuesIteratorTest, EmptyIteration) { 43 TEST_F(StateValuesIteratorTest, EmptyIteration) {
44 NodeVector inputs(zone()); 44 NodeVector inputs(zone());
45 Node* state_values = StateValuesFromVector(&inputs); 45 Node* state_values = StateValuesFromVector(&inputs);
46 for (Node* node : StateValuesAccess(state_values)) { 46 for (auto node : StateValuesAccess(state_values)) {
47 USE(node); 47 USE(node);
48 FAIL(); 48 FAIL();
49 } 49 }
50 } 50 }
51 51
52 52
53 TEST_F(StateValuesIteratorTest, NestedIteration) { 53 TEST_F(StateValuesIteratorTest, NestedIteration) {
54 NodeVector inputs(zone()); 54 NodeVector inputs(zone());
55 int count = 0; 55 int count = 0;
56 for (int i = 0; i < 8; i++) { 56 for (int i = 0; i < 8; i++) {
(...skipping 18 matching lines...) Expand all
75 nested_inputs.push_back(Int32Constant(count++)); 75 nested_inputs.push_back(Int32Constant(count++));
76 } 76 }
77 } 77 }
78 inputs.push_back(StateValuesFromVector(&nested_inputs)); 78 inputs.push_back(StateValuesFromVector(&nested_inputs));
79 } else { 79 } else {
80 inputs.push_back(Int32Constant(count++)); 80 inputs.push_back(Int32Constant(count++));
81 } 81 }
82 } 82 }
83 Node* state_values = StateValuesFromVector(&inputs); 83 Node* state_values = StateValuesFromVector(&inputs);
84 int i = 0; 84 int i = 0;
85 for (Node* node : StateValuesAccess(state_values)) { 85 for (StateValuesAccess::TypedNode node : StateValuesAccess(state_values)) {
86 EXPECT_THAT(node, IsInt32Constant(i)); 86 EXPECT_THAT(node.node, IsInt32Constant(i));
87 i++; 87 i++;
88 } 88 }
89 EXPECT_EQ(count, i); 89 EXPECT_EQ(count, i);
90 } 90 }
91 91
92 92
93 TEST_F(StateValuesIteratorTest, TreeFromVector) { 93 TEST_F(StateValuesIteratorTest, TreeFromVector) {
94 int sizes[] = {0, 1, 2, 100, 5000, 30000}; 94 int sizes[] = {0, 1, 2, 100, 5000, 30000};
95 TRACED_FOREACH(int, count, sizes) { 95 TRACED_FOREACH(int, count, sizes) {
96 JSOperatorBuilder javascript(zone()); 96 JSOperatorBuilder javascript(zone());
97 MachineOperatorBuilder machine(zone()); 97 MachineOperatorBuilder machine(zone());
98 JSGraph jsgraph(isolate(), graph(), common(), &javascript, &machine); 98 JSGraph jsgraph(isolate(), graph(), common(), &javascript, &machine);
99 99
100 // Generate the input vector. 100 // Generate the input vector.
101 NodeVector inputs(zone()); 101 NodeVector inputs(zone());
102 for (int i = 0; i < count; i++) { 102 for (int i = 0; i < count; i++) {
103 inputs.push_back(Int32Constant(i)); 103 inputs.push_back(Int32Constant(i));
104 } 104 }
105 105
106 // Build the tree. 106 // Build the tree.
107 StateValuesCache builder(&jsgraph); 107 StateValuesCache builder(&jsgraph);
108 Node* values_node = builder.GetNodeForValues( 108 Node* values_node = builder.GetNodeForValues(
109 inputs.size() == 0 ? nullptr : &(inputs.front()), inputs.size()); 109 inputs.size() == 0 ? nullptr : &(inputs.front()), inputs.size());
110 110
111 // Check the tree contents with vector. 111 // Check the tree contents with vector.
112 int i = 0; 112 int i = 0;
113 for (Node* node : StateValuesAccess(values_node)) { 113 for (StateValuesAccess::TypedNode node : StateValuesAccess(values_node)) {
114 EXPECT_THAT(node, IsInt32Constant(i)); 114 EXPECT_THAT(node.node, IsInt32Constant(i));
115 i++; 115 i++;
116 } 116 }
117 EXPECT_EQ(inputs.size(), static_cast<size_t>(i)); 117 EXPECT_EQ(inputs.size(), static_cast<size_t>(i));
118 } 118 }
119 } 119 }
120 120
121 121
122 TEST_F(StateValuesIteratorTest, BuildTreeIdentical) { 122 TEST_F(StateValuesIteratorTest, BuildTreeIdentical) {
123 int sizes[] = {0, 1, 2, 100, 5000, 30000}; 123 int sizes[] = {0, 1, 2, 100, 5000, 30000};
124 TRACED_FOREACH(int, count, sizes) { 124 TRACED_FOREACH(int, count, sizes) {
(...skipping 15 matching lines...) Expand all
140 inputs.size() == 0 ? nullptr : &(inputs.front()), inputs.size()); 140 inputs.size() == 0 ? nullptr : &(inputs.front()), inputs.size());
141 141
142 // The trees should be equal since the data was the same. 142 // The trees should be equal since the data was the same.
143 EXPECT_EQ(node1, node2); 143 EXPECT_EQ(node1, node2);
144 } 144 }
145 } 145 }
146 146
147 } // namespace compiler 147 } // namespace compiler
148 } // namespace internal 148 } // namespace internal
149 } // namespace v8 149 } // namespace v8
OLDNEW
« no previous file with comments | « test/unittests/compiler/liveness-analyzer-unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698