Mercurial > hg > truffle
annotate src/share/vm/prims/methodHandleWalk.cpp @ 3387:2848194272f4
7044892: JSR 292: API entry points sometimes throw the wrong exceptions or doesn't throw the expected one
Summary: Fix to 7042656: JSR292: invokeExact/Generic doesn't throw UnsupportedOperationException if invoked via Method.invoke
Reviewed-by: never
author | jrose |
---|---|
date | Tue, 17 May 2011 15:43:46 -0700 |
parents | 33ae33516634 |
children | a80577f854f9 |
rev | line source |
---|---|
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1 /* |
2117
70427f06ea47
7010913: JSR 292 ciMethodHandle does not handle MethodHandleCompiler exceptions properly
twisti
parents:
2001
diff
changeset
|
2 * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
4 * |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
8 * |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
13 * accompanied this code). |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
14 * |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
18 * |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1507
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1507
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1507
diff
changeset
|
21 * questions. |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
22 * |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
23 */ |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
24 |
1972 | 25 #include "precompiled.hpp" |
26 #include "interpreter/rewriter.hpp" | |
27 #include "memory/oopFactory.hpp" | |
28 #include "prims/methodHandleWalk.hpp" | |
29 | |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
30 /* |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
31 * JSR 292 reference implementation: method handle structure analysis |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
32 */ |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
33 |
3371
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
34 #ifdef PRODUCT |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
35 #define print_method_handle(mh) {} |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
36 #else //PRODUCT |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
37 extern "C" void print_method_handle(oop mh); |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
38 #endif //PRODUCT |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
39 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
40 // ----------------------------------------------------------------------------- |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
41 // MethodHandleChain |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
42 |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
43 void MethodHandleChain::set_method_handle(Handle mh, TRAPS) { |
2357
8033953d67ff
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
2356
diff
changeset
|
44 if (!java_lang_invoke_MethodHandle::is_instance(mh())) lose("bad method handle", CHECK); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
45 |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
46 // set current method handle and unpack partially |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
47 _method_handle = mh; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
48 _is_last = false; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
49 _is_bound = false; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
50 _arg_slot = -1; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
51 _arg_type = T_VOID; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
52 _conversion = -1; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
53 _last_invoke = Bytecodes::_nop; //arbitrary non-garbage |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
54 |
2357
8033953d67ff
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
2356
diff
changeset
|
55 if (java_lang_invoke_DirectMethodHandle::is_instance(mh())) { |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
56 set_last_method(mh(), THREAD); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
57 return; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
58 } |
2357
8033953d67ff
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
2356
diff
changeset
|
59 if (java_lang_invoke_AdapterMethodHandle::is_instance(mh())) { |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
60 _conversion = AdapterMethodHandle_conversion(); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
61 assert(_conversion != -1, "bad conv value"); |
2357
8033953d67ff
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
2356
diff
changeset
|
62 assert(java_lang_invoke_BoundMethodHandle::is_instance(mh()), "also BMH"); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
63 } |
2357
8033953d67ff
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
2356
diff
changeset
|
64 if (java_lang_invoke_BoundMethodHandle::is_instance(mh())) { |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
65 if (!is_adapter()) // keep AMH and BMH separate in this model |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
66 _is_bound = true; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
67 _arg_slot = BoundMethodHandle_vmargslot(); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
68 oop target = MethodHandle_vmtarget_oop(); |
2357
8033953d67ff
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
2356
diff
changeset
|
69 if (!is_bound() || java_lang_invoke_MethodHandle::is_instance(target)) { |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
70 _arg_type = compute_bound_arg_type(target, NULL, _arg_slot, CHECK); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
71 } else if (target != NULL && target->is_method()) { |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
72 methodOop m = (methodOop) target; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
73 _arg_type = compute_bound_arg_type(NULL, m, _arg_slot, CHECK); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
74 set_last_method(mh(), CHECK); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
75 } else { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
76 _is_bound = false; // lose! |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
77 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
78 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
79 if (is_bound() && _arg_type == T_VOID) { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
80 lose("bad vmargslot", CHECK); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
81 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
82 if (!is_bound() && !is_adapter()) { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
83 lose("unrecognized MH type", CHECK); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
84 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
85 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
86 |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
87 |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
88 void MethodHandleChain::set_last_method(oop target, TRAPS) { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
89 _is_last = true; |
3274
2a23b1b5a0a8
7018355: JSR 292: VM crash in DefNewGeneration::copy_to_survivor_space
twisti
parents:
2460
diff
changeset
|
90 KlassHandle receiver_limit; int flags = 0; |
2a23b1b5a0a8
7018355: JSR 292: VM crash in DefNewGeneration::copy_to_survivor_space
twisti
parents:
2460
diff
changeset
|
91 _last_method = MethodHandles::decode_method(target, receiver_limit, flags); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
92 if ((flags & MethodHandles::_dmf_has_receiver) == 0) |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
93 _last_invoke = Bytecodes::_invokestatic; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
94 else if ((flags & MethodHandles::_dmf_does_dispatch) == 0) |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
95 _last_invoke = Bytecodes::_invokespecial; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
96 else if ((flags & MethodHandles::_dmf_from_interface) != 0) |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
97 _last_invoke = Bytecodes::_invokeinterface; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
98 else |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
99 _last_invoke = Bytecodes::_invokevirtual; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
100 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
101 |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
102 |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
103 BasicType MethodHandleChain::compute_bound_arg_type(oop target, methodOop m, int arg_slot, TRAPS) { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
104 // There is no direct indication of whether the argument is primitive or not. |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
105 // It is implied by the _vmentry code, and by the MethodType of the target. |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
106 BasicType arg_type = T_VOID; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
107 if (target != NULL) { |
2357
8033953d67ff
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
2356
diff
changeset
|
108 oop mtype = java_lang_invoke_MethodHandle::type(target); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
109 int arg_num = MethodHandles::argument_slot_to_argnum(mtype, arg_slot); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
110 if (arg_num >= 0) { |
2357
8033953d67ff
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
2356
diff
changeset
|
111 oop ptype = java_lang_invoke_MethodType::ptype(mtype, arg_num); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
112 arg_type = java_lang_Class::as_BasicType(ptype); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
113 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
114 } else if (m != NULL) { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
115 // figure out the argument type from the slot |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
116 // FIXME: make this explicit in the MH |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
117 int cur_slot = m->size_of_parameters(); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
118 if (arg_slot >= cur_slot) |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
119 return T_VOID; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
120 if (!m->is_static()) { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
121 cur_slot -= type2size[T_OBJECT]; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
122 if (cur_slot == arg_slot) |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
123 return T_OBJECT; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
124 } |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2117
diff
changeset
|
125 ResourceMark rm(THREAD); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
126 for (SignatureStream ss(m->signature()); !ss.is_done(); ss.next()) { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
127 BasicType bt = ss.type(); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
128 cur_slot -= type2size[bt]; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
129 if (cur_slot <= arg_slot) { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
130 if (cur_slot == arg_slot) |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
131 arg_type = bt; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
132 break; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
133 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
134 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
135 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
136 if (arg_type == T_ARRAY) |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
137 arg_type = T_OBJECT; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
138 return arg_type; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
139 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
140 |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
141 |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
142 void MethodHandleChain::lose(const char* msg, TRAPS) { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
143 _lose_message = msg; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
144 if (!THREAD->is_Java_thread() || ((JavaThread*)THREAD)->thread_state() != _thread_in_vm) { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
145 // throw a preallocated exception |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
146 THROW_OOP(Universe::virtual_machine_error_instance()); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
147 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
148 THROW_MSG(vmSymbols::java_lang_InternalError(), msg); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
149 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
150 |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
151 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
152 // ----------------------------------------------------------------------------- |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
153 // MethodHandleWalker |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
154 |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
155 Bytecodes::Code MethodHandleWalker::conversion_code(BasicType src, BasicType dest) { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
156 if (is_subword_type(src)) { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
157 src = T_INT; // all subword src types act like int |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
158 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
159 if (src == dest) { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
160 return Bytecodes::_nop; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
161 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
162 |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
163 #define SRC_DEST(s,d) (((int)(s) << 4) + (int)(d)) |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
164 switch (SRC_DEST(src, dest)) { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
165 case SRC_DEST(T_INT, T_LONG): return Bytecodes::_i2l; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
166 case SRC_DEST(T_INT, T_FLOAT): return Bytecodes::_i2f; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
167 case SRC_DEST(T_INT, T_DOUBLE): return Bytecodes::_i2d; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
168 case SRC_DEST(T_INT, T_BYTE): return Bytecodes::_i2b; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
169 case SRC_DEST(T_INT, T_CHAR): return Bytecodes::_i2c; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
170 case SRC_DEST(T_INT, T_SHORT): return Bytecodes::_i2s; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
171 |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
172 case SRC_DEST(T_LONG, T_INT): return Bytecodes::_l2i; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
173 case SRC_DEST(T_LONG, T_FLOAT): return Bytecodes::_l2f; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
174 case SRC_DEST(T_LONG, T_DOUBLE): return Bytecodes::_l2d; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
175 |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
176 case SRC_DEST(T_FLOAT, T_INT): return Bytecodes::_f2i; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
177 case SRC_DEST(T_FLOAT, T_LONG): return Bytecodes::_f2l; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
178 case SRC_DEST(T_FLOAT, T_DOUBLE): return Bytecodes::_f2d; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
179 |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
180 case SRC_DEST(T_DOUBLE, T_INT): return Bytecodes::_d2i; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
181 case SRC_DEST(T_DOUBLE, T_LONG): return Bytecodes::_d2l; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
182 case SRC_DEST(T_DOUBLE, T_FLOAT): return Bytecodes::_d2f; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
183 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
184 #undef SRC_DEST |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
185 |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
186 // cannot do it in one step, or at all |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
187 return Bytecodes::_illegal; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
188 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
189 |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
190 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
191 // ----------------------------------------------------------------------------- |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
192 // MethodHandleWalker::walk |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
193 // |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
194 MethodHandleWalker::ArgToken |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
195 MethodHandleWalker::walk(TRAPS) { |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
196 ArgToken empty = ArgToken(); // Empty return value. |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
197 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
198 walk_incoming_state(CHECK_(empty)); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
199 |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
200 for (;;) { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
201 set_method_handle(chain().method_handle_oop()); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
202 |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
203 assert(_outgoing_argc == argument_count_slow(), "empty slots under control"); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
204 |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
205 if (chain().is_adapter()) { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
206 int conv_op = chain().adapter_conversion_op(); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
207 int arg_slot = chain().adapter_arg_slot(); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
208 SlotState* arg_state = slot_state(arg_slot); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
209 if (arg_state == NULL |
2357
8033953d67ff
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
2356
diff
changeset
|
210 && conv_op > java_lang_invoke_AdapterMethodHandle::OP_RETYPE_RAW) { |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
211 lose("bad argument index", CHECK_(empty)); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
212 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
213 |
3371
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
214 bool retain_original_args = false; // used by fold/collect logic |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
215 |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
216 // perform the adapter action |
3371
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
217 switch (conv_op) { |
2357
8033953d67ff
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
2356
diff
changeset
|
218 case java_lang_invoke_AdapterMethodHandle::OP_RETYPE_ONLY: |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
219 // No changes to arguments; pass the bits through. |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
220 break; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
221 |
2357
8033953d67ff
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
2356
diff
changeset
|
222 case java_lang_invoke_AdapterMethodHandle::OP_RETYPE_RAW: { |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
223 // To keep the verifier happy, emit bitwise ("raw") conversions as needed. |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
224 // See MethodHandles::same_basic_type_for_arguments for allowed conversions. |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
225 Handle incoming_mtype(THREAD, chain().method_type_oop()); |
3371
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
226 Handle outgoing_mtype; |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
227 { |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
228 oop outgoing_mh_oop = chain().vmtarget_oop(); |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
229 if (!java_lang_invoke_MethodHandle::is_instance(outgoing_mh_oop)) |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
230 lose("outgoing target not a MethodHandle", CHECK_(empty)); |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
231 outgoing_mtype = Handle(THREAD, java_lang_invoke_MethodHandle::type(outgoing_mh_oop)); |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
232 } |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
233 |
2357
8033953d67ff
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
2356
diff
changeset
|
234 int nptypes = java_lang_invoke_MethodType::ptype_count(outgoing_mtype()); |
8033953d67ff
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
2356
diff
changeset
|
235 if (nptypes != java_lang_invoke_MethodType::ptype_count(incoming_mtype())) |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
236 lose("incoming and outgoing parameter count do not agree", CHECK_(empty)); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
237 |
3371
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
238 // Argument types. |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
239 for (int i = 0, slot = _outgoing.length() - 1; slot >= 0; slot--) { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
240 SlotState* arg_state = slot_state(slot); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
241 if (arg_state->_type == T_VOID) continue; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
242 |
3371
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
243 klassOop src_klass = NULL; |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
244 klassOop dst_klass = NULL; |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
245 BasicType src = java_lang_Class::as_BasicType(java_lang_invoke_MethodType::ptype(incoming_mtype(), i), &src_klass); |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
246 BasicType dst = java_lang_Class::as_BasicType(java_lang_invoke_MethodType::ptype(outgoing_mtype(), i), &dst_klass); |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
247 retype_raw_argument_type(src, dst, slot, CHECK_(empty)); |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
248 i++; // We need to skip void slots at the top of the loop. |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
249 } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
250 |
3371
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
251 // Return type. |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
252 { |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
253 BasicType src = java_lang_Class::as_BasicType(java_lang_invoke_MethodType::rtype(incoming_mtype())); |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
254 BasicType dst = java_lang_Class::as_BasicType(java_lang_invoke_MethodType::rtype(outgoing_mtype())); |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
255 retype_raw_return_type(src, dst, CHECK_(empty)); |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
256 } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
257 break; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
258 } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
259 |
2357
8033953d67ff
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
2356
diff
changeset
|
260 case java_lang_invoke_AdapterMethodHandle::OP_CHECK_CAST: { |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
261 // checkcast the Nth outgoing argument in place |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
262 klassOop dest_klass = NULL; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
263 BasicType dest = java_lang_Class::as_BasicType(chain().adapter_arg_oop(), &dest_klass); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
264 assert(dest == T_OBJECT, ""); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
265 assert(dest == arg_state->_type, ""); |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
266 ArgToken arg = arg_state->_arg; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
267 ArgToken new_arg = make_conversion(T_OBJECT, dest_klass, Bytecodes::_checkcast, arg, CHECK_(empty)); |
3371
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
268 assert(arg.token_type() >= tt_symbolic || arg.index() == new_arg.index(), "should be the same index"); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
269 debug_only(dest_klass = (klassOop)badOop); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
270 break; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
271 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
272 |
2357
8033953d67ff
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
2356
diff
changeset
|
273 case java_lang_invoke_AdapterMethodHandle::OP_PRIM_TO_PRIM: { |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
274 // i2l, etc., on the Nth outgoing argument in place |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
275 BasicType src = chain().adapter_conversion_src_type(), |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
276 dest = chain().adapter_conversion_dest_type(); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
277 Bytecodes::Code bc = conversion_code(src, dest); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
278 ArgToken arg = arg_state->_arg; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
279 if (bc == Bytecodes::_nop) { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
280 break; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
281 } else if (bc != Bytecodes::_illegal) { |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
282 arg = make_conversion(dest, NULL, bc, arg, CHECK_(empty)); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
283 } else if (is_subword_type(dest)) { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
284 bc = conversion_code(src, T_INT); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
285 if (bc != Bytecodes::_illegal) { |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
286 arg = make_conversion(dest, NULL, bc, arg, CHECK_(empty)); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
287 bc = conversion_code(T_INT, dest); |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
288 arg = make_conversion(dest, NULL, bc, arg, CHECK_(empty)); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
289 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
290 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
291 if (bc == Bytecodes::_illegal) { |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
292 lose("bad primitive conversion", CHECK_(empty)); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
293 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
294 change_argument(src, arg_slot, dest, arg); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
295 break; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
296 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
297 |
2357
8033953d67ff
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
2356
diff
changeset
|
298 case java_lang_invoke_AdapterMethodHandle::OP_REF_TO_PRIM: { |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
299 // checkcast to wrapper type & call intValue, etc. |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
300 BasicType dest = chain().adapter_conversion_dest_type(); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
301 ArgToken arg = arg_state->_arg; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
302 arg = make_conversion(T_OBJECT, SystemDictionary::box_klass(dest), |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
303 Bytecodes::_checkcast, arg, CHECK_(empty)); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
304 vmIntrinsics::ID unboxer = vmIntrinsics::for_unboxing(dest); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
305 if (unboxer == vmIntrinsics::_none) { |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
306 lose("no unboxing method", CHECK_(empty)); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
307 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
308 ArgToken arglist[2]; |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
309 arglist[0] = arg; // outgoing 'this' |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
310 arglist[1] = ArgToken(); // sentinel |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
311 arg = make_invoke(NULL, unboxer, Bytecodes::_invokevirtual, false, 1, &arglist[0], CHECK_(empty)); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
312 change_argument(T_OBJECT, arg_slot, dest, arg); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
313 break; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
314 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
315 |
2357
8033953d67ff
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
2356
diff
changeset
|
316 case java_lang_invoke_AdapterMethodHandle::OP_PRIM_TO_REF: { |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
317 // call wrapper type.valueOf |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
318 BasicType src = chain().adapter_conversion_src_type(); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
319 ArgToken arg = arg_state->_arg; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
320 vmIntrinsics::ID boxer = vmIntrinsics::for_boxing(src); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
321 if (boxer == vmIntrinsics::_none) { |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
322 lose("no boxing method", CHECK_(empty)); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
323 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
324 ArgToken arglist[2]; |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
325 arglist[0] = arg; // outgoing value |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
326 arglist[1] = ArgToken(); // sentinel |
3371
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
327 arg = make_invoke(NULL, boxer, Bytecodes::_invokestatic, false, 1, &arglist[0], CHECK_(empty)); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
328 change_argument(src, arg_slot, T_OBJECT, arg); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
329 break; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
330 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
331 |
2357
8033953d67ff
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
2356
diff
changeset
|
332 case java_lang_invoke_AdapterMethodHandle::OP_SWAP_ARGS: { |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
333 int dest_arg_slot = chain().adapter_conversion_vminfo(); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
334 if (!slot_has_argument(dest_arg_slot)) { |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
335 lose("bad swap index", CHECK_(empty)); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
336 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
337 // a simple swap between two arguments |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
338 SlotState* dest_arg_state = slot_state(dest_arg_slot); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
339 SlotState temp = (*dest_arg_state); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
340 (*dest_arg_state) = (*arg_state); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
341 (*arg_state) = temp; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
342 break; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
343 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
344 |
2357
8033953d67ff
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
2356
diff
changeset
|
345 case java_lang_invoke_AdapterMethodHandle::OP_ROT_ARGS: { |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
346 int dest_arg_slot = chain().adapter_conversion_vminfo(); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
347 if (!slot_has_argument(dest_arg_slot) || arg_slot == dest_arg_slot) { |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
348 lose("bad rotate index", CHECK_(empty)); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
349 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
350 SlotState* dest_arg_state = slot_state(dest_arg_slot); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
351 // Rotate the source argument (plus following N slots) into the |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
352 // position occupied by the dest argument (plus following N slots). |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
353 int rotate_count = type2size[dest_arg_state->_type]; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
354 // (no other rotate counts are currently supported) |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
355 if (arg_slot < dest_arg_slot) { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
356 for (int i = 0; i < rotate_count; i++) { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
357 SlotState temp = _outgoing.at(arg_slot); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
358 _outgoing.remove_at(arg_slot); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
359 _outgoing.insert_before(dest_arg_slot + rotate_count - 1, temp); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
360 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
361 } else { // arg_slot > dest_arg_slot |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
362 for (int i = 0; i < rotate_count; i++) { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
363 SlotState temp = _outgoing.at(arg_slot + rotate_count - 1); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
364 _outgoing.remove_at(arg_slot + rotate_count - 1); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
365 _outgoing.insert_before(dest_arg_slot, temp); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
366 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
367 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
368 break; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
369 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
370 |
2357
8033953d67ff
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
2356
diff
changeset
|
371 case java_lang_invoke_AdapterMethodHandle::OP_DUP_ARGS: { |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
372 int dup_slots = chain().adapter_conversion_stack_pushes(); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
373 if (dup_slots <= 0) { |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
374 lose("bad dup count", CHECK_(empty)); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
375 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
376 for (int i = 0; i < dup_slots; i++) { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
377 SlotState* dup = slot_state(arg_slot + 2*i); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
378 if (dup == NULL) break; // safety net |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
379 if (dup->_type != T_VOID) _outgoing_argc += 1; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
380 _outgoing.insert_before(i, (*dup)); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
381 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
382 break; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
383 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
384 |
2357
8033953d67ff
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
2356
diff
changeset
|
385 case java_lang_invoke_AdapterMethodHandle::OP_DROP_ARGS: { |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
386 int drop_slots = -chain().adapter_conversion_stack_pushes(); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
387 if (drop_slots <= 0) { |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
388 lose("bad drop count", CHECK_(empty)); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
389 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
390 for (int i = 0; i < drop_slots; i++) { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
391 SlotState* drop = slot_state(arg_slot); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
392 if (drop == NULL) break; // safety net |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
393 if (drop->_type != T_VOID) _outgoing_argc -= 1; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
394 _outgoing.remove_at(arg_slot); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
395 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
396 break; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
397 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
398 |
3371
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
399 case java_lang_invoke_AdapterMethodHandle::OP_FOLD_ARGS: |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
400 retain_original_args = true; // and fall through: |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
401 case java_lang_invoke_AdapterMethodHandle::OP_COLLECT_ARGS: { |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
402 // call argument MH recursively |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
403 //{static int x; if (!x++) print_method_handle(chain().method_handle_oop()); --x;} |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
404 Handle recursive_mh(THREAD, chain().adapter_arg_oop()); |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
405 if (!java_lang_invoke_MethodHandle::is_instance(recursive_mh())) { |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
406 lose("recursive target not a MethodHandle", CHECK_(empty)); |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
407 } |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
408 Handle recursive_mtype(THREAD, java_lang_invoke_MethodHandle::type(recursive_mh())); |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
409 int argc = java_lang_invoke_MethodType::ptype_count(recursive_mtype()); |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
410 int coll_slots = java_lang_invoke_MethodHandle::vmslots(recursive_mh()); |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
411 BasicType rtype = java_lang_Class::as_BasicType(java_lang_invoke_MethodType::rtype(recursive_mtype())); |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
412 ArgToken* arglist = NEW_RESOURCE_ARRAY(ArgToken, 1 + argc + 1); // 1+: mh, +1: sentinel |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
413 arglist[0] = make_oop_constant(recursive_mh(), CHECK_(empty)); |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
414 if (arg_slot < 0 || coll_slots < 0 || arg_slot + coll_slots > _outgoing.length()) { |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
415 lose("bad fold/collect arg slot", CHECK_(empty)); |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
416 } |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
417 for (int i = 0, slot = arg_slot + coll_slots - 1; slot >= arg_slot; slot--) { |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
418 SlotState* arg_state = slot_state(slot); |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
419 BasicType arg_type = arg_state->_type; |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
420 if (arg_type == T_VOID) continue; |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
421 ArgToken arg = _outgoing.at(slot)._arg; |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
422 if (i >= argc) { lose("bad fold/collect arg", CHECK_(empty)); } |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
423 arglist[1+i] = arg; |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
424 if (!retain_original_args) |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
425 change_argument(arg_type, slot, T_VOID, ArgToken(tt_void)); |
3385
33ae33516634
7045515: ARM assembly code for JSR 292 ricochet frames
bdelsart
parents:
3371
diff
changeset
|
426 i++; |
3371
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
427 } |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
428 arglist[1+argc] = ArgToken(); // sentinel |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
429 oop invoker = java_lang_invoke_MethodTypeForm::vmlayout( |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
430 java_lang_invoke_MethodType::form(recursive_mtype()) ); |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
431 if (invoker == NULL || !invoker->is_method()) { |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
432 lose("bad vmlayout slot", CHECK_(empty)); |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
433 } |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
434 // FIXME: consider inlining the invokee at the bytecode level |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
435 ArgToken ret = make_invoke(methodOop(invoker), vmIntrinsics::_none, |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
436 Bytecodes::_invokevirtual, false, 1+argc, &arglist[0], CHECK_(empty)); |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
437 DEBUG_ONLY(invoker = NULL); |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
438 if (rtype == T_OBJECT) { |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
439 klassOop rklass = java_lang_Class::as_klassOop( java_lang_invoke_MethodType::rtype(recursive_mtype()) ); |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
440 if (rklass != SystemDictionary::Object_klass() && |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
441 !Klass::cast(rklass)->is_interface()) { |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
442 // preserve type safety |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
443 ret = make_conversion(T_OBJECT, rklass, Bytecodes::_checkcast, ret, CHECK_(empty)); |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
444 } |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
445 } |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
446 int ret_slot = arg_slot + (retain_original_args ? coll_slots : 0); |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
447 change_argument(T_VOID, ret_slot, rtype, ret); |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3274
diff
changeset
|
448 break; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3274
diff
changeset
|
449 } |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3274
diff
changeset
|
450 |
2357
8033953d67ff
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
2356
diff
changeset
|
451 case java_lang_invoke_AdapterMethodHandle::OP_SPREAD_ARGS: { |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
452 klassOop array_klass_oop = NULL; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
453 BasicType array_type = java_lang_Class::as_BasicType(chain().adapter_arg_oop(), |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
454 &array_klass_oop); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
455 assert(array_type == T_OBJECT, ""); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
456 assert(Klass::cast(array_klass_oop)->oop_is_array(), ""); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
457 arrayKlassHandle array_klass(THREAD, array_klass_oop); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
458 debug_only(array_klass_oop = (klassOop)badOop); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
459 |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
460 klassOop element_klass_oop = NULL; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
461 BasicType element_type = java_lang_Class::as_BasicType(array_klass->component_mirror(), |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
462 &element_klass_oop); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
463 KlassHandle element_klass(THREAD, element_klass_oop); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
464 debug_only(element_klass_oop = (klassOop)badOop); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
465 |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
466 // Fetch the argument, which we will cast to the required array type. |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
467 assert(arg_state->_type == T_OBJECT, ""); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
468 ArgToken array_arg = arg_state->_arg; |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
469 array_arg = make_conversion(T_OBJECT, array_klass(), Bytecodes::_checkcast, array_arg, CHECK_(empty)); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
470 change_argument(T_OBJECT, arg_slot, T_VOID, ArgToken(tt_void)); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
471 |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
472 // Check the required length. |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
473 int spread_slots = 1 + chain().adapter_conversion_stack_pushes(); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
474 int spread_length = spread_slots; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
475 if (type2size[element_type] == 2) { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
476 if (spread_slots % 2 != 0) spread_slots = -1; // force error |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
477 spread_length = spread_slots / 2; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
478 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
479 if (spread_slots < 0) { |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
480 lose("bad spread length", CHECK_(empty)); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
481 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
482 |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
483 jvalue length_jvalue; length_jvalue.i = spread_length; |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
484 ArgToken length_arg = make_prim_constant(T_INT, &length_jvalue, CHECK_(empty)); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
485 // Call a built-in method known to the JVM to validate the length. |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
486 ArgToken arglist[3]; |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
487 arglist[0] = array_arg; // value to check |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
488 arglist[1] = length_arg; // length to check |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
489 arglist[2] = ArgToken(); // sentinel |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
490 make_invoke(NULL, vmIntrinsics::_checkSpreadArgument, |
3385
33ae33516634
7045515: ARM assembly code for JSR 292 ricochet frames
bdelsart
parents:
3371
diff
changeset
|
491 Bytecodes::_invokestatic, false, 2, &arglist[0], CHECK_(empty)); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
492 |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
493 // Spread out the array elements. |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3274
diff
changeset
|
494 Bytecodes::Code aload_op = Bytecodes::_nop; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3274
diff
changeset
|
495 switch (element_type) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3274
diff
changeset
|
496 case T_INT: aload_op = Bytecodes::_iaload; break; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3274
diff
changeset
|
497 case T_LONG: aload_op = Bytecodes::_laload; break; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3274
diff
changeset
|
498 case T_FLOAT: aload_op = Bytecodes::_faload; break; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3274
diff
changeset
|
499 case T_DOUBLE: aload_op = Bytecodes::_daload; break; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3274
diff
changeset
|
500 case T_OBJECT: aload_op = Bytecodes::_aaload; break; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3274
diff
changeset
|
501 case T_BOOLEAN: // fall through: |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3274
diff
changeset
|
502 case T_BYTE: aload_op = Bytecodes::_baload; break; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3274
diff
changeset
|
503 case T_CHAR: aload_op = Bytecodes::_caload; break; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3274
diff
changeset
|
504 case T_SHORT: aload_op = Bytecodes::_saload; break; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3274
diff
changeset
|
505 default: lose("primitive array NYI", CHECK_(empty)); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
506 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
507 int ap = arg_slot; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
508 for (int i = 0; i < spread_length; i++) { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
509 jvalue offset_jvalue; offset_jvalue.i = i; |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
510 ArgToken offset_arg = make_prim_constant(T_INT, &offset_jvalue, CHECK_(empty)); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
511 ArgToken element_arg = make_fetch(element_type, element_klass(), aload_op, array_arg, offset_arg, CHECK_(empty)); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
512 change_argument(T_VOID, ap, element_type, element_arg); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
513 ap += type2size[element_type]; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
514 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
515 break; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
516 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
517 |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
518 default: |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
519 lose("bad adapter conversion", CHECK_(empty)); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
520 break; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
521 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
522 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
523 |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
524 if (chain().is_bound()) { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
525 // push a new argument |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
526 BasicType arg_type = chain().bound_arg_type(); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
527 jint arg_slot = chain().bound_arg_slot(); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
528 oop arg_oop = chain().bound_arg_oop(); |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
529 ArgToken arg; |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
530 if (arg_type == T_OBJECT) { |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
531 arg = make_oop_constant(arg_oop, CHECK_(empty)); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
532 } else { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
533 jvalue arg_value; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
534 BasicType bt = java_lang_boxing_object::get_value(arg_oop, &arg_value); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
535 if (bt == arg_type) { |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
536 arg = make_prim_constant(arg_type, &arg_value, CHECK_(empty)); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
537 } else { |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
538 lose("bad bound value", CHECK_(empty)); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
539 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
540 } |
3371
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
541 DEBUG_ONLY(arg_oop = badOop); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
542 change_argument(T_VOID, arg_slot, arg_type, arg); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
543 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
544 |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
545 // this test must come after the body of the loop |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
546 if (!chain().is_last()) { |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
547 chain().next(CHECK_(empty)); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
548 } else { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
549 break; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
550 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
551 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
552 |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
553 // finish the sequence with a tail-call to the ultimate target |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
554 // parameters are passed in logical order (recv 1st), not slot order |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
555 ArgToken* arglist = NEW_RESOURCE_ARRAY(ArgToken, _outgoing.length() + 1); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
556 int ap = 0; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
557 for (int i = _outgoing.length() - 1; i >= 0; i--) { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
558 SlotState* arg_state = slot_state(i); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
559 if (arg_state->_type == T_VOID) continue; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
560 arglist[ap++] = _outgoing.at(i)._arg; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
561 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
562 assert(ap == _outgoing_argc, ""); |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
563 arglist[ap] = ArgToken(); // add a sentinel, for the sake of asserts |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
564 return make_invoke(chain().last_method_oop(), |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
565 vmIntrinsics::_none, |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
566 chain().last_invoke_code(), true, |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
567 ap, arglist, THREAD); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
568 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
569 |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
570 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
571 // ----------------------------------------------------------------------------- |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
572 // MethodHandleWalker::walk_incoming_state |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
573 // |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
574 void MethodHandleWalker::walk_incoming_state(TRAPS) { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
575 Handle mtype(THREAD, chain().method_type_oop()); |
2357
8033953d67ff
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
2356
diff
changeset
|
576 int nptypes = java_lang_invoke_MethodType::ptype_count(mtype()); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
577 _outgoing_argc = nptypes; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
578 int argp = nptypes - 1; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
579 if (argp >= 0) { |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
580 _outgoing.at_grow(argp, make_state(T_VOID, ArgToken(tt_void))); // presize |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
581 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
582 for (int i = 0; i < nptypes; i++) { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
583 klassOop arg_type_klass = NULL; |
3371
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
584 BasicType arg_type = java_lang_Class::as_BasicType(java_lang_invoke_MethodType::ptype(mtype(), i), &arg_type_klass); |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
585 int index = new_local_index(arg_type); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
586 ArgToken arg = make_parameter(arg_type, arg_type_klass, index, CHECK); |
3371
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
587 DEBUG_ONLY(arg_type_klass = (klassOop) NULL); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
588 _outgoing.at_put(argp, make_state(arg_type, arg)); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
589 if (type2size[arg_type] == 2) { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
590 // add the extra slot, so we can model the JVM stack |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
591 _outgoing.insert_before(argp+1, make_state(T_VOID, ArgToken(tt_void))); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
592 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
593 --argp; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
594 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
595 // call make_parameter at the end of the list for the return type |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
596 klassOop ret_type_klass = NULL; |
3371
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
597 BasicType ret_type = java_lang_Class::as_BasicType(java_lang_invoke_MethodType::rtype(mtype()), &ret_type_klass); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
598 ArgToken ret = make_parameter(ret_type, ret_type_klass, -1, CHECK); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
599 // ignore ret; client can catch it if needed |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
600 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
601 |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
602 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
603 // ----------------------------------------------------------------------------- |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
604 // MethodHandleWalker::change_argument |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
605 // |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
606 // This is messy because some kinds of arguments are paired with |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
607 // companion slots containing an empty value. |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
608 void MethodHandleWalker::change_argument(BasicType old_type, int slot, BasicType new_type, |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
609 const ArgToken& new_arg) { |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
610 int old_size = type2size[old_type]; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
611 int new_size = type2size[new_type]; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
612 if (old_size == new_size) { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
613 // simple case first |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
614 _outgoing.at_put(slot, make_state(new_type, new_arg)); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
615 } else if (old_size > new_size) { |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
616 for (int i = old_size - 1; i >= new_size; i--) { |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
617 assert((i != 0) == (_outgoing.at(slot + i)._type == T_VOID), ""); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
618 _outgoing.remove_at(slot + i); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
619 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
620 if (new_size > 0) |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
621 _outgoing.at_put(slot, make_state(new_type, new_arg)); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
622 else |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
623 _outgoing_argc -= 1; // deleted a real argument |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
624 } else { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
625 for (int i = old_size; i < new_size; i++) { |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
626 _outgoing.insert_before(slot + i, make_state(T_VOID, ArgToken(tt_void))); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
627 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
628 _outgoing.at_put(slot, make_state(new_type, new_arg)); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
629 if (old_size == 0) |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
630 _outgoing_argc += 1; // inserted a real argument |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
631 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
632 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
633 |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
634 |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
635 #ifdef ASSERT |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
636 int MethodHandleWalker::argument_count_slow() { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
637 int args_seen = 0; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
638 for (int i = _outgoing.length() - 1; i >= 0; i--) { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
639 if (_outgoing.at(i)._type != T_VOID) { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
640 ++args_seen; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
641 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
642 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
643 return args_seen; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
644 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
645 #endif |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
646 |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
647 |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
648 // ----------------------------------------------------------------------------- |
3371
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
649 // MethodHandleWalker::retype_raw_conversion |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
650 // |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
651 // Do the raw retype conversions for OP_RETYPE_RAW. |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
652 void MethodHandleWalker::retype_raw_conversion(BasicType src, BasicType dst, bool for_return, int slot, TRAPS) { |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
653 if (src != dst) { |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
654 if (MethodHandles::same_basic_type_for_returns(src, dst, /*raw*/ true)) { |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
655 if (MethodHandles::is_float_fixed_reinterpretation_cast(src, dst)) { |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
656 if (for_return) Untested("MHW return raw conversion"); // still untested |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
657 vmIntrinsics::ID iid = vmIntrinsics::for_raw_conversion(src, dst); |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
658 if (iid == vmIntrinsics::_none) { |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
659 lose("no raw conversion method", CHECK); |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
660 } |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
661 ArgToken arglist[2]; |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
662 if (!for_return) { |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
663 // argument type conversion |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
664 ArgToken arg = _outgoing.at(slot)._arg; |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
665 assert(arg.token_type() >= tt_symbolic || src == arg.basic_type(), "sanity"); |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
666 arglist[0] = arg; // outgoing 'this' |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
667 arglist[1] = ArgToken(); // sentinel |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
668 arg = make_invoke(NULL, iid, Bytecodes::_invokestatic, false, 1, &arglist[0], CHECK); |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
669 change_argument(src, slot, dst, arg); |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
670 } else { |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
671 // return type conversion |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
672 klassOop arg_klass = NULL; |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
673 arglist[0] = make_parameter(src, arg_klass, -1, CHECK); // return value |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
674 arglist[1] = ArgToken(); // sentinel |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
675 (void) make_invoke(NULL, iid, Bytecodes::_invokestatic, false, 1, &arglist[0], CHECK); |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
676 } |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
677 } else { |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
678 // Nothing to do. |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
679 } |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
680 } else if (src == T_OBJECT && is_java_primitive(dst)) { |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
681 // ref-to-prim: discard ref, push zero |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
682 lose("requested ref-to-prim conversion not expected", CHECK); |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
683 } else { |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
684 lose("requested raw conversion not allowed", CHECK); |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
685 } |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
686 } |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
687 } |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
688 |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
689 |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
690 // ----------------------------------------------------------------------------- |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
691 // MethodHandleCompiler |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
692 |
3366
e2a92dd0d3d2
7042122: JSR 292: adjust various inline thresholds for JSR 292 API methods and method handle adapters
twisti
parents:
3363
diff
changeset
|
693 MethodHandleCompiler::MethodHandleCompiler(Handle root, methodHandle callee, int invoke_count, bool is_invokedynamic, TRAPS) |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
694 : MethodHandleWalker(root, is_invokedynamic, THREAD), |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
695 _callee(callee), |
3366
e2a92dd0d3d2
7042122: JSR 292: adjust various inline thresholds for JSR 292 API methods and method handle adapters
twisti
parents:
3363
diff
changeset
|
696 _invoke_count(invoke_count), |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
697 _thread(THREAD), |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
698 _bytecode(THREAD, 50), |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
699 _constants(THREAD, 10), |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
700 _cur_stack(0), |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
701 _max_stack(0), |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
702 _rtype(T_ILLEGAL) |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
703 { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
704 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
705 // Element zero is always the null constant. |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
706 (void) _constants.append(NULL); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
707 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
708 // Set name and signature index. |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
709 _name_index = cpool_symbol_put(_callee->name()); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
710 _signature_index = cpool_symbol_put(_callee->signature()); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
711 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
712 // Get return type klass. |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
713 Handle first_mtype(THREAD, chain().method_type_oop()); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
714 // _rklass is NULL for primitives. |
2357
8033953d67ff
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
2356
diff
changeset
|
715 _rtype = java_lang_Class::as_BasicType(java_lang_invoke_MethodType::rtype(first_mtype()), &_rklass); |
1152
cd37471eaecc
6914206: change way of permission checking for generated MethodHandle adapters
twisti
parents:
1142
diff
changeset
|
716 if (_rtype == T_ARRAY) _rtype = T_OBJECT; |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
717 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
718 int params = _callee->size_of_parameters(); // Incoming arguments plus receiver. |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
719 _num_params = for_invokedynamic() ? params - 1 : params; // XXX Check if callee is static? |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
720 } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
721 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
722 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
723 // ----------------------------------------------------------------------------- |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
724 // MethodHandleCompiler::compile |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
725 // |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
726 // Compile this MethodHandle into a bytecode adapter and return a |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
727 // methodOop. |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
728 methodHandle MethodHandleCompiler::compile(TRAPS) { |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
729 assert(_thread == THREAD, "must be same thread"); |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
730 methodHandle nullHandle; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
731 (void) walk(CHECK_(nullHandle)); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
732 return get_method_oop(CHECK_(nullHandle)); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
733 } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
734 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
735 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
736 void MethodHandleCompiler::emit_bc(Bytecodes::Code op, int index) { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
737 Bytecodes::check(op); // Are we legal? |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
738 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
739 switch (op) { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
740 // b |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
741 case Bytecodes::_aconst_null: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
742 case Bytecodes::_iconst_m1: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
743 case Bytecodes::_iconst_0: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
744 case Bytecodes::_iconst_1: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
745 case Bytecodes::_iconst_2: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
746 case Bytecodes::_iconst_3: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
747 case Bytecodes::_iconst_4: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
748 case Bytecodes::_iconst_5: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
749 case Bytecodes::_lconst_0: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
750 case Bytecodes::_lconst_1: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
751 case Bytecodes::_fconst_0: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
752 case Bytecodes::_fconst_1: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
753 case Bytecodes::_fconst_2: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
754 case Bytecodes::_dconst_0: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
755 case Bytecodes::_dconst_1: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
756 case Bytecodes::_iload_0: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
757 case Bytecodes::_iload_1: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
758 case Bytecodes::_iload_2: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
759 case Bytecodes::_iload_3: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
760 case Bytecodes::_lload_0: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
761 case Bytecodes::_lload_1: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
762 case Bytecodes::_lload_2: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
763 case Bytecodes::_lload_3: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
764 case Bytecodes::_fload_0: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
765 case Bytecodes::_fload_1: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
766 case Bytecodes::_fload_2: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
767 case Bytecodes::_fload_3: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
768 case Bytecodes::_dload_0: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
769 case Bytecodes::_dload_1: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
770 case Bytecodes::_dload_2: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
771 case Bytecodes::_dload_3: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
772 case Bytecodes::_aload_0: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
773 case Bytecodes::_aload_1: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
774 case Bytecodes::_aload_2: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
775 case Bytecodes::_aload_3: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
776 case Bytecodes::_istore_0: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
777 case Bytecodes::_istore_1: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
778 case Bytecodes::_istore_2: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
779 case Bytecodes::_istore_3: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
780 case Bytecodes::_lstore_0: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
781 case Bytecodes::_lstore_1: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
782 case Bytecodes::_lstore_2: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
783 case Bytecodes::_lstore_3: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
784 case Bytecodes::_fstore_0: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
785 case Bytecodes::_fstore_1: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
786 case Bytecodes::_fstore_2: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
787 case Bytecodes::_fstore_3: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
788 case Bytecodes::_dstore_0: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
789 case Bytecodes::_dstore_1: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
790 case Bytecodes::_dstore_2: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
791 case Bytecodes::_dstore_3: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
792 case Bytecodes::_astore_0: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
793 case Bytecodes::_astore_1: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
794 case Bytecodes::_astore_2: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
795 case Bytecodes::_astore_3: |
3371
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
796 case Bytecodes::_iand: |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
797 case Bytecodes::_i2l: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
798 case Bytecodes::_i2f: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
799 case Bytecodes::_i2d: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
800 case Bytecodes::_i2b: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
801 case Bytecodes::_i2c: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
802 case Bytecodes::_i2s: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
803 case Bytecodes::_l2i: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
804 case Bytecodes::_l2f: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
805 case Bytecodes::_l2d: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
806 case Bytecodes::_f2i: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
807 case Bytecodes::_f2l: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
808 case Bytecodes::_f2d: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
809 case Bytecodes::_d2i: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
810 case Bytecodes::_d2l: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
811 case Bytecodes::_d2f: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
812 case Bytecodes::_ireturn: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
813 case Bytecodes::_lreturn: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
814 case Bytecodes::_freturn: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
815 case Bytecodes::_dreturn: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
816 case Bytecodes::_areturn: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
817 case Bytecodes::_return: |
1565 | 818 assert(Bytecodes::format_bits(op, false) == Bytecodes::_fmt_b, "wrong bytecode format"); |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
819 _bytecode.push(op); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
820 break; |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
821 |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
822 // bi |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
823 case Bytecodes::_ldc: |
1662
e0ba4e04c839
6969574: invokedynamic call sites deoptimize instead of executing
jrose
parents:
1579
diff
changeset
|
824 assert(Bytecodes::format_bits(op, false) == (Bytecodes::_fmt_b|Bytecodes::_fmt_has_k), "wrong bytecode format"); |
e0ba4e04c839
6969574: invokedynamic call sites deoptimize instead of executing
jrose
parents:
1579
diff
changeset
|
825 assert((char) index == index, "index does not fit in 8-bit"); |
e0ba4e04c839
6969574: invokedynamic call sites deoptimize instead of executing
jrose
parents:
1579
diff
changeset
|
826 _bytecode.push(op); |
e0ba4e04c839
6969574: invokedynamic call sites deoptimize instead of executing
jrose
parents:
1579
diff
changeset
|
827 _bytecode.push(index); |
e0ba4e04c839
6969574: invokedynamic call sites deoptimize instead of executing
jrose
parents:
1579
diff
changeset
|
828 break; |
e0ba4e04c839
6969574: invokedynamic call sites deoptimize instead of executing
jrose
parents:
1579
diff
changeset
|
829 |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
830 case Bytecodes::_iload: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
831 case Bytecodes::_lload: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
832 case Bytecodes::_fload: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
833 case Bytecodes::_dload: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
834 case Bytecodes::_aload: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
835 case Bytecodes::_istore: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
836 case Bytecodes::_lstore: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
837 case Bytecodes::_fstore: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
838 case Bytecodes::_dstore: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
839 case Bytecodes::_astore: |
1565 | 840 assert(Bytecodes::format_bits(op, false) == Bytecodes::_fmt_bi, "wrong bytecode format"); |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
841 assert((char) index == index, "index does not fit in 8-bit"); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
842 _bytecode.push(op); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
843 _bytecode.push(index); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
844 break; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
845 |
1662
e0ba4e04c839
6969574: invokedynamic call sites deoptimize instead of executing
jrose
parents:
1579
diff
changeset
|
846 // bkk |
e0ba4e04c839
6969574: invokedynamic call sites deoptimize instead of executing
jrose
parents:
1579
diff
changeset
|
847 case Bytecodes::_ldc_w: |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
848 case Bytecodes::_ldc2_w: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
849 case Bytecodes::_checkcast: |
1565 | 850 assert(Bytecodes::format_bits(op, false) == Bytecodes::_fmt_bkk, "wrong bytecode format"); |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
851 assert((short) index == index, "index does not fit in 16-bit"); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
852 _bytecode.push(op); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
853 _bytecode.push(index >> 8); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
854 _bytecode.push(index); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
855 break; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
856 |
1565 | 857 // bJJ |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
858 case Bytecodes::_invokestatic: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
859 case Bytecodes::_invokespecial: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
860 case Bytecodes::_invokevirtual: |
1565 | 861 assert(Bytecodes::format_bits(op, false) == Bytecodes::_fmt_bJJ, "wrong bytecode format"); |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
862 assert((short) index == index, "index does not fit in 16-bit"); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
863 _bytecode.push(op); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
864 _bytecode.push(index >> 8); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
865 _bytecode.push(index); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
866 break; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
867 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
868 default: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
869 ShouldNotReachHere(); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
870 } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
871 } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
872 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
873 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
874 void MethodHandleCompiler::emit_load(BasicType bt, int index) { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
875 if (index <= 3) { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
876 switch (bt) { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
877 case T_BOOLEAN: case T_BYTE: case T_CHAR: case T_SHORT: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
878 case T_INT: emit_bc(Bytecodes::cast(Bytecodes::_iload_0 + index)); break; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
879 case T_LONG: emit_bc(Bytecodes::cast(Bytecodes::_lload_0 + index)); break; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
880 case T_FLOAT: emit_bc(Bytecodes::cast(Bytecodes::_fload_0 + index)); break; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
881 case T_DOUBLE: emit_bc(Bytecodes::cast(Bytecodes::_dload_0 + index)); break; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
882 case T_OBJECT: emit_bc(Bytecodes::cast(Bytecodes::_aload_0 + index)); break; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
883 default: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
884 ShouldNotReachHere(); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
885 } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
886 } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
887 else { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
888 switch (bt) { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
889 case T_BOOLEAN: case T_BYTE: case T_CHAR: case T_SHORT: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
890 case T_INT: emit_bc(Bytecodes::_iload, index); break; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
891 case T_LONG: emit_bc(Bytecodes::_lload, index); break; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
892 case T_FLOAT: emit_bc(Bytecodes::_fload, index); break; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
893 case T_DOUBLE: emit_bc(Bytecodes::_dload, index); break; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
894 case T_OBJECT: emit_bc(Bytecodes::_aload, index); break; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
895 default: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
896 ShouldNotReachHere(); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
897 } |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
898 } |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
899 stack_push(bt); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
900 } |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
901 |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
902 void MethodHandleCompiler::emit_store(BasicType bt, int index) { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
903 if (index <= 3) { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
904 switch (bt) { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
905 case T_BOOLEAN: case T_BYTE: case T_CHAR: case T_SHORT: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
906 case T_INT: emit_bc(Bytecodes::cast(Bytecodes::_istore_0 + index)); break; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
907 case T_LONG: emit_bc(Bytecodes::cast(Bytecodes::_lstore_0 + index)); break; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
908 case T_FLOAT: emit_bc(Bytecodes::cast(Bytecodes::_fstore_0 + index)); break; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
909 case T_DOUBLE: emit_bc(Bytecodes::cast(Bytecodes::_dstore_0 + index)); break; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
910 case T_OBJECT: emit_bc(Bytecodes::cast(Bytecodes::_astore_0 + index)); break; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
911 default: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
912 ShouldNotReachHere(); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
913 } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
914 } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
915 else { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
916 switch (bt) { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
917 case T_BOOLEAN: case T_BYTE: case T_CHAR: case T_SHORT: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
918 case T_INT: emit_bc(Bytecodes::_istore, index); break; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
919 case T_LONG: emit_bc(Bytecodes::_lstore, index); break; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
920 case T_FLOAT: emit_bc(Bytecodes::_fstore, index); break; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
921 case T_DOUBLE: emit_bc(Bytecodes::_dstore, index); break; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
922 case T_OBJECT: emit_bc(Bytecodes::_astore, index); break; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
923 default: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
924 ShouldNotReachHere(); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
925 } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
926 } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
927 stack_pop(bt); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
928 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
929 |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
930 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
931 void MethodHandleCompiler::emit_load_constant(ArgToken arg) { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
932 BasicType bt = arg.basic_type(); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
933 switch (bt) { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
934 case T_INT: { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
935 jint value = arg.get_jint(); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
936 if (-1 <= value && value <= 5) |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
937 emit_bc(Bytecodes::cast(Bytecodes::_iconst_0 + value)); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
938 else |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
939 emit_bc(Bytecodes::_ldc, cpool_int_put(value)); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
940 break; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
941 } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
942 case T_LONG: { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
943 jlong value = arg.get_jlong(); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
944 if (0 <= value && value <= 1) |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
945 emit_bc(Bytecodes::cast(Bytecodes::_lconst_0 + (int) value)); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
946 else |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
947 emit_bc(Bytecodes::_ldc2_w, cpool_long_put(value)); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
948 break; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
949 } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
950 case T_FLOAT: { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
951 jfloat value = arg.get_jfloat(); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
952 if (value == 0.0 || value == 1.0 || value == 2.0) |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
953 emit_bc(Bytecodes::cast(Bytecodes::_fconst_0 + (int) value)); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
954 else |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
955 emit_bc(Bytecodes::_ldc, cpool_float_put(value)); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
956 break; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
957 } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
958 case T_DOUBLE: { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
959 jdouble value = arg.get_jdouble(); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
960 if (value == 0.0 || value == 1.0) |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
961 emit_bc(Bytecodes::cast(Bytecodes::_dconst_0 + (int) value)); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
962 else |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
963 emit_bc(Bytecodes::_ldc2_w, cpool_double_put(value)); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
964 break; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
965 } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
966 case T_OBJECT: { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
967 Handle value = arg.object(); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
968 if (value.is_null()) |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
969 emit_bc(Bytecodes::_aconst_null); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
970 else |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
971 emit_bc(Bytecodes::_ldc, cpool_object_put(value)); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
972 break; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
973 } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
974 default: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
975 ShouldNotReachHere(); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
976 } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
977 stack_push(bt); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
978 } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
979 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
980 |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
981 MethodHandleWalker::ArgToken |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
982 MethodHandleCompiler::make_conversion(BasicType type, klassOop tk, Bytecodes::Code op, |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
983 const ArgToken& src, TRAPS) { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
984 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
985 BasicType srctype = src.basic_type(); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
986 int index = src.index(); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
987 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
988 switch (op) { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
989 case Bytecodes::_i2l: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
990 case Bytecodes::_i2f: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
991 case Bytecodes::_i2d: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
992 case Bytecodes::_i2b: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
993 case Bytecodes::_i2c: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
994 case Bytecodes::_i2s: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
995 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
996 case Bytecodes::_l2i: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
997 case Bytecodes::_l2f: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
998 case Bytecodes::_l2d: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
999 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1000 case Bytecodes::_f2i: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1001 case Bytecodes::_f2l: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1002 case Bytecodes::_f2d: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1003 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1004 case Bytecodes::_d2i: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1005 case Bytecodes::_d2l: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1006 case Bytecodes::_d2f: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1007 emit_load(srctype, index); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1008 stack_pop(srctype); // pop the src type |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1009 emit_bc(op); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1010 stack_push(type); // push the dest value |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1011 if (srctype != type) |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1012 index = new_local_index(type); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1013 emit_store(type, index); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1014 break; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1015 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1016 case Bytecodes::_checkcast: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1017 emit_load(srctype, index); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1018 emit_bc(op, cpool_klass_put(tk)); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1019 emit_store(srctype, index); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1020 break; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1021 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1022 default: |
3371
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1023 if (op == Bytecodes::_illegal) |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1024 lose("no such primitive conversion", THREAD); |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1025 else |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1026 lose("bad primitive conversion op", THREAD); |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1027 return make_prim_constant(type, &zero_jvalue, THREAD); |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1028 } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1029 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1030 return make_parameter(type, tk, index, THREAD); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1031 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1032 |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1033 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1034 // ----------------------------------------------------------------------------- |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1035 // MethodHandleCompiler |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1036 // |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1037 |
3371
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1038 // Values used by the compiler. |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1039 jvalue MethodHandleCompiler::zero_jvalue = { 0 }; |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1040 jvalue MethodHandleCompiler::one_jvalue = { 1 }; |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1041 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1042 // Emit bytecodes for the given invoke instruction. |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1043 MethodHandleWalker::ArgToken |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1044 MethodHandleCompiler::make_invoke(methodOop m, vmIntrinsics::ID iid, |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1045 Bytecodes::Code op, bool tailcall, |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1046 int argc, MethodHandleWalker::ArgToken* argv, |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1047 TRAPS) { |
3371
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1048 ArgToken zero; |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1049 if (m == NULL) { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1050 // Get the intrinsic methodOop. |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1051 m = vmIntrinsics::method_for(iid); |
2356
72dee110246f
6839872: remove implementation inheritance from JSR 292 APIs
jrose
parents:
2226
diff
changeset
|
1052 if (m == NULL) { |
72dee110246f
6839872: remove implementation inheritance from JSR 292 APIs
jrose
parents:
2226
diff
changeset
|
1053 lose(vmIntrinsics::name_at(iid), CHECK_(zero)); |
72dee110246f
6839872: remove implementation inheritance from JSR 292 APIs
jrose
parents:
2226
diff
changeset
|
1054 } |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1055 } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1056 |
3371
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1057 klassOop klass = m->method_holder(); |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1058 Symbol* name = m->name(); |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1059 Symbol* signature = m->signature(); |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1060 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1061 if (tailcall) { |
1152
cd37471eaecc
6914206: change way of permission checking for generated MethodHandle adapters
twisti
parents:
1142
diff
changeset
|
1062 // Actually, in order to make these methods more recognizable, |
2001
f2da85a9b08e
7001363: java/dyn/InvokeDynamic should not be a well-known class in the JVM
twisti
parents:
1972
diff
changeset
|
1063 // let's put them in holder class MethodHandle. That way stack |
f2da85a9b08e
7001363: java/dyn/InvokeDynamic should not be a well-known class in the JVM
twisti
parents:
1972
diff
changeset
|
1064 // walkers and compiler heuristics can recognize them. |
f2da85a9b08e
7001363: java/dyn/InvokeDynamic should not be a well-known class in the JVM
twisti
parents:
1972
diff
changeset
|
1065 _target_klass = SystemDictionary::MethodHandle_klass(); |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1066 } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1067 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1068 // Inline the method. |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1069 InvocationCounter* ic = m->invocation_counter(); |
1783 | 1070 ic->set_carry_flag(); |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1071 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1072 for (int i = 0; i < argc; i++) { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1073 ArgToken arg = argv[i]; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1074 TokenType tt = arg.token_type(); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1075 BasicType bt = arg.basic_type(); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1076 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1077 switch (tt) { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1078 case tt_parameter: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1079 case tt_temporary: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1080 emit_load(bt, arg.index()); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1081 break; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1082 case tt_constant: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1083 emit_load_constant(arg); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1084 break; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1085 case tt_illegal: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1086 // Sentinel. |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1087 assert(i == (argc - 1), "sentinel must be last entry"); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1088 break; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1089 case tt_void: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1090 default: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1091 ShouldNotReachHere(); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1092 } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1093 } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1094 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1095 // Populate constant pool. |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1096 int name_index = cpool_symbol_put(name); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1097 int signature_index = cpool_symbol_put(signature); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1098 int name_and_type_index = cpool_name_and_type_put(name_index, signature_index); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1099 int klass_index = cpool_klass_put(klass); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1100 int methodref_index = cpool_methodref_put(klass_index, name_and_type_index); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1101 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1102 // Generate invoke. |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1103 switch (op) { |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1104 case Bytecodes::_invokestatic: |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1105 case Bytecodes::_invokespecial: |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1106 case Bytecodes::_invokevirtual: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1107 emit_bc(op, methodref_index); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1108 break; |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1109 case Bytecodes::_invokeinterface: |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1110 Unimplemented(); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1111 break; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1112 default: |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1113 ShouldNotReachHere(); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1114 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1115 |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1116 // If tailcall, we have walked all the way to a direct method handle. |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1117 // Otherwise, make a recursive call to some helper routine. |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1118 BasicType rbt = m->result_type(); |
1152
cd37471eaecc
6914206: change way of permission checking for generated MethodHandle adapters
twisti
parents:
1142
diff
changeset
|
1119 if (rbt == T_ARRAY) rbt = T_OBJECT; |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1120 ArgToken ret; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1121 if (tailcall) { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1122 if (rbt != _rtype) { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1123 if (rbt == T_VOID) { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1124 // push a zero of the right sort |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1125 if (_rtype == T_OBJECT) { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1126 zero = make_oop_constant(NULL, CHECK_(zero)); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1127 } else { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1128 zero = make_prim_constant(_rtype, &zero_jvalue, CHECK_(zero)); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1129 } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1130 emit_load_constant(zero); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1131 } else if (_rtype == T_VOID) { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1132 // We'll emit a _return with something on the stack. |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1133 // It's OK to ignore what's on the stack. |
3371
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1134 } else if (rbt == T_INT && is_subword_type(_rtype)) { |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1135 // Convert value to match return type. |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1136 switch (_rtype) { |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1137 case T_BOOLEAN: { |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1138 // boolean is treated as a one-bit unsigned integer. |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1139 // Cf. API documentation: java/lang/invoke/MethodHandles.html#explicitCastArguments |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1140 ArgToken one = make_prim_constant(T_INT, &one_jvalue, CHECK_(zero)); |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1141 emit_load_constant(one); |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1142 emit_bc(Bytecodes::_iand); |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1143 break; |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1144 } |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1145 case T_BYTE: emit_bc(Bytecodes::_i2b); break; |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1146 case T_CHAR: emit_bc(Bytecodes::_i2c); break; |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1147 case T_SHORT: emit_bc(Bytecodes::_i2s); break; |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1148 default: ShouldNotReachHere(); |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1149 } |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1150 } else if (is_subword_type(rbt) && (is_subword_type(_rtype) || (_rtype == T_INT))) { |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1151 // The subword type was returned as an int and will be passed |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1152 // on as an int. |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1153 } else { |
3371
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1154 lose("unknown conversion", CHECK_(zero)); |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1155 } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1156 } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1157 switch (_rtype) { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1158 case T_BOOLEAN: case T_BYTE: case T_CHAR: case T_SHORT: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1159 case T_INT: emit_bc(Bytecodes::_ireturn); break; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1160 case T_LONG: emit_bc(Bytecodes::_lreturn); break; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1161 case T_FLOAT: emit_bc(Bytecodes::_freturn); break; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1162 case T_DOUBLE: emit_bc(Bytecodes::_dreturn); break; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1163 case T_VOID: emit_bc(Bytecodes::_return); break; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1164 case T_OBJECT: |
1142 | 1165 if (_rklass.not_null() && _rklass() != SystemDictionary::Object_klass()) |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1166 emit_bc(Bytecodes::_checkcast, cpool_klass_put(_rklass())); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1167 emit_bc(Bytecodes::_areturn); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1168 break; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1169 default: ShouldNotReachHere(); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1170 } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1171 ret = ArgToken(); // Dummy return value. |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1172 } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1173 else { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1174 stack_push(rbt); // The return value is already pushed onto the stack. |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1175 int index = new_local_index(rbt); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1176 switch (rbt) { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1177 case T_BOOLEAN: case T_BYTE: case T_CHAR: case T_SHORT: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1178 case T_INT: case T_LONG: case T_FLOAT: case T_DOUBLE: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1179 case T_OBJECT: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1180 emit_store(rbt, index); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1181 ret = ArgToken(tt_temporary, rbt, index); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1182 break; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1183 case T_VOID: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1184 ret = ArgToken(tt_void); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1185 break; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1186 default: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1187 ShouldNotReachHere(); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1188 } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1189 } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1190 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1191 return ret; |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1192 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1193 |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1194 MethodHandleWalker::ArgToken |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1195 MethodHandleCompiler::make_fetch(BasicType type, klassOop tk, Bytecodes::Code op, |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1196 const MethodHandleWalker::ArgToken& base, |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1197 const MethodHandleWalker::ArgToken& offset, |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1198 TRAPS) { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1199 Unimplemented(); |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1200 return ArgToken(); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1201 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1202 |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1203 |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1204 int MethodHandleCompiler::cpool_primitive_put(BasicType bt, jvalue* con) { |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1205 jvalue con_copy; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1206 assert(bt < T_OBJECT, ""); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1207 if (type2aelembytes(bt) < jintSize) { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1208 // widen to int |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1209 con_copy = (*con); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1210 con = &con_copy; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1211 switch (bt) { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1212 case T_BOOLEAN: con->i = (con->z ? 1 : 0); break; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1213 case T_BYTE: con->i = con->b; break; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1214 case T_CHAR: con->i = con->c; break; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1215 case T_SHORT: con->i = con->s; break; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1216 default: ShouldNotReachHere(); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1217 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1218 bt = T_INT; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1219 } |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1220 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1221 // for (int i = 1, imax = _constants.length(); i < imax; i++) { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1222 // ConstantValue* con = _constants.at(i); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1223 // if (con != NULL && con->is_primitive() && con->_type == bt) { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1224 // bool match = false; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1225 // switch (type2size[bt]) { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1226 // case 1: if (pcon->_value.i == con->i) match = true; break; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1227 // case 2: if (pcon->_value.j == con->j) match = true; break; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1228 // } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1229 // if (match) |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1230 // return i; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1231 // } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1232 // } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1233 ConstantValue* cv = new ConstantValue(bt, *con); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1234 int index = _constants.append(cv); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1235 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1236 // long and double entries take 2 slots, we add another empty entry. |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1237 if (type2size[bt] == 2) |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1238 (void) _constants.append(NULL); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1239 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1240 return index; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1241 } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1242 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1243 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1244 constantPoolHandle MethodHandleCompiler::get_constant_pool(TRAPS) const { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1245 constantPoolHandle nullHandle; |
2226
c5a923563727
6912621: iCMS: Error: assert(_markBitMap.isMarked(addr + 1),"Missing Printezis bit?")
ysr
parents:
2177
diff
changeset
|
1246 constantPoolOop cpool_oop = oopFactory::new_constantPool(_constants.length(), |
c5a923563727
6912621: iCMS: Error: assert(_markBitMap.isMarked(addr + 1),"Missing Printezis bit?")
ysr
parents:
2177
diff
changeset
|
1247 oopDesc::IsSafeConc, |
c5a923563727
6912621: iCMS: Error: assert(_markBitMap.isMarked(addr + 1),"Missing Printezis bit?")
ysr
parents:
2177
diff
changeset
|
1248 CHECK_(nullHandle)); |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1249 constantPoolHandle cpool(THREAD, cpool_oop); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1250 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1251 // Fill the real constant pool skipping the zero element. |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1252 for (int i = 1; i < _constants.length(); i++) { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1253 ConstantValue* cv = _constants.at(i); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1254 switch (cv->tag()) { |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2117
diff
changeset
|
1255 case JVM_CONSTANT_Utf8: cpool->symbol_at_put( i, cv->symbol() ); break; |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1256 case JVM_CONSTANT_Integer: cpool->int_at_put( i, cv->get_jint() ); break; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1257 case JVM_CONSTANT_Float: cpool->float_at_put( i, cv->get_jfloat() ); break; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1258 case JVM_CONSTANT_Long: cpool->long_at_put( i, cv->get_jlong() ); break; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1259 case JVM_CONSTANT_Double: cpool->double_at_put( i, cv->get_jdouble() ); break; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1260 case JVM_CONSTANT_Class: cpool->klass_at_put( i, cv->klass_oop() ); break; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1261 case JVM_CONSTANT_Methodref: cpool->method_at_put( i, cv->first_index(), cv->second_index()); break; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1262 case JVM_CONSTANT_NameAndType: cpool->name_and_type_at_put(i, cv->first_index(), cv->second_index()); break; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1263 case JVM_CONSTANT_Object: cpool->object_at_put( i, cv->object_oop() ); break; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1264 default: ShouldNotReachHere(); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1265 } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1266 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1267 switch (cv->tag()) { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1268 case JVM_CONSTANT_Long: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1269 case JVM_CONSTANT_Double: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1270 i++; // Skip empty entry. |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1271 assert(_constants.at(i) == NULL, "empty entry"); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1272 break; |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1273 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1274 } |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1275 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1276 // Set the constant pool holder to the target method's class. |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1277 cpool->set_pool_holder(_target_klass()); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1278 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1279 return cpool; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1280 } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1281 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1282 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1283 methodHandle MethodHandleCompiler::get_method_oop(TRAPS) const { |
3366
e2a92dd0d3d2
7042122: JSR 292: adjust various inline thresholds for JSR 292 API methods and method handle adapters
twisti
parents:
3363
diff
changeset
|
1284 methodHandle empty; |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1285 // Create a method that holds the generated bytecode. invokedynamic |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1286 // has no receiver, normal MH calls do. |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1287 int flags_bits; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1288 if (for_invokedynamic()) |
1507
cd5dbf694d45
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
1152
diff
changeset
|
1289 flags_bits = (/*JVM_MH_INVOKE_BITS |*/ JVM_ACC_PUBLIC | JVM_ACC_FINAL | JVM_ACC_SYNTHETIC | JVM_ACC_STATIC); |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1290 else |
1507
cd5dbf694d45
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
1152
diff
changeset
|
1291 flags_bits = (/*JVM_MH_INVOKE_BITS |*/ JVM_ACC_PUBLIC | JVM_ACC_FINAL | JVM_ACC_SYNTHETIC); |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1292 |
3366
e2a92dd0d3d2
7042122: JSR 292: adjust various inline thresholds for JSR 292 API methods and method handle adapters
twisti
parents:
3363
diff
changeset
|
1293 // Create a new method |
e2a92dd0d3d2
7042122: JSR 292: adjust various inline thresholds for JSR 292 API methods and method handle adapters
twisti
parents:
3363
diff
changeset
|
1294 methodHandle m; |
e2a92dd0d3d2
7042122: JSR 292: adjust various inline thresholds for JSR 292 API methods and method handle adapters
twisti
parents:
3363
diff
changeset
|
1295 { |
e2a92dd0d3d2
7042122: JSR 292: adjust various inline thresholds for JSR 292 API methods and method handle adapters
twisti
parents:
3363
diff
changeset
|
1296 methodOop m_oop = oopFactory::new_method(bytecode_length(), |
e2a92dd0d3d2
7042122: JSR 292: adjust various inline thresholds for JSR 292 API methods and method handle adapters
twisti
parents:
3363
diff
changeset
|
1297 accessFlags_from(flags_bits), |
e2a92dd0d3d2
7042122: JSR 292: adjust various inline thresholds for JSR 292 API methods and method handle adapters
twisti
parents:
3363
diff
changeset
|
1298 0, 0, 0, oopDesc::IsSafeConc, CHECK_(empty)); |
e2a92dd0d3d2
7042122: JSR 292: adjust various inline thresholds for JSR 292 API methods and method handle adapters
twisti
parents:
3363
diff
changeset
|
1299 m = methodHandle(THREAD, m_oop); |
e2a92dd0d3d2
7042122: JSR 292: adjust various inline thresholds for JSR 292 API methods and method handle adapters
twisti
parents:
3363
diff
changeset
|
1300 } |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1301 |
3366
e2a92dd0d3d2
7042122: JSR 292: adjust various inline thresholds for JSR 292 API methods and method handle adapters
twisti
parents:
3363
diff
changeset
|
1302 constantPoolHandle cpool = get_constant_pool(CHECK_(empty)); |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1303 m->set_constants(cpool()); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1304 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1305 m->set_name_index(_name_index); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1306 m->set_signature_index(_signature_index); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1307 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1308 m->set_code((address) bytecode()); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1309 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1310 m->set_max_stack(_max_stack); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1311 m->set_max_locals(max_locals()); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1312 m->set_size_of_parameters(_num_params); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1313 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1314 typeArrayHandle exception_handlers(THREAD, Universe::the_empty_int_array()); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1315 m->set_exception_table(exception_handlers()); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1316 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1317 // Rewrite the method and set up the constant pool cache. |
3366
e2a92dd0d3d2
7042122: JSR 292: adjust various inline thresholds for JSR 292 API methods and method handle adapters
twisti
parents:
3363
diff
changeset
|
1318 objArrayOop m_array = oopFactory::new_system_objArray(1, CHECK_(empty)); |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1319 objArrayHandle methods(THREAD, m_array); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1320 methods->obj_at_put(0, m()); |
3366
e2a92dd0d3d2
7042122: JSR 292: adjust various inline thresholds for JSR 292 API methods and method handle adapters
twisti
parents:
3363
diff
changeset
|
1321 Rewriter::rewrite(_target_klass(), cpool, methods, CHECK_(empty)); // Use fake class. |
e2a92dd0d3d2
7042122: JSR 292: adjust various inline thresholds for JSR 292 API methods and method handle adapters
twisti
parents:
3363
diff
changeset
|
1322 |
3371
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1323 // Set the invocation counter's count to the invoke count of the |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1324 // original call site. |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1325 InvocationCounter* ic = m->invocation_counter(); |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1326 ic->set(InvocationCounter::wait_for_compile, _invoke_count); |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1327 |
3366
e2a92dd0d3d2
7042122: JSR 292: adjust various inline thresholds for JSR 292 API methods and method handle adapters
twisti
parents:
3363
diff
changeset
|
1328 // Create a new MDO |
e2a92dd0d3d2
7042122: JSR 292: adjust various inline thresholds for JSR 292 API methods and method handle adapters
twisti
parents:
3363
diff
changeset
|
1329 { |
e2a92dd0d3d2
7042122: JSR 292: adjust various inline thresholds for JSR 292 API methods and method handle adapters
twisti
parents:
3363
diff
changeset
|
1330 methodDataOop mdo = oopFactory::new_methodData(m, CHECK_(empty)); |
e2a92dd0d3d2
7042122: JSR 292: adjust various inline thresholds for JSR 292 API methods and method handle adapters
twisti
parents:
3363
diff
changeset
|
1331 assert(m->method_data() == NULL, "there should not be an MDO yet"); |
e2a92dd0d3d2
7042122: JSR 292: adjust various inline thresholds for JSR 292 API methods and method handle adapters
twisti
parents:
3363
diff
changeset
|
1332 m->set_method_data(mdo); |
e2a92dd0d3d2
7042122: JSR 292: adjust various inline thresholds for JSR 292 API methods and method handle adapters
twisti
parents:
3363
diff
changeset
|
1333 |
e2a92dd0d3d2
7042122: JSR 292: adjust various inline thresholds for JSR 292 API methods and method handle adapters
twisti
parents:
3363
diff
changeset
|
1334 // Iterate over all profile data and set the count of the counter |
e2a92dd0d3d2
7042122: JSR 292: adjust various inline thresholds for JSR 292 API methods and method handle adapters
twisti
parents:
3363
diff
changeset
|
1335 // data entries to the original call site counter. |
3371
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1336 for (ProfileData* profile_data = mdo->first_data(); |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1337 mdo->is_valid(profile_data); |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1338 profile_data = mdo->next_data(profile_data)) { |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1339 if (profile_data->is_CounterData()) { |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1340 CounterData* counter_data = profile_data->as_CounterData(); |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1341 counter_data->set_count(_invoke_count); |
3366
e2a92dd0d3d2
7042122: JSR 292: adjust various inline thresholds for JSR 292 API methods and method handle adapters
twisti
parents:
3363
diff
changeset
|
1342 } |
e2a92dd0d3d2
7042122: JSR 292: adjust various inline thresholds for JSR 292 API methods and method handle adapters
twisti
parents:
3363
diff
changeset
|
1343 } |
e2a92dd0d3d2
7042122: JSR 292: adjust various inline thresholds for JSR 292 API methods and method handle adapters
twisti
parents:
3363
diff
changeset
|
1344 } |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1345 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1346 #ifndef PRODUCT |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1347 if (TraceMethodHandles) { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1348 m->print(); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1349 m->print_codes(); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1350 } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1351 #endif //PRODUCT |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1352 |
1507
cd5dbf694d45
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
1152
diff
changeset
|
1353 assert(m->is_method_handle_adapter(), "must be recognized as an adapter"); |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1354 return m; |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1355 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1356 |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1357 |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1358 #ifndef PRODUCT |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1359 |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1360 // MH printer for debugging. |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1361 |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1362 class MethodHandlePrinter : public MethodHandleWalker { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1363 private: |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1364 outputStream* _out; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1365 bool _verbose; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1366 int _temp_num; |
3371
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1367 int _param_state; |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1368 stringStream _strbuf; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1369 const char* strbuf() { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1370 const char* s = _strbuf.as_string(); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1371 _strbuf.reset(); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1372 return s; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1373 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1374 ArgToken token(const char* str) { |
3371
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1375 jvalue string_con; |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1376 string_con.j = (intptr_t) str; |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1377 return ArgToken(tt_symbolic, T_LONG, string_con); |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1378 } |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1379 const char* string(ArgToken token) { |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1380 return (const char*) (intptr_t) token.get_jlong(); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1381 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1382 void start_params() { |
3371
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1383 _param_state <<= 1; |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1384 _out->print("("); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1385 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1386 void end_params() { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1387 if (_verbose) _out->print("\n"); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1388 _out->print(") => {"); |
3371
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1389 _param_state >>= 1; |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1390 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1391 void put_type_name(BasicType type, klassOop tk, outputStream* s) { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1392 const char* kname = NULL; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1393 if (tk != NULL) |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1394 kname = Klass::cast(tk)->external_name(); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1395 s->print("%s", (kname != NULL) ? kname : type2name(type)); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1396 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1397 ArgToken maybe_make_temp(const char* statement_op, BasicType type, const char* temp_name) { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1398 const char* value = strbuf(); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1399 if (!_verbose) return token(value); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1400 // make an explicit binding for each separate value |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1401 _strbuf.print("%s%d", temp_name, ++_temp_num); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1402 const char* temp = strbuf(); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1403 _out->print("\n %s %s %s = %s;", statement_op, type2name(type), temp, value); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1404 return token(temp); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1405 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1406 |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1407 public: |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1408 MethodHandlePrinter(Handle root, bool verbose, outputStream* out, TRAPS) |
3371
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1409 : MethodHandleWalker(root, false, THREAD), |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1410 _out(out), |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1411 _verbose(verbose), |
3371
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1412 _param_state(0), |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1413 _temp_num(0) |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1414 { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1415 start_params(); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1416 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1417 virtual ArgToken make_parameter(BasicType type, klassOop tk, int argnum, TRAPS) { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1418 if (argnum < 0) { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1419 end_params(); |
3371
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1420 return token("return"); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1421 } |
3371
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1422 if ((_param_state & 1) == 0) { |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1423 _param_state |= 1; |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1424 _out->print(_verbose ? "\n " : ""); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1425 } else { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1426 _out->print(_verbose ? ",\n " : ", "); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1427 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1428 if (argnum >= _temp_num) |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1429 _temp_num = argnum; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1430 // generate an argument name |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1431 _strbuf.print("a%d", argnum); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1432 const char* arg = strbuf(); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1433 put_type_name(type, tk, _out); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1434 _out->print(" %s", arg); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1435 return token(arg); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1436 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1437 virtual ArgToken make_oop_constant(oop con, TRAPS) { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1438 if (con == NULL) |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1439 _strbuf.print("null"); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1440 else |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1441 con->print_value_on(&_strbuf); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1442 if (_strbuf.size() == 0) { // yuck |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1443 _strbuf.print("(a "); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1444 put_type_name(T_OBJECT, con->klass(), &_strbuf); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1445 _strbuf.print(")"); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1446 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1447 return maybe_make_temp("constant", T_OBJECT, "k"); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1448 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1449 virtual ArgToken make_prim_constant(BasicType type, jvalue* con, TRAPS) { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1450 java_lang_boxing_object::print(type, con, &_strbuf); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1451 return maybe_make_temp("constant", type, "k"); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1452 } |
3371
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1453 void print_bytecode_name(Bytecodes::Code op) { |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1454 if (Bytecodes::is_defined(op)) |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1455 _strbuf.print("%s", Bytecodes::name(op)); |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1456 else |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1457 _strbuf.print("bytecode_%d", (int) op); |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1458 } |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1459 virtual ArgToken make_conversion(BasicType type, klassOop tk, Bytecodes::Code op, const ArgToken& src, TRAPS) { |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1460 print_bytecode_name(op); |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1461 _strbuf.print("(%s", string(src)); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1462 if (tk != NULL) { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1463 _strbuf.print(", "); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1464 put_type_name(type, tk, &_strbuf); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1465 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1466 _strbuf.print(")"); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1467 return maybe_make_temp("convert", type, "v"); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1468 } |
3371
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1469 virtual ArgToken make_fetch(BasicType type, klassOop tk, Bytecodes::Code op, const ArgToken& base, const ArgToken& offset, TRAPS) { |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1470 _strbuf.print("%s(%s, %s", Bytecodes::name(op), string(base), string(offset)); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1471 if (tk != NULL) { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1472 _strbuf.print(", "); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1473 put_type_name(type, tk, &_strbuf); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1474 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1475 _strbuf.print(")"); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1476 return maybe_make_temp("fetch", type, "x"); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1477 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1478 virtual ArgToken make_invoke(methodOop m, vmIntrinsics::ID iid, |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1479 Bytecodes::Code op, bool tailcall, |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1480 int argc, ArgToken* argv, TRAPS) { |
3371
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1481 Symbol* name; |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1482 Symbol* sig; |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1483 if (m != NULL) { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1484 name = m->name(); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1485 sig = m->signature(); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1486 } else { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1487 name = vmSymbols::symbol_at(vmIntrinsics::name_for(iid)); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1488 sig = vmSymbols::symbol_at(vmIntrinsics::signature_for(iid)); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1489 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1490 _strbuf.print("%s %s%s(", Bytecodes::name(op), name->as_C_string(), sig->as_C_string()); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1491 for (int i = 0; i < argc; i++) { |
3371
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1492 _strbuf.print("%s%s", (i > 0 ? ", " : ""), string(argv[i])); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1493 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1494 _strbuf.print(")"); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1495 if (!tailcall) { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1496 BasicType rt = char2type(sig->byte_at(sig->utf8_length()-1)); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1497 if (rt == T_ILLEGAL) rt = T_OBJECT; // ';' at the end of '(...)L...;' |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1498 return maybe_make_temp("invoke", rt, "x"); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1499 } else { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1500 const char* ret = strbuf(); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1501 _out->print(_verbose ? "\n return " : " "); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1502 _out->print("%s", ret); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1503 _out->print(_verbose ? "\n}\n" : " }"); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1504 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1505 return ArgToken(); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1506 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1507 |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1508 virtual void set_method_handle(oop mh) { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1509 if (WizardMode && Verbose) { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1510 tty->print("\n--- next target: "); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1511 mh->print(); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1512 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1513 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1514 |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1515 static void print(Handle root, bool verbose, outputStream* out, TRAPS) { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1516 ResourceMark rm; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1517 MethodHandlePrinter printer(root, verbose, out, CHECK); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1518 printer.walk(CHECK); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1519 out->print("\n"); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1520 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1521 static void print(Handle root, bool verbose = Verbose, outputStream* out = tty) { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1522 EXCEPTION_MARK; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1523 ResourceMark rm; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1524 MethodHandlePrinter printer(root, verbose, out, THREAD); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1525 if (!HAS_PENDING_EXCEPTION) |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1526 printer.walk(THREAD); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1527 if (HAS_PENDING_EXCEPTION) { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1528 oop ex = PENDING_EXCEPTION; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1529 CLEAR_PENDING_EXCEPTION; |
3371
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1530 out->print(" *** "); |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1531 if (printer.lose_message() != NULL) out->print("%s ", printer.lose_message()); |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1532 out->print("}"); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1533 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1534 out->print("\n"); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1535 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1536 }; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1537 |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1538 extern "C" |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1539 void print_method_handle(oop mh) { |
1793
d257356e35f0
6939224: MethodHandle.invokeGeneric needs to perform the correct set of conversions
jrose
parents:
1783
diff
changeset
|
1540 if (!mh->is_oop()) { |
3371
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1541 tty->print_cr("*** not a method handle: "PTR_FORMAT, (intptr_t)mh); |
2357
8033953d67ff
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
2356
diff
changeset
|
1542 } else if (java_lang_invoke_MethodHandle::is_instance(mh)) { |
3371
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1543 MethodHandlePrinter::print(mh); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1544 } else { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1545 tty->print("*** not a method handle: "); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1546 mh->print(); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1547 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1548 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1549 |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1550 #endif // PRODUCT |