Chromium Code Reviews| 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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 105 // This allows conversion of 0-relative int offsets into Addresses and | 105 // This allows conversion of 0-relative int offsets into Addresses and |
| 106 // integral types. | 106 // integral types. |
| 107 template <typename T> | 107 template <typename T> |
| 108 static inline T AddressFrom(intptr_t x) { | 108 static inline T AddressFrom(intptr_t x) { |
| 109 return static_cast<T>(static_cast<T>(0) + x); | 109 return static_cast<T>(static_cast<T>(0) + x); |
| 110 } | 110 } |
| 111 | 111 |
| 112 | 112 |
| 113 // Return the largest multiple of m which is <= x. | 113 // Return the largest multiple of m which is <= x. |
| 114 template <typename T> | 114 template <typename T> |
| 115 static inline T RoundDown(T x, int m) { | 115 static inline T RoundDown(T x, intptr_t m) { |
| 116 ASSERT(IsPowerOf2(m)); | 116 ASSERT(IsPowerOf2(m)); |
| 117 return AddressFrom<T>(OffsetFrom(x) & -m); | 117 return AddressFrom<T>(OffsetFrom(x) & -m); |
| 118 } | 118 } |
| 119 | 119 |
| 120 | 120 |
| 121 // Return the smallest multiple of m which is >= x. | 121 // Return the smallest multiple of m which is >= x. |
| 122 template <typename T> | 122 template <typename T> |
| 123 static inline T RoundUp(T x, int m) { | 123 static inline T RoundUp(T x, intptr_t m) { |
|
Erik Corry
2011/07/15 21:37:33
This would seem to make unneccessary some of the o
Lasse Reichstein
2011/08/01 12:40:33
I have fixed one - hope it's all.
| |
| 124 return RoundDown(x + m - 1, m); | 124 return RoundDown<T>(static_cast<T>(x + m - 1), m); |
| 125 } | 125 } |
| 126 | 126 |
| 127 | 127 |
| 128 template <typename T> | 128 template <typename T> |
| 129 static int Compare(const T& a, const T& b) { | 129 static int Compare(const T& a, const T& b) { |
| 130 if (a == b) | 130 if (a == b) |
| 131 return 0; | 131 return 0; |
| 132 else if (a < b) | 132 else if (a < b) |
| 133 return -1; | 133 return -1; |
| 134 else | 134 else |
| (...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 887 int position_; | 887 int position_; |
| 888 | 888 |
| 889 bool is_finalized() const { return position_ < 0; } | 889 bool is_finalized() const { return position_ < 0; } |
| 890 private: | 890 private: |
| 891 DISALLOW_IMPLICIT_CONSTRUCTORS(SimpleStringBuilder); | 891 DISALLOW_IMPLICIT_CONSTRUCTORS(SimpleStringBuilder); |
| 892 }; | 892 }; |
| 893 | 893 |
| 894 } } // namespace v8::internal | 894 } } // namespace v8::internal |
| 895 | 895 |
| 896 #endif // V8_UTILS_H_ | 896 #endif // V8_UTILS_H_ |
| OLD | NEW |