RFR: 8369296: Add fast class init checks in interpreter for resolving ConstantPool entries for static field [v2]

Ashutosh Mehra asmehra at openjdk.org
Fri Oct 10 03:46:06 UTC 2025


On Tue, 7 Oct 2025 16:37:24 GMT, Amit Kumar <amitkumar at openjdk.org> wrote:

>> @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");
>  }

@offamitkumar @RealFYang @TheRealMDoerr
I have made some changes on top of the arch specific patches to make it easier to understand the code flow. Can you please review the changes and provide approval if it all looks good.

@vnkozlov I have incorporated your suggestion. Please review again.

-------------

PR Comment: https://git.openjdk.org/jdk/pull/27676#issuecomment-3388181594


More information about the hotspot-dev mailing list