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::kNumberOrOddball: |
20 return os << "NumberOrUndefined"; | 20 return os << "NumberOrOddball"; |
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 std::ostream& operator<<(std::ostream& os, BinaryOperationHints hints) { | 30 std::ostream& operator<<(std::ostream& os, BinaryOperationHints hints) { |
31 return os << hints.left() << "*" << hints.right() << "->" << hints.result(); | 31 return os << hints.left() << "*" << hints.right() << "->" << hints.result(); |
32 } | 32 } |
33 | 33 |
34 std::ostream& operator<<(std::ostream& os, CompareOperationHints::Hint hint) { | 34 std::ostream& operator<<(std::ostream& os, CompareOperationHints::Hint hint) { |
35 switch (hint) { | 35 switch (hint) { |
36 case CompareOperationHints::kNone: | 36 case CompareOperationHints::kNone: |
37 return os << "None"; | 37 return os << "None"; |
38 case CompareOperationHints::kBoolean: | 38 case CompareOperationHints::kBoolean: |
39 return os << "Boolean"; | 39 return os << "Boolean"; |
40 case CompareOperationHints::kSignedSmall: | 40 case CompareOperationHints::kSignedSmall: |
41 return os << "SignedSmall"; | 41 return os << "SignedSmall"; |
42 case CompareOperationHints::kNumber: | 42 case CompareOperationHints::kNumberOrOddball: |
43 return os << "Number"; | 43 return os << "NumberOrOddball"; |
44 case CompareOperationHints::kString: | 44 case CompareOperationHints::kString: |
45 return os << "String"; | 45 return os << "String"; |
46 case CompareOperationHints::kInternalizedString: | 46 case CompareOperationHints::kInternalizedString: |
47 return os << "InternalizedString"; | 47 return os << "InternalizedString"; |
48 case CompareOperationHints::kUniqueName: | 48 case CompareOperationHints::kUniqueName: |
49 return os << "UniqueName"; | 49 return os << "UniqueName"; |
50 case CompareOperationHints::kReceiver: | 50 case CompareOperationHints::kReceiver: |
51 return os << "Receiver"; | 51 return os << "Receiver"; |
52 case CompareOperationHints::kAny: | 52 case CompareOperationHints::kAny: |
53 return os << "Any"; | 53 return os << "Any"; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 return os; | 105 return os; |
106 } | 106 } |
107 | 107 |
108 // static | 108 // static |
109 bool BinaryOperationHints::Is(Hint h1, Hint h2) { | 109 bool BinaryOperationHints::Is(Hint h1, Hint h2) { |
110 if (h1 == h2) return true; | 110 if (h1 == h2) return true; |
111 switch (h1) { | 111 switch (h1) { |
112 case kNone: | 112 case kNone: |
113 return true; | 113 return true; |
114 case kSignedSmall: | 114 case kSignedSmall: |
115 return h2 == kSigned32 || h2 == kNumberOrUndefined || h2 == kAny; | 115 return h2 == kSigned32 || h2 == kNumberOrOddball || h2 == kAny; |
116 case kSigned32: | 116 case kSigned32: |
117 return h2 == kNumberOrUndefined || h2 == kAny; | 117 return h2 == kNumberOrOddball || h2 == kAny; |
118 case kNumberOrUndefined: | 118 case kNumberOrOddball: |
119 return h2 == kAny; | 119 return h2 == kAny; |
120 case kString: | 120 case kString: |
121 return h2 == kAny; | 121 return h2 == kAny; |
122 case kAny: | 122 case kAny: |
123 return false; | 123 return false; |
124 } | 124 } |
125 UNREACHABLE(); | 125 UNREACHABLE(); |
126 return false; | 126 return false; |
127 } | 127 } |
128 | 128 |
129 // static | 129 // static |
130 BinaryOperationHints::Hint BinaryOperationHints::Combine(Hint h1, Hint h2) { | 130 BinaryOperationHints::Hint BinaryOperationHints::Combine(Hint h1, Hint h2) { |
131 if (Is(h1, h2)) return h2; | 131 if (Is(h1, h2)) return h2; |
132 if (Is(h2, h1)) return h1; | 132 if (Is(h2, h1)) return h1; |
133 return kAny; | 133 return kAny; |
134 } | 134 } |
135 | 135 |
136 } // namespace compiler | 136 } // namespace compiler |
137 } // namespace internal | 137 } // namespace internal |
138 } // namespace v8 | 138 } // namespace v8 |
OLD | NEW |