| 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 | 68 |
| 69 std::ostream& operator<<(std::ostream& os, DeoptimizeParameters p) { | 69 std::ostream& operator<<(std::ostream& os, DeoptimizeParameters p) { |
| 70 return os << p.kind() << ":" << p.reason(); | 70 return os << p.kind() << ":" << p.reason(); |
| 71 } | 71 } |
| 72 | 72 |
| 73 DeoptimizeParameters const& DeoptimizeParametersOf(Operator const* const op) { | 73 DeoptimizeParameters const& DeoptimizeParametersOf(Operator const* const op) { |
| 74 DCHECK_EQ(IrOpcode::kDeoptimize, op->opcode()); | 74 DCHECK_EQ(IrOpcode::kDeoptimize, op->opcode()); |
| 75 return OpParameter<DeoptimizeParameters>(op); | 75 return OpParameter<DeoptimizeParameters>(op); |
| 76 } | 76 } |
| 77 | 77 |
| 78 IfExceptionHint ExceptionHintFromCatchPrediction( |
| 79 HandlerTable::CatchPrediction prediction) { |
| 80 switch (prediction) { |
| 81 case HandlerTable::UNCAUGHT: |
| 82 return IfExceptionHint::kLocallyUncaught; |
| 83 case HandlerTable::CAUGHT: |
| 84 return IfExceptionHint::kLocallyCaught; |
| 85 case HandlerTable::PROMISE: |
| 86 return IfExceptionHint::kLocallyCaughtForPromiseReject; |
| 87 } |
| 88 UNREACHABLE(); |
| 89 return IfExceptionHint::kLocallyUncaught; |
| 90 } |
| 91 |
| 78 size_t hash_value(IfExceptionHint hint) { return static_cast<size_t>(hint); } | 92 size_t hash_value(IfExceptionHint hint) { return static_cast<size_t>(hint); } |
| 79 | 93 |
| 80 | 94 |
| 81 std::ostream& operator<<(std::ostream& os, IfExceptionHint hint) { | 95 std::ostream& operator<<(std::ostream& os, IfExceptionHint hint) { |
| 82 switch (hint) { | 96 switch (hint) { |
| 97 case IfExceptionHint::kLocallyUncaught: |
| 98 return os << "Uncaught"; |
| 83 case IfExceptionHint::kLocallyCaught: | 99 case IfExceptionHint::kLocallyCaught: |
| 84 return os << "Caught"; | 100 return os << "Caught"; |
| 85 case IfExceptionHint::kLocallyUncaught: | 101 case IfExceptionHint::kLocallyCaughtForPromiseReject: |
| 86 return os << "Uncaught"; | 102 return os << "CaughtForPromiseReject"; |
| 87 } | 103 } |
| 88 UNREACHABLE(); | 104 UNREACHABLE(); |
| 89 return os; | 105 return os; |
| 90 } | 106 } |
| 91 | 107 |
| 92 | 108 |
| 93 bool operator==(SelectParameters const& lhs, SelectParameters const& rhs) { | 109 bool operator==(SelectParameters const& lhs, SelectParameters const& rhs) { |
| 94 return lhs.representation() == rhs.representation() && | 110 return lhs.representation() == rhs.representation() && |
| 95 lhs.hint() == rhs.hint(); | 111 lhs.hint() == rhs.hint(); |
| 96 } | 112 } |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 | 354 |
| 339 template <IfExceptionHint kCaughtLocally> | 355 template <IfExceptionHint kCaughtLocally> |
| 340 struct IfExceptionOperator final : public Operator1<IfExceptionHint> { | 356 struct IfExceptionOperator final : public Operator1<IfExceptionHint> { |
| 341 IfExceptionOperator() | 357 IfExceptionOperator() |
| 342 : Operator1<IfExceptionHint>( // -- | 358 : Operator1<IfExceptionHint>( // -- |
| 343 IrOpcode::kIfException, Operator::kKontrol, // opcode | 359 IrOpcode::kIfException, Operator::kKontrol, // opcode |
| 344 "IfException", // name | 360 "IfException", // name |
| 345 0, 1, 1, 1, 1, 1, // counts | 361 0, 1, 1, 1, 1, 1, // counts |
| 346 kCaughtLocally) {} // parameter | 362 kCaughtLocally) {} // parameter |
| 347 }; | 363 }; |
| 364 IfExceptionOperator<IfExceptionHint::kLocallyUncaught> kIfExceptionUOperator; |
| 348 IfExceptionOperator<IfExceptionHint::kLocallyCaught> kIfExceptionCOperator; | 365 IfExceptionOperator<IfExceptionHint::kLocallyCaught> kIfExceptionCOperator; |
| 349 IfExceptionOperator<IfExceptionHint::kLocallyUncaught> kIfExceptionUOperator; | 366 IfExceptionOperator<IfExceptionHint::kLocallyCaughtForPromiseReject> |
| 367 kIfExceptionPOperator; |
| 350 | 368 |
| 351 template <size_t kInputCount> | 369 template <size_t kInputCount> |
| 352 struct EndOperator final : public Operator { | 370 struct EndOperator final : public Operator { |
| 353 EndOperator() | 371 EndOperator() |
| 354 : Operator( // -- | 372 : Operator( // -- |
| 355 IrOpcode::kEnd, Operator::kKontrol, // opcode | 373 IrOpcode::kEnd, Operator::kKontrol, // opcode |
| 356 "End", // name | 374 "End", // name |
| 357 0, 0, kInputCount, 0, 0, 0) {} // counts | 375 0, 0, kInputCount, 0, 0, 0) {} // counts |
| 358 }; | 376 }; |
| 359 #define CACHED_END(input_count) \ | 377 #define CACHED_END(input_count) \ |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 595 return new (zone()) Operator1<DeoptimizeReason>( // -- | 613 return new (zone()) Operator1<DeoptimizeReason>( // -- |
| 596 IrOpcode::kDeoptimizeUnless, // opcode | 614 IrOpcode::kDeoptimizeUnless, // opcode |
| 597 Operator::kFoldable | Operator::kNoThrow, // properties | 615 Operator::kFoldable | Operator::kNoThrow, // properties |
| 598 "DeoptimizeUnless", // name | 616 "DeoptimizeUnless", // name |
| 599 2, 1, 1, 0, 1, 1, // counts | 617 2, 1, 1, 0, 1, 1, // counts |
| 600 reason); // parameter | 618 reason); // parameter |
| 601 } | 619 } |
| 602 | 620 |
| 603 const Operator* CommonOperatorBuilder::IfException(IfExceptionHint hint) { | 621 const Operator* CommonOperatorBuilder::IfException(IfExceptionHint hint) { |
| 604 switch (hint) { | 622 switch (hint) { |
| 623 case IfExceptionHint::kLocallyUncaught: |
| 624 return &cache_.kIfExceptionUOperator; |
| 605 case IfExceptionHint::kLocallyCaught: | 625 case IfExceptionHint::kLocallyCaught: |
| 606 return &cache_.kIfExceptionCOperator; | 626 return &cache_.kIfExceptionCOperator; |
| 607 case IfExceptionHint::kLocallyUncaught: | 627 case IfExceptionHint::kLocallyCaughtForPromiseReject: |
| 608 return &cache_.kIfExceptionUOperator; | 628 return &cache_.kIfExceptionPOperator; |
| 609 } | 629 } |
| 610 UNREACHABLE(); | 630 UNREACHABLE(); |
| 611 return nullptr; | 631 return nullptr; |
| 612 } | 632 } |
| 613 | 633 |
| 614 | 634 |
| 615 const Operator* CommonOperatorBuilder::Switch(size_t control_output_count) { | 635 const Operator* CommonOperatorBuilder::Switch(size_t control_output_count) { |
| 616 return new (zone()) Operator( // -- | 636 return new (zone()) Operator( // -- |
| 617 IrOpcode::kSwitch, Operator::kKontrol, // opcode | 637 IrOpcode::kSwitch, Operator::kKontrol, // opcode |
| 618 "Switch", // name | 638 "Switch", // name |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 972 CommonOperatorBuilder::CreateFrameStateFunctionInfo( | 992 CommonOperatorBuilder::CreateFrameStateFunctionInfo( |
| 973 FrameStateType type, int parameter_count, int local_count, | 993 FrameStateType type, int parameter_count, int local_count, |
| 974 Handle<SharedFunctionInfo> shared_info) { | 994 Handle<SharedFunctionInfo> shared_info) { |
| 975 return new (zone()->New(sizeof(FrameStateFunctionInfo))) | 995 return new (zone()->New(sizeof(FrameStateFunctionInfo))) |
| 976 FrameStateFunctionInfo(type, parameter_count, local_count, shared_info); | 996 FrameStateFunctionInfo(type, parameter_count, local_count, shared_info); |
| 977 } | 997 } |
| 978 | 998 |
| 979 } // namespace compiler | 999 } // namespace compiler |
| 980 } // namespace internal | 1000 } // namespace internal |
| 981 } // namespace v8 | 1001 } // namespace v8 |
| OLD | NEW |