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
diff --git a/runtime/utils.h b/runtime/utils.h
index 448c591..b47de81 100644
--- a/runtime/utils.h
+++ b/runtime/utils.h
@@ -167,6 +167,10 @@
// 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 @@
}
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));
}