OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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_BASE_MACROS_H_ | 5 #ifndef V8_BASE_MACROS_H_ |
6 #define V8_BASE_MACROS_H_ | 6 #define V8_BASE_MACROS_H_ |
7 | 7 |
8 #include "include/v8stdint.h" | 8 #include "include/v8stdint.h" |
9 #include "src/base/build_config.h" | 9 #include "src/base/build_config.h" |
10 #include "src/base/compiler-specific.h" | 10 #include "src/base/compiler-specific.h" |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 return AddressFrom<T>(OffsetFrom(x) & -m); | 264 return AddressFrom<T>(OffsetFrom(x) & -m); |
265 } | 265 } |
266 | 266 |
267 | 267 |
268 // Return the smallest multiple of m which is >= x. | 268 // Return the smallest multiple of m which is >= x. |
269 template <typename T> | 269 template <typename T> |
270 inline T RoundUp(T x, intptr_t m) { | 270 inline T RoundUp(T x, intptr_t m) { |
271 return RoundDown<T>(static_cast<T>(x + m - 1), m); | 271 return RoundDown<T>(static_cast<T>(x + m - 1), m); |
272 } | 272 } |
273 | 273 |
274 | |
275 template <typename T, typename U> | |
276 inline bool IsAligned(T value, U alignment) { | |
277 return (value & (alignment - 1)) == 0; | |
278 } | |
279 | |
280 | |
281 // Returns current value of top of the stack. Works correctly with ASAN. | |
282 DISABLE_ASAN | |
283 inline uintptr_t GetCurrentStackPosition() { | |
284 // Takes the address of the limit variable in order to find out where | |
285 // the top of stack is right now. | |
286 uintptr_t limit = reinterpret_cast<uintptr_t>(&limit); | |
287 return limit; | |
288 } | |
289 | |
290 #endif // V8_BASE_MACROS_H_ | 274 #endif // V8_BASE_MACROS_H_ |
OLD | NEW |