Index: src/compiler/type-hints.cc |
diff --git a/src/compiler/type-hints.cc b/src/compiler/type-hints.cc |
index 06abad6380ef77f15981b41454c716311d89ce59..19ebd2f24cd7f4eeeadc717eaa491a0f8dafc12e 100644 |
--- a/src/compiler/type-hints.cc |
+++ b/src/compiler/type-hints.cc |
@@ -16,8 +16,8 @@ std::ostream& operator<<(std::ostream& os, BinaryOperationHints::Hint hint) { |
return os << "SignedSmall"; |
case BinaryOperationHints::kSigned32: |
return os << "Signed32"; |
- case BinaryOperationHints::kNumber: |
- return os << "Number"; |
+ case BinaryOperationHints::kNumberOrUndefined: |
+ return os << "NumberOrUndefined"; |
case BinaryOperationHints::kString: |
return os << "String"; |
case BinaryOperationHints::kAny: |
@@ -78,6 +78,34 @@ std::ostream& operator<<(std::ostream& os, ToBooleanHints hints) { |
return os; |
} |
+// static |
+bool BinaryOperationHints::Is(Hint h1, Hint h2) { |
+ if (h1 == h2) return true; |
+ switch (h1) { |
+ case kNone: |
+ return true; |
+ case kSignedSmall: |
+ return h2 == kSigned32 || h2 == kNumberOrUndefined || h2 == kAny; |
+ case kSigned32: |
+ return h2 == kNumberOrUndefined || h2 == kAny; |
+ case kNumberOrUndefined: |
+ return h2 == kAny; |
+ case kString: |
+ return h2 == kAny; |
+ case kAny: |
+ return false; |
+ } |
+ UNREACHABLE(); |
+ return false; |
+} |
+ |
+// static |
+BinaryOperationHints::Hint BinaryOperationHints::Combine(Hint h1, Hint h2) { |
+ if (Is(h1, h2)) return h2; |
+ if (Is(h2, h1)) return h1; |
+ return kAny; |
+} |
+ |
} // namespace compiler |
} // namespace internal |
} // namespace v8 |