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 886 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
897 #define DECLARE_TRUNCATE_TO_INT_N(N) \ | 897 #define DECLARE_TRUNCATE_TO_INT_N(N) \ |
898 template <class T> \ | 898 template <class T> \ |
899 inline T truncate_to_int##N(T x) { return truncate_to_intn(x, N); } | 899 inline T truncate_to_int##N(T x) { return truncate_to_intn(x, N); } |
900 INT_1_TO_63_LIST(DECLARE_IS_INT_N) | 900 INT_1_TO_63_LIST(DECLARE_IS_INT_N) |
901 INT_1_TO_63_LIST(DECLARE_IS_UINT_N) | 901 INT_1_TO_63_LIST(DECLARE_IS_UINT_N) |
902 INT_1_TO_63_LIST(DECLARE_TRUNCATE_TO_INT_N) | 902 INT_1_TO_63_LIST(DECLARE_TRUNCATE_TO_INT_N) |
903 #undef DECLARE_IS_INT_N | 903 #undef DECLARE_IS_INT_N |
904 #undef DECLARE_IS_UINT_N | 904 #undef DECLARE_IS_UINT_N |
905 #undef DECLARE_TRUNCATE_TO_INT_N | 905 #undef DECLARE_TRUNCATE_TO_INT_N |
906 | 906 |
907 class TypeFeedbackId { | |
908 public: | |
909 explicit TypeFeedbackId(int id) : id_(id) { } | |
910 int ToInt() const { return id_; } | |
911 | |
912 static TypeFeedbackId None() { return TypeFeedbackId(kNoneId); } | |
913 bool IsNone() const { return id_ == kNoneId; } | |
914 | |
915 private: | |
916 static const int kNoneId = -1; | |
917 | |
918 int id_; | |
919 }; | |
920 | |
921 inline bool operator<(TypeFeedbackId lhs, TypeFeedbackId rhs) { | |
922 return lhs.ToInt() < rhs.ToInt(); | |
923 } | |
924 inline bool operator>(TypeFeedbackId lhs, TypeFeedbackId rhs) { | |
925 return lhs.ToInt() > rhs.ToInt(); | |
926 } | |
927 | |
928 class FeedbackSlot { | 907 class FeedbackSlot { |
929 public: | 908 public: |
930 FeedbackSlot() : id_(kInvalidSlot) {} | 909 FeedbackSlot() : id_(kInvalidSlot) {} |
931 explicit FeedbackSlot(int id) : id_(id) {} | 910 explicit FeedbackSlot(int id) : id_(id) {} |
932 | 911 |
933 int ToInt() const { return id_; } | 912 int ToInt() const { return id_; } |
934 | 913 |
935 static FeedbackSlot Invalid() { return FeedbackSlot(); } | 914 static FeedbackSlot Invalid() { return FeedbackSlot(); } |
936 bool IsInvalid() const { return id_ == kInvalidSlot; } | 915 bool IsInvalid() const { return id_ == kInvalidSlot; } |
937 | 916 |
(...skipping 794 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1732 private: | 1711 private: |
1733 T value_; | 1712 T value_; |
1734 ThreadedListZoneEntry<T>* next_; | 1713 ThreadedListZoneEntry<T>* next_; |
1735 DISALLOW_COPY_AND_ASSIGN(ThreadedListZoneEntry); | 1714 DISALLOW_COPY_AND_ASSIGN(ThreadedListZoneEntry); |
1736 }; | 1715 }; |
1737 | 1716 |
1738 } // namespace internal | 1717 } // namespace internal |
1739 } // namespace v8 | 1718 } // namespace v8 |
1740 | 1719 |
1741 #endif // V8_UTILS_H_ | 1720 #endif // V8_UTILS_H_ |
OLD | NEW |