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

Side by Side Diff: src/compiler/simplified-operator.cc

Issue 2066223002: [turbofan] Introduce CheckHole and CheckHoleNaN operators. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Address comments. Blacklist test Created 4 years, 6 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 | « src/compiler/simplified-operator.h ('k') | src/compiler/typer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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/base/lazy-instance.h" 7 #include "src/base/lazy-instance.h"
8 #include "src/compiler/opcodes.h" 8 #include "src/compiler/opcodes.h"
9 #include "src/compiler/operator.h" 9 #include "src/compiler/operator.h"
10 #include "src/types.h" 10 #include "src/types.h"
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 } 165 }
166 166
167 167
168 const ElementAccess& ElementAccessOf(const Operator* op) { 168 const ElementAccess& ElementAccessOf(const Operator* op) {
169 DCHECK_NOT_NULL(op); 169 DCHECK_NOT_NULL(op);
170 DCHECK(op->opcode() == IrOpcode::kLoadElement || 170 DCHECK(op->opcode() == IrOpcode::kLoadElement ||
171 op->opcode() == IrOpcode::kStoreElement); 171 op->opcode() == IrOpcode::kStoreElement);
172 return OpParameter<ElementAccess>(op); 172 return OpParameter<ElementAccess>(op);
173 } 173 }
174 174
175 size_t hash_value(CheckFloat64HoleMode mode) {
176 return static_cast<size_t>(mode);
177 }
178
179 std::ostream& operator<<(std::ostream& os, CheckFloat64HoleMode mode) {
180 switch (mode) {
181 case CheckFloat64HoleMode::kAllowReturnHole:
182 return os << "allow-return-hole";
183 case CheckFloat64HoleMode::kNeverReturnHole:
184 return os << "never-return-hole";
185 }
186 UNREACHABLE();
187 return os;
188 }
189
190 CheckFloat64HoleMode CheckFloat64HoleModeOf(const Operator* op) {
191 DCHECK_EQ(IrOpcode::kCheckFloat64Hole, op->opcode());
192 return OpParameter<CheckFloat64HoleMode>(op);
193 }
194
195 size_t hash_value(CheckTaggedHoleMode mode) {
196 return static_cast<size_t>(mode);
197 }
198
199 std::ostream& operator<<(std::ostream& os, CheckTaggedHoleMode mode) {
200 switch (mode) {
201 case CheckTaggedHoleMode::kConvertHoleToUndefined:
202 return os << "convert-hole-to-undefined";
203 case CheckTaggedHoleMode::kNeverReturnHole:
204 return os << "never-return-hole";
205 }
206 UNREACHABLE();
207 return os;
208 }
209
210 CheckTaggedHoleMode CheckTaggedHoleModeOf(const Operator* op) {
211 DCHECK_EQ(IrOpcode::kCheckTaggedHole, op->opcode());
212 return OpParameter<CheckTaggedHoleMode>(op);
213 }
214
175 Type* TypeOf(const Operator* op) { 215 Type* TypeOf(const Operator* op) {
176 DCHECK_EQ(IrOpcode::kTypeGuard, op->opcode()); 216 DCHECK_EQ(IrOpcode::kTypeGuard, op->opcode());
177 return OpParameter<Type*>(op); 217 return OpParameter<Type*>(op);
178 } 218 }
179 219
180 BinaryOperationHints::Hint BinaryOperationHintOf(const Operator* op) { 220 BinaryOperationHints::Hint BinaryOperationHintOf(const Operator* op) {
181 DCHECK(op->opcode() == IrOpcode::kSpeculativeNumberAdd || 221 DCHECK(op->opcode() == IrOpcode::kSpeculativeNumberAdd ||
182 op->opcode() == IrOpcode::kSpeculativeNumberSubtract); 222 op->opcode() == IrOpcode::kSpeculativeNumberSubtract);
183 return OpParameter<BinaryOperationHints::Hint>(op); 223 return OpParameter<BinaryOperationHints::Hint>(op);
184 } 224 }
(...skipping 22 matching lines...) Expand all
207 V(NumberFround, Operator::kNoProperties, 1) \ 247 V(NumberFround, Operator::kNoProperties, 1) \
208 V(NumberAtan, Operator::kNoProperties, 1) \ 248 V(NumberAtan, Operator::kNoProperties, 1) \
209 V(NumberAtan2, Operator::kNoProperties, 2) \ 249 V(NumberAtan2, Operator::kNoProperties, 2) \
210 V(NumberLog, Operator::kNoProperties, 1) \ 250 V(NumberLog, Operator::kNoProperties, 1) \
211 V(NumberLog1p, Operator::kNoProperties, 1) \ 251 V(NumberLog1p, Operator::kNoProperties, 1) \
212 V(NumberRound, Operator::kNoProperties, 1) \ 252 V(NumberRound, Operator::kNoProperties, 1) \
213 V(NumberSqrt, Operator::kNoProperties, 1) \ 253 V(NumberSqrt, Operator::kNoProperties, 1) \
214 V(NumberTrunc, Operator::kNoProperties, 1) \ 254 V(NumberTrunc, Operator::kNoProperties, 1) \
215 V(NumberToInt32, Operator::kNoProperties, 1) \ 255 V(NumberToInt32, Operator::kNoProperties, 1) \
216 V(NumberToUint32, Operator::kNoProperties, 1) \ 256 V(NumberToUint32, Operator::kNoProperties, 1) \
217 V(NumberIsHoleNaN, Operator::kNoProperties, 1) \
218 V(NumberSilenceNaN, Operator::kNoProperties, 1) \ 257 V(NumberSilenceNaN, Operator::kNoProperties, 1) \
219 V(NumberConvertHoleNaN, Operator::kNoProperties, 1) \
220 V(StringFromCharCode, Operator::kNoProperties, 1) \ 258 V(StringFromCharCode, Operator::kNoProperties, 1) \
221 V(StringToNumber, Operator::kNoProperties, 1) \ 259 V(StringToNumber, Operator::kNoProperties, 1) \
222 V(PlainPrimitiveToNumber, Operator::kNoProperties, 1) \ 260 V(PlainPrimitiveToNumber, Operator::kNoProperties, 1) \
223 V(PlainPrimitiveToWord32, Operator::kNoProperties, 1) \ 261 V(PlainPrimitiveToWord32, Operator::kNoProperties, 1) \
224 V(PlainPrimitiveToFloat64, Operator::kNoProperties, 1) \ 262 V(PlainPrimitiveToFloat64, Operator::kNoProperties, 1) \
225 V(ChangeTaggedSignedToInt32, Operator::kNoProperties, 1) \ 263 V(ChangeTaggedSignedToInt32, Operator::kNoProperties, 1) \
226 V(ChangeTaggedToInt32, Operator::kNoProperties, 1) \ 264 V(ChangeTaggedToInt32, Operator::kNoProperties, 1) \
227 V(ChangeTaggedToUint32, Operator::kNoProperties, 1) \ 265 V(ChangeTaggedToUint32, Operator::kNoProperties, 1) \
228 V(ChangeTaggedToFloat64, Operator::kNoProperties, 1) \ 266 V(ChangeTaggedToFloat64, Operator::kNoProperties, 1) \
229 V(ChangeInt31ToTaggedSigned, Operator::kNoProperties, 1) \ 267 V(ChangeInt31ToTaggedSigned, Operator::kNoProperties, 1) \
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 #define CHECKED(Name) \ 302 #define CHECKED(Name) \
265 struct Name##Operator final : public Operator { \ 303 struct Name##Operator final : public Operator { \
266 Name##Operator() \ 304 Name##Operator() \
267 : Operator(IrOpcode::k##Name, Operator::kNoThrow, #Name, 1, 1, 1, 1, \ 305 : Operator(IrOpcode::k##Name, Operator::kNoThrow, #Name, 1, 1, 1, 1, \
268 1, 1) {} \ 306 1, 1) {} \
269 }; \ 307 }; \
270 Name##Operator k##Name; 308 Name##Operator k##Name;
271 CHECKED_OP_LIST(CHECKED) 309 CHECKED_OP_LIST(CHECKED)
272 #undef CHECKED 310 #undef CHECKED
273 311
312 template <CheckFloat64HoleMode kMode>
313 struct CheckFloat64HoleNaNOperatortor final
314 : public Operator1<CheckFloat64HoleMode> {
315 CheckFloat64HoleNaNOperatortor()
316 : Operator1<CheckFloat64HoleMode>(
317 IrOpcode::kCheckFloat64Hole, Operator::kFoldable,
318 "CheckFloat64Hole", 1, 1, 1, 1, 1, 0, kMode) {}
319 };
320 CheckFloat64HoleNaNOperatortor<CheckFloat64HoleMode::kAllowReturnHole>
321 kCheckFloat64HoleAllowReturnHoleOperator;
322 CheckFloat64HoleNaNOperatortor<CheckFloat64HoleMode::kNeverReturnHole>
323 kCheckFloat64HoleNeverReturnHoleOperator;
324
325 template <CheckTaggedHoleMode kMode>
326 struct CheckTaggedHoleOperator final : public Operator1<CheckTaggedHoleMode> {
327 CheckTaggedHoleOperator()
328 : Operator1<CheckTaggedHoleMode>(IrOpcode::kCheckTaggedHole,
329 Operator::kFoldable, "CheckTaggedHole",
330 1, 1, 1, 1, 1, 0, kMode) {}
331 };
332 CheckTaggedHoleOperator<CheckTaggedHoleMode::kConvertHoleToUndefined>
333 kCheckTaggedHoleConvertHoleToUndefinedOperator;
334 CheckTaggedHoleOperator<CheckTaggedHoleMode::kNeverReturnHole>
335 kCheckTaggedHoleNeverReturnHoleOperator;
336
274 struct CheckIfOperator final : public Operator { 337 struct CheckIfOperator final : public Operator {
275 CheckIfOperator() 338 CheckIfOperator()
276 : Operator(IrOpcode::kCheckIf, Operator::kFoldable, "CheckIf", 1, 1, 1, 339 : Operator(IrOpcode::kCheckIf, Operator::kFoldable, "CheckIf", 1, 1, 1,
277 0, 1, 1) {} 340 0, 1, 1) {}
278 }; 341 };
279 CheckIfOperator kCheckIf; 342 CheckIfOperator kCheckIf;
280 343
281 template <PretenureFlag kPretenure> 344 template <PretenureFlag kPretenure>
282 struct AllocateOperator final : public Operator1<PretenureFlag> { 345 struct AllocateOperator final : public Operator1<PretenureFlag> {
283 AllocateOperator() 346 AllocateOperator()
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 #define GET_FROM_CACHE(Name, properties, input_count) \ 382 #define GET_FROM_CACHE(Name, properties, input_count) \
320 const Operator* SimplifiedOperatorBuilder::Name() { return &cache_.k##Name; } 383 const Operator* SimplifiedOperatorBuilder::Name() { return &cache_.k##Name; }
321 PURE_OP_LIST(GET_FROM_CACHE) 384 PURE_OP_LIST(GET_FROM_CACHE)
322 #undef GET_FROM_CACHE 385 #undef GET_FROM_CACHE
323 386
324 #define GET_FROM_CACHE(Name) \ 387 #define GET_FROM_CACHE(Name) \
325 const Operator* SimplifiedOperatorBuilder::Name() { return &cache_.k##Name; } 388 const Operator* SimplifiedOperatorBuilder::Name() { return &cache_.k##Name; }
326 CHECKED_OP_LIST(GET_FROM_CACHE) 389 CHECKED_OP_LIST(GET_FROM_CACHE)
327 #undef GET_FROM_CACHE 390 #undef GET_FROM_CACHE
328 391
392 const Operator* SimplifiedOperatorBuilder::CheckFloat64Hole(
393 CheckFloat64HoleMode mode) {
394 switch (mode) {
395 case CheckFloat64HoleMode::kAllowReturnHole:
396 return &cache_.kCheckFloat64HoleAllowReturnHoleOperator;
397 case CheckFloat64HoleMode::kNeverReturnHole:
398 return &cache_.kCheckFloat64HoleNeverReturnHoleOperator;
399 }
400 UNREACHABLE();
401 return nullptr;
402 }
403
404 const Operator* SimplifiedOperatorBuilder::CheckTaggedHole(
405 CheckTaggedHoleMode mode) {
406 switch (mode) {
407 case CheckTaggedHoleMode::kConvertHoleToUndefined:
408 return &cache_.kCheckTaggedHoleConvertHoleToUndefinedOperator;
409 case CheckTaggedHoleMode::kNeverReturnHole:
410 return &cache_.kCheckTaggedHoleNeverReturnHoleOperator;
411 }
412 UNREACHABLE();
413 return nullptr;
414 }
415
329 const Operator* SimplifiedOperatorBuilder::CheckIf() { 416 const Operator* SimplifiedOperatorBuilder::CheckIf() {
330 return &cache_.kCheckIf; 417 return &cache_.kCheckIf;
331 } 418 }
332 419
333 const Operator* SimplifiedOperatorBuilder::ReferenceEqual(Type* type) { 420 const Operator* SimplifiedOperatorBuilder::ReferenceEqual(Type* type) {
334 return new (zone()) Operator(IrOpcode::kReferenceEqual, 421 return new (zone()) Operator(IrOpcode::kReferenceEqual,
335 Operator::kCommutative | Operator::kPure, 422 Operator::kCommutative | Operator::kPure,
336 "ReferenceEqual", 2, 0, 0, 1, 0, 0); 423 "ReferenceEqual", 2, 0, 0, 1, 0, 0);
337 } 424 }
338 425
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 Operator1<Type>(IrOpcode::k##Name, Operator::kNoThrow | properties, \ 505 Operator1<Type>(IrOpcode::k##Name, Operator::kNoThrow | properties, \
419 #Name, value_input_count, 1, control_input_count, \ 506 #Name, value_input_count, 1, control_input_count, \
420 output_count, 1, 0, access); \ 507 output_count, 1, 0, access); \
421 } 508 }
422 ACCESS_OP_LIST(ACCESS) 509 ACCESS_OP_LIST(ACCESS)
423 #undef ACCESS 510 #undef ACCESS
424 511
425 } // namespace compiler 512 } // namespace compiler
426 } // namespace internal 513 } // namespace internal
427 } // namespace v8 514 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/simplified-operator.h ('k') | src/compiler/typer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698