OLD | NEW |
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 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 V(StringLessThan, Operator::kNoProperties, 2) \ | 301 V(StringLessThan, Operator::kNoProperties, 2) \ |
302 V(StringLessThanOrEqual, Operator::kNoProperties, 2) | 302 V(StringLessThanOrEqual, Operator::kNoProperties, 2) |
303 | 303 |
304 #define SPECULATIVE_BINOP_LIST(V) \ | 304 #define SPECULATIVE_BINOP_LIST(V) \ |
305 V(SpeculativeNumberAdd) \ | 305 V(SpeculativeNumberAdd) \ |
306 V(SpeculativeNumberSubtract) \ | 306 V(SpeculativeNumberSubtract) \ |
307 V(SpeculativeNumberDivide) \ | 307 V(SpeculativeNumberDivide) \ |
308 V(SpeculativeNumberMultiply) \ | 308 V(SpeculativeNumberMultiply) \ |
309 V(SpeculativeNumberModulus) | 309 V(SpeculativeNumberModulus) |
310 | 310 |
311 #define CHECKED_OP_LIST(V) \ | 311 #define CHECKED_OP_LIST(V) \ |
312 V(CheckTaggedPointer) \ | 312 V(CheckTaggedPointer, 1) \ |
313 V(CheckTaggedSigned) \ | 313 V(CheckTaggedSigned, 1) \ |
314 V(CheckedUint32ToInt32) \ | 314 V(CheckedInt32Add, 2) \ |
315 V(CheckedFloat64ToInt32) \ | 315 V(CheckedInt32Sub, 2) \ |
316 V(CheckedTaggedToInt32) \ | 316 V(CheckedUint32ToInt32, 1) \ |
317 V(CheckedTaggedToFloat64) | 317 V(CheckedFloat64ToInt32, 1) \ |
| 318 V(CheckedTaggedToInt32, 1) \ |
| 319 V(CheckedTaggedToFloat64, 1) |
318 | 320 |
319 struct SimplifiedOperatorGlobalCache final { | 321 struct SimplifiedOperatorGlobalCache final { |
320 #define PURE(Name, properties, input_count) \ | 322 #define PURE(Name, properties, input_count) \ |
321 struct Name##Operator final : public Operator { \ | 323 struct Name##Operator final : public Operator { \ |
322 Name##Operator() \ | 324 Name##Operator() \ |
323 : Operator(IrOpcode::k##Name, Operator::kPure | properties, #Name, \ | 325 : Operator(IrOpcode::k##Name, Operator::kPure | properties, #Name, \ |
324 input_count, 0, 0, 1, 0, 0) {} \ | 326 input_count, 0, 0, 1, 0, 0) {} \ |
325 }; \ | 327 }; \ |
326 Name##Operator k##Name; | 328 Name##Operator k##Name; |
327 PURE_OP_LIST(PURE) | 329 PURE_OP_LIST(PURE) |
328 #undef PURE | 330 #undef PURE |
329 | 331 |
330 #define CHECKED(Name) \ | 332 #define CHECKED(Name, value_input_count) \ |
331 struct Name##Operator final : public Operator { \ | 333 struct Name##Operator final : public Operator { \ |
332 Name##Operator() \ | 334 Name##Operator() \ |
333 : Operator(IrOpcode::k##Name, \ | 335 : Operator(IrOpcode::k##Name, \ |
334 Operator::kFoldable | Operator::kNoThrow, #Name, 1, 1, 1, \ | 336 Operator::kFoldable | Operator::kNoThrow, #Name, \ |
335 1, 1, 0) {} \ | 337 value_input_count, 1, 1, 1, 1, 0) {} \ |
336 }; \ | 338 }; \ |
337 Name##Operator k##Name; | 339 Name##Operator k##Name; |
338 CHECKED_OP_LIST(CHECKED) | 340 CHECKED_OP_LIST(CHECKED) |
339 #undef CHECKED | 341 #undef CHECKED |
340 | 342 |
341 template <CheckFloat64HoleMode kMode> | 343 template <CheckFloat64HoleMode kMode> |
342 struct CheckFloat64HoleNaNOperatortor final | 344 struct CheckFloat64HoleNaNOperator final |
343 : public Operator1<CheckFloat64HoleMode> { | 345 : public Operator1<CheckFloat64HoleMode> { |
344 CheckFloat64HoleNaNOperatortor() | 346 CheckFloat64HoleNaNOperator() |
345 : Operator1<CheckFloat64HoleMode>( | 347 : Operator1<CheckFloat64HoleMode>( |
346 IrOpcode::kCheckFloat64Hole, | 348 IrOpcode::kCheckFloat64Hole, |
347 Operator::kFoldable | Operator::kNoDeopt, "CheckFloat64Hole", 1, | 349 Operator::kFoldable | Operator::kNoThrow, "CheckFloat64Hole", 1, |
348 1, 1, 1, 1, 0, kMode) {} | 350 1, 1, 1, 1, 0, kMode) {} |
349 }; | 351 }; |
350 CheckFloat64HoleNaNOperatortor<CheckFloat64HoleMode::kAllowReturnHole> | 352 CheckFloat64HoleNaNOperator<CheckFloat64HoleMode::kAllowReturnHole> |
351 kCheckFloat64HoleAllowReturnHoleOperator; | 353 kCheckFloat64HoleAllowReturnHoleOperator; |
352 CheckFloat64HoleNaNOperatortor<CheckFloat64HoleMode::kNeverReturnHole> | 354 CheckFloat64HoleNaNOperator<CheckFloat64HoleMode::kNeverReturnHole> |
353 kCheckFloat64HoleNeverReturnHoleOperator; | 355 kCheckFloat64HoleNeverReturnHoleOperator; |
354 | 356 |
355 template <CheckTaggedHoleMode kMode> | 357 template <CheckTaggedHoleMode kMode> |
356 struct CheckTaggedHoleOperator final : public Operator1<CheckTaggedHoleMode> { | 358 struct CheckTaggedHoleOperator final : public Operator1<CheckTaggedHoleMode> { |
357 CheckTaggedHoleOperator() | 359 CheckTaggedHoleOperator() |
358 : Operator1<CheckTaggedHoleMode>( | 360 : Operator1<CheckTaggedHoleMode>( |
359 IrOpcode::kCheckTaggedHole, | 361 IrOpcode::kCheckTaggedHole, |
360 Operator::kFoldable | Operator::kNoDeopt, "CheckTaggedHole", 1, 1, | 362 Operator::kFoldable | Operator::kNoThrow, "CheckTaggedHole", 1, 1, |
361 1, 1, 1, 0, kMode) {} | 363 1, 1, 1, 0, kMode) {} |
362 }; | 364 }; |
363 CheckTaggedHoleOperator<CheckTaggedHoleMode::kConvertHoleToUndefined> | 365 CheckTaggedHoleOperator<CheckTaggedHoleMode::kConvertHoleToUndefined> |
364 kCheckTaggedHoleConvertHoleToUndefinedOperator; | 366 kCheckTaggedHoleConvertHoleToUndefinedOperator; |
365 CheckTaggedHoleOperator<CheckTaggedHoleMode::kNeverReturnHole> | 367 CheckTaggedHoleOperator<CheckTaggedHoleMode::kNeverReturnHole> |
366 kCheckTaggedHoleNeverReturnHoleOperator; | 368 kCheckTaggedHoleNeverReturnHoleOperator; |
367 | 369 |
368 struct CheckIfOperator final : public Operator { | |
369 CheckIfOperator() | |
370 : Operator(IrOpcode::kCheckIf, Operator::kFoldable | Operator::kNoDeopt, | |
371 "CheckIf", 1, 1, 1, 0, 1, 0) {} | |
372 }; | |
373 CheckIfOperator kCheckIf; | |
374 | |
375 template <PretenureFlag kPretenure> | 370 template <PretenureFlag kPretenure> |
376 struct AllocateOperator final : public Operator1<PretenureFlag> { | 371 struct AllocateOperator final : public Operator1<PretenureFlag> { |
377 AllocateOperator() | 372 AllocateOperator() |
378 : Operator1<PretenureFlag>( | 373 : Operator1<PretenureFlag>( |
379 IrOpcode::kAllocate, | 374 IrOpcode::kAllocate, |
380 Operator::kNoDeopt | Operator::kNoThrow | Operator::kNoWrite, | 375 Operator::kNoDeopt | Operator::kNoThrow | Operator::kNoWrite, |
381 "Allocate", 1, 1, 1, 1, 1, 0, kPretenure) {} | 376 "Allocate", 1, 1, 1, 1, 1, 0, kPretenure) {} |
382 }; | 377 }; |
383 AllocateOperator<NOT_TENURED> kAllocateNotTenuredOperator; | 378 AllocateOperator<NOT_TENURED> kAllocateNotTenuredOperator; |
384 AllocateOperator<TENURED> kAllocateTenuredOperator; | 379 AllocateOperator<TENURED> kAllocateTenuredOperator; |
(...skipping 27 matching lines...) Expand all Loading... |
412 | 407 |
413 | 408 |
414 SimplifiedOperatorBuilder::SimplifiedOperatorBuilder(Zone* zone) | 409 SimplifiedOperatorBuilder::SimplifiedOperatorBuilder(Zone* zone) |
415 : cache_(kCache.Get()), zone_(zone) {} | 410 : cache_(kCache.Get()), zone_(zone) {} |
416 | 411 |
417 #define GET_FROM_CACHE(Name, properties, input_count) \ | 412 #define GET_FROM_CACHE(Name, properties, input_count) \ |
418 const Operator* SimplifiedOperatorBuilder::Name() { return &cache_.k##Name; } | 413 const Operator* SimplifiedOperatorBuilder::Name() { return &cache_.k##Name; } |
419 PURE_OP_LIST(GET_FROM_CACHE) | 414 PURE_OP_LIST(GET_FROM_CACHE) |
420 #undef GET_FROM_CACHE | 415 #undef GET_FROM_CACHE |
421 | 416 |
422 #define GET_FROM_CACHE(Name) \ | 417 #define GET_FROM_CACHE(Name, value_input_count) \ |
423 const Operator* SimplifiedOperatorBuilder::Name() { return &cache_.k##Name; } | 418 const Operator* SimplifiedOperatorBuilder::Name() { return &cache_.k##Name; } |
424 CHECKED_OP_LIST(GET_FROM_CACHE) | 419 CHECKED_OP_LIST(GET_FROM_CACHE) |
425 #undef GET_FROM_CACHE | 420 #undef GET_FROM_CACHE |
426 | 421 |
427 const Operator* SimplifiedOperatorBuilder::CheckFloat64Hole( | 422 const Operator* SimplifiedOperatorBuilder::CheckFloat64Hole( |
428 CheckFloat64HoleMode mode) { | 423 CheckFloat64HoleMode mode) { |
429 switch (mode) { | 424 switch (mode) { |
430 case CheckFloat64HoleMode::kAllowReturnHole: | 425 case CheckFloat64HoleMode::kAllowReturnHole: |
431 return &cache_.kCheckFloat64HoleAllowReturnHoleOperator; | 426 return &cache_.kCheckFloat64HoleAllowReturnHoleOperator; |
432 case CheckFloat64HoleMode::kNeverReturnHole: | 427 case CheckFloat64HoleMode::kNeverReturnHole: |
433 return &cache_.kCheckFloat64HoleNeverReturnHoleOperator; | 428 return &cache_.kCheckFloat64HoleNeverReturnHoleOperator; |
434 } | 429 } |
435 UNREACHABLE(); | 430 UNREACHABLE(); |
436 return nullptr; | 431 return nullptr; |
437 } | 432 } |
438 | 433 |
439 const Operator* SimplifiedOperatorBuilder::CheckTaggedHole( | 434 const Operator* SimplifiedOperatorBuilder::CheckTaggedHole( |
440 CheckTaggedHoleMode mode) { | 435 CheckTaggedHoleMode mode) { |
441 switch (mode) { | 436 switch (mode) { |
442 case CheckTaggedHoleMode::kConvertHoleToUndefined: | 437 case CheckTaggedHoleMode::kConvertHoleToUndefined: |
443 return &cache_.kCheckTaggedHoleConvertHoleToUndefinedOperator; | 438 return &cache_.kCheckTaggedHoleConvertHoleToUndefinedOperator; |
444 case CheckTaggedHoleMode::kNeverReturnHole: | 439 case CheckTaggedHoleMode::kNeverReturnHole: |
445 return &cache_.kCheckTaggedHoleNeverReturnHoleOperator; | 440 return &cache_.kCheckTaggedHoleNeverReturnHoleOperator; |
446 } | 441 } |
447 UNREACHABLE(); | 442 UNREACHABLE(); |
448 return nullptr; | 443 return nullptr; |
449 } | 444 } |
450 | 445 |
451 const Operator* SimplifiedOperatorBuilder::CheckIf() { | |
452 return &cache_.kCheckIf; | |
453 } | |
454 | |
455 const Operator* SimplifiedOperatorBuilder::ReferenceEqual(Type* type) { | 446 const Operator* SimplifiedOperatorBuilder::ReferenceEqual(Type* type) { |
456 return new (zone()) Operator(IrOpcode::kReferenceEqual, | 447 return new (zone()) Operator(IrOpcode::kReferenceEqual, |
457 Operator::kCommutative | Operator::kPure, | 448 Operator::kCommutative | Operator::kPure, |
458 "ReferenceEqual", 2, 0, 0, 1, 0, 0); | 449 "ReferenceEqual", 2, 0, 0, 1, 0, 0); |
459 } | 450 } |
460 | 451 |
461 const Operator* SimplifiedOperatorBuilder::CheckBounds() { | 452 const Operator* SimplifiedOperatorBuilder::CheckBounds() { |
462 // TODO(bmeurer): Cache this operator. Make it pure! | 453 // TODO(bmeurer): Cache this operator. Make it pure! |
463 return new (zone()) | 454 return new (zone()) |
464 Operator(IrOpcode::kCheckBounds, Operator::kFoldable | Operator::kNoThrow, | 455 Operator(IrOpcode::kCheckBounds, Operator::kFoldable | Operator::kNoThrow, |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
567 Operator::kNoDeopt | Operator::kNoThrow | properties, \ | 558 Operator::kNoDeopt | Operator::kNoThrow | properties, \ |
568 #Name, value_input_count, 1, control_input_count, \ | 559 #Name, value_input_count, 1, control_input_count, \ |
569 output_count, 1, 0, access); \ | 560 output_count, 1, 0, access); \ |
570 } | 561 } |
571 ACCESS_OP_LIST(ACCESS) | 562 ACCESS_OP_LIST(ACCESS) |
572 #undef ACCESS | 563 #undef ACCESS |
573 | 564 |
574 } // namespace compiler | 565 } // namespace compiler |
575 } // namespace internal | 566 } // namespace internal |
576 } // namespace v8 | 567 } // namespace v8 |
OLD | NEW |