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

Vladimir Ivanov vlivanov at openjdk.org
Wed Oct 8 19:42:38 UTC 2025


On Wed, 8 Oct 2025 19:19:13 GMT, Vladimir Kozlov <kvn at openjdk.org> wrote:

>>> After returning it again executes clinit_barrier. But this time the class should have initialized, so it just falls through.
>> 
>> There are no guarantees that the class is initialized. But the only case when it doesn't hold is when the class is being initialized and current thread is initializing one. So, it is guaranteed that slow path is taken at most once. 
>> 
>>> I think fast_clinit_check better conveys what it is doing
>> 
>> `clinit_barrier` implements a fast path check, so `clinit_barrier_fast_path` maybe a more accurate variant.
>
> @iwanowww  I see next changes in Leyden repo only for aarch64. Do we need it?
> 
> 
> diff --git a/src/hotspot/cpu/aarch64/templateTable_aarch64.cpp b/src/hotspot/cpu/aarch64/templateTable_aarch64.cpp
> index 2ccde98d98d..6fbe6a3a89d 100644
> --- a/src/hotspot/cpu/aarch64/templateTable_aarch64.cpp
> +++ b/src/hotspot/cpu/aarch64/templateTable_aarch64.cpp
> @@ -352,6 +352,18 @@ void TemplateTable::ldc(LdcType type)
>    __ cmp(r3, (u1)JVM_CONSTANT_Class);
>    __ br(Assembler::NE, notClass);
> 
> +  __ load_resolved_klass_at_offset(r2, r1, r3, rscratch1); // kills r3=tag
> +
> +  __ cmp(r3, zr); // resolved_klass ?= null
> +  __ br(Assembler::EQ, call_ldc);
> +
> +  const int mirror_offset = in_bytes(Klass::java_mirror_offset());
> +  __ ldr(r3, Address(r3, mirror_offset));
> +  __ resolve_oop_handle(r3, rscratch1, rscratch2);
> +  __ push_ptr(r3);
> +
> +  __ b(Done);
> +
>    __ bind(call_ldc);
>    __ mov(c_rarg1, is_ldc_wide(type) ? 1 : 0);
>    call_VM(r0, CAST_FROM_FN_PTR(address, InterpreterRuntime::ldc), c_rarg1);

@vnkozlov it is an unrelated change in Leyden to support pre-resolved CP entries for ldc bytecode (to save on `InterpreterRuntime::ldc` calls into interpreter runtime).

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

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


More information about the hotspot-dev mailing list