OLD | NEW |
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/common-operator.h" | 5 #include "src/compiler/common-operator.h" |
6 | 6 |
7 #include "src/assembler.h" | 7 #include "src/assembler.h" |
8 #include "src/base/lazy-instance.h" | 8 #include "src/base/lazy-instance.h" |
9 #include "src/compiler/linkage.h" | 9 #include "src/compiler/linkage.h" |
10 #include "src/compiler/opcodes.h" | 10 #include "src/compiler/opcodes.h" |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 V(LostPrecision) \ | 323 V(LostPrecision) \ |
324 V(LostPrecisionOrNaN) \ | 324 V(LostPrecisionOrNaN) \ |
325 V(NoReason) \ | 325 V(NoReason) \ |
326 V(NotAHeapNumber) \ | 326 V(NotAHeapNumber) \ |
327 V(NotANumberOrOddball) \ | 327 V(NotANumberOrOddball) \ |
328 V(NotASmi) \ | 328 V(NotASmi) \ |
329 V(OutOfBounds) \ | 329 V(OutOfBounds) \ |
330 V(WrongInstanceType) \ | 330 V(WrongInstanceType) \ |
331 V(WrongMap) | 331 V(WrongMap) |
332 | 332 |
| 333 #define CACHED_TRAP_IF_LIST(V) \ |
| 334 V(TrapDivUnrepresentable) \ |
| 335 V(TrapFloatUnrepresentable) |
| 336 |
| 337 // The reason for a trap. |
| 338 #define CACHED_TRAP_UNLESS_LIST(V) \ |
| 339 V(TrapUnreachable) \ |
| 340 V(TrapMemOutOfBounds) \ |
| 341 V(TrapDivByZero) \ |
| 342 V(TrapDivUnrepresentable) \ |
| 343 V(TrapRemByZero) \ |
| 344 V(TrapFloatUnrepresentable) \ |
| 345 V(TrapFuncInvalid) \ |
| 346 V(TrapFuncSigMismatch) |
| 347 |
333 #define CACHED_PARAMETER_LIST(V) \ | 348 #define CACHED_PARAMETER_LIST(V) \ |
334 V(0) \ | 349 V(0) \ |
335 V(1) \ | 350 V(1) \ |
336 V(2) \ | 351 V(2) \ |
337 V(3) \ | 352 V(3) \ |
338 V(4) \ | 353 V(4) \ |
339 V(5) \ | 354 V(5) \ |
340 V(6) | 355 V(6) |
341 | 356 |
342 | 357 |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
522 "DeoptimizeUnless", // name | 537 "DeoptimizeUnless", // name |
523 2, 1, 1, 0, 1, 1, // counts | 538 2, 1, 1, 0, 1, 1, // counts |
524 kReason) {} // parameter | 539 kReason) {} // parameter |
525 }; | 540 }; |
526 #define CACHED_DEOPTIMIZE_UNLESS(Reason) \ | 541 #define CACHED_DEOPTIMIZE_UNLESS(Reason) \ |
527 DeoptimizeUnlessOperator<DeoptimizeReason::k##Reason> \ | 542 DeoptimizeUnlessOperator<DeoptimizeReason::k##Reason> \ |
528 kDeoptimizeUnless##Reason##Operator; | 543 kDeoptimizeUnless##Reason##Operator; |
529 CACHED_DEOPTIMIZE_UNLESS_LIST(CACHED_DEOPTIMIZE_UNLESS) | 544 CACHED_DEOPTIMIZE_UNLESS_LIST(CACHED_DEOPTIMIZE_UNLESS) |
530 #undef CACHED_DEOPTIMIZE_UNLESS | 545 #undef CACHED_DEOPTIMIZE_UNLESS |
531 | 546 |
| 547 template <int32_t trap_id> |
| 548 struct TrapIfOperator final : public Operator1<int32_t> { |
| 549 TrapIfOperator() |
| 550 : Operator1<int32_t>( // -- |
| 551 IrOpcode::kTrapIf, // opcode |
| 552 Operator::kFoldable | Operator::kNoThrow, // properties |
| 553 "TrapIf", // name |
| 554 1, 1, 1, 0, 0, 1, // counts |
| 555 trap_id) {} // parameter |
| 556 }; |
| 557 #define CACHED_TRAP_IF(Trap) \ |
| 558 TrapIfOperator<static_cast<int32_t>(Runtime::kThrowWasm##Trap)> \ |
| 559 kTrapIf##Trap##Operator; |
| 560 CACHED_TRAP_IF_LIST(CACHED_TRAP_IF) |
| 561 #undef CACHED_TRAP_IF |
| 562 |
| 563 template <int32_t trap_id> |
| 564 struct TrapUnlessOperator final : public Operator1<int32_t> { |
| 565 TrapUnlessOperator() |
| 566 : Operator1<int32_t>( // -- |
| 567 IrOpcode::kTrapUnless, // opcode |
| 568 Operator::kFoldable | Operator::kNoThrow, // properties |
| 569 "TrapUnless", // name |
| 570 1, 1, 1, 0, 0, 1, // counts |
| 571 trap_id) {} // parameter |
| 572 }; |
| 573 #define CACHED_TRAP_UNLESS(Trap) \ |
| 574 TrapUnlessOperator<static_cast<int32_t>(Runtime::kThrowWasm##Trap)> \ |
| 575 kTrapUnless##Trap##Operator; |
| 576 CACHED_TRAP_UNLESS_LIST(CACHED_TRAP_UNLESS) |
| 577 #undef CACHED_TRAP_UNLESS |
| 578 |
532 template <MachineRepresentation kRep, int kInputCount> | 579 template <MachineRepresentation kRep, int kInputCount> |
533 struct PhiOperator final : public Operator1<MachineRepresentation> { | 580 struct PhiOperator final : public Operator1<MachineRepresentation> { |
534 PhiOperator() | 581 PhiOperator() |
535 : Operator1<MachineRepresentation>( //-- | 582 : Operator1<MachineRepresentation>( //-- |
536 IrOpcode::kPhi, Operator::kPure, // opcode | 583 IrOpcode::kPhi, Operator::kPure, // opcode |
537 "Phi", // name | 584 "Phi", // name |
538 kInputCount, 0, 1, 1, 0, 0, // counts | 585 kInputCount, 0, 1, 1, 0, 0, // counts |
539 kRep) {} // parameter | 586 kRep) {} // parameter |
540 }; | 587 }; |
541 #define CACHED_PHI(rep, input_count) \ | 588 #define CACHED_PHI(rep, input_count) \ |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
720 } | 767 } |
721 // Uncached | 768 // Uncached |
722 return new (zone()) Operator1<DeoptimizeReason>( // -- | 769 return new (zone()) Operator1<DeoptimizeReason>( // -- |
723 IrOpcode::kDeoptimizeUnless, // opcode | 770 IrOpcode::kDeoptimizeUnless, // opcode |
724 Operator::kFoldable | Operator::kNoThrow, // properties | 771 Operator::kFoldable | Operator::kNoThrow, // properties |
725 "DeoptimizeUnless", // name | 772 "DeoptimizeUnless", // name |
726 2, 1, 1, 0, 1, 1, // counts | 773 2, 1, 1, 0, 1, 1, // counts |
727 reason); // parameter | 774 reason); // parameter |
728 } | 775 } |
729 | 776 |
| 777 const Operator* CommonOperatorBuilder::TrapIf(int32_t trap_id) { |
| 778 switch (trap_id) { |
| 779 #define CACHED_TRAP_IF(Trap) \ |
| 780 case Runtime::kThrowWasm##Trap: \ |
| 781 return &cache_.kTrapIf##Trap##Operator; |
| 782 CACHED_TRAP_IF_LIST(CACHED_TRAP_IF) |
| 783 #undef CACHED_TRAP_IF |
| 784 default: |
| 785 break; |
| 786 } |
| 787 // Uncached |
| 788 return new (zone()) Operator1<int>( // -- |
| 789 IrOpcode::kTrapIf, // opcode |
| 790 Operator::kFoldable | Operator::kNoThrow, // properties |
| 791 "TrapIf", // name |
| 792 1, 1, 1, 0, 0, 1, // counts |
| 793 trap_id); // parameter |
| 794 } |
| 795 |
| 796 const Operator* CommonOperatorBuilder::TrapUnless(int32_t trap_id) { |
| 797 switch (trap_id) { |
| 798 #define CACHED_TRAP_UNLESS(Trap) \ |
| 799 case Runtime::kThrowWasm##Trap: \ |
| 800 return &cache_.kTrapUnless##Trap##Operator; |
| 801 CACHED_TRAP_UNLESS_LIST(CACHED_TRAP_UNLESS) |
| 802 #undef CACHED_TRAP_UNLESS |
| 803 default: |
| 804 break; |
| 805 } |
| 806 // Uncached |
| 807 return new (zone()) Operator1<int>( // -- |
| 808 IrOpcode::kTrapUnless, // opcode |
| 809 Operator::kFoldable | Operator::kNoThrow, // properties |
| 810 "TrapUnless", // name |
| 811 1, 1, 1, 0, 0, 1, // counts |
| 812 trap_id); // parameter |
| 813 } |
730 | 814 |
731 const Operator* CommonOperatorBuilder::Switch(size_t control_output_count) { | 815 const Operator* CommonOperatorBuilder::Switch(size_t control_output_count) { |
732 return new (zone()) Operator( // -- | 816 return new (zone()) Operator( // -- |
733 IrOpcode::kSwitch, Operator::kKontrol, // opcode | 817 IrOpcode::kSwitch, Operator::kKontrol, // opcode |
734 "Switch", // name | 818 "Switch", // name |
735 1, 0, 1, 0, 0, control_output_count); // counts | 819 1, 0, 1, 0, 0, control_output_count); // counts |
736 } | 820 } |
737 | 821 |
738 | 822 |
739 const Operator* CommonOperatorBuilder::IfValue(int32_t index) { | 823 const Operator* CommonOperatorBuilder::IfValue(int32_t index) { |
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1173 CommonOperatorBuilder::CreateFrameStateFunctionInfo( | 1257 CommonOperatorBuilder::CreateFrameStateFunctionInfo( |
1174 FrameStateType type, int parameter_count, int local_count, | 1258 FrameStateType type, int parameter_count, int local_count, |
1175 Handle<SharedFunctionInfo> shared_info) { | 1259 Handle<SharedFunctionInfo> shared_info) { |
1176 return new (zone()->New(sizeof(FrameStateFunctionInfo))) | 1260 return new (zone()->New(sizeof(FrameStateFunctionInfo))) |
1177 FrameStateFunctionInfo(type, parameter_count, local_count, shared_info); | 1261 FrameStateFunctionInfo(type, parameter_count, local_count, shared_info); |
1178 } | 1262 } |
1179 | 1263 |
1180 } // namespace compiler | 1264 } // namespace compiler |
1181 } // namespace internal | 1265 } // namespace internal |
1182 } // namespace v8 | 1266 } // namespace v8 |
OLD | NEW |