< prev index next >

src/hotspot/cpu/s390/vtableStubs_s390.cpp

Print this page

  1 /*
  2  * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved.
  3  * Copyright (c) 2016, 2023 SAP SE. All rights reserved.
  4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  5  *
  6  * This code is free software; you can redistribute it and/or modify it
  7  * under the terms of the GNU General Public License version 2 only, as
  8  * published by the Free Software Foundation.
  9  *
 10  * This code is distributed in the hope that it will be useful, but WITHOUT
 11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 13  * version 2 for more details (a copy is included in the LICENSE file that
 14  * accompanied this code).
 15  *
 16  * You should have received a copy of the GNU General Public License version
 17  * 2 along with this work; if not, write to the Free Software Foundation,
 18  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 19  *
 20  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 21  * or visit www.oracle.com if you need additional information or have any
 22  * questions.

 27 #include "code/compiledIC.hpp"
 28 #include "code/vtableStubs.hpp"
 29 #include "interp_masm_s390.hpp"
 30 #include "memory/resourceArea.hpp"
 31 #include "oops/instanceKlass.hpp"
 32 #include "oops/klass.inline.hpp"
 33 #include "oops/klassVtable.hpp"
 34 #include "runtime/sharedRuntime.hpp"
 35 #include "vmreg_s390.inline.hpp"
 36 #ifdef COMPILER2
 37 #include "opto/runtime.hpp"
 38 #endif
 39 
 40 #define __ masm->
 41 
 42 #ifndef PRODUCT
 43 extern "C" void bad_compiled_vtable_index(JavaThread* thread, oop receiver, int index);
 44 #endif
 45 
 46 // Used by compiler only; may use only caller saved, non-argument registers.
 47 VtableStub* VtableStubs::create_vtable_stub(int vtable_index) {
 48   // Read "A word on VtableStub sizing" in share/code/vtableStubs.hpp for details on stub sizing.
 49   const int stub_code_length = code_size_limit(true);
 50   VtableStub* s = new(stub_code_length) VtableStub(true, vtable_index);
 51   // Can be null if there is no free space in the code cache.
 52   if (s == nullptr) {
 53     return nullptr;
 54   }
 55 
 56   // Count unused bytes in instruction sequences of variable size.
 57   // We add them to the computed buffer size in order to avoid
 58   // overflow in subsequently generated stubs.
 59   address   start_pc;
 60   int       slop_bytes = 0;
 61   int       slop_delta = 0;
 62 
 63   ResourceMark    rm;
 64   CodeBuffer      cb(s->entry_point(), stub_code_length);
 65   MacroAssembler* masm = new MacroAssembler(&cb);
 66 
 67 #if (!defined(PRODUCT) && defined(COMPILER2))
 68   if (CountCompiledCalls) {
 69     //               worst case             actual size
 70     slop_delta  = __ load_const_size() - __ load_const_optimized_rtn_len(Z_R1_scratch, (long)SharedRuntime::nof_megamorphic_calls_addr(), true);

130     NearLabel L;
131     __ z_ltgr(Z_method, Z_method);
132     __ z_brne(L);
133     __ stop("Vtable entry is ZERO", 102);
134     __ bind(L);
135   }
136 #endif
137 
138   // Must do an explicit check if offset too large or implicit checks are disabled.
139   address ame_addr = __ pc();
140   __ null_check(Z_method, Z_R1_scratch, in_bytes(Method::from_compiled_offset()));
141   __ z_lg(Z_R1_scratch, in_bytes(Method::from_compiled_offset()), Z_method);
142   __ z_br(Z_R1_scratch);
143 
144   masm->flush();
145   bookkeeping(masm, tty, s, npe_addr, ame_addr, true, vtable_index, slop_bytes, 0);
146 
147   return s;
148 }
149 
150 VtableStub* VtableStubs::create_itable_stub(int itable_index) {
151   // Read "A word on VtableStub sizing" in share/code/vtableStubs.hpp for details on stub sizing.
152   const int stub_code_length = code_size_limit(false);
153   VtableStub* s = new(stub_code_length) VtableStub(false, itable_index);
154   // Can be null if there is no free space in the code cache.
155   if (s == nullptr) {
156     return nullptr;
157   }
158 
159   // Count unused bytes in instruction sequences of variable size.
160   // We add them to the computed buffer size in order to avoid
161   // overflow in subsequently generated stubs.
162   address   start_pc;
163   int       slop_bytes = 0;
164   int       slop_delta = 0;
165 
166   ResourceMark    rm;
167   CodeBuffer      cb(s->entry_point(), stub_code_length);
168   MacroAssembler* masm = new MacroAssembler(&cb);
169 
170 #if (!defined(PRODUCT) && defined(COMPILER2))
171   if (CountCompiledCalls) {
172     //               worst case             actual size
173     slop_delta  = __ load_const_size() - __ load_const_optimized_rtn_len(Z_R1_scratch, (long)SharedRuntime::nof_megamorphic_calls_addr(), true);

  1 /*
  2  * Copyright (c) 2016, 2026, Oracle and/or its affiliates. All rights reserved.
  3  * Copyright (c) 2016, 2023 SAP SE. All rights reserved.
  4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  5  *
  6  * This code is free software; you can redistribute it and/or modify it
  7  * under the terms of the GNU General Public License version 2 only, as
  8  * published by the Free Software Foundation.
  9  *
 10  * This code is distributed in the hope that it will be useful, but WITHOUT
 11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 13  * version 2 for more details (a copy is included in the LICENSE file that
 14  * accompanied this code).
 15  *
 16  * You should have received a copy of the GNU General Public License version
 17  * 2 along with this work; if not, write to the Free Software Foundation,
 18  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 19  *
 20  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 21  * or visit www.oracle.com if you need additional information or have any
 22  * questions.

 27 #include "code/compiledIC.hpp"
 28 #include "code/vtableStubs.hpp"
 29 #include "interp_masm_s390.hpp"
 30 #include "memory/resourceArea.hpp"
 31 #include "oops/instanceKlass.hpp"
 32 #include "oops/klass.inline.hpp"
 33 #include "oops/klassVtable.hpp"
 34 #include "runtime/sharedRuntime.hpp"
 35 #include "vmreg_s390.inline.hpp"
 36 #ifdef COMPILER2
 37 #include "opto/runtime.hpp"
 38 #endif
 39 
 40 #define __ masm->
 41 
 42 #ifndef PRODUCT
 43 extern "C" void bad_compiled_vtable_index(JavaThread* thread, oop receiver, int index);
 44 #endif
 45 
 46 // Used by compiler only; may use only caller saved, non-argument registers.
 47 VtableStub* VtableStubs::create_vtable_stub(int vtable_index, bool caller_is_c1) {
 48   // Read "A word on VtableStub sizing" in share/code/vtableStubs.hpp for details on stub sizing.
 49   const int stub_code_length = code_size_limit(true);
 50   VtableStub* s = new(stub_code_length) VtableStub(true, vtable_index, caller_is_c1);
 51   // Can be null if there is no free space in the code cache.
 52   if (s == nullptr) {
 53     return nullptr;
 54   }
 55 
 56   // Count unused bytes in instruction sequences of variable size.
 57   // We add them to the computed buffer size in order to avoid
 58   // overflow in subsequently generated stubs.
 59   address   start_pc;
 60   int       slop_bytes = 0;
 61   int       slop_delta = 0;
 62 
 63   ResourceMark    rm;
 64   CodeBuffer      cb(s->entry_point(), stub_code_length);
 65   MacroAssembler* masm = new MacroAssembler(&cb);
 66 
 67 #if (!defined(PRODUCT) && defined(COMPILER2))
 68   if (CountCompiledCalls) {
 69     //               worst case             actual size
 70     slop_delta  = __ load_const_size() - __ load_const_optimized_rtn_len(Z_R1_scratch, (long)SharedRuntime::nof_megamorphic_calls_addr(), true);

130     NearLabel L;
131     __ z_ltgr(Z_method, Z_method);
132     __ z_brne(L);
133     __ stop("Vtable entry is ZERO", 102);
134     __ bind(L);
135   }
136 #endif
137 
138   // Must do an explicit check if offset too large or implicit checks are disabled.
139   address ame_addr = __ pc();
140   __ null_check(Z_method, Z_R1_scratch, in_bytes(Method::from_compiled_offset()));
141   __ z_lg(Z_R1_scratch, in_bytes(Method::from_compiled_offset()), Z_method);
142   __ z_br(Z_R1_scratch);
143 
144   masm->flush();
145   bookkeeping(masm, tty, s, npe_addr, ame_addr, true, vtable_index, slop_bytes, 0);
146 
147   return s;
148 }
149 
150 VtableStub* VtableStubs::create_itable_stub(int itable_index, bool caller_is_c1) {
151   // Read "A word on VtableStub sizing" in share/code/vtableStubs.hpp for details on stub sizing.
152   const int stub_code_length = code_size_limit(false);
153   VtableStub* s = new(stub_code_length) VtableStub(false, itable_index, caller_is_c1);
154   // Can be null if there is no free space in the code cache.
155   if (s == nullptr) {
156     return nullptr;
157   }
158 
159   // Count unused bytes in instruction sequences of variable size.
160   // We add them to the computed buffer size in order to avoid
161   // overflow in subsequently generated stubs.
162   address   start_pc;
163   int       slop_bytes = 0;
164   int       slop_delta = 0;
165 
166   ResourceMark    rm;
167   CodeBuffer      cb(s->entry_point(), stub_code_length);
168   MacroAssembler* masm = new MacroAssembler(&cb);
169 
170 #if (!defined(PRODUCT) && defined(COMPILER2))
171   if (CountCompiledCalls) {
172     //               worst case             actual size
173     slop_delta  = __ load_const_size() - __ load_const_optimized_rtn_len(Z_R1_scratch, (long)SharedRuntime::nof_megamorphic_calls_addr(), true);
< prev index next >