From 849d09a81907f16d8ccc6019b8baf86a304b730c Mon Sep 17 00:00:00 2001 From: Vladimir Marko Date: Mon, 21 Nov 2022 16:50:32 +0100 Subject: Split local reference table out of `IndirectReferenceTable`. In preparation for rewriting the representation of local JNI references, split their implementation out of the shared `IndirectReferenceTable` which shall be used only for global and weak global references going forward. Make the new `LocalReferenceTable` always resizable (remove the enum `ResizableCapacity`) and rename the memory mappings for LRT to "local ref table". Remove `IndirectReferenceTable` code that was needed only for local references, make these tables non-resizable. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Bug: 172332525 Change-Id: I87f02c93694577d1b577c4114fa86c2cd23b4c97 --- runtime/jni/jni_internal_test.cc | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'runtime/jni/jni_internal_test.cc') diff --git a/runtime/jni/jni_internal_test.cc b/runtime/jni/jni_internal_test.cc index a41043b9ea..5abedb922e 100644 --- a/runtime/jni/jni_internal_test.cc +++ b/runtime/jni/jni_internal_test.cc @@ -21,7 +21,7 @@ #include "art_method-inl.h" #include "base/mem_map.h" #include "common_runtime_test.h" -#include "indirect_reference_table.h" +#include "local_reference_table.h" #include "java_vm_ext.h" #include "jni_env_ext.h" #include "mirror/string-inl.h" @@ -2580,24 +2580,23 @@ TEST_F(JniInternalTest, IndirectReferenceTableOffsets) { // by modifying memory. // The parameters don't really matter here. std::string error_msg; - IndirectReferenceTable irt(IndirectRefKind::kGlobal, - IndirectReferenceTable::ResizableCapacity::kNo); - bool success = irt.Initialize(/*max_count=*/ 5, &error_msg); + jni::LocalReferenceTable lrt; + bool success = lrt.Initialize(/*max_count=*/ 5, &error_msg); ASSERT_TRUE(success) << error_msg; - IRTSegmentState old_state = irt.GetSegmentState(); + jni::LRTSegmentState old_state = lrt.GetSegmentState(); // Write some new state directly. We invert parts of old_state to ensure a new value. - IRTSegmentState new_state; + jni::LRTSegmentState 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(&irt); + uint8_t* base = reinterpret_cast(&lrt); int32_t segment_state_offset = - IndirectReferenceTable::SegmentStateOffset(sizeof(void*)).Int32Value(); - *reinterpret_cast(base + segment_state_offset) = new_state; + jni::LocalReferenceTable::SegmentStateOffset(sizeof(void*)).Int32Value(); + *reinterpret_cast(base + segment_state_offset) = new_state; // Read and compare. - EXPECT_EQ(new_state.top_index, irt.GetSegmentState().top_index); + EXPECT_EQ(new_state.top_index, lrt.GetSegmentState().top_index); } // Test the offset computation of JNIEnvExt offsets. b/26071368. @@ -2611,7 +2610,7 @@ TEST_F(JniInternalTest, JNIEnvExtOffsets) { // hope it to be. uint32_t segment_state_now = OFFSETOF_MEMBER(JNIEnvExt, locals_) + - IndirectReferenceTable::SegmentStateOffset(sizeof(void*)).Uint32Value(); + jni::LocalReferenceTable::SegmentStateOffset(sizeof(void*)).Uint32Value(); uint32_t segment_state_computed = JNIEnvExt::SegmentStateOffset(sizeof(void*)).Uint32Value(); EXPECT_EQ(segment_state_now, segment_state_computed); } -- cgit v1.2.3-59-g8ed1b