OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 return 1; | 136 return 1; |
137 } | 137 } |
138 | 138 |
139 | 139 |
140 template <typename T> | 140 template <typename T> |
141 static int PointerValueCompare(const T* a, const T* b) { | 141 static int PointerValueCompare(const T* a, const T* b) { |
142 return Compare<T>(*a, *b); | 142 return Compare<T>(*a, *b); |
143 } | 143 } |
144 | 144 |
145 | 145 |
| 146 // Compare function to compare the object pointer value of two |
| 147 // handlified objects. The handles are passed as pointers to the |
| 148 // handles. |
| 149 template<typename T> class Handle; // Forward declaration. |
| 150 template <typename T> |
| 151 static int HandleObjectPointerCompare(const Handle<T>* a, const Handle<T>* b) { |
| 152 return Compare<T*>(*(*a), *(*b)); |
| 153 } |
| 154 |
| 155 |
146 // Returns the smallest power of two which is >= x. If you pass in a | 156 // Returns the smallest power of two which is >= x. If you pass in a |
147 // number that is already a power of two, it is returned as is. | 157 // number that is already a power of two, it is returned as is. |
148 // Implementation is from "Hacker's Delight" by Henry S. Warren, Jr., | 158 // Implementation is from "Hacker's Delight" by Henry S. Warren, Jr., |
149 // figure 3-3, page 48, where the function is called clp2. | 159 // figure 3-3, page 48, where the function is called clp2. |
150 static inline uint32_t RoundUpToPowerOf2(uint32_t x) { | 160 static inline uint32_t RoundUpToPowerOf2(uint32_t x) { |
151 ASSERT(x <= 0x80000000u); | 161 ASSERT(x <= 0x80000000u); |
152 x = x - 1; | 162 x = x - 1; |
153 x = x | (x >> 1); | 163 x = x | (x >> 1); |
154 x = x | (x >> 2); | 164 x = x | (x >> 2); |
155 x = x | (x >> 4); | 165 x = x | (x >> 4); |
(...skipping 760 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
916 ASSERT(element < static_cast<int>(sizeof(T) * CHAR_BIT)); | 926 ASSERT(element < static_cast<int>(sizeof(T) * CHAR_BIT)); |
917 return 1 << element; | 927 return 1 << element; |
918 } | 928 } |
919 | 929 |
920 T bits_; | 930 T bits_; |
921 }; | 931 }; |
922 | 932 |
923 } } // namespace v8::internal | 933 } } // namespace v8::internal |
924 | 934 |
925 #endif // V8_UTILS_H_ | 935 #endif // V8_UTILS_H_ |
OLD | NEW |