diff options
author | Mingyao Yang <mingyao@google.com> | 2014-05-15 17:02:16 -0700 |
---|---|---|
committer | Ian Rogers <irogers@google.com> | 2014-07-11 17:17:10 -0700 |
commit | 98d1cc8033251c93786e2fa8c59a2e555a9493be (patch) | |
tree | f0a76b8fff060ee484af09028da65a8339d57057 /runtime/utils.h | |
parent | aebf3cda094f34cf846d19a7724bdc8005267c95 (diff) | |
download | android_art-98d1cc8033251c93786e2fa8c59a2e555a9493be.tar.gz android_art-98d1cc8033251c93786e2fa8c59a2e555a9493be.tar.bz2 android_art-98d1cc8033251c93786e2fa8c59a2e555a9493be.zip |
Improve performance of invokevirtual/invokeinterface with embedded imt/vtable
Add an embedded version of imt/vtable into class object. Both tables start at
fixed offset within class object so method/entry point can be loaded directly
from class object for invokeinterface/invokevirtual.
Bug: 8142917
Change-Id: I4240d58cfbe9250107c95c0708c036854c455968
Diffstat (limited to 'runtime/utils.h')
-rw-r--r-- | runtime/utils.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/runtime/utils.h b/runtime/utils.h index 448c591f2b..b47de81d62 100644 --- a/runtime/utils.h +++ b/runtime/utils.h @@ -167,6 +167,10 @@ struct TypeIdentity { // For rounding integers. template<typename T> +static constexpr T RoundDown(T x, typename TypeIdentity<T>::type n) + __attribute__((warn_unused_result)); + +template<typename T> static constexpr T RoundDown(T x, typename TypeIdentity<T>::type n) { return DCHECK_CONSTEXPR(IsPowerOfTwo(n), , T(0)) @@ -174,17 +178,27 @@ static constexpr T RoundDown(T x, typename TypeIdentity<T>::type n) { } template<typename T> +static constexpr T RoundUp(T x, typename TypeIdentity<T>::type n) + __attribute__((warn_unused_result)); + +template<typename T> static constexpr T RoundUp(T x, typename TypeIdentity<T>::type n) { return RoundDown(x + n - 1, n); } // For aligning pointers. template<typename T> +static inline T* AlignDown(T* x, uintptr_t n) __attribute__((warn_unused_result)); + +template<typename T> static inline T* AlignDown(T* x, uintptr_t n) { return reinterpret_cast<T*>(RoundDown(reinterpret_cast<uintptr_t>(x), n)); } template<typename T> +static inline T* AlignUp(T* x, uintptr_t n) __attribute__((warn_unused_result)); + +template<typename T> static inline T* AlignUp(T* x, uintptr_t n) { return reinterpret_cast<T*>(RoundUp(reinterpret_cast<uintptr_t>(x), n)); } |