1 /*
2 * Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
104 __ lduw(Address(member_reg, NONZERO(java_lang_invoke_MemberName::flags_offset_in_bytes())), temp);
105 __ srl( temp, java_lang_invoke_MemberName::MN_REFERENCE_KIND_SHIFT, temp);
106 __ and3(temp, java_lang_invoke_MemberName::MN_REFERENCE_KIND_MASK, temp);
107 __ cmp_and_br_short(temp, ref_kind, Assembler::equal, Assembler::pt, L);
108 { char* buf = NEW_C_HEAP_ARRAY(char, 100, mtInternal);
109 jio_snprintf(buf, 100, "verify_ref_kind expected %x", ref_kind);
110 if (ref_kind == JVM_REF_invokeVirtual ||
111 ref_kind == JVM_REF_invokeSpecial)
112 // could do this for all ref_kinds, but would explode assembly code size
113 trace_method_handle(_masm, buf);
114 __ STOP(buf);
115 }
116 BLOCK_COMMENT("} verify_ref_kind");
117 __ bind(L);
118 }
119
120 #endif // ASSERT
121
122 void MethodHandles::jump_from_method_handle(MacroAssembler* _masm, Register method, Register target, Register temp,
123 bool for_compiler_entry) {
124 assert(method == G5_method, "interpreter calling convention");
125 assert_different_registers(method, target, temp);
126
127 if (!for_compiler_entry && JvmtiExport::can_post_interpreter_events()) {
128 Label run_compiled_code;
129 // JVMTI events, such as single-stepping, are implemented partly by avoiding running
130 // compiled code in threads for which the event is enabled. Check here for
131 // interp_only_mode if these events CAN be enabled.
132 __ verify_thread();
133 const Address interp_only(G2_thread, JavaThread::interp_only_mode_offset());
134 __ ld(interp_only, temp);
135 __ cmp_and_br_short(temp, 0, Assembler::zero, Assembler::pt, run_compiled_code);
136 __ ld_ptr(G5_method, in_bytes(Method::interpreter_entry_offset()), target);
137 __ jmp(target, 0);
138 __ delayed()->nop();
139 __ BIND(run_compiled_code);
140 // Note: we could fill some delay slots here, but
141 // it doesn't matter, since this is interpreter code.
142 }
143
144 const ByteSize entry_offset = for_compiler_entry ? Method::from_compiled_offset() :
145 Method::from_interpreted_offset();
146 __ ld_ptr(G5_method, in_bytes(entry_offset), target);
147 __ jmp(target, 0);
148 __ delayed()->nop();
149 }
150
151 void MethodHandles::jump_to_lambda_form(MacroAssembler* _masm,
152 Register recv, Register method_temp,
153 Register temp2, Register temp3,
154 bool for_compiler_entry) {
155 BLOCK_COMMENT("jump_to_lambda_form {");
156 // This is the initial entry point of a lazy method handle.
157 // After type checking, it picks up the invoker from the LambdaForm.
158 assert_different_registers(recv, method_temp, temp2); // temp3 is only passed on
159 assert(method_temp == G5_method, "required register for loading method");
160
161 //NOT_PRODUCT({ FlagSetting fs(TraceMethodHandles, true); trace_method_handle(_masm, "LZMH"); });
162
163 // Load the invoker, as MH -> MH.form -> LF.vmentry
164 __ verify_oop(recv);
165 __ load_heap_oop(Address(recv, NONZERO(java_lang_invoke_MethodHandle::form_offset_in_bytes())), method_temp);
166 __ verify_oop(method_temp);
167 __ load_heap_oop(Address(method_temp, NONZERO(java_lang_invoke_LambdaForm::vmentry_offset_in_bytes())), method_temp);
168 __ verify_oop(method_temp);
|
1 /*
2 * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
104 __ lduw(Address(member_reg, NONZERO(java_lang_invoke_MemberName::flags_offset_in_bytes())), temp);
105 __ srl( temp, java_lang_invoke_MemberName::MN_REFERENCE_KIND_SHIFT, temp);
106 __ and3(temp, java_lang_invoke_MemberName::MN_REFERENCE_KIND_MASK, temp);
107 __ cmp_and_br_short(temp, ref_kind, Assembler::equal, Assembler::pt, L);
108 { char* buf = NEW_C_HEAP_ARRAY(char, 100, mtInternal);
109 jio_snprintf(buf, 100, "verify_ref_kind expected %x", ref_kind);
110 if (ref_kind == JVM_REF_invokeVirtual ||
111 ref_kind == JVM_REF_invokeSpecial)
112 // could do this for all ref_kinds, but would explode assembly code size
113 trace_method_handle(_masm, buf);
114 __ STOP(buf);
115 }
116 BLOCK_COMMENT("} verify_ref_kind");
117 __ bind(L);
118 }
119
120 #endif // ASSERT
121
122 void MethodHandles::jump_from_method_handle(MacroAssembler* _masm, Register method, Register target, Register temp,
123 bool for_compiler_entry) {
124 Label L_no_such_method;
125 assert(method == G5_method, "interpreter calling convention");
126 assert_different_registers(method, target, temp);
127
128 if (!for_compiler_entry && JvmtiExport::can_post_interpreter_events()) {
129 Label run_compiled_code;
130 // JVMTI events, such as single-stepping, are implemented partly by avoiding running
131 // compiled code in threads for which the event is enabled. Check here for
132 // interp_only_mode if these events CAN be enabled.
133 __ verify_thread();
134 const Address interp_only(G2_thread, JavaThread::interp_only_mode_offset());
135 __ ld(interp_only, temp);
136 __ cmp_and_br_short(temp, 0, Assembler::zero, Assembler::pt, run_compiled_code);
137 // Null method test is replicated below in compiled case,
138 // it might be able to address across the verify_thread()
139 __ br_null_short(G5_method, Assembler::pn, L_no_such_method);
140 __ ld_ptr(G5_method, in_bytes(Method::interpreter_entry_offset()), target);
141 __ jmp(target, 0);
142 __ delayed()->nop();
143 __ BIND(run_compiled_code);
144 // Note: we could fill some delay slots here, but
145 // it doesn't matter, since this is interpreter code.
146 }
147
148 // Compiled case, either static or fall-through from runtime conditional
149 __ br_null_short(G5_method, Assembler::pn, L_no_such_method);
150
151 const ByteSize entry_offset = for_compiler_entry ? Method::from_compiled_offset() :
152 Method::from_interpreted_offset();
153 __ ld_ptr(G5_method, in_bytes(entry_offset), target);
154 __ jmp(target, 0);
155 __ delayed()->nop();
156
157 __ bind(L_no_such_method);
158 AddressLiteral ame(StubRoutines::throw_AbstractMethodError_entry());
159 __ jump_to(ame, temp);
160 __ delayed()->nop();
161 }
162
163 void MethodHandles::jump_to_lambda_form(MacroAssembler* _masm,
164 Register recv, Register method_temp,
165 Register temp2, Register temp3,
166 bool for_compiler_entry) {
167 BLOCK_COMMENT("jump_to_lambda_form {");
168 // This is the initial entry point of a lazy method handle.
169 // After type checking, it picks up the invoker from the LambdaForm.
170 assert_different_registers(recv, method_temp, temp2); // temp3 is only passed on
171 assert(method_temp == G5_method, "required register for loading method");
172
173 //NOT_PRODUCT({ FlagSetting fs(TraceMethodHandles, true); trace_method_handle(_masm, "LZMH"); });
174
175 // Load the invoker, as MH -> MH.form -> LF.vmentry
176 __ verify_oop(recv);
177 __ load_heap_oop(Address(recv, NONZERO(java_lang_invoke_MethodHandle::form_offset_in_bytes())), method_temp);
178 __ verify_oop(method_temp);
179 __ load_heap_oop(Address(method_temp, NONZERO(java_lang_invoke_LambdaForm::vmentry_offset_in_bytes())), method_temp);
180 __ verify_oop(method_temp);
|