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

Side by Side Diff: test/unittests/compiler/change-lowering-unittest.cc

Issue 1952703002: Turn on -Wmissing-field-initializers on Linux. (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/code-stubs.h" 5 #include "src/code-stubs.h"
6 #include "src/compiler/change-lowering.h" 6 #include "src/compiler/change-lowering.h"
7 #include "src/compiler/js-graph.h" 7 #include "src/compiler/js-graph.h"
8 #include "src/compiler/linkage.h" 8 #include "src/compiler/linkage.h"
9 #include "src/compiler/node-properties.h" 9 #include "src/compiler/node-properties.h"
10 #include "src/compiler/simplified-operator.h" 10 #include "src/compiler/simplified-operator.h"
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 class ChangeLoweringCommonTest 99 class ChangeLoweringCommonTest
100 : public ChangeLoweringTest, 100 : public ChangeLoweringTest,
101 public ::testing::WithParamInterface<MachineRepresentation> { 101 public ::testing::WithParamInterface<MachineRepresentation> {
102 public: 102 public:
103 ~ChangeLoweringCommonTest() override {} 103 ~ChangeLoweringCommonTest() override {}
104 104
105 MachineRepresentation WordRepresentation() const final { return GetParam(); } 105 MachineRepresentation WordRepresentation() const final { return GetParam(); }
106 }; 106 };
107 107
108 TARGET_TEST_P(ChangeLoweringCommonTest, StoreFieldSmi) { 108 TARGET_TEST_P(ChangeLoweringCommonTest, StoreFieldSmi) {
109 FieldAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize, 109 FieldAccess access = {
110 Handle<Name>::null(), Type::Any(), 110 kTaggedBase, FixedArrayBase::kHeaderSize, Handle<Name>::null(),
111 MachineType::AnyTagged()}; 111 Type::Any(), MachineType::AnyTagged(), kNoWriteBarrier};
112 Node* p0 = Parameter(Type::TaggedPointer()); 112 Node* p0 = Parameter(Type::TaggedPointer());
113 Node* p1 = Parameter(Type::TaggedSigned()); 113 Node* p1 = Parameter(Type::TaggedSigned());
114 Node* store = graph()->NewNode(simplified()->StoreField(access), p0, p1, 114 Node* store = graph()->NewNode(simplified()->StoreField(access), p0, p1,
115 graph()->start(), graph()->start()); 115 graph()->start(), graph()->start());
116 Reduction r = Reduce(store); 116 Reduction r = Reduce(store);
117 117
118 ASSERT_TRUE(r.Changed()); 118 ASSERT_TRUE(r.Changed());
119 EXPECT_THAT(r.replacement(), 119 EXPECT_THAT(r.replacement(),
120 IsStore(StoreRepresentation(MachineRepresentation::kTagged, 120 IsStore(StoreRepresentation(MachineRepresentation::kTagged,
121 kNoWriteBarrier), 121 kNoWriteBarrier),
122 p0, IsIntPtrConstant(access.offset - access.tag()), p1, 122 p0, IsIntPtrConstant(access.offset - access.tag()), p1,
123 graph()->start(), graph()->start())); 123 graph()->start(), graph()->start()));
124 } 124 }
125 125
126 126
127 TARGET_TEST_P(ChangeLoweringCommonTest, StoreFieldTagged) { 127 TARGET_TEST_P(ChangeLoweringCommonTest, StoreFieldTagged) {
128 FieldAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize, 128 FieldAccess access = {
129 Handle<Name>::null(), Type::Any(), 129 kTaggedBase, FixedArrayBase::kHeaderSize, Handle<Name>::null(),
130 MachineType::AnyTagged()}; 130 Type::Any(), MachineType::AnyTagged(), kFullWriteBarrier};
131 Node* p0 = Parameter(Type::TaggedPointer()); 131 Node* p0 = Parameter(Type::TaggedPointer());
132 Node* p1 = Parameter(Type::Tagged()); 132 Node* p1 = Parameter(Type::Tagged());
133 Node* store = graph()->NewNode(simplified()->StoreField(access), p0, p1, 133 Node* store = graph()->NewNode(simplified()->StoreField(access), p0, p1,
134 graph()->start(), graph()->start()); 134 graph()->start(), graph()->start());
135 Reduction r = Reduce(store); 135 Reduction r = Reduce(store);
136 136
137 ASSERT_TRUE(r.Changed()); 137 ASSERT_TRUE(r.Changed());
138 EXPECT_THAT(r.replacement(), 138 EXPECT_THAT(r.replacement(),
139 IsStore(StoreRepresentation(MachineRepresentation::kTagged, 139 IsStore(StoreRepresentation(MachineRepresentation::kTagged,
140 kFullWriteBarrier), 140 kFullWriteBarrier),
141 p0, IsIntPtrConstant(access.offset - access.tag()), p1, 141 p0, IsIntPtrConstant(access.offset - access.tag()), p1,
142 graph()->start(), graph()->start())); 142 graph()->start(), graph()->start()));
143 } 143 }
144 144
145 145
146 TARGET_TEST_P(ChangeLoweringCommonTest, LoadField) { 146 TARGET_TEST_P(ChangeLoweringCommonTest, LoadField) {
147 FieldAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize, 147 FieldAccess access = {
148 Handle<Name>::null(), Type::Any(), 148 kTaggedBase, FixedArrayBase::kHeaderSize, Handle<Name>::null(),
149 MachineType::AnyTagged()}; 149 Type::Any(), MachineType::AnyTagged(), kNoWriteBarrier};
150 Node* p0 = Parameter(Type::TaggedPointer()); 150 Node* p0 = Parameter(Type::TaggedPointer());
151 Node* load = graph()->NewNode(simplified()->LoadField(access), p0, 151 Node* load = graph()->NewNode(simplified()->LoadField(access), p0,
152 graph()->start(), graph()->start()); 152 graph()->start(), graph()->start());
153 Reduction r = Reduce(load); 153 Reduction r = Reduce(load);
154 154
155 ASSERT_TRUE(r.Changed()); 155 ASSERT_TRUE(r.Changed());
156 Matcher<Node*> index_match = IsIntPtrConstant(access.offset - access.tag()); 156 Matcher<Node*> index_match = IsIntPtrConstant(access.offset - access.tag());
157 EXPECT_THAT(r.replacement(), 157 EXPECT_THAT(r.replacement(),
158 IsLoad(MachineType::AnyTagged(), p0, 158 IsLoad(MachineType::AnyTagged(), p0,
159 IsIntPtrConstant(access.offset - access.tag()), 159 IsIntPtrConstant(access.offset - access.tag()),
160 graph()->start(), graph()->start())); 160 graph()->start(), graph()->start()));
161 } 161 }
162 162
163 163
164 TARGET_TEST_P(ChangeLoweringCommonTest, StoreElementTagged) { 164 TARGET_TEST_P(ChangeLoweringCommonTest, StoreElementTagged) {
165 ElementAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize, Type::Any(), 165 ElementAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize, Type::Any(),
166 MachineType::AnyTagged()}; 166 MachineType::AnyTagged(), kFullWriteBarrier};
167 Node* p0 = Parameter(Type::TaggedPointer()); 167 Node* p0 = Parameter(Type::TaggedPointer());
168 Node* p1 = Parameter(Type::Signed32()); 168 Node* p1 = Parameter(Type::Signed32());
169 Node* p2 = Parameter(Type::Tagged()); 169 Node* p2 = Parameter(Type::Tagged());
170 Node* store = graph()->NewNode(simplified()->StoreElement(access), p0, p1, p2, 170 Node* store = graph()->NewNode(simplified()->StoreElement(access), p0, p1, p2,
171 graph()->start(), graph()->start()); 171 graph()->start(), graph()->start());
172 Reduction r = Reduce(store); 172 Reduction r = Reduce(store);
173 173
174 const int element_size_shift = 174 const int element_size_shift =
175 ElementSizeLog2Of(access.machine_type.representation()); 175 ElementSizeLog2Of(access.machine_type.representation());
176 ASSERT_TRUE(r.Changed()); 176 ASSERT_TRUE(r.Changed());
177 Matcher<Node*> index_match = 177 Matcher<Node*> index_match =
178 IsInt32Add(IsWord32Shl(p1, IsInt32Constant(element_size_shift)), 178 IsInt32Add(IsWord32Shl(p1, IsInt32Constant(element_size_shift)),
179 IsInt32Constant(access.header_size - access.tag())); 179 IsInt32Constant(access.header_size - access.tag()));
180 if (!Is32()) { 180 if (!Is32()) {
181 index_match = IsChangeUint32ToUint64(index_match); 181 index_match = IsChangeUint32ToUint64(index_match);
182 } 182 }
183 183
184 EXPECT_THAT(r.replacement(), 184 EXPECT_THAT(r.replacement(),
185 IsStore(StoreRepresentation(MachineRepresentation::kTagged, 185 IsStore(StoreRepresentation(MachineRepresentation::kTagged,
186 kFullWriteBarrier), 186 kFullWriteBarrier),
187 p0, index_match, p2, graph()->start(), graph()->start())); 187 p0, index_match, p2, graph()->start(), graph()->start()));
188 } 188 }
189 189
190 190
191 TARGET_TEST_P(ChangeLoweringCommonTest, StoreElementUint8) { 191 TARGET_TEST_P(ChangeLoweringCommonTest, StoreElementUint8) {
192 ElementAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize, 192 ElementAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize,
193 Type::Signed32(), MachineType::Uint8()}; 193 Type::Signed32(), MachineType::Uint8(),
194 kNoWriteBarrier};
194 Node* p0 = Parameter(Type::TaggedPointer()); 195 Node* p0 = Parameter(Type::TaggedPointer());
195 Node* p1 = Parameter(Type::Signed32()); 196 Node* p1 = Parameter(Type::Signed32());
196 Node* p2 = Parameter(Type::Signed32()); 197 Node* p2 = Parameter(Type::Signed32());
197 Node* store = graph()->NewNode(simplified()->StoreElement(access), p0, p1, p2, 198 Node* store = graph()->NewNode(simplified()->StoreElement(access), p0, p1, p2,
198 graph()->start(), graph()->start()); 199 graph()->start(), graph()->start());
199 Reduction r = Reduce(store); 200 Reduction r = Reduce(store);
200 201
201 ASSERT_TRUE(r.Changed()); 202 ASSERT_TRUE(r.Changed());
202 Matcher<Node*> index_match = 203 Matcher<Node*> index_match =
203 IsInt32Add(p1, IsInt32Constant(access.header_size - access.tag())); 204 IsInt32Add(p1, IsInt32Constant(access.header_size - access.tag()));
204 if (!Is32()) { 205 if (!Is32()) {
205 index_match = IsChangeUint32ToUint64(index_match); 206 index_match = IsChangeUint32ToUint64(index_match);
206 } 207 }
207 208
208 EXPECT_THAT(r.replacement(), 209 EXPECT_THAT(r.replacement(),
209 IsStore(StoreRepresentation(MachineRepresentation::kWord8, 210 IsStore(StoreRepresentation(MachineRepresentation::kWord8,
210 kNoWriteBarrier), 211 kNoWriteBarrier),
211 p0, index_match, p2, graph()->start(), graph()->start())); 212 p0, index_match, p2, graph()->start(), graph()->start()));
212 } 213 }
213 214
214 215
215 TARGET_TEST_P(ChangeLoweringCommonTest, LoadElementTagged) { 216 TARGET_TEST_P(ChangeLoweringCommonTest, LoadElementTagged) {
216 ElementAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize, Type::Any(), 217 ElementAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize, Type::Any(),
217 MachineType::AnyTagged()}; 218 MachineType::AnyTagged(), kNoWriteBarrier};
218 Node* p0 = Parameter(Type::TaggedPointer()); 219 Node* p0 = Parameter(Type::TaggedPointer());
219 Node* p1 = Parameter(Type::Signed32()); 220 Node* p1 = Parameter(Type::Signed32());
220 Node* load = graph()->NewNode(simplified()->LoadElement(access), p0, p1, 221 Node* load = graph()->NewNode(simplified()->LoadElement(access), p0, p1,
221 graph()->start(), graph()->start()); 222 graph()->start(), graph()->start());
222 Reduction r = Reduce(load); 223 Reduction r = Reduce(load);
223 224
224 const int element_size_shift = 225 const int element_size_shift =
225 ElementSizeLog2Of(access.machine_type.representation()); 226 ElementSizeLog2Of(access.machine_type.representation());
226 ASSERT_TRUE(r.Changed()); 227 ASSERT_TRUE(r.Changed());
227 Matcher<Node*> index_match = 228 Matcher<Node*> index_match =
228 IsInt32Add(IsWord32Shl(p1, IsInt32Constant(element_size_shift)), 229 IsInt32Add(IsWord32Shl(p1, IsInt32Constant(element_size_shift)),
229 IsInt32Constant(access.header_size - access.tag())); 230 IsInt32Constant(access.header_size - access.tag()));
230 if (!Is32()) { 231 if (!Is32()) {
231 index_match = IsChangeUint32ToUint64(index_match); 232 index_match = IsChangeUint32ToUint64(index_match);
232 } 233 }
233 234
234 EXPECT_THAT(r.replacement(), IsLoad(MachineType::AnyTagged(), p0, index_match, 235 EXPECT_THAT(r.replacement(), IsLoad(MachineType::AnyTagged(), p0, index_match,
235 graph()->start(), graph()->start())); 236 graph()->start(), graph()->start()));
236 } 237 }
237 238
238 239
239 TARGET_TEST_P(ChangeLoweringCommonTest, LoadElementInt8) { 240 TARGET_TEST_P(ChangeLoweringCommonTest, LoadElementInt8) {
240 ElementAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize, 241 ElementAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize,
241 Type::Signed32(), MachineType::Int8()}; 242 Type::Signed32(), MachineType::Int8(),
243 kNoWriteBarrier};
242 Node* p0 = Parameter(Type::TaggedPointer()); 244 Node* p0 = Parameter(Type::TaggedPointer());
243 Node* p1 = Parameter(Type::Signed32()); 245 Node* p1 = Parameter(Type::Signed32());
244 Node* load = graph()->NewNode(simplified()->LoadElement(access), p0, p1, 246 Node* load = graph()->NewNode(simplified()->LoadElement(access), p0, p1,
245 graph()->start(), graph()->start()); 247 graph()->start(), graph()->start());
246 Reduction r = Reduce(load); 248 Reduction r = Reduce(load);
247 249
248 ASSERT_TRUE(r.Changed()); 250 ASSERT_TRUE(r.Changed());
249 Matcher<Node*> index_match = 251 Matcher<Node*> index_match =
250 IsInt32Add(p1, IsInt32Constant(access.header_size - access.tag())); 252 IsInt32Add(p1, IsInt32Constant(access.header_size - access.tag()));
251 if (!Is32()) { 253 if (!Is32()) {
(...skipping 12 matching lines...) Expand all
264 Reduction r = Reduce(alloc); 266 Reduction r = Reduce(alloc);
265 267
266 // Only check that we lowered, but do not specify the exact form since 268 // Only check that we lowered, but do not specify the exact form since
267 // this is subject to change. 269 // this is subject to change.
268 ASSERT_TRUE(r.Changed()); 270 ASSERT_TRUE(r.Changed());
269 } 271 }
270 272
271 } // namespace compiler 273 } // namespace compiler
272 } // namespace internal 274 } // namespace internal
273 } // namespace v8 275 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698