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/jni_internal_test.cc b/runtime/jni_internal_test.cc
index 9479a18..e5fe860 100644
--- a/runtime/jni_internal_test.cc
+++ b/runtime/jni_internal_test.cc
@@ -2310,19 +2310,20 @@
std::string error_msg;
IndirectReferenceTable irt(5, IndirectRefKind::kGlobal, &error_msg);
ASSERT_TRUE(irt.IsValid()) << error_msg;
- uint32_t old_state = irt.GetSegmentState();
+ IRTSegmentState old_state = irt.GetSegmentState();
// Write some new state directly. We invert parts of old_state to ensure a new value.
- uint32_t new_state = old_state ^ 0x07705005;
- ASSERT_NE(old_state, new_state);
+ IRTSegmentState new_state;
+ new_state.top_index = old_state.top_index ^ 0x07705005;
+ ASSERT_NE(old_state.top_index, new_state.top_index);
uint8_t* base = reinterpret_cast<uint8_t*>(&irt);
int32_t segment_state_offset =
IndirectReferenceTable::SegmentStateOffset(sizeof(void*)).Int32Value();
- *reinterpret_cast<uint32_t*>(base + segment_state_offset) = new_state;
+ *reinterpret_cast<IRTSegmentState*>(base + segment_state_offset) = new_state;
// Read and compare.
- EXPECT_EQ(new_state, irt.GetSegmentState());
+ EXPECT_EQ(new_state.top_index, irt.GetSegmentState().top_index);
}
// Test the offset computation of JNIEnvExt offsets. b/26071368.