ART: Change IndirectReferenceTable
Change cookie structure to allow for more entries. Use a local
hole-count caching scheme. The design is driven by two
considerations. For one, the change is small and mostly local.
The other point is to still allow inlining of functions involved
with JNI transitions.
This change is in preparation for a resizable backing table for
"unlimite" local references.
micro_native tests show changes are in the noise.
Bug: 32125344
Test: m test-art-host
Change-Id: I08ff5d6eaed75d13ec88f469fb0d18328a0eeb70
diff --git a/runtime/entrypoints/quick/quick_jni_entrypoints.cc b/runtime/entrypoints/quick/quick_jni_entrypoints.cc
index 330c742..670dadc 100644
--- a/runtime/entrypoints/quick/quick_jni_entrypoints.cc
+++ b/runtime/entrypoints/quick/quick_jni_entrypoints.cc
@@ -15,13 +15,18 @@
*/
#include "art_method-inl.h"
+#include "base/casts.h"
#include "entrypoints/entrypoint_utils-inl.h"
+#include "indirect_reference_table.h"
#include "mirror/object-inl.h"
#include "thread-inl.h"
#include "verify_object-inl.h"
namespace art {
+static_assert(sizeof(IRTSegmentState) == sizeof(uint32_t), "IRTSegmentState size unexpected");
+static_assert(std::is_trivial<IRTSegmentState>::value, "IRTSegmentState not trivial");
+
template <bool kDynamicFast>
static inline void GoToRunnableFast(Thread* self) NO_THREAD_SAFETY_ANALYSIS;
@@ -45,7 +50,7 @@
extern uint32_t JniMethodFastStart(Thread* self) {
JNIEnvExt* env = self->GetJniEnv();
DCHECK(env != nullptr);
- uint32_t saved_local_ref_cookie = env->local_ref_cookie;
+ uint32_t saved_local_ref_cookie = bit_cast<uint32_t>(env->local_ref_cookie);
env->local_ref_cookie = env->locals.GetSegmentState();
if (kIsDebugBuild) {
@@ -60,7 +65,7 @@
extern uint32_t JniMethodStart(Thread* self) {
JNIEnvExt* env = self->GetJniEnv();
DCHECK(env != nullptr);
- uint32_t saved_local_ref_cookie = env->local_ref_cookie;
+ uint32_t saved_local_ref_cookie = bit_cast<uint32_t>(env->local_ref_cookie);
env->local_ref_cookie = env->locals.GetSegmentState();
ArtMethod* native_method = *self->GetManagedStack()->GetTopQuickFrame();
if (!native_method->IsFastNative()) {
@@ -117,7 +122,7 @@
env->CheckNoHeldMonitors();
}
env->locals.SetSegmentState(env->local_ref_cookie);
- env->local_ref_cookie = saved_local_ref_cookie;
+ env->local_ref_cookie = bit_cast<IRTSegmentState>(saved_local_ref_cookie);
self->PopHandleScope();
}