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 "precompiled.hpp"
27 #include "interpreter/interpreterGenerator.hpp"
28 #include "interpreter/interpreter.hpp"
29 #include "memory/allocation.inline.hpp"
30 #include "oops/oop.inline.hpp"
31 #include "prims/methodHandles.hpp"
32
33 void MethodHandles::invoke_target(Method* method, TRAPS) {
34
35 JavaThread *thread = (JavaThread *) THREAD;
36 ZeroStack *stack = thread->zero_stack();
37 InterpreterFrame *frame = thread->top_zero_frame()->as_interpreter_frame();
38 interpreterState istate = frame->interpreter_state();
39
40 // Trim back the stack to put the parameters at the top
41 stack->set_sp(istate->stack() + 1);
42
43 Interpreter::invoke_method(method, method->from_interpreted_entry(), THREAD);
44
45 // Convert the result
46 istate->set_stack(stack->sp() - 1);
47
150 Method* vmtarget = vtable->method_at(vmindex);
151
152 invoke_target(vmtarget, THREAD);
153
154 return 0;
155 }
156
157 int MethodHandles::method_handle_entry_invalid(Method* method, intptr_t UNUSED, TRAPS) {
158 ShouldNotReachHere();
159 return 0;
160 }
161
162 address MethodHandles::generate_method_handle_interpreter_entry(MacroAssembler* masm,
163 vmIntrinsics::ID iid) {
164 switch (iid) {
165 case vmIntrinsics::_invokeGeneric:
166 case vmIntrinsics::_compiledLambdaForm:
167 // Perhaps surprisingly, the symbolic references visible to Java are not directly used.
168 // They are linked to Java-generated adapters via MethodHandleNatives.linkMethod.
169 // They all allow an appendix argument.
170 return InterpreterGenerator::generate_entry_impl(masm, (address) MethodHandles::method_handle_entry_invalid);
171 case vmIntrinsics::_invokeBasic:
172 return InterpreterGenerator::generate_entry_impl(masm, (address) MethodHandles::method_handle_entry_invokeBasic);
173 case vmIntrinsics::_linkToStatic:
174 case vmIntrinsics::_linkToSpecial:
175 return InterpreterGenerator::generate_entry_impl(masm, (address) MethodHandles::method_handle_entry_linkToStaticOrSpecial);
176 case vmIntrinsics::_linkToInterface:
177 return InterpreterGenerator::generate_entry_impl(masm, (address) MethodHandles::method_handle_entry_linkToInterface);
178 case vmIntrinsics::_linkToVirtual:
179 return InterpreterGenerator::generate_entry_impl(masm, (address) MethodHandles::method_handle_entry_linkToVirtual);
180 default:
181 ShouldNotReachHere();
182 return NULL;
183 }
184 }
|
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 "precompiled.hpp"
27 #include "interpreter/cppInterpreterGenerator.hpp"
28 #include "interpreter/interpreter.hpp"
29 #include "memory/allocation.inline.hpp"
30 #include "oops/oop.inline.hpp"
31 #include "prims/methodHandles.hpp"
32
33 void MethodHandles::invoke_target(Method* method, TRAPS) {
34
35 JavaThread *thread = (JavaThread *) THREAD;
36 ZeroStack *stack = thread->zero_stack();
37 InterpreterFrame *frame = thread->top_zero_frame()->as_interpreter_frame();
38 interpreterState istate = frame->interpreter_state();
39
40 // Trim back the stack to put the parameters at the top
41 stack->set_sp(istate->stack() + 1);
42
43 Interpreter::invoke_method(method, method->from_interpreted_entry(), THREAD);
44
45 // Convert the result
46 istate->set_stack(stack->sp() - 1);
47
150 Method* vmtarget = vtable->method_at(vmindex);
151
152 invoke_target(vmtarget, THREAD);
153
154 return 0;
155 }
156
157 int MethodHandles::method_handle_entry_invalid(Method* method, intptr_t UNUSED, TRAPS) {
158 ShouldNotReachHere();
159 return 0;
160 }
161
162 address MethodHandles::generate_method_handle_interpreter_entry(MacroAssembler* masm,
163 vmIntrinsics::ID iid) {
164 switch (iid) {
165 case vmIntrinsics::_invokeGeneric:
166 case vmIntrinsics::_compiledLambdaForm:
167 // Perhaps surprisingly, the symbolic references visible to Java are not directly used.
168 // They are linked to Java-generated adapters via MethodHandleNatives.linkMethod.
169 // They all allow an appendix argument.
170 return CppInterpreterGenerator::generate_entry_impl(masm, (address) MethodHandles::method_handle_entry_invalid);
171 case vmIntrinsics::_invokeBasic:
172 return CppInterpreterGenerator::generate_entry_impl(masm, (address) MethodHandles::method_handle_entry_invokeBasic);
173 case vmIntrinsics::_linkToStatic:
174 case vmIntrinsics::_linkToSpecial:
175 return CppInterpreterGenerator::generate_entry_impl(masm, (address) MethodHandles::method_handle_entry_linkToStaticOrSpecial);
176 case vmIntrinsics::_linkToInterface:
177 return CppInterpreterGenerator::generate_entry_impl(masm, (address) MethodHandles::method_handle_entry_linkToInterface);
178 case vmIntrinsics::_linkToVirtual:
179 return CppInterpreterGenerator::generate_entry_impl(masm, (address) MethodHandles::method_handle_entry_linkToVirtual);
180 default:
181 ShouldNotReachHere();
182 return NULL;
183 }
184 }
|