From 524da141e7976cb136fa1769714a01235cd39508 Mon Sep 17 00:00:00 2001 From: Martin Doerr Date: Wed, 22 Nov 2023 16:08:54 +0000 Subject: [PATCH] 8320418: PPC64: invokevfinal_helper duplicates code to handle ResolvedMethodEntry Reviewed-by: rrich, lucy --- src/hotspot/cpu/ppc/templateTable_ppc.hpp | 2 +- src/hotspot/cpu/ppc/templateTable_ppc_64.cpp | 52 +++++++------------ .../share/interpreter/templateInterpreter.cpp | 1 + 3 files changed, 22 insertions(+), 33 deletions(-) diff --git a/src/hotspot/cpu/ppc/templateTable_ppc.hpp b/src/hotspot/cpu/ppc/templateTable_ppc.hpp index 2245533be12..3396acb1926 100644 --- a/src/hotspot/cpu/ppc/templateTable_ppc.hpp +++ b/src/hotspot/cpu/ppc/templateTable_ppc.hpp @@ -27,7 +27,7 @@ #define CPU_PPC_TEMPLATETABLE_PPC_HPP static void prepare_invoke(Register Rcache, Register Rret_addr, Register Rrecv, Register Rscratch); - static void invokevfinal_helper(Register Rcache, Register Rscratch1, Register Rscratch2, Register Rscratch3); + static void invokevfinal_helper(Register Rcache, Register Rscratch1, Register Rscratch2, Register Rscratch3, Register Rscratch4); static void generate_vtable_call(Register Rrecv_klass, Register Rindex, Register Rret, Register Rtemp); static void invokeinterface_object_method(Register Rrecv_klass, Register Rret, Register Rflags, Register Rcache, Register Rtemp, Register Rtemp2); diff --git a/src/hotspot/cpu/ppc/templateTable_ppc_64.cpp b/src/hotspot/cpu/ppc/templateTable_ppc_64.cpp index 7d6e14d26c1..84ecfc4f934 100644 --- a/src/hotspot/cpu/ppc/templateTable_ppc_64.cpp +++ b/src/hotspot/cpu/ppc/templateTable_ppc_64.cpp @@ -3487,7 +3487,7 @@ void TemplateTable::invokevirtual(int byte_no) { if (RewriteBytecodes && !UseSharedSpaces && !CDSConfig::is_dumping_static_archive()) { patch_bytecode(Bytecodes::_fast_invokevfinal, Rnew_bc, R12_scratch2); } - invokevfinal_helper(Rcache, R11_scratch1, R12_scratch2, Rflags /* tmp */); + invokevfinal_helper(Rcache, R11_scratch1, R12_scratch2, Rflags /* tmp */, Rrecv /* tmp */); __ align(32, 12); __ bind(LnotFinal); @@ -3510,36 +3510,24 @@ void TemplateTable::fast_invokevfinal(int byte_no) { assert(byte_no == f2_byte, "use this argument"); Register Rcache = R31; __ load_method_entry(Rcache, R11_scratch1); - invokevfinal_helper(Rcache, R11_scratch1, R12_scratch2, R22_tmp2); + invokevfinal_helper(Rcache, R11_scratch1, R12_scratch2, R22_tmp2, R23_tmp3); } -void TemplateTable::invokevfinal_helper(Register Rcache, Register Rscratch1, Register Rscratch2, Register Rscratch3) { +void TemplateTable::invokevfinal_helper(Register Rcache, + Register Rscratch1, Register Rscratch2, Register Rscratch3, Register Rscratch4) { - assert_different_registers(Rcache, Rscratch1, Rscratch2, Rscratch3); + assert_different_registers(Rcache, Rscratch1, Rscratch2, Rscratch3, Rscratch4); - // Load receiver from stack slot. - Register Rmethod = Rscratch3; - __ ld(Rmethod, in_bytes(ResolvedMethodEntry::method_offset()), Rcache); + Register Rrecv = Rscratch2, + Rmethod = Rscratch3, + Rret_addr = Rscratch4; + prepare_invoke(Rcache, Rret_addr, Rrecv, Rscratch1); - // Get return address. - Register Rtable_addr = Rscratch2, - Rret_addr = Rcache, - Rret_type = Rscratch1; - // Get return type. It's coded into the upper 4 bits of the lower half of the 64 bit value. - __ lbz(Rret_type, in_bytes(ResolvedMethodEntry::type_offset()), Rcache); - __ load_dispatch_table(Rtable_addr, Interpreter::invoke_return_entry_table()); - __ sldi(Rret_type, Rret_type, LogBytesPerWord); - __ ldx(Rret_addr, Rret_type, Rtable_addr); // kills Rcache - - Register Rnum_params = Rscratch2, - Rrecv = Rscratch2; - __ ld(Rnum_params, in_bytes(Method::const_offset()), Rmethod); - __ lhz(Rnum_params /* number of params */, in_bytes(ConstMethod::size_of_parameters_offset()), Rnum_params); - - // Load receiver and receiver null check. - __ load_receiver(Rnum_params, Rrecv); + // Receiver null check. __ null_check_throw(Rrecv, -1, Rscratch1); + __ ld(Rmethod, in_bytes(ResolvedMethodEntry::method_offset()), Rcache); + __ profile_final_call(Rrecv, Rscratch1); // Argument and return type profiling. __ profile_arguments_type(Rmethod, Rscratch1, Rscratch2, true); @@ -3558,9 +3546,9 @@ void TemplateTable::invokespecial(int byte_no) { Rmethod = R31; load_resolved_method_entry_special_or_static(Rcache, // ResolvedMethodEntry* - Rmethod, // Method* or itable index + Rmethod, // Method* noreg); // flags - prepare_invoke(Rcache, Rret_addr, Rreceiver, R11_scratch1); // recv + prepare_invoke(Rcache, Rret_addr, Rreceiver, R11_scratch1); // Receiver null check. __ null_check_throw(Rreceiver, -1, R11_scratch1); @@ -3578,10 +3566,10 @@ void TemplateTable::invokestatic(int byte_no) { Register Rcache = R3_ARG1, Rret_addr = R4_ARG2; - load_resolved_method_entry_special_or_static(Rcache, // ResolvedMethodEntry* - R19_method, // Method* or itable index - noreg); // flags - prepare_invoke(Rcache, Rret_addr, noreg, R11_scratch1); // recv + load_resolved_method_entry_special_or_static(Rcache, // ResolvedMethodEntry* + R19_method, // Method* + noreg); // flags + prepare_invoke(Rcache, Rret_addr, noreg, R11_scratch1); __ profile_call(R11_scratch1, R12_scratch2); // Argument and return type profiling. @@ -3639,7 +3627,7 @@ void TemplateTable::invokeinterface(int byte_no) { Rcache = R31; load_resolved_method_entry_interface(Rcache, noreg, noreg, Rflags); - prepare_invoke(Rcache, Rret_addr, Rreceiver, Rscratch1); // recv + prepare_invoke(Rcache, Rret_addr, Rreceiver, Rscratch1); // First check for Object case, then private interface method, // then regular interface method. @@ -3757,7 +3745,7 @@ void TemplateTable::invokehandle(int byte_no) { Rcache = R31; load_resolved_method_entry_handle(Rcache, // ResolvedMethodEntry* - Rmethod, // Method* or itable index + Rmethod, // Method* Rscratch1, Rflags); prepare_invoke(Rcache, Rret_addr, Rrecv, Rscratch1); diff --git a/src/hotspot/share/interpreter/templateInterpreter.cpp b/src/hotspot/share/interpreter/templateInterpreter.cpp index 8f8abd30288..58559481e5d 100644 --- a/src/hotspot/share/interpreter/templateInterpreter.cpp +++ b/src/hotspot/share/interpreter/templateInterpreter.cpp @@ -244,6 +244,7 @@ address* TemplateInterpreter::invoke_return_entry_table_for(Bytecodes::Code code case Bytecodes::_invokespecial: case Bytecodes::_invokevirtual: case Bytecodes::_invokehandle: + case Bytecodes::_fast_invokevfinal: return Interpreter::invoke_return_entry_table(); case Bytecodes::_invokeinterface: return Interpreter::invokeinterface_return_entry_table();