| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 template <typename T> | 164 template <typename T> |
| 165 static inline bool IsAligned(T value, T alignment) { | 165 static inline bool IsAligned(T value, T alignment) { |
| 166 ASSERT(IsPowerOf2(alignment)); | 166 ASSERT(IsPowerOf2(alignment)); |
| 167 return (value & (alignment - 1)) == 0; | 167 return (value & (alignment - 1)) == 0; |
| 168 } | 168 } |
| 169 | 169 |
| 170 | 170 |
| 171 // Returns true if (addr + offset) is aligned. | 171 // Returns true if (addr + offset) is aligned. |
| 172 static inline bool IsAddressAligned(Address addr, | 172 static inline bool IsAddressAligned(Address addr, |
| 173 intptr_t alignment, | 173 intptr_t alignment, |
| 174 int offset) { | 174 int offset = 0) { |
| 175 intptr_t offs = OffsetFrom(addr + offset); | 175 intptr_t offs = OffsetFrom(addr + offset); |
| 176 return IsAligned(offs, alignment); | 176 return IsAligned(offs, alignment); |
| 177 } | 177 } |
| 178 | 178 |
| 179 | 179 |
| 180 // Returns the maximum of the two parameters. | 180 // Returns the maximum of the two parameters. |
| 181 template <typename T> | 181 template <typename T> |
| 182 static T Max(T a, T b) { | 182 static T Max(T a, T b) { |
| 183 return a < b ? b : a; | 183 return a < b ? b : a; |
| 184 } | 184 } |
| (...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 754 } | 754 } |
| 755 | 755 |
| 756 template <class Dest, class Source> | 756 template <class Dest, class Source> |
| 757 inline Dest BitCast(Source* source) { | 757 inline Dest BitCast(Source* source) { |
| 758 return BitCast<Dest>(reinterpret_cast<uintptr_t>(source)); | 758 return BitCast<Dest>(reinterpret_cast<uintptr_t>(source)); |
| 759 } | 759 } |
| 760 | 760 |
| 761 } } // namespace v8::internal | 761 } } // namespace v8::internal |
| 762 | 762 |
| 763 #endif // V8_UTILS_H_ | 763 #endif // V8_UTILS_H_ |
| OLD | NEW |