| 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 #ifndef V8_COMPILER_TYPE_HINTS_H_ | 5 #ifndef V8_COMPILER_TYPE_HINTS_H_ |
| 6 #define V8_COMPILER_TYPE_HINTS_H_ | 6 #define V8_COMPILER_TYPE_HINTS_H_ |
| 7 | 7 |
| 8 #include "src/base/flags.h" | 8 #include "src/base/flags.h" |
| 9 #include "src/utils.h" | 9 #include "src/utils.h" |
| 10 | 10 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 typedef BitField<Hint, 0, 3> LeftField; | 57 typedef BitField<Hint, 0, 3> LeftField; |
| 58 typedef BitField<Hint, 3, 3> RightField; | 58 typedef BitField<Hint, 3, 3> RightField; |
| 59 typedef BitField<Hint, 6, 3> ResultField; | 59 typedef BitField<Hint, 6, 3> ResultField; |
| 60 | 60 |
| 61 uint32_t bit_field_; | 61 uint32_t bit_field_; |
| 62 }; | 62 }; |
| 63 | 63 |
| 64 std::ostream& operator<<(std::ostream&, BinaryOperationHints::Hint); | 64 std::ostream& operator<<(std::ostream&, BinaryOperationHints::Hint); |
| 65 std::ostream& operator<<(std::ostream&, BinaryOperationHints); | 65 std::ostream& operator<<(std::ostream&, BinaryOperationHints); |
| 66 | 66 |
| 67 // Type hints for an binary operation. |
| 68 class CompareOperationHints final { |
| 69 public: |
| 70 enum Hint { |
| 71 kNone, |
| 72 kSignedSmall, |
| 73 kSigned32, |
| 74 kNumberOrUndefined, |
| 75 kString, |
| 76 kAny |
| 77 }; |
| 78 |
| 79 CompareOperationHints() : CompareOperationHints(kNone, kNone, kNone) {} |
| 80 CompareOperationHints(Hint left, Hint right, Hint combined) |
| 81 : bit_field_(LeftField::encode(left) | RightField::encode(right) | |
| 82 CombinedField::encode(combined)) {} |
| 83 |
| 84 static CompareOperationHints Any() { |
| 85 return CompareOperationHints(kAny, kAny, kAny); |
| 86 } |
| 87 |
| 88 Hint left() const { return LeftField::decode(bit_field_); } |
| 89 Hint right() const { return RightField::decode(bit_field_); } |
| 90 Hint combined() const { return CombinedField::decode(bit_field_); } |
| 91 |
| 92 bool operator==(CompareOperationHints const& that) const { |
| 93 return this->bit_field_ == that.bit_field_; |
| 94 } |
| 95 bool operator!=(CompareOperationHints const& that) const { |
| 96 return !(*this == that); |
| 97 } |
| 98 |
| 99 friend size_t hash_value(CompareOperationHints const& hints) { |
| 100 return hints.bit_field_; |
| 101 } |
| 102 |
| 103 private: |
| 104 typedef BitField<Hint, 0, 3> LeftField; |
| 105 typedef BitField<Hint, 3, 3> RightField; |
| 106 typedef BitField<Hint, 6, 3> CombinedField; |
| 107 |
| 108 uint32_t bit_field_; |
| 109 }; |
| 110 |
| 111 std::ostream& operator<<(std::ostream&, CompareOperationHints::Hint); |
| 112 std::ostream& operator<<(std::ostream&, CompareOperationHints); |
| 67 | 113 |
| 68 // Type hints for the ToBoolean type conversion. | 114 // Type hints for the ToBoolean type conversion. |
| 69 enum class ToBooleanHint : uint16_t { | 115 enum class ToBooleanHint : uint16_t { |
| 70 kNone = 0u, | 116 kNone = 0u, |
| 71 kUndefined = 1u << 0, | 117 kUndefined = 1u << 0, |
| 72 kBoolean = 1u << 1, | 118 kBoolean = 1u << 1, |
| 73 kNull = 1u << 2, | 119 kNull = 1u << 2, |
| 74 kSmallInteger = 1u << 3, | 120 kSmallInteger = 1u << 3, |
| 75 kReceiver = 1u << 4, | 121 kReceiver = 1u << 4, |
| 76 kString = 1u << 5, | 122 kString = 1u << 5, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 87 | 133 |
| 88 std::ostream& operator<<(std::ostream&, ToBooleanHints); | 134 std::ostream& operator<<(std::ostream&, ToBooleanHints); |
| 89 | 135 |
| 90 DEFINE_OPERATORS_FOR_FLAGS(ToBooleanHints) | 136 DEFINE_OPERATORS_FOR_FLAGS(ToBooleanHints) |
| 91 | 137 |
| 92 } // namespace compiler | 138 } // namespace compiler |
| 93 } // namespace internal | 139 } // namespace internal |
| 94 } // namespace v8 | 140 } // namespace v8 |
| 95 | 141 |
| 96 #endif // V8_COMPILER_TYPE_HINTS_H_ | 142 #endif // V8_COMPILER_TYPE_HINTS_H_ |
| OLD | NEW |