Index: src/compiler/common-operator.cc |
diff --git a/src/compiler/common-operator.cc b/src/compiler/common-operator.cc |
index 99e53a24abf6dc3c23f23830907ccc81f86c76a2..eb398d4c1ff5354f2e2bc8d3688d9bd98f35620a 100644 |
--- a/src/compiler/common-operator.cc |
+++ b/src/compiler/common-operator.cc |
@@ -50,6 +50,19 @@ |
return op->ValueInputCount() - 1; |
} |
+size_t hash_value(DeoptimizeKind kind) { return static_cast<size_t>(kind); } |
+ |
+std::ostream& operator<<(std::ostream& os, DeoptimizeKind kind) { |
+ switch (kind) { |
+ case DeoptimizeKind::kEager: |
+ return os << "Eager"; |
+ case DeoptimizeKind::kSoft: |
+ return os << "Soft"; |
+ } |
+ UNREACHABLE(); |
+ return os; |
+} |
+ |
bool operator==(DeoptimizeParameters lhs, DeoptimizeParameters rhs) { |
return lhs.kind() == rhs.kind() && lhs.reason() == rhs.reason(); |
} |
@@ -67,9 +80,7 @@ |
} |
DeoptimizeParameters const& DeoptimizeParametersOf(Operator const* const op) { |
- DCHECK(op->opcode() == IrOpcode::kDeoptimize || |
- op->opcode() == IrOpcode::kDeoptimizeIf || |
- op->opcode() == IrOpcode::kDeoptimizeUnless); |
+ DCHECK_EQ(IrOpcode::kDeoptimize, op->opcode()); |
return OpParameter<DeoptimizeParameters>(op); |
} |
@@ -425,22 +436,22 @@ |
V(Soft, InsufficientTypeFeedbackForGenericNamedAccess) |
#define CACHED_DEOPTIMIZE_IF_LIST(V) \ |
- V(Eager, DivisionByZero) \ |
- V(Eager, Hole) \ |
- V(Eager, MinusZero) \ |
- V(Eager, Overflow) \ |
- V(Eager, Smi) |
+ V(DivisionByZero) \ |
+ V(Hole) \ |
+ V(MinusZero) \ |
+ V(Overflow) \ |
+ V(Smi) |
#define CACHED_DEOPTIMIZE_UNLESS_LIST(V) \ |
- V(Eager, LostPrecision) \ |
- V(Eager, LostPrecisionOrNaN) \ |
- V(Eager, NoReason) \ |
- V(Eager, NotAHeapNumber) \ |
- V(Eager, NotANumberOrOddball) \ |
- V(Eager, NotASmi) \ |
- V(Eager, OutOfBounds) \ |
- V(Eager, WrongInstanceType) \ |
- V(Eager, WrongMap) |
+ V(LostPrecision) \ |
+ V(LostPrecisionOrNaN) \ |
+ V(NoReason) \ |
+ V(NotAHeapNumber) \ |
+ V(NotANumberOrOddball) \ |
+ V(NotASmi) \ |
+ V(OutOfBounds) \ |
+ V(WrongInstanceType) \ |
+ V(WrongMap) |
#define CACHED_TRAP_IF_LIST(V) \ |
V(TrapDivUnrepresentable) \ |
@@ -624,37 +635,35 @@ |
CACHED_DEOPTIMIZE_LIST(CACHED_DEOPTIMIZE) |
#undef CACHED_DEOPTIMIZE |
- template <DeoptimizeKind kKind, DeoptimizeReason kReason> |
- struct DeoptimizeIfOperator final : public Operator1<DeoptimizeParameters> { |
+ template <DeoptimizeReason kReason> |
+ struct DeoptimizeIfOperator final : public Operator1<DeoptimizeReason> { |
DeoptimizeIfOperator() |
- : Operator1<DeoptimizeParameters>( // -- |
+ : Operator1<DeoptimizeReason>( // -- |
IrOpcode::kDeoptimizeIf, // opcode |
Operator::kFoldable | Operator::kNoThrow, // properties |
"DeoptimizeIf", // name |
2, 1, 1, 0, 1, 1, // counts |
- DeoptimizeParameters(kKind, kReason)) {} // parameter |
- }; |
-#define CACHED_DEOPTIMIZE_IF(Kind, Reason) \ |
- DeoptimizeIfOperator<DeoptimizeKind::k##Kind, DeoptimizeReason::k##Reason> \ |
- kDeoptimizeIf##Kind##Reason##Operator; |
+ kReason) {} // parameter |
+ }; |
+#define CACHED_DEOPTIMIZE_IF(Reason) \ |
+ DeoptimizeIfOperator<DeoptimizeReason::k##Reason> \ |
+ kDeoptimizeIf##Reason##Operator; |
CACHED_DEOPTIMIZE_IF_LIST(CACHED_DEOPTIMIZE_IF) |
#undef CACHED_DEOPTIMIZE_IF |
- template <DeoptimizeKind kKind, DeoptimizeReason kReason> |
- struct DeoptimizeUnlessOperator final |
- : public Operator1<DeoptimizeParameters> { |
+ template <DeoptimizeReason kReason> |
+ struct DeoptimizeUnlessOperator final : public Operator1<DeoptimizeReason> { |
DeoptimizeUnlessOperator() |
- : Operator1<DeoptimizeParameters>( // -- |
+ : Operator1<DeoptimizeReason>( // -- |
IrOpcode::kDeoptimizeUnless, // opcode |
Operator::kFoldable | Operator::kNoThrow, // properties |
"DeoptimizeUnless", // name |
2, 1, 1, 0, 1, 1, // counts |
- DeoptimizeParameters(kKind, kReason)) {} // parameter |
- }; |
-#define CACHED_DEOPTIMIZE_UNLESS(Kind, Reason) \ |
- DeoptimizeUnlessOperator<DeoptimizeKind::k##Kind, \ |
- DeoptimizeReason::k##Reason> \ |
- kDeoptimizeUnless##Kind##Reason##Operator; |
+ kReason) {} // parameter |
+ }; |
+#define CACHED_DEOPTIMIZE_UNLESS(Reason) \ |
+ DeoptimizeUnlessOperator<DeoptimizeReason::k##Reason> \ |
+ kDeoptimizeUnless##Reason##Operator; |
CACHED_DEOPTIMIZE_UNLESS_LIST(CACHED_DEOPTIMIZE_UNLESS) |
#undef CACHED_DEOPTIMIZE_UNLESS |
@@ -850,42 +859,43 @@ |
parameter); // parameter |
} |
-const Operator* CommonOperatorBuilder::DeoptimizeIf(DeoptimizeKind kind, |
- DeoptimizeReason reason) { |
-#define CACHED_DEOPTIMIZE_IF(Kind, Reason) \ |
- if (kind == DeoptimizeKind::k##Kind && \ |
- reason == DeoptimizeReason::k##Reason) { \ |
- return &cache_.kDeoptimizeIf##Kind##Reason##Operator; \ |
- } |
- CACHED_DEOPTIMIZE_IF_LIST(CACHED_DEOPTIMIZE_IF) |
+const Operator* CommonOperatorBuilder::DeoptimizeIf(DeoptimizeReason reason) { |
+ switch (reason) { |
+#define CACHED_DEOPTIMIZE_IF(Reason) \ |
+ case DeoptimizeReason::k##Reason: \ |
+ return &cache_.kDeoptimizeIf##Reason##Operator; |
+ CACHED_DEOPTIMIZE_IF_LIST(CACHED_DEOPTIMIZE_IF) |
#undef CACHED_DEOPTIMIZE_IF |
+ default: |
+ break; |
+ } |
// Uncached |
- DeoptimizeParameters parameter(kind, reason); |
- return new (zone()) Operator1<DeoptimizeParameters>( // -- |
- IrOpcode::kDeoptimizeIf, // opcode |
- Operator::kFoldable | Operator::kNoThrow, // properties |
- "DeoptimizeIf", // name |
- 2, 1, 1, 0, 1, 1, // counts |
- parameter); // parameter |
+ return new (zone()) Operator1<DeoptimizeReason>( // -- |
+ IrOpcode::kDeoptimizeIf, // opcode |
+ Operator::kFoldable | Operator::kNoThrow, // properties |
+ "DeoptimizeIf", // name |
+ 2, 1, 1, 0, 1, 1, // counts |
+ reason); // parameter |
} |
const Operator* CommonOperatorBuilder::DeoptimizeUnless( |
- DeoptimizeKind kind, DeoptimizeReason reason) { |
-#define CACHED_DEOPTIMIZE_UNLESS(Kind, Reason) \ |
- if (kind == DeoptimizeKind::k##Kind && \ |
- reason == DeoptimizeReason::k##Reason) { \ |
- return &cache_.kDeoptimizeUnless##Kind##Reason##Operator; \ |
- } |
- CACHED_DEOPTIMIZE_UNLESS_LIST(CACHED_DEOPTIMIZE_UNLESS) |
+ DeoptimizeReason reason) { |
+ switch (reason) { |
+#define CACHED_DEOPTIMIZE_UNLESS(Reason) \ |
+ case DeoptimizeReason::k##Reason: \ |
+ return &cache_.kDeoptimizeUnless##Reason##Operator; |
+ CACHED_DEOPTIMIZE_UNLESS_LIST(CACHED_DEOPTIMIZE_UNLESS) |
#undef CACHED_DEOPTIMIZE_UNLESS |
+ default: |
+ break; |
+ } |
// Uncached |
- DeoptimizeParameters parameter(kind, reason); |
- return new (zone()) Operator1<DeoptimizeParameters>( // -- |
- IrOpcode::kDeoptimizeUnless, // opcode |
- Operator::kFoldable | Operator::kNoThrow, // properties |
- "DeoptimizeUnless", // name |
- 2, 1, 1, 0, 1, 1, // counts |
- parameter); // parameter |
+ return new (zone()) Operator1<DeoptimizeReason>( // -- |
+ IrOpcode::kDeoptimizeUnless, // opcode |
+ Operator::kFoldable | Operator::kNoThrow, // properties |
+ "DeoptimizeUnless", // name |
+ 2, 1, 1, 0, 1, 1, // counts |
+ reason); // parameter |
} |
const Operator* CommonOperatorBuilder::TrapIf(int32_t trap_id) { |