1 /*
  2  * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved.
  3  * Copyright 2007, 2008, 2009, 2010, 2011 Red Hat, Inc.
  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.
 23  *
 24  */
 25 
 26 #include "asm/assembler.inline.hpp"
 27 #include "code/debugInfoRec.hpp"
 28 #include "code/vtableStubs.hpp"
 29 #include "interpreter/interpreter.hpp"
 30 #include "runtime/interfaceSupport.inline.hpp"
 31 #include "runtime/sharedRuntime.hpp"
 32 #include "runtime/vframeArray.hpp"
 33 #include "vmreg_zero.inline.hpp"
 34 #ifdef COMPILER1
 35 #include "c1/c1_Runtime1.hpp"
 36 #endif
 37 #ifdef COMPILER2
 38 #include "opto/runtime.hpp"
 39 #endif
 40 
 41 
 42 static address zero_null_code_stub() {
 43   address start = ShouldNotCallThisStub();
 44   return start;
 45 }
 46 
 47 int SharedRuntime::java_calling_convention(const BasicType *sig_bt,
 48                                            VMRegPair *regs,
 49                                            int total_args_passed) {
 50   return 0;
 51 }
 52 
 53 int SharedRuntime::java_return_convention(const BasicType *sig_bt,
 54                                            VMRegPair *regs,
 55                                            int total_args_passed) {
 56   Unimplemented();
 57   return 0;
 58 }
 59 
 60 BufferedInlineTypeBlob* SharedRuntime::generate_buffered_inline_type_adapter(const InlineKlass* vk) {
 61   Unimplemented();
 62   return nullptr;
 63 }
 64 
 65 void SharedRuntime::generate_i2c2i_adapters(MacroAssembler *masm,
 66                                             int comp_args_on_stack,
 67                                             const GrowableArray <SigEntry>* sig,
 68                                             const VMRegPair* regs,
 69                                             const GrowableArray <SigEntry>* sig_cc,
 70                                             const VMRegPair* regs_cc,
 71                                             const GrowableArray <SigEntry>* sig_cc_ro,
 72                                             const VMRegPair* regs_cc_ro,
 73                                             AdapterHandlerEntry* handler,
 74                                             AdapterBlob*& new_adapter,
 75                                             bool allocate_code_blob) {
 76   if (allocate_code_blob) {
 77     int entry_offset[AdapterHandlerEntry::ENTRIES_COUNT];
 78     assert(AdapterHandlerEntry::ENTRIES_COUNT == 7, "sanity");
 79     entry_offset[0] = 0; // i2c_entry offset
 80     entry_offset[1] = -1;
 81     entry_offset[2] = -1;
 82     entry_offset[3] = -1;
 83     entry_offset[4] = -1;
 84     entry_offset[5] = -1;
 85     entry_offset[6] = -1;
 86 
 87     new_adapter = AdapterBlob::create(masm->code(), entry_offset, 0, 0, nullptr);
 88   }
 89   // foil any attempt to call the i2c, c2i or unverified c2i entries
 90   handler->set_entry_points(CAST_FROM_FN_PTR(address,zero_null_code_stub),
 91                             CAST_FROM_FN_PTR(address,zero_null_code_stub),
 92                             CAST_FROM_FN_PTR(address,zero_null_code_stub),
 93                             CAST_FROM_FN_PTR(address,zero_null_code_stub),
 94                             CAST_FROM_FN_PTR(address,zero_null_code_stub),
 95                             CAST_FROM_FN_PTR(address,zero_null_code_stub),
 96                             nullptr);
 97 }
 98 
 99 nmethod *SharedRuntime::generate_native_wrapper(MacroAssembler *masm,
100                                                 const methodHandle& method,
101                                                 int compile_id,
102                                                 BasicType *sig_bt,
103                                                 VMRegPair *regs,
104                                                 BasicType ret_type) {
105   ShouldNotCallThis();
106   return nullptr;
107 }
108 
109 int Deoptimization::last_frame_adjust(int callee_parameters,
110                                       int callee_locals) {
111   return 0;
112 }
113 
114 uint SharedRuntime::out_preserve_stack_slots() {
115   ShouldNotCallThis();
116   return 0;
117 }
118 
119 VMReg SharedRuntime::thread_register() {
120   Unimplemented();
121   return nullptr;
122 }
123 
124 JRT_LEAF(void, zero_stub())
125   ShouldNotCallThis();
126 JRT_END
127 
128 static RuntimeStub* generate_empty_runtime_stub() {
129   return CAST_FROM_FN_PTR(RuntimeStub*,zero_stub);
130 }
131 
132 static SafepointBlob* generate_empty_safepoint_blob() {
133   return CAST_FROM_FN_PTR(SafepointBlob*,zero_stub);
134 }
135 
136 static DeoptimizationBlob* generate_empty_deopt_blob() {
137   return CAST_FROM_FN_PTR(DeoptimizationBlob*,zero_stub);
138 }
139 
140 void SharedRuntime::generate_deopt_blob() {
141   _deopt_blob = generate_empty_deopt_blob();
142 }
143 
144 SafepointBlob* SharedRuntime::generate_handler_blob(StubId id, address call_ptr) {
145   return generate_empty_safepoint_blob();
146 }
147 
148 RuntimeStub* SharedRuntime::generate_resolve_blob(StubId id, address destination) {
149   return generate_empty_runtime_stub();
150 }
151 
152 RuntimeStub* SharedRuntime::generate_throw_exception(StubId id, address runtime_entry) {
153   return generate_empty_runtime_stub();
154 }
155 
156 int SharedRuntime::c_calling_convention(const BasicType *sig_bt,
157                                          VMRegPair *regs,
158                                          int total_args_passed) {
159   ShouldNotCallThis();
160   return 0;
161 }
162 
163 int SharedRuntime::vector_calling_convention(VMRegPair *regs,
164                                              uint num_bits,
165                                              uint total_args_passed) {
166   ShouldNotCallThis();
167   return 0;
168 }
169 
170 #if INCLUDE_JFR
171 RuntimeStub* SharedRuntime::generate_jfr_write_checkpoint() {
172   return nullptr;
173 }
174 
175 RuntimeStub* SharedRuntime::generate_jfr_return_lease() {
176   return nullptr;
177 }
178 
179 #endif // INCLUDE_JFR
180