OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 } | 276 } |
277 | 277 |
278 | 278 |
279 inline int StrLength(const char* string) { | 279 inline int StrLength(const char* string) { |
280 size_t length = strlen(string); | 280 size_t length = strlen(string); |
281 ASSERT(length == static_cast<size_t>(static_cast<int>(length))); | 281 ASSERT(length == static_cast<size_t>(static_cast<int>(length))); |
282 return static_cast<int>(length); | 282 return static_cast<int>(length); |
283 } | 283 } |
284 | 284 |
285 | 285 |
| 286 // TODO(svenpanne) Clean up the whole power-of-2 mess. |
| 287 inline int32_t WhichPowerOf2Abs(int32_t x) { |
| 288 return (x == kMinInt) ? 31 : WhichPowerOf2(Abs(x)); |
| 289 } |
| 290 |
| 291 |
286 // ---------------------------------------------------------------------------- | 292 // ---------------------------------------------------------------------------- |
287 // BitField is a help template for encoding and decode bitfield with | 293 // BitField is a help template for encoding and decode bitfield with |
288 // unsigned content. | 294 // unsigned content. |
289 | 295 |
290 template<class T, int shift, int size, class U> | 296 template<class T, int shift, int size, class U> |
291 class BitFieldBase { | 297 class BitFieldBase { |
292 public: | 298 public: |
293 // A type U mask of bit field. To use all bits of a type U of x bits | 299 // A type U mask of bit field. To use all bits of a type U of x bits |
294 // in a bitfield without compiler warnings we have to compute 2^x | 300 // in a bitfield without compiler warnings we have to compute 2^x |
295 // without using a shift count of x in the computation. | 301 // without using a shift count of x in the computation. |
(...skipping 926 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1222 iterator end() { return container_->end(); } | 1228 iterator end() { return container_->end(); } |
1223 reverse_iterator rbegin() { return container_->rbegin(); } | 1229 reverse_iterator rbegin() { return container_->rbegin(); } |
1224 reverse_iterator rend() { return container_->rend(); } | 1230 reverse_iterator rend() { return container_->rend(); } |
1225 private: | 1231 private: |
1226 C* container_; | 1232 C* container_; |
1227 }; | 1233 }; |
1228 | 1234 |
1229 } } // namespace v8::internal | 1235 } } // namespace v8::internal |
1230 | 1236 |
1231 #endif // V8_UTILS_H_ | 1237 #endif // V8_UTILS_H_ |
OLD | NEW |