< prev index next >

src/hotspot/cpu/ppc/vtableStubs_ppc_64.cpp

Print this page

  1 /*
  2  * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved.
  3  * Copyright (c) 2012, 2025 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_ppc.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_ppc.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, oopDesc* 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 = 8; // just a two-instruction safety net
 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     start_pc = __ pc();
 70     int load_const_maxLen = 5*BytesPerInstWord;  // load_const generates 5 instructions. Assume that as max size for laod_const_optimized

113     __ stop("Vtable entry is ZERO");
114     __ bind(L);
115   }
116 #endif
117 
118   address ame_addr = __ pc(); // ame = abstract method error
119                               // if the vtable entry is null, the method is abstract
120                               // NOTE: for vtable dispatches, the vtable entry will never be null.
121 
122   __ null_check(R19_method, in_bytes(Method::from_compiled_offset()), /*implicit only*/nullptr);
123   __ ld(R12_scratch2, in_bytes(Method::from_compiled_offset()), R19_method);
124   __ mtctr(R12_scratch2);
125   __ bctr();
126 
127   masm->flush();
128   bookkeeping(masm, tty, s, npe_addr, ame_addr, true, vtable_index, slop_bytes, 0);
129 
130   return s;
131 }
132 
133 VtableStub* VtableStubs::create_itable_stub(int itable_index) {
134   // Read "A word on VtableStub sizing" in share/code/vtableStubs.hpp for details on stub sizing.
135   const int stub_code_length = code_size_limit(false);
136   VtableStub* s = new(stub_code_length) VtableStub(false, itable_index);
137   // Can be null if there is no free space in the code cache.
138   if (s == nullptr) {
139     return nullptr;
140   }
141 
142   // Count unused bytes in instruction sequences of variable size.
143   // We add them to the computed buffer size in order to avoid
144   // overflow in subsequently generated stubs.
145   address   start_pc;
146   int       slop_bytes = 8; // just a two-instruction safety net
147   int       slop_delta = 0;
148 
149   ResourceMark    rm;
150   CodeBuffer      cb(s->entry_point(), stub_code_length);
151   MacroAssembler* masm = new MacroAssembler(&cb);
152   int             load_const_maxLen = 5*BytesPerInstWord;  // load_const generates 5 instructions. Assume that as max size for laod_const_optimized
153 
154 #if (!defined(PRODUCT) && defined(COMPILER2))
155   if (CountCompiledCalls) {
156     start_pc = __ pc();

  1 /*
  2  * Copyright (c) 1997, 2026, Oracle and/or its affiliates. All rights reserved.
  3  * Copyright (c) 2012, 2025 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_ppc.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_ppc.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, oopDesc* 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 = 8; // just a two-instruction safety net
 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     start_pc = __ pc();
 70     int load_const_maxLen = 5*BytesPerInstWord;  // load_const generates 5 instructions. Assume that as max size for laod_const_optimized

113     __ stop("Vtable entry is ZERO");
114     __ bind(L);
115   }
116 #endif
117 
118   address ame_addr = __ pc(); // ame = abstract method error
119                               // if the vtable entry is null, the method is abstract
120                               // NOTE: for vtable dispatches, the vtable entry will never be null.
121 
122   __ null_check(R19_method, in_bytes(Method::from_compiled_offset()), /*implicit only*/nullptr);
123   __ ld(R12_scratch2, in_bytes(Method::from_compiled_offset()), R19_method);
124   __ mtctr(R12_scratch2);
125   __ bctr();
126 
127   masm->flush();
128   bookkeeping(masm, tty, s, npe_addr, ame_addr, true, vtable_index, slop_bytes, 0);
129 
130   return s;
131 }
132 
133 VtableStub* VtableStubs::create_itable_stub(int itable_index, bool caller_is_c1) {
134   // Read "A word on VtableStub sizing" in share/code/vtableStubs.hpp for details on stub sizing.
135   const int stub_code_length = code_size_limit(false);
136   VtableStub* s = new(stub_code_length) VtableStub(false, itable_index, caller_is_c1);
137   // Can be null if there is no free space in the code cache.
138   if (s == nullptr) {
139     return nullptr;
140   }
141 
142   // Count unused bytes in instruction sequences of variable size.
143   // We add them to the computed buffer size in order to avoid
144   // overflow in subsequently generated stubs.
145   address   start_pc;
146   int       slop_bytes = 8; // just a two-instruction safety net
147   int       slop_delta = 0;
148 
149   ResourceMark    rm;
150   CodeBuffer      cb(s->entry_point(), stub_code_length);
151   MacroAssembler* masm = new MacroAssembler(&cb);
152   int             load_const_maxLen = 5*BytesPerInstWord;  // load_const generates 5 instructions. Assume that as max size for laod_const_optimized
153 
154 #if (!defined(PRODUCT) && defined(COMPILER2))
155   if (CountCompiledCalls) {
156     start_pc = __ pc();
< prev index next >