| OLD | NEW |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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/type-hints.h" | 5 #include "src/compiler/type-hints.h" |
| 6 | 6 |
| 7 namespace v8 { | 7 namespace v8 { |
| 8 namespace internal { | 8 namespace internal { |
| 9 namespace compiler { | 9 namespace compiler { |
| 10 | 10 |
| 11 std::ostream& operator<<(std::ostream& os, BinaryOperationHints::Hint hint) { | 11 std::ostream& operator<<(std::ostream& os, BinaryOperationHints::Hint hint) { |
| 12 switch (hint) { | 12 switch (hint) { |
| 13 case BinaryOperationHints::kNone: | 13 case BinaryOperationHints::kNone: |
| 14 return os << "None"; | 14 return os << "None"; |
| 15 case BinaryOperationHints::kSignedSmall: | 15 case BinaryOperationHints::kSignedSmall: |
| 16 return os << "SignedSmall"; | 16 return os << "SignedSmall"; |
| 17 case BinaryOperationHints::kSigned32: | 17 case BinaryOperationHints::kSigned32: |
| 18 return os << "Signed32"; | 18 return os << "Signed32"; |
| 19 case BinaryOperationHints::kNumberOrUndefined: | 19 case BinaryOperationHints::kNumberOrUndefined: |
| 20 return os << "NumberOrUndefined"; | 20 return os << "NumberOrUndefined"; |
| 21 case BinaryOperationHints::kString: | 21 case BinaryOperationHints::kString: |
| 22 return os << "String"; | 22 return os << "String"; |
| 23 case BinaryOperationHints::kAny: | 23 case BinaryOperationHints::kAny: |
| 24 return os << "Any"; | 24 return os << "Any"; |
| 25 } | 25 } |
| 26 UNREACHABLE(); | 26 UNREACHABLE(); |
| 27 return os; | 27 return os; |
| 28 } | 28 } |
| 29 | 29 |
| 30 | |
| 31 std::ostream& operator<<(std::ostream& os, BinaryOperationHints hints) { | 30 std::ostream& operator<<(std::ostream& os, BinaryOperationHints hints) { |
| 32 return os << hints.left() << "*" << hints.right() << "->" << hints.result(); | 31 return os << hints.left() << "*" << hints.right() << "->" << hints.result(); |
| 33 } | 32 } |
| 34 | 33 |
| 34 std::ostream& operator<<(std::ostream& os, CompareOperationHints::Hint hint) { |
| 35 switch (hint) { |
| 36 case CompareOperationHints::kNone: |
| 37 return os << "None"; |
| 38 case CompareOperationHints::kBoolean: |
| 39 return os << "Boolean"; |
| 40 case CompareOperationHints::kSignedSmall: |
| 41 return os << "SignedSmall"; |
| 42 case CompareOperationHints::kNumber: |
| 43 return os << "Number"; |
| 44 case CompareOperationHints::kString: |
| 45 return os << "String"; |
| 46 case CompareOperationHints::kInternalizedString: |
| 47 return os << "InternalizedString"; |
| 48 case CompareOperationHints::kUniqueName: |
| 49 return os << "UniqueName"; |
| 50 case CompareOperationHints::kReceiver: |
| 51 return os << "Receiver"; |
| 52 case CompareOperationHints::kAny: |
| 53 return os << "Any"; |
| 54 } |
| 55 UNREACHABLE(); |
| 56 return os; |
| 57 } |
| 58 |
| 59 std::ostream& operator<<(std::ostream& os, CompareOperationHints hints) { |
| 60 return os << hints.left() << "*" << hints.right() << " (" << hints.combined() |
| 61 << ")"; |
| 62 } |
| 35 | 63 |
| 36 std::ostream& operator<<(std::ostream& os, ToBooleanHint hint) { | 64 std::ostream& operator<<(std::ostream& os, ToBooleanHint hint) { |
| 37 switch (hint) { | 65 switch (hint) { |
| 38 case ToBooleanHint::kNone: | 66 case ToBooleanHint::kNone: |
| 39 return os << "None"; | 67 return os << "None"; |
| 40 case ToBooleanHint::kUndefined: | 68 case ToBooleanHint::kUndefined: |
| 41 return os << "Undefined"; | 69 return os << "Undefined"; |
| 42 case ToBooleanHint::kBoolean: | 70 case ToBooleanHint::kBoolean: |
| 43 return os << "Boolean"; | 71 return os << "Boolean"; |
| 44 case ToBooleanHint::kNull: | 72 case ToBooleanHint::kNull: |
| (...skipping 10 matching lines...) Expand all Loading... |
| 55 return os << "HeapNumber"; | 83 return os << "HeapNumber"; |
| 56 case ToBooleanHint::kSimdValue: | 84 case ToBooleanHint::kSimdValue: |
| 57 return os << "SimdValue"; | 85 return os << "SimdValue"; |
| 58 case ToBooleanHint::kAny: | 86 case ToBooleanHint::kAny: |
| 59 return os << "Any"; | 87 return os << "Any"; |
| 60 } | 88 } |
| 61 UNREACHABLE(); | 89 UNREACHABLE(); |
| 62 return os; | 90 return os; |
| 63 } | 91 } |
| 64 | 92 |
| 65 | |
| 66 std::ostream& operator<<(std::ostream& os, ToBooleanHints hints) { | 93 std::ostream& operator<<(std::ostream& os, ToBooleanHints hints) { |
| 67 if (hints == ToBooleanHint::kAny) return os << "Any"; | 94 if (hints == ToBooleanHint::kAny) return os << "Any"; |
| 68 if (hints == ToBooleanHint::kNone) return os << "None"; | 95 if (hints == ToBooleanHint::kNone) return os << "None"; |
| 69 bool first = true; | 96 bool first = true; |
| 70 for (ToBooleanHints::mask_type i = 0; i < sizeof(i) * CHAR_BIT; ++i) { | 97 for (ToBooleanHints::mask_type i = 0; i < sizeof(i) * CHAR_BIT; ++i) { |
| 71 ToBooleanHint const hint = static_cast<ToBooleanHint>(1u << i); | 98 ToBooleanHint const hint = static_cast<ToBooleanHint>(1u << i); |
| 72 if (hints & hint) { | 99 if (hints & hint) { |
| 73 if (!first) os << "|"; | 100 if (!first) os << "|"; |
| 74 first = false; | 101 first = false; |
| 75 os << hint; | 102 os << hint; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 102 // static | 129 // static |
| 103 BinaryOperationHints::Hint BinaryOperationHints::Combine(Hint h1, Hint h2) { | 130 BinaryOperationHints::Hint BinaryOperationHints::Combine(Hint h1, Hint h2) { |
| 104 if (Is(h1, h2)) return h2; | 131 if (Is(h1, h2)) return h2; |
| 105 if (Is(h2, h1)) return h1; | 132 if (Is(h2, h1)) return h1; |
| 106 return kAny; | 133 return kAny; |
| 107 } | 134 } |
| 108 | 135 |
| 109 } // namespace compiler | 136 } // namespace compiler |
| 110 } // namespace internal | 137 } // namespace internal |
| 111 } // namespace v8 | 138 } // namespace v8 |
| OLD | NEW |