1 /*
2 * Copyright (c) 1997, 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 *
97 __ andl(temp, java_lang_invoke_MemberName::MN_REFERENCE_KIND_MASK);
98 __ cmpl(temp, ref_kind);
99 __ jcc(Assembler::equal, L);
100 { char* buf = NEW_C_HEAP_ARRAY(char, 100, mtInternal);
101 jio_snprintf(buf, 100, "verify_ref_kind expected %x", ref_kind);
102 if (ref_kind == JVM_REF_invokeVirtual ||
103 ref_kind == JVM_REF_invokeSpecial)
104 // could do this for all ref_kinds, but would explode assembly code size
105 trace_method_handle(_masm, buf);
106 __ STOP(buf);
107 }
108 BLOCK_COMMENT("} verify_ref_kind");
109 __ bind(L);
110 }
111
112 #endif //ASSERT
113
114 void MethodHandles::jump_from_method_handle(MacroAssembler* _masm, Register method, Register temp,
115 bool for_compiler_entry) {
116 assert(method == rbx, "interpreter calling convention");
117 __ verify_method_ptr(method);
118
119 if (!for_compiler_entry && JvmtiExport::can_post_interpreter_events()) {
120 Label run_compiled_code;
121 // JVMTI events, such as single-stepping, are implemented partly by avoiding running
122 // compiled code in threads for which the event is enabled. Check here for
123 // interp_only_mode if these events CAN be enabled.
124 #ifdef _LP64
125 Register rthread = r15_thread;
126 #else
127 Register rthread = temp;
128 __ get_thread(rthread);
129 #endif
130 // interp_only is an int, on little endian it is sufficient to test the byte only
131 // Is a cmpl faster?
132 __ cmpb(Address(rthread, JavaThread::interp_only_mode_offset()), 0);
133 __ jccb(Assembler::zero, run_compiled_code);
134 __ jmp(Address(method, Method::interpreter_entry_offset()));
135 __ BIND(run_compiled_code);
136 }
137
138 const ByteSize entry_offset = for_compiler_entry ? Method::from_compiled_offset() :
139 Method::from_interpreted_offset();
140 __ jmp(Address(method, entry_offset));
141 }
142
143 void MethodHandles::jump_to_lambda_form(MacroAssembler* _masm,
144 Register recv, Register method_temp,
145 Register temp2,
146 bool for_compiler_entry) {
147 BLOCK_COMMENT("jump_to_lambda_form {");
148 // This is the initial entry point of a lazy method handle.
149 // After type checking, it picks up the invoker from the LambdaForm.
150 assert_different_registers(recv, method_temp, temp2);
151 assert(recv != noreg, "required register");
152 assert(method_temp == rbx, "required register for loading method");
153
154 //NOT_PRODUCT({ FlagSetting fs(TraceMethodHandles, true); trace_method_handle(_masm, "LZMH"); });
155
156 // Load the invoker, as MH -> MH.form -> LF.vmentry
157 __ verify_oop(recv);
158 __ load_heap_oop(method_temp, Address(recv, NONZERO(java_lang_invoke_MethodHandle::form_offset_in_bytes())));
159 __ verify_oop(method_temp);
160 __ load_heap_oop(method_temp, Address(method_temp, NONZERO(java_lang_invoke_LambdaForm::vmentry_offset_in_bytes())));
|
1 /*
2 * Copyright (c) 1997, 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 *
97 __ andl(temp, java_lang_invoke_MemberName::MN_REFERENCE_KIND_MASK);
98 __ cmpl(temp, ref_kind);
99 __ jcc(Assembler::equal, L);
100 { char* buf = NEW_C_HEAP_ARRAY(char, 100, mtInternal);
101 jio_snprintf(buf, 100, "verify_ref_kind expected %x", ref_kind);
102 if (ref_kind == JVM_REF_invokeVirtual ||
103 ref_kind == JVM_REF_invokeSpecial)
104 // could do this for all ref_kinds, but would explode assembly code size
105 trace_method_handle(_masm, buf);
106 __ STOP(buf);
107 }
108 BLOCK_COMMENT("} verify_ref_kind");
109 __ bind(L);
110 }
111
112 #endif //ASSERT
113
114 void MethodHandles::jump_from_method_handle(MacroAssembler* _masm, Register method, Register temp,
115 bool for_compiler_entry) {
116 assert(method == rbx, "interpreter calling convention");
117
118 Label no_such_method;
119 __ testptr(rbx, rbx);
120 __ jcc(Assembler::zero, no_such_method);
121
122 __ verify_method_ptr(method);
123
124 if (!for_compiler_entry && JvmtiExport::can_post_interpreter_events()) {
125 Label run_compiled_code;
126 // JVMTI events, such as single-stepping, are implemented partly by avoiding running
127 // compiled code in threads for which the event is enabled. Check here for
128 // interp_only_mode if these events CAN be enabled.
129 #ifdef _LP64
130 Register rthread = r15_thread;
131 #else
132 Register rthread = temp;
133 __ get_thread(rthread);
134 #endif
135 // interp_only is an int, on little endian it is sufficient to test the byte only
136 // Is a cmpl faster?
137 __ cmpb(Address(rthread, JavaThread::interp_only_mode_offset()), 0);
138 __ jccb(Assembler::zero, run_compiled_code);
139 __ jmp(Address(method, Method::interpreter_entry_offset()));
140 __ BIND(run_compiled_code);
141 }
142
143 const ByteSize entry_offset = for_compiler_entry ? Method::from_compiled_offset() :
144 Method::from_interpreted_offset();
145 __ jmp(Address(method, entry_offset));
146
147 __ bind(no_such_method);
148 __ jump(RuntimeAddress(StubRoutines::throw_AbstractMethodError_entry()));
149 }
150
151 void MethodHandles::jump_to_lambda_form(MacroAssembler* _masm,
152 Register recv, Register method_temp,
153 Register temp2,
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);
159 assert(recv != noreg, "required register");
160 assert(method_temp == rbx, "required register for loading method");
161
162 //NOT_PRODUCT({ FlagSetting fs(TraceMethodHandles, true); trace_method_handle(_masm, "LZMH"); });
163
164 // Load the invoker, as MH -> MH.form -> LF.vmentry
165 __ verify_oop(recv);
166 __ load_heap_oop(method_temp, Address(recv, NONZERO(java_lang_invoke_MethodHandle::form_offset_in_bytes())));
167 __ verify_oop(method_temp);
168 __ load_heap_oop(method_temp, Address(method_temp, NONZERO(java_lang_invoke_LambdaForm::vmentry_offset_in_bytes())));
|