| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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_UTILS_H_ | 5 #ifndef V8_UTILS_H_ |
| 6 #define V8_UTILS_H_ | 6 #define V8_UTILS_H_ |
| 7 | 7 |
| 8 #include <limits.h> | 8 #include <limits.h> |
| 9 #include <stdlib.h> | 9 #include <stdlib.h> |
| 10 #include <string.h> | 10 #include <string.h> |
| (...skipping 1025 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1036 static TypeFeedbackId None() { return TypeFeedbackId(kNoneId); } | 1036 static TypeFeedbackId None() { return TypeFeedbackId(kNoneId); } |
| 1037 bool IsNone() const { return id_ == kNoneId; } | 1037 bool IsNone() const { return id_ == kNoneId; } |
| 1038 | 1038 |
| 1039 private: | 1039 private: |
| 1040 static const int kNoneId = -1; | 1040 static const int kNoneId = -1; |
| 1041 | 1041 |
| 1042 int id_; | 1042 int id_; |
| 1043 }; | 1043 }; |
| 1044 | 1044 |
| 1045 | 1045 |
| 1046 template <int dummy_parameter> | 1046 class FeedbackVectorSlot { |
| 1047 class VectorSlot { | |
| 1048 public: | 1047 public: |
| 1049 explicit VectorSlot(int id) : id_(id) {} | 1048 FeedbackVectorSlot() : id_(kInvalidSlot) {} |
| 1049 explicit FeedbackVectorSlot(int id) : id_(id) {} |
| 1050 | 1050 |
| 1051 int ToInt() const { return id_; } | 1051 int ToInt() const { return id_; } |
| 1052 | 1052 |
| 1053 static VectorSlot Invalid() { return VectorSlot(kInvalidSlot); } | 1053 static FeedbackVectorSlot Invalid() { return FeedbackVectorSlot(); } |
| 1054 bool IsInvalid() const { return id_ == kInvalidSlot; } | 1054 bool IsInvalid() const { return id_ == kInvalidSlot; } |
| 1055 | 1055 |
| 1056 VectorSlot next() const { | 1056 bool operator==(FeedbackVectorSlot that) const { |
| 1057 DCHECK_NE(kInvalidSlot, id_); | 1057 return this->id_ == that.id_; |
| 1058 return VectorSlot(id_ + 1); | |
| 1059 } | 1058 } |
| 1059 bool operator!=(FeedbackVectorSlot that) const { return !(*this == that); } |
| 1060 | 1060 |
| 1061 bool operator==(VectorSlot that) const { return this->id_ == that.id_; } | 1061 friend size_t hash_value(FeedbackVectorSlot slot) { return slot.ToInt(); } |
| 1062 bool operator!=(VectorSlot that) const { return !(*this == that); } | 1062 friend std::ostream& operator<<(std::ostream& os, FeedbackVectorSlot); |
| 1063 | 1063 |
| 1064 private: | 1064 private: |
| 1065 static const int kInvalidSlot = -1; | 1065 static const int kInvalidSlot = -1; |
| 1066 | 1066 |
| 1067 int id_; | 1067 int id_; |
| 1068 }; | 1068 }; |
| 1069 | 1069 |
| 1070 | 1070 |
| 1071 template <int dummy_parameter> | |
| 1072 size_t hash_value(VectorSlot<dummy_parameter> slot) { | |
| 1073 return slot.ToInt(); | |
| 1074 } | |
| 1075 | |
| 1076 | |
| 1077 typedef VectorSlot<0> FeedbackVectorSlot; | |
| 1078 typedef VectorSlot<1> FeedbackVectorICSlot; | |
| 1079 | |
| 1080 | |
| 1081 class BailoutId { | 1071 class BailoutId { |
| 1082 public: | 1072 public: |
| 1083 explicit BailoutId(int id) : id_(id) { } | 1073 explicit BailoutId(int id) : id_(id) { } |
| 1084 int ToInt() const { return id_; } | 1074 int ToInt() const { return id_; } |
| 1085 | 1075 |
| 1086 static BailoutId None() { return BailoutId(kNoneId); } | 1076 static BailoutId None() { return BailoutId(kNoneId); } |
| 1087 static BailoutId Prologue() { return BailoutId(kPrologueId); } | 1077 static BailoutId Prologue() { return BailoutId(kPrologueId); } |
| 1088 static BailoutId FunctionEntry() { return BailoutId(kFunctionEntryId); } | 1078 static BailoutId FunctionEntry() { return BailoutId(kFunctionEntryId); } |
| 1089 static BailoutId Declarations() { return BailoutId(kDeclarationsId); } | 1079 static BailoutId Declarations() { return BailoutId(kDeclarationsId); } |
| 1090 static BailoutId FirstUsable() { return BailoutId(kFirstUsableId); } | 1080 static BailoutId FirstUsable() { return BailoutId(kFirstUsableId); } |
| (...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1739 uint32_t* ptr = reinterpret_cast<uint32_t*>(p); | 1729 uint32_t* ptr = reinterpret_cast<uint32_t*>(p); |
| 1740 *ptr = c.u[0]; | 1730 *ptr = c.u[0]; |
| 1741 *(ptr + 1) = c.u[1]; | 1731 *(ptr + 1) = c.u[1]; |
| 1742 #endif // V8_TARGET_ARCH_MIPS | 1732 #endif // V8_TARGET_ARCH_MIPS |
| 1743 } | 1733 } |
| 1744 | 1734 |
| 1745 } // namespace internal | 1735 } // namespace internal |
| 1746 } // namespace v8 | 1736 } // namespace v8 |
| 1747 | 1737 |
| 1748 #endif // V8_UTILS_H_ | 1738 #endif // V8_UTILS_H_ |
| OLD | NEW |