1 /*
2 * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved.
3 * Copyright (c) 2014, Red Hat Inc. All rights reserved.
4 * Copyright (c) 2020, 2023, Huawei Technologies Co., Ltd. All rights reserved.
5 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 *
7 * This code is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License version 2 only, as
9 * published by the Free Software Foundation.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
149 void MethodHandles::jump_from_method_handle(MacroAssembler* _masm, Register method, Register temp,
150 bool for_compiler_entry, vmIntrinsics::ID iid) {
151 assert(method == xmethod, "interpreter calling convention");
152 Label L_no_such_method;
153 __ beqz(xmethod, L_no_such_method);
154 verify_method(_masm, method, iid);
155
156 if (!for_compiler_entry && JvmtiExport::can_post_interpreter_events()) {
157 Label run_compiled_code;
158 // JVMTI events, such as single-stepping, are implemented partly by avoiding running
159 // compiled code in threads for which the event is enabled. Check here for
160 // interp_only_mode if these events CAN be enabled.
161
162 __ lwu(t1, Address(xthread, JavaThread::interp_only_mode_offset()));
163 __ beqz(t1, run_compiled_code);
164 __ ld(t1, Address(method, Method::interpreter_entry_offset()));
165 __ jr(t1);
166 __ BIND(run_compiled_code);
167 }
168
169 const ByteSize entry_offset = for_compiler_entry ? Method::from_compiled_offset() :
170 Method::from_interpreted_offset();
171 __ ld(t1, Address(method, entry_offset));
172 __ jr(t1);
173 __ bind(L_no_such_method);
174 __ far_jump(RuntimeAddress(SharedRuntime::throw_AbstractMethodError_entry()));
175 }
176
177 void MethodHandles::jump_to_lambda_form(MacroAssembler* _masm,
178 Register recv, Register method_temp,
179 Register temp2,
180 bool for_compiler_entry) {
181 BLOCK_COMMENT("jump_to_lambda_form {");
182 // This is the initial entry point of a lazy method handle.
183 // After type checking, it picks up the invoker from the LambdaForm.
184 assert_different_registers(recv, method_temp, temp2);
185 assert(recv != noreg, "required register");
186 assert(method_temp == xmethod, "required register for loading method");
187
188 // Load the invoker, as MH -> MH.form -> LF.vmentry
189 __ verify_oop(recv);
|
1 /*
2 * Copyright (c) 1997, 2026, Oracle and/or its affiliates. All rights reserved.
3 * Copyright (c) 2014, Red Hat Inc. All rights reserved.
4 * Copyright (c) 2020, 2023, Huawei Technologies Co., Ltd. All rights reserved.
5 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 *
7 * This code is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License version 2 only, as
9 * published by the Free Software Foundation.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
149 void MethodHandles::jump_from_method_handle(MacroAssembler* _masm, Register method, Register temp,
150 bool for_compiler_entry, vmIntrinsics::ID iid) {
151 assert(method == xmethod, "interpreter calling convention");
152 Label L_no_such_method;
153 __ beqz(xmethod, L_no_such_method);
154 verify_method(_masm, method, iid);
155
156 if (!for_compiler_entry && JvmtiExport::can_post_interpreter_events()) {
157 Label run_compiled_code;
158 // JVMTI events, such as single-stepping, are implemented partly by avoiding running
159 // compiled code in threads for which the event is enabled. Check here for
160 // interp_only_mode if these events CAN be enabled.
161
162 __ lwu(t1, Address(xthread, JavaThread::interp_only_mode_offset()));
163 __ beqz(t1, run_compiled_code);
164 __ ld(t1, Address(method, Method::interpreter_entry_offset()));
165 __ jr(t1);
166 __ BIND(run_compiled_code);
167 }
168
169 // The following jump might pass an inline type argument that was erased to Object as oop to a
170 // callee that expects inline type arguments to be passed as fields. We need to call the compiled
171 // value entry (_code->inline_entry_point() or _adapter->c2i_inline_entry()) which will take care
172 // of translating between the calling conventions.
173 const ByteSize entry_offset = for_compiler_entry ? Method::from_compiled_inline_offset() :
174 Method::from_interpreted_offset();
175 __ ld(t1, Address(method, entry_offset));
176 __ jr(t1);
177 __ bind(L_no_such_method);
178 __ far_jump(RuntimeAddress(SharedRuntime::throw_AbstractMethodError_entry()));
179 }
180
181 void MethodHandles::jump_to_lambda_form(MacroAssembler* _masm,
182 Register recv, Register method_temp,
183 Register temp2,
184 bool for_compiler_entry) {
185 BLOCK_COMMENT("jump_to_lambda_form {");
186 // This is the initial entry point of a lazy method handle.
187 // After type checking, it picks up the invoker from the LambdaForm.
188 assert_different_registers(recv, method_temp, temp2);
189 assert(recv != noreg, "required register");
190 assert(method_temp == xmethod, "required register for loading method");
191
192 // Load the invoker, as MH -> MH.form -> LF.vmentry
193 __ verify_oop(recv);
|