RFR: 8369296: Add fast class init checks in interpreter for resolving ConstantPool entries for static field [v2]
Amit Kumar
amitkumar at openjdk.org
Tue Oct 7 16:39:49 UTC 2025
On Tue, 7 Oct 2025 16:05:18 GMT, Ashutosh Mehra <asmehra at openjdk.org> wrote:
>> Ashutosh Mehra has updated the pull request incrementally with one additional commit since the last revision:
>>
>> Fix compile failure
>>
>> Signed-off-by: Ashutosh Mehra <asmehra at redhat.com>
>
> @offamitkumar @Hamlin-Li @RealFYang @TheRealMDoerr
> I need help in adding arch specific code for s390, risc-v and ppc for this PR. Would you be able to contribute the code for these platforms? Specifically, we need to add a call to `clinit_barrier` in `TemplateTable::resolve_cache_and_index_for_field`.
>
> @vnkozlov @adinn @iwanowww can you please review this patch.
Hi @ashu-mehra,
This is fixing the test failure on s390:
diff --git a/src/hotspot/cpu/s390/templateTable_s390.cpp b/src/hotspot/cpu/s390/templateTable_s390.cpp
index 2b39cc8318c..cf34bff7746 100644
--- a/src/hotspot/cpu/s390/templateTable_s390.cpp
+++ b/src/hotspot/cpu/s390/templateTable_s390.cpp
@@ -2409,6 +2409,7 @@ void TemplateTable::resolve_cache_and_index_for_field(int byte_no,
assert(byte_no == f1_byte || byte_no == f2_byte, "byte_no out of range");
NearLabel resolved;
+ Label L_clinit_barrier_slow;
Bytecodes::Code code = bytecode();
switch (code) {
@@ -2425,6 +2426,8 @@ void TemplateTable::resolve_cache_and_index_for_field(int byte_no,
__ z_bre(resolved);
// resolve first time through
+ // Class initialization barrier slow path lands here as well.
+ __ bind(L_clinit_barrier_slow);
address entry = CAST_FROM_FN_PTR(address, InterpreterRuntime::resolve_from_cache);
__ load_const_optimized(Z_ARG2, (int)code);
__ call_VM(noreg, entry, Z_ARG2);
@@ -2434,6 +2437,15 @@ void TemplateTable::resolve_cache_and_index_for_field(int byte_no,
__ bind(resolved);
+ // Class initialization barrier for static fields
+ if (VM_Version::supports_fast_class_init_checks() &&
+ (bytecode() == Bytecodes::_getstatic || bytecode() == Bytecodes::_putstatic)) {
+ const Register field_holder = index;
+
+ __ load_sized_value(field_holder, Address(cache, ResolvedFieldEntry::field_holder_offset()), sizeof(void*), false);
+ __ clinit_barrier(field_holder, Z_thread, nullptr /*L_fast_path*/, &L_clinit_barrier_slow);
+ }
+
BLOCK_COMMENT("} resolve_cache_and_index_for_field");
}
-------------
PR Comment: https://git.openjdk.org/jdk/pull/27676#issuecomment-3377691185
More information about the hotspot-dev
mailing list