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

Side by Side Diff: test/unittests/compiler/simplified-operator-unittest.cc

Issue 763963002: [turbofan] Add checked load/store operators. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Reapply fix. Created 6 years 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/simplified-operator.h" 5 #include "src/compiler/simplified-operator.h"
6 6
7 #include "src/compiler/operator-properties-inl.h" 7 #include "src/compiler/operator-properties-inl.h"
8 #include "test/unittests/test-utils.h" 8 #include "test/unittests/test-utils.h"
9 9
10 namespace v8 { 10 namespace v8 {
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 const PureOperator& pop = GetParam(); 107 const PureOperator& pop = GetParam();
108 const Operator* op = (simplified.*pop.constructor)(); 108 const Operator* op = (simplified.*pop.constructor)();
109 EXPECT_EQ(pop.properties, op->properties() & pop.properties); 109 EXPECT_EQ(pop.properties, op->properties() & pop.properties);
110 } 110 }
111 111
112 INSTANTIATE_TEST_CASE_P(SimplifiedOperatorTest, SimplifiedPureOperatorTest, 112 INSTANTIATE_TEST_CASE_P(SimplifiedOperatorTest, SimplifiedPureOperatorTest,
113 ::testing::ValuesIn(kPureOperators)); 113 ::testing::ValuesIn(kPureOperators));
114 114
115 115
116 // ----------------------------------------------------------------------------- 116 // -----------------------------------------------------------------------------
117 // Buffer access operators.
118
119
120 namespace {
121
122 const ExternalArrayType kExternalArrayTypes[] = {
123 kExternalUint8Array, kExternalInt8Array, kExternalUint16Array,
124 kExternalInt16Array, kExternalUint32Array, kExternalInt32Array,
125 kExternalFloat32Array, kExternalFloat64Array};
126
127 } // namespace
128
129
130 class SimplifiedBufferAccessOperatorTest
131 : public TestWithZone,
132 public ::testing::WithParamInterface<ExternalArrayType> {};
133
134
135 TEST_P(SimplifiedBufferAccessOperatorTest, InstancesAreGloballyShared) {
136 BufferAccess const access(GetParam());
137 SimplifiedOperatorBuilder simplified1(zone());
138 SimplifiedOperatorBuilder simplified2(zone());
139 EXPECT_EQ(simplified1.LoadBuffer(access), simplified2.LoadBuffer(access));
140 EXPECT_EQ(simplified1.StoreBuffer(access), simplified2.StoreBuffer(access));
141 }
142
143
144 TEST_P(SimplifiedBufferAccessOperatorTest, LoadBuffer) {
145 SimplifiedOperatorBuilder simplified(zone());
146 BufferAccess const access(GetParam());
147 const Operator* op = simplified.LoadBuffer(access);
148
149 EXPECT_EQ(IrOpcode::kLoadBuffer, op->opcode());
150 EXPECT_EQ(Operator::kNoThrow | Operator::kNoWrite, op->properties());
151 EXPECT_EQ(access, BufferAccessOf(op));
152
153 EXPECT_EQ(3, op->ValueInputCount());
154 EXPECT_EQ(1, op->EffectInputCount());
155 EXPECT_EQ(1, op->ControlInputCount());
156 EXPECT_EQ(5, OperatorProperties::GetTotalInputCount(op));
157
158 EXPECT_EQ(1, op->ValueOutputCount());
159 EXPECT_EQ(1, op->EffectOutputCount());
160 EXPECT_EQ(0, op->ControlOutputCount());
161 }
162
163
164 TEST_P(SimplifiedBufferAccessOperatorTest, StoreBuffer) {
165 SimplifiedOperatorBuilder simplified(zone());
166 BufferAccess const access(GetParam());
167 const Operator* op = simplified.StoreBuffer(access);
168
169 EXPECT_EQ(IrOpcode::kStoreBuffer, op->opcode());
170 EXPECT_EQ(Operator::kNoRead | Operator::kNoThrow, op->properties());
171 EXPECT_EQ(access, BufferAccessOf(op));
172
173 EXPECT_EQ(4, op->ValueInputCount());
174 EXPECT_EQ(1, op->EffectInputCount());
175 EXPECT_EQ(1, op->ControlInputCount());
176 EXPECT_EQ(6, OperatorProperties::GetTotalInputCount(op));
177
178 EXPECT_EQ(0, op->ValueOutputCount());
179 EXPECT_EQ(1, op->EffectOutputCount());
180 EXPECT_EQ(0, op->ControlOutputCount());
181 }
182
183
184 INSTANTIATE_TEST_CASE_P(SimplifiedOperatorTest,
185 SimplifiedBufferAccessOperatorTest,
186 ::testing::ValuesIn(kExternalArrayTypes));
187
188
189 // -----------------------------------------------------------------------------
117 // Element access operators. 190 // Element access operators.
118 191
192
119 namespace { 193 namespace {
120 194
121 const ElementAccess kElementAccesses[] = { 195 const ElementAccess kElementAccesses[] = {
122 {kNoBoundsCheck, kTaggedBase, FixedArray::kHeaderSize, Type::Any(), 196 {kTaggedBase, FixedArray::kHeaderSize, Type::Any(), kMachAnyTagged},
123 kMachAnyTagged}, 197 {kUntaggedBase, 0, Type::Any(), kMachInt8},
124 {kNoBoundsCheck, kUntaggedBase, kNonHeapObjectHeaderSize - kHeapObjectTag, 198 {kUntaggedBase, 0, Type::Any(), kMachInt16},
125 Type::Any(), kMachInt8}, 199 {kUntaggedBase, 0, Type::Any(), kMachInt32},
126 {kNoBoundsCheck, kUntaggedBase, kNonHeapObjectHeaderSize - kHeapObjectTag, 200 {kUntaggedBase, 0, Type::Any(), kMachUint8},
127 Type::Any(), kMachInt16}, 201 {kUntaggedBase, 0, Type::Any(), kMachUint16},
128 {kNoBoundsCheck, kUntaggedBase, kNonHeapObjectHeaderSize - kHeapObjectTag, 202 {kUntaggedBase, 0, Type::Any(), kMachUint32},
129 Type::Any(), kMachInt32}, 203 {kUntaggedBase, 0, Type::Signed32(), kMachInt8},
130 {kNoBoundsCheck, kUntaggedBase, kNonHeapObjectHeaderSize - kHeapObjectTag, 204 {kUntaggedBase, 0, Type::Unsigned32(), kMachUint8},
131 Type::Any(), kMachUint8}, 205 {kUntaggedBase, 0, Type::Signed32(), kMachInt16},
132 {kNoBoundsCheck, kUntaggedBase, kNonHeapObjectHeaderSize - kHeapObjectTag, 206 {kUntaggedBase, 0, Type::Unsigned32(), kMachUint16},
133 Type::Any(), kMachUint16}, 207 {kUntaggedBase, 0, Type::Signed32(), kMachInt32},
134 {kNoBoundsCheck, kUntaggedBase, kNonHeapObjectHeaderSize - kHeapObjectTag, 208 {kUntaggedBase, 0, Type::Unsigned32(), kMachUint32},
135 Type::Any(), kMachUint32}, 209 {kUntaggedBase, 0, Type::Number(), kRepFloat32},
136 {kTypedArrayBoundsCheck, kUntaggedBase, 0, Type::Signed32(), kMachInt8}, 210 {kUntaggedBase, 0, Type::Number(), kRepFloat64},
137 {kTypedArrayBoundsCheck, kUntaggedBase, 0, Type::Unsigned32(), kMachUint8}, 211 {kTaggedBase, FixedTypedArrayBase::kDataOffset, Type::Signed32(),
138 {kTypedArrayBoundsCheck, kUntaggedBase, 0, Type::Signed32(), kMachInt16}, 212 kMachInt8},
139 {kTypedArrayBoundsCheck, kUntaggedBase, 0, Type::Unsigned32(), kMachUint16}, 213 {kTaggedBase, FixedTypedArrayBase::kDataOffset, Type::Unsigned32(),
140 {kTypedArrayBoundsCheck, kUntaggedBase, 0, Type::Signed32(), kMachInt32}, 214 kMachUint8},
141 {kTypedArrayBoundsCheck, kUntaggedBase, 0, Type::Unsigned32(), kMachUint32}, 215 {kTaggedBase, FixedTypedArrayBase::kDataOffset, Type::Signed32(),
142 {kTypedArrayBoundsCheck, kUntaggedBase, 0, Type::Number(), kRepFloat32}, 216 kMachInt16},
143 {kTypedArrayBoundsCheck, kUntaggedBase, 0, Type::Number(), kRepFloat64}, 217 {kTaggedBase, FixedTypedArrayBase::kDataOffset, Type::Unsigned32(),
144 {kTypedArrayBoundsCheck, kTaggedBase, FixedTypedArrayBase::kDataOffset, 218 kMachUint16},
145 Type::Signed32(), kMachInt8}, 219 {kTaggedBase, FixedTypedArrayBase::kDataOffset, Type::Signed32(),
146 {kTypedArrayBoundsCheck, kTaggedBase, FixedTypedArrayBase::kDataOffset, 220 kMachInt32},
147 Type::Unsigned32(), kMachUint8}, 221 {kTaggedBase, FixedTypedArrayBase::kDataOffset, Type::Unsigned32(),
148 {kTypedArrayBoundsCheck, kTaggedBase, FixedTypedArrayBase::kDataOffset, 222 kMachUint32},
149 Type::Signed32(), kMachInt16}, 223 {kTaggedBase, FixedTypedArrayBase::kDataOffset, Type::Number(),
150 {kTypedArrayBoundsCheck, kTaggedBase, FixedTypedArrayBase::kDataOffset, 224 kRepFloat32},
151 Type::Unsigned32(), kMachUint16}, 225 {kTaggedBase, FixedTypedArrayBase::kDataOffset, Type::Number(),
152 {kTypedArrayBoundsCheck, kTaggedBase, FixedTypedArrayBase::kDataOffset, 226 kRepFloat64}};
153 Type::Signed32(), kMachInt32},
154 {kTypedArrayBoundsCheck, kTaggedBase, FixedTypedArrayBase::kDataOffset,
155 Type::Unsigned32(), kMachUint32},
156 {kTypedArrayBoundsCheck, kTaggedBase, FixedTypedArrayBase::kDataOffset,
157 Type::Number(), kRepFloat32},
158 {kTypedArrayBoundsCheck, kTaggedBase, FixedTypedArrayBase::kDataOffset,
159 Type::Number(), kRepFloat64}};
160 227
161 } // namespace 228 } // namespace
162 229
163 230
164 class SimplifiedElementAccessOperatorTest 231 class SimplifiedElementAccessOperatorTest
165 : public TestWithZone, 232 : public TestWithZone,
166 public ::testing::WithParamInterface<ElementAccess> {}; 233 public ::testing::WithParamInterface<ElementAccess> {};
167 234
168 235
169 TEST_P(SimplifiedElementAccessOperatorTest, LoadElement) { 236 TEST_P(SimplifiedElementAccessOperatorTest, LoadElement) {
170 SimplifiedOperatorBuilder simplified(zone()); 237 SimplifiedOperatorBuilder simplified(zone());
171 const ElementAccess& access = GetParam(); 238 const ElementAccess& access = GetParam();
172 const Operator* op = simplified.LoadElement(access); 239 const Operator* op = simplified.LoadElement(access);
173 240
174 EXPECT_EQ(IrOpcode::kLoadElement, op->opcode()); 241 EXPECT_EQ(IrOpcode::kLoadElement, op->opcode());
175 EXPECT_EQ(Operator::kNoThrow | Operator::kNoWrite, op->properties()); 242 EXPECT_EQ(Operator::kNoThrow | Operator::kNoWrite, op->properties());
176 EXPECT_EQ(access, ElementAccessOf(op)); 243 EXPECT_EQ(access, ElementAccessOf(op));
177 244
178 EXPECT_EQ(3, op->ValueInputCount()); 245 EXPECT_EQ(2, op->ValueInputCount());
179 EXPECT_EQ(1, op->EffectInputCount()); 246 EXPECT_EQ(1, op->EffectInputCount());
180 EXPECT_EQ(0, op->ControlInputCount()); 247 EXPECT_EQ(1, op->ControlInputCount());
181 EXPECT_EQ(4, OperatorProperties::GetTotalInputCount(op)); 248 EXPECT_EQ(4, OperatorProperties::GetTotalInputCount(op));
182 249
183 EXPECT_EQ(1, op->ValueOutputCount()); 250 EXPECT_EQ(1, op->ValueOutputCount());
184 EXPECT_EQ(1, op->EffectOutputCount()); 251 EXPECT_EQ(1, op->EffectOutputCount());
185 EXPECT_EQ(0, op->ControlOutputCount()); 252 EXPECT_EQ(0, op->ControlOutputCount());
186 } 253 }
187 254
188 255
189 TEST_P(SimplifiedElementAccessOperatorTest, StoreElement) { 256 TEST_P(SimplifiedElementAccessOperatorTest, StoreElement) {
190 SimplifiedOperatorBuilder simplified(zone()); 257 SimplifiedOperatorBuilder simplified(zone());
191 const ElementAccess& access = GetParam(); 258 const ElementAccess& access = GetParam();
192 const Operator* op = simplified.StoreElement(access); 259 const Operator* op = simplified.StoreElement(access);
193 260
194 EXPECT_EQ(IrOpcode::kStoreElement, op->opcode()); 261 EXPECT_EQ(IrOpcode::kStoreElement, op->opcode());
195 EXPECT_EQ(Operator::kNoRead | Operator::kNoThrow, op->properties()); 262 EXPECT_EQ(Operator::kNoRead | Operator::kNoThrow, op->properties());
196 EXPECT_EQ(access, ElementAccessOf(op)); 263 EXPECT_EQ(access, ElementAccessOf(op));
197 264
198 EXPECT_EQ(4, op->ValueInputCount()); 265 EXPECT_EQ(3, op->ValueInputCount());
199 EXPECT_EQ(1, op->EffectInputCount()); 266 EXPECT_EQ(1, op->EffectInputCount());
200 EXPECT_EQ(1, op->ControlInputCount()); 267 EXPECT_EQ(1, op->ControlInputCount());
201 EXPECT_EQ(6, OperatorProperties::GetTotalInputCount(op)); 268 EXPECT_EQ(5, OperatorProperties::GetTotalInputCount(op));
202 269
203 EXPECT_EQ(0, op->ValueOutputCount()); 270 EXPECT_EQ(0, op->ValueOutputCount());
204 EXPECT_EQ(1, op->EffectOutputCount()); 271 EXPECT_EQ(1, op->EffectOutputCount());
205 EXPECT_EQ(0, op->ControlOutputCount()); 272 EXPECT_EQ(0, op->ControlOutputCount());
206 } 273 }
207 274
208 275
209 INSTANTIATE_TEST_CASE_P(SimplifiedOperatorTest, 276 INSTANTIATE_TEST_CASE_P(SimplifiedOperatorTest,
210 SimplifiedElementAccessOperatorTest, 277 SimplifiedElementAccessOperatorTest,
211 ::testing::ValuesIn(kElementAccesses)); 278 ::testing::ValuesIn(kElementAccesses));
212 279
213 } // namespace compiler 280 } // namespace compiler
214 } // namespace internal 281 } // namespace internal
215 } // namespace v8 282 } // namespace v8
OLDNEW
« no previous file with comments | « test/unittests/compiler/simplified-operator-reducer-unittest.cc ('k') | test/unittests/test-utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698