[jdk17u-dev] RFR: 8280481: Duplicated stubs to interpreter for static calls

Evgeny Astigeevich eastigeevich at openjdk.org
Tue Oct 11 21:49:24 UTC 2022


On Tue, 11 Oct 2022 18:53:21 GMT, Evgeny Astigeevich <eastigeevich at openjdk.org> wrote:

> This is a backport of shared stubs to the interpreter for statically bound Java methods calls.
> Stubs to the interpreter are used when an invoked Java method is not compiled.
> 
> The full description of the changes and improvements in saving nmethod memory can be found in https://github.com/openjdk/jdk/pull/8816
> 
> The backport contains implementations for the aarch64, x86 and x86_64 backends. Other backends are guarded with `Unimplemented()` calls and `constexpr supports_shared_stubs()` returning `false`.
> 
> A risk is between low and moderate. Performance regressions are unlikely because stubs are used to go to the interpreter which will be the main contributor to the  execution time. Crashes are unlikely because we either successfully generate a shared stub during compilation or fail. If generation fails, there will be no compiled method with missing stubs.
> 
> Tested with fastdebug and release builds on aarch64, x86 and x86_64:
> - `gtest`: Passed
> - `tier1`, `tier2`: Passed
> 
> The backport can be considered clean. `git backport` conflicts were caused by changes positioning issues.

The log of backporting:

$ git backport --from https://github.com/openjdk/jdk 351560414d7ddc0694126ab184bdb78be604e51f
Fetching ...
Cherry picking ...
Auto-merging src/hotspot/share/runtime/globals.hpp
Auto-merging src/hotspot/share/ci/ciEnv.cpp
Auto-merging src/hotspot/share/c1/c1_LIRAssembler.cpp
Auto-merging src/hotspot/share/asm/codeBuffer.hpp
Auto-merging src/hotspot/share/asm/codeBuffer.cpp
Auto-merging src/hotspot/cpu/x86/x86_64.ad
Auto-merging src/hotspot/cpu/x86/x86_32.ad
CONFLICT (content): Merge conflict in src/hotspot/cpu/x86/x86_32.ad
Auto-merging src/hotspot/cpu/x86/macroAssembler_x86.hpp
Auto-merging src/hotspot/cpu/x86/macroAssembler_x86.cpp
Auto-merging src/hotspot/cpu/ppc/register_definitions_ppc.cpp
CONFLICT (content): Merge conflict in src/hotspot/cpu/ppc/register_definitions_ppc.cpp
Auto-merging src/hotspot/cpu/aarch64/aarch64.ad


The conflict in `src/hotspot/cpu/ppc/register_definitions_ppc.cpp` is the false conflict. The changes applied to it were intended for  `src/hotspot/cpu/riscv/codeBuffer_riscv.hpp` but there is no riscv backend in jdk17u.

The conflict in `x86_32.ad`

git diff x86/x86_32.ad
diff --cc src/hotspot/cpu/x86/x86_32.ad
index 92cd95e7443,f13ad0936aa..00000000000
--- a/src/hotspot/cpu/x86/x86_32.ad
+++ b/src/hotspot/cpu/x86/x86_32.ad
@@@ -1813,11 -1813,19 +1813,27 @@@ encode %
                                                    : static_call_Relocation::spec(method_index);
        emit_d32_reloc(cbuf, ($meth$$method - (int)(cbuf.insts_end()) - 4),
                       rspec, RELOC_DISP32);
++<<<<<<< HEAD
 +      // Emit stubs for static call.
 +      address stub = CompiledStaticCall::emit_to_interp_stub(cbuf);
 +      if (stub == NULL) {
 +        ciEnv::current()->record_failure("CodeCache is full");
 +        return;
++=======
+       __ post_call_nop();
+       address mark = cbuf.insts_mark();
+       if (CodeBuffer::supports_shared_stubs() && _method->can_be_statically_bound()) {
+         // Calls of the same statically bound method can share
+         // a stub to the interpreter.
+         cbuf.shared_stub_to_interp_for(_method, cbuf.insts()->mark_off());
+       } else {
+         // Emit stubs for static call.
+         address stub = CompiledStaticCall::emit_to_interp_stub(cbuf, mark);
+         if (stub == NULL) {
+           ciEnv::current()->record_failure("CodeCache is full");
+           return;
+         }
++>>>>>>> 351560414d7 (8280481: Duplicated stubs to interpreter for static calls)
        }
      }
    %}
 ```
The original patch does not add the change `+       __ post_call_nop();`. It's existed in jdk before the changes. As jdk17u does not have it, positioning the changes in jdk17u caused a merge conflict.

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

PR: https://git.openjdk.org/jdk17u-dev/pull/780


More information about the jdk-updates-dev mailing list