Mercurial > hg > graal-compiler
annotate src/share/vm/prims/methodHandleWalk.cpp @ 3917:eca1193ca245
4965777: GC changes to support use of discovered field for pending references
Summary: If and when the reference handler thread is able to use the discovered field to link reference objects in its pending list, so will GC. In that case, GC will scan through this field once a reference object has been placed on the pending list, but not scan that field before that stage, as the field is used by the concurrent GC thread to link discovered objects. When ReferenceHandleR thread does not use the discovered field for the purpose of linking the elements in the pending list, as would be the case in older JDKs, the JVM will fall back to the old behaviour of using the next field for that purpose.
Reviewed-by: jcoomes, mchung, stefank
author | ysr |
---|---|
date | Wed, 07 Sep 2011 13:55:42 -0700 |
parents | ddd894528dbc |
children | c26de9aef2ed |
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; |
3740
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
144 #ifdef ASSERT |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
145 if (Verbose) { |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
146 tty->print_cr(INTPTR_FORMAT " lose: %s", _method_handle(), msg); |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
147 print(); |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
148 } |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
149 #endif |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
150 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
|
151 // throw a preallocated exception |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
152 THROW_OOP(Universe::virtual_machine_error_instance()); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
153 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
154 THROW_MSG(vmSymbols::java_lang_InternalError(), msg); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
155 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
156 |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
157 |
3740
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
158 #ifdef ASSERT |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
159 static const char* adapter_ops[] = { |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
160 "retype_only" , |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
161 "retype_raw" , |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
162 "check_cast" , |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
163 "prim_to_prim" , |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
164 "ref_to_prim" , |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
165 "prim_to_ref" , |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
166 "swap_args" , |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
167 "rot_args" , |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
168 "dup_args" , |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
169 "drop_args" , |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
170 "collect_args" , |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
171 "spread_args" , |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
172 "fold_args" |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
173 }; |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
174 |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
175 static const char* adapter_op_to_string(int op) { |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
176 if (op >= 0 && op < (int)ARRAY_SIZE(adapter_ops)) |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
177 return adapter_ops[op]; |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
178 return "unknown_op"; |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
179 } |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
180 |
3753
cba7b5c2d53f
7045514: SPARC assembly code for JSR 292 ricochet frames
never
parents:
3740
diff
changeset
|
181 void MethodHandleChain::print(oopDesc* m) { |
cba7b5c2d53f
7045514: SPARC assembly code for JSR 292 ricochet frames
never
parents:
3740
diff
changeset
|
182 HandleMark hm; |
cba7b5c2d53f
7045514: SPARC assembly code for JSR 292 ricochet frames
never
parents:
3740
diff
changeset
|
183 ResourceMark rm; |
cba7b5c2d53f
7045514: SPARC assembly code for JSR 292 ricochet frames
never
parents:
3740
diff
changeset
|
184 Handle mh(m); |
cba7b5c2d53f
7045514: SPARC assembly code for JSR 292 ricochet frames
never
parents:
3740
diff
changeset
|
185 print(mh); |
cba7b5c2d53f
7045514: SPARC assembly code for JSR 292 ricochet frames
never
parents:
3740
diff
changeset
|
186 } |
3740
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
187 |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
188 void MethodHandleChain::print(Handle mh) { |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
189 EXCEPTION_MARK; |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
190 MethodHandleChain mhc(mh, THREAD); |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
191 if (HAS_PENDING_EXCEPTION) { |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
192 oop ex = THREAD->pending_exception(); |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
193 CLEAR_PENDING_EXCEPTION; |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
194 ex->print(); |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
195 return; |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
196 } |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
197 mhc.print(); |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
198 } |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
199 |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
200 |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
201 void MethodHandleChain::print() { |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
202 EXCEPTION_MARK; |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
203 print_impl(THREAD); |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
204 if (HAS_PENDING_EXCEPTION) { |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
205 oop ex = THREAD->pending_exception(); |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
206 CLEAR_PENDING_EXCEPTION; |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
207 ex->print(); |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
208 } |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
209 } |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
210 |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
211 void MethodHandleChain::print_impl(TRAPS) { |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
212 ResourceMark rm; |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
213 |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
214 MethodHandleChain chain(_root, CHECK); |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
215 for (;;) { |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
216 tty->print(INTPTR_FORMAT ": ", chain.method_handle()()); |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
217 if (chain.is_bound()) { |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
218 tty->print("bound: arg_type %s arg_slot %d", |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
219 type2name(chain.bound_arg_type()), |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
220 chain.bound_arg_slot()); |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
221 oop o = chain.bound_arg_oop(); |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
222 if (o != NULL) { |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
223 if (o->is_instance()) { |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
224 tty->print(" instance %s", o->klass()->klass_part()->internal_name()); |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
225 } else { |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
226 o->print(); |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
227 } |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
228 } |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
229 } else if (chain.is_adapter()) { |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
230 tty->print("adapter: arg_slot %d conversion op %s", |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
231 chain.adapter_arg_slot(), |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
232 adapter_op_to_string(chain.adapter_conversion_op())); |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
233 switch (chain.adapter_conversion_op()) { |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
234 case java_lang_invoke_AdapterMethodHandle::OP_RETYPE_ONLY: |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
235 case java_lang_invoke_AdapterMethodHandle::OP_RETYPE_RAW: |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
236 case java_lang_invoke_AdapterMethodHandle::OP_CHECK_CAST: |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
237 case java_lang_invoke_AdapterMethodHandle::OP_PRIM_TO_PRIM: |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
238 case java_lang_invoke_AdapterMethodHandle::OP_REF_TO_PRIM: |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
239 break; |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
240 |
3757
f8c9417e3571
7052219: JSR 292: Crash in ~BufferBlob::MethodHandles adapters
never
parents:
3753
diff
changeset
|
241 case java_lang_invoke_AdapterMethodHandle::OP_PRIM_TO_REF: { |
f8c9417e3571
7052219: JSR 292: Crash in ~BufferBlob::MethodHandles adapters
never
parents:
3753
diff
changeset
|
242 tty->print(" src_type = %s", type2name(chain.adapter_conversion_src_type())); |
f8c9417e3571
7052219: JSR 292: Crash in ~BufferBlob::MethodHandles adapters
never
parents:
3753
diff
changeset
|
243 break; |
f8c9417e3571
7052219: JSR 292: Crash in ~BufferBlob::MethodHandles adapters
never
parents:
3753
diff
changeset
|
244 } |
f8c9417e3571
7052219: JSR 292: Crash in ~BufferBlob::MethodHandles adapters
never
parents:
3753
diff
changeset
|
245 |
3740
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
246 case java_lang_invoke_AdapterMethodHandle::OP_SWAP_ARGS: |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
247 case java_lang_invoke_AdapterMethodHandle::OP_ROT_ARGS: { |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
248 int dest_arg_slot = chain.adapter_conversion_vminfo(); |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
249 tty->print(" dest_arg_slot %d type %s", dest_arg_slot, type2name(chain.adapter_conversion_src_type())); |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
250 break; |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
251 } |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
252 |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
253 case java_lang_invoke_AdapterMethodHandle::OP_DUP_ARGS: |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
254 case java_lang_invoke_AdapterMethodHandle::OP_DROP_ARGS: { |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
255 int dup_slots = chain.adapter_conversion_stack_pushes(); |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
256 tty->print(" pushes %d", dup_slots); |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
257 break; |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
258 } |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
259 |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
260 case java_lang_invoke_AdapterMethodHandle::OP_FOLD_ARGS: |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
261 case java_lang_invoke_AdapterMethodHandle::OP_COLLECT_ARGS: { |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
262 int coll_slots = chain.MethodHandle_vmslots(); |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
263 tty->print(" coll_slots %d", coll_slots); |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
264 break; |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
265 } |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
266 |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
267 case java_lang_invoke_AdapterMethodHandle::OP_SPREAD_ARGS: { |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
268 // Check the required length. |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
269 int spread_slots = 1 + chain.adapter_conversion_stack_pushes(); |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
270 tty->print(" spread_slots %d", spread_slots); |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
271 break; |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
272 } |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
273 |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
274 default: |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
275 tty->print_cr("bad adapter conversion"); |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
276 break; |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
277 } |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
278 } else { |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
279 // DMH |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
280 tty->print("direct: "); |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
281 chain.last_method_oop()->print_short_name(tty); |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
282 } |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
283 |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
284 tty->print(" ("); |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
285 objArrayOop ptypes = java_lang_invoke_MethodType::ptypes(chain.method_type_oop()); |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
286 for (int i = ptypes->length() - 1; i >= 0; i--) { |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
287 BasicType t = java_lang_Class::as_BasicType(ptypes->obj_at(i)); |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
288 if (t == T_ARRAY) t = T_OBJECT; |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
289 tty->print("%c", type2char(t)); |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
290 if (t == T_LONG || t == T_DOUBLE) tty->print("_"); |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
291 } |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
292 tty->print(")"); |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
293 BasicType rtype = java_lang_Class::as_BasicType(java_lang_invoke_MethodType::rtype(chain.method_type_oop())); |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
294 if (rtype == T_ARRAY) rtype = T_OBJECT; |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
295 tty->print("%c", type2char(rtype)); |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
296 tty->cr(); |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
297 if (!chain.is_last()) { |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
298 chain.next(CHECK); |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
299 } else { |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
300 break; |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
301 } |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
302 } |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
303 } |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
304 #endif |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
305 |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
306 |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
307 // ----------------------------------------------------------------------------- |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
308 // MethodHandleWalker |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
309 |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
310 Bytecodes::Code MethodHandleWalker::conversion_code(BasicType src, BasicType dest) { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
311 if (is_subword_type(src)) { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
312 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
|
313 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
314 if (src == dest) { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
315 return Bytecodes::_nop; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
316 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
317 |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
318 #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
|
319 switch (SRC_DEST(src, dest)) { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
320 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
|
321 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
|
322 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
|
323 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
|
324 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
|
325 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
|
326 |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
327 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
|
328 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
|
329 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
|
330 |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
331 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
|
332 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
|
333 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
|
334 |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
335 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
|
336 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
|
337 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
|
338 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
339 #undef SRC_DEST |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
340 |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
341 // cannot do it in one step, or at all |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
342 return Bytecodes::_illegal; |
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 |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
345 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
346 // ----------------------------------------------------------------------------- |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
347 // MethodHandleWalker::walk |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
348 // |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
349 MethodHandleWalker::ArgToken |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
350 MethodHandleWalker::walk(TRAPS) { |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
351 ArgToken empty = ArgToken(); // Empty return value. |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
352 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
353 walk_incoming_state(CHECK_(empty)); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
354 |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
355 for (;;) { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
356 set_method_handle(chain().method_handle_oop()); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
357 |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
358 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
|
359 |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
360 if (chain().is_adapter()) { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
361 int conv_op = chain().adapter_conversion_op(); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
362 int arg_slot = chain().adapter_arg_slot(); |
3740
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
363 |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
364 // Check that the arg_slot is valid. In most cases it must be |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
365 // within range of the current arguments but there are some |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
366 // exceptions. Those are sanity checked in their implemention |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
367 // below. |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
368 if ((arg_slot < 0 || arg_slot >= _outgoing.length()) && |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
369 conv_op > java_lang_invoke_AdapterMethodHandle::OP_RETYPE_RAW && |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
370 conv_op != java_lang_invoke_AdapterMethodHandle::OP_COLLECT_ARGS && |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
371 conv_op != java_lang_invoke_AdapterMethodHandle::OP_FOLD_ARGS) { |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
372 lose(err_msg("bad argument index %d", arg_slot), CHECK_(empty)); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
373 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
374 |
3371
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
375 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
|
376 |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
377 // perform the adapter action |
3371
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
378 switch (conv_op) { |
2357
8033953d67ff
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
2356
diff
changeset
|
379 case java_lang_invoke_AdapterMethodHandle::OP_RETYPE_ONLY: |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
380 // No changes to arguments; pass the bits through. |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
381 break; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
382 |
2357
8033953d67ff
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
2356
diff
changeset
|
383 case java_lang_invoke_AdapterMethodHandle::OP_RETYPE_RAW: { |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
384 // 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
|
385 // See MethodHandles::same_basic_type_for_arguments for allowed conversions. |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
386 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
|
387 Handle outgoing_mtype; |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
388 { |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
389 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
|
390 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
|
391 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
|
392 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
|
393 } |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
394 |
2357
8033953d67ff
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
2356
diff
changeset
|
395 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
|
396 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
|
397 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
|
398 |
3371
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
399 // Argument types. |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
400 for (int i = 0, slot = _outgoing.length() - 1; slot >= 0; slot--) { |
3740
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
401 if (arg_type(slot) == T_VOID) continue; |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
402 |
3371
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
403 klassOop src_klass = NULL; |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
404 klassOop dst_klass = NULL; |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
405 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
|
406 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
|
407 retype_raw_argument_type(src, dst, slot, CHECK_(empty)); |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
408 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
|
409 } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
410 |
3371
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
411 // Return type. |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
412 { |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
413 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
|
414 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
|
415 retype_raw_return_type(src, dst, CHECK_(empty)); |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
416 } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
417 break; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
418 } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
419 |
2357
8033953d67ff
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
2356
diff
changeset
|
420 case java_lang_invoke_AdapterMethodHandle::OP_CHECK_CAST: { |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
421 // checkcast the Nth outgoing argument in place |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
422 klassOop dest_klass = NULL; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
423 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
|
424 assert(dest == T_OBJECT, ""); |
3740
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
425 ArgToken arg = _outgoing.at(arg_slot); |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
426 assert(dest == arg.basic_type(), ""); |
3753
cba7b5c2d53f
7045514: SPARC assembly code for JSR 292 ricochet frames
never
parents:
3740
diff
changeset
|
427 arg = make_conversion(T_OBJECT, dest_klass, Bytecodes::_checkcast, arg, CHECK_(empty)); |
3785
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
428 // replace the object by the result of the cast, to make the compiler happy: |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
429 change_argument(T_OBJECT, arg_slot, T_OBJECT, arg); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
430 debug_only(dest_klass = (klassOop)badOop); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
431 break; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
432 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
433 |
2357
8033953d67ff
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
2356
diff
changeset
|
434 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
|
435 // i2l, etc., on the Nth outgoing argument in place |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
436 BasicType src = chain().adapter_conversion_src_type(), |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
437 dest = chain().adapter_conversion_dest_type(); |
3740
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
438 ArgToken arg = _outgoing.at(arg_slot); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
439 Bytecodes::Code bc = conversion_code(src, dest); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
440 if (bc == Bytecodes::_nop) { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
441 break; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
442 } else if (bc != Bytecodes::_illegal) { |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
443 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
|
444 } else if (is_subword_type(dest)) { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
445 bc = conversion_code(src, T_INT); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
446 if (bc != Bytecodes::_illegal) { |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
447 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
|
448 bc = conversion_code(T_INT, dest); |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
449 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
|
450 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
451 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
452 if (bc == Bytecodes::_illegal) { |
3740
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
453 lose(err_msg("bad primitive conversion for %s -> %s", type2name(src), type2name(dest)), CHECK_(empty)); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
454 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
455 change_argument(src, arg_slot, dest, arg); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
456 break; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
457 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
458 |
2357
8033953d67ff
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
2356
diff
changeset
|
459 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
|
460 // checkcast to wrapper type & call intValue, etc. |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
461 BasicType dest = chain().adapter_conversion_dest_type(); |
3740
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
462 ArgToken arg = _outgoing.at(arg_slot); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
463 arg = make_conversion(T_OBJECT, SystemDictionary::box_klass(dest), |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
464 Bytecodes::_checkcast, arg, CHECK_(empty)); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
465 vmIntrinsics::ID unboxer = vmIntrinsics::for_unboxing(dest); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
466 if (unboxer == vmIntrinsics::_none) { |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
467 lose("no unboxing method", CHECK_(empty)); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
468 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
469 ArgToken arglist[2]; |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
470 arglist[0] = arg; // outgoing 'this' |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
471 arglist[1] = ArgToken(); // sentinel |
3785
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
472 arg = make_invoke(methodHandle(), 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
|
473 change_argument(T_OBJECT, arg_slot, dest, arg); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
474 break; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
475 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
476 |
2357
8033953d67ff
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
2356
diff
changeset
|
477 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
|
478 // call wrapper type.valueOf |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
479 BasicType src = chain().adapter_conversion_src_type(); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
480 vmIntrinsics::ID boxer = vmIntrinsics::for_boxing(src); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
481 if (boxer == vmIntrinsics::_none) { |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
482 lose("no boxing method", CHECK_(empty)); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
483 } |
3740
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
484 ArgToken arg = _outgoing.at(arg_slot); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
485 ArgToken arglist[2]; |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
486 arglist[0] = arg; // outgoing value |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
487 arglist[1] = ArgToken(); // sentinel |
3785
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
488 arg = make_invoke(methodHandle(), 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
|
489 change_argument(src, arg_slot, T_OBJECT, arg); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
490 break; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
491 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
492 |
2357
8033953d67ff
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
2356
diff
changeset
|
493 case java_lang_invoke_AdapterMethodHandle::OP_SWAP_ARGS: { |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
494 int dest_arg_slot = chain().adapter_conversion_vminfo(); |
3740
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
495 if (!has_argument(dest_arg_slot)) { |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
496 lose("bad swap index", CHECK_(empty)); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
497 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
498 // a simple swap between two arguments |
3740
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
499 if (arg_slot > dest_arg_slot) { |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
500 int tmp = arg_slot; |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
501 arg_slot = dest_arg_slot; |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
502 dest_arg_slot = tmp; |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
503 } |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
504 ArgToken a1 = _outgoing.at(arg_slot); |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
505 ArgToken a2 = _outgoing.at(dest_arg_slot); |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
506 change_argument(a2.basic_type(), dest_arg_slot, a1); |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
507 change_argument(a1.basic_type(), arg_slot, a2); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
508 break; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
509 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
510 |
2357
8033953d67ff
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
2356
diff
changeset
|
511 case java_lang_invoke_AdapterMethodHandle::OP_ROT_ARGS: { |
3757
f8c9417e3571
7052219: JSR 292: Crash in ~BufferBlob::MethodHandles adapters
never
parents:
3753
diff
changeset
|
512 int limit_raw = chain().adapter_conversion_vminfo(); |
f8c9417e3571
7052219: JSR 292: Crash in ~BufferBlob::MethodHandles adapters
never
parents:
3753
diff
changeset
|
513 bool rot_down = (arg_slot < limit_raw); |
f8c9417e3571
7052219: JSR 292: Crash in ~BufferBlob::MethodHandles adapters
never
parents:
3753
diff
changeset
|
514 int limit_bias = (rot_down ? MethodHandles::OP_ROT_ARGS_DOWN_LIMIT_BIAS : 0); |
f8c9417e3571
7052219: JSR 292: Crash in ~BufferBlob::MethodHandles adapters
never
parents:
3753
diff
changeset
|
515 int limit_slot = limit_raw - limit_bias; |
f8c9417e3571
7052219: JSR 292: Crash in ~BufferBlob::MethodHandles adapters
never
parents:
3753
diff
changeset
|
516 if ((uint)limit_slot > (uint)_outgoing.length()) { |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
517 lose("bad rotate index", CHECK_(empty)); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
518 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
519 // 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
|
520 // position occupied by the dest argument (plus following N slots). |
3740
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
521 int rotate_count = type2size[chain().adapter_conversion_src_type()]; |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
522 // (no other rotate counts are currently supported) |
3757
f8c9417e3571
7052219: JSR 292: Crash in ~BufferBlob::MethodHandles adapters
never
parents:
3753
diff
changeset
|
523 if (rot_down) { |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
524 for (int i = 0; i < rotate_count; i++) { |
3740
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
525 ArgToken temp = _outgoing.at(arg_slot); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
526 _outgoing.remove_at(arg_slot); |
3757
f8c9417e3571
7052219: JSR 292: Crash in ~BufferBlob::MethodHandles adapters
never
parents:
3753
diff
changeset
|
527 _outgoing.insert_before(limit_slot - 1, temp); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
528 } |
3757
f8c9417e3571
7052219: JSR 292: Crash in ~BufferBlob::MethodHandles adapters
never
parents:
3753
diff
changeset
|
529 } else { // arg_slot > limit_slot => rotate_up |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
530 for (int i = 0; i < rotate_count; i++) { |
3740
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
531 ArgToken temp = _outgoing.at(arg_slot + rotate_count - 1); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
532 _outgoing.remove_at(arg_slot + rotate_count - 1); |
3757
f8c9417e3571
7052219: JSR 292: Crash in ~BufferBlob::MethodHandles adapters
never
parents:
3753
diff
changeset
|
533 _outgoing.insert_before(limit_slot, temp); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
534 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
535 } |
3740
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
536 assert(_outgoing_argc == argument_count_slow(), "empty slots under control"); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
537 break; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
538 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
539 |
2357
8033953d67ff
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
2356
diff
changeset
|
540 case java_lang_invoke_AdapterMethodHandle::OP_DUP_ARGS: { |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
541 int dup_slots = chain().adapter_conversion_stack_pushes(); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
542 if (dup_slots <= 0) { |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
543 lose("bad dup count", CHECK_(empty)); |
1133
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 for (int i = 0; i < dup_slots; i++) { |
3740
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
546 ArgToken dup = _outgoing.at(arg_slot + 2*i); |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
547 if (dup.basic_type() != T_VOID) _outgoing_argc += 1; |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
548 _outgoing.insert_before(i, dup); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
549 } |
3740
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
550 assert(_outgoing_argc == argument_count_slow(), "empty slots under control"); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
551 break; |
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 |
2357
8033953d67ff
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
2356
diff
changeset
|
554 case java_lang_invoke_AdapterMethodHandle::OP_DROP_ARGS: { |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
555 int drop_slots = -chain().adapter_conversion_stack_pushes(); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
556 if (drop_slots <= 0) { |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
557 lose("bad drop count", CHECK_(empty)); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
558 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
559 for (int i = 0; i < drop_slots; i++) { |
3740
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
560 ArgToken drop = _outgoing.at(arg_slot); |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
561 if (drop.basic_type() != T_VOID) _outgoing_argc -= 1; |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
562 _outgoing.remove_at(arg_slot); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
563 } |
3740
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
564 assert(_outgoing_argc == argument_count_slow(), "empty slots under control"); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
565 break; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
566 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
567 |
3371
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
568 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
|
569 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
|
570 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
|
571 // call argument MH recursively |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
572 //{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
|
573 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
|
574 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
|
575 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
|
576 } |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
577 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
|
578 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
|
579 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
|
580 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
|
581 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
|
582 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
|
583 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
|
584 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
|
585 } |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
586 for (int i = 0, slot = arg_slot + coll_slots - 1; slot >= arg_slot; slot--) { |
3740
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
587 ArgToken arg_state = _outgoing.at(slot); |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
588 BasicType arg_type = arg_state.basic_type(); |
3371
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
589 if (arg_type == T_VOID) continue; |
3740
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
590 ArgToken arg = _outgoing.at(slot); |
3371
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
591 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
|
592 arglist[1+i] = arg; |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
593 if (!retain_original_args) |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
594 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
|
595 i++; |
3371
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
596 } |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
597 arglist[1+argc] = ArgToken(); // sentinel |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
598 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
|
599 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
|
600 if (invoker == NULL || !invoker->is_method()) { |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
601 lose("bad vmlayout slot", CHECK_(empty)); |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
602 } |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
603 // FIXME: consider inlining the invokee at the bytecode level |
3785
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
604 ArgToken ret = make_invoke(methodHandle(THREAD, methodOop(invoker)), vmIntrinsics::_invokeGeneric, |
3371
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
605 Bytecodes::_invokevirtual, false, 1+argc, &arglist[0], CHECK_(empty)); |
3785
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
606 // The iid = _invokeGeneric really means to adjust reference types as needed. |
3371
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
607 DEBUG_ONLY(invoker = NULL); |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
608 if (rtype == T_OBJECT) { |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
609 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
|
610 if (rklass != SystemDictionary::Object_klass() && |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
611 !Klass::cast(rklass)->is_interface()) { |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
612 // preserve type safety |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
613 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
|
614 } |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
615 } |
3388
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
616 if (rtype != T_VOID) { |
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
617 int ret_slot = arg_slot + (retain_original_args ? coll_slots : 0); |
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
618 change_argument(T_VOID, ret_slot, rtype, ret); |
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
619 } |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3274
diff
changeset
|
620 break; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3274
diff
changeset
|
621 } |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3274
diff
changeset
|
622 |
2357
8033953d67ff
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
2356
diff
changeset
|
623 case java_lang_invoke_AdapterMethodHandle::OP_SPREAD_ARGS: { |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
624 klassOop array_klass_oop = NULL; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
625 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
|
626 &array_klass_oop); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
627 assert(array_type == T_OBJECT, ""); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
628 assert(Klass::cast(array_klass_oop)->oop_is_array(), ""); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
629 arrayKlassHandle array_klass(THREAD, array_klass_oop); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
630 debug_only(array_klass_oop = (klassOop)badOop); |
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 klassOop element_klass_oop = NULL; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
633 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
|
634 &element_klass_oop); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
635 KlassHandle element_klass(THREAD, element_klass_oop); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
636 debug_only(element_klass_oop = (klassOop)badOop); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
637 |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
638 // Fetch the argument, which we will cast to the required array type. |
3740
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
639 ArgToken arg = _outgoing.at(arg_slot); |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
640 assert(arg.basic_type() == T_OBJECT, ""); |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
641 ArgToken array_arg = arg; |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
642 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
|
643 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
|
644 |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
645 // Check the required length. |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
646 int spread_slots = 1 + chain().adapter_conversion_stack_pushes(); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
647 int spread_length = spread_slots; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
648 if (type2size[element_type] == 2) { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
649 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
|
650 spread_length = spread_slots / 2; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
651 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
652 if (spread_slots < 0) { |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
653 lose("bad spread length", CHECK_(empty)); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
654 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
655 |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
656 jvalue length_jvalue; length_jvalue.i = spread_length; |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
657 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
|
658 // 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
|
659 ArgToken arglist[3]; |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
660 arglist[0] = array_arg; // value to check |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
661 arglist[1] = length_arg; // length to check |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
662 arglist[2] = ArgToken(); // sentinel |
3785
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
663 make_invoke(methodHandle(), vmIntrinsics::_checkSpreadArgument, |
3385
33ae33516634
7045515: ARM assembly code for JSR 292 ricochet frames
bdelsart
parents:
3371
diff
changeset
|
664 Bytecodes::_invokestatic, false, 2, &arglist[0], CHECK_(empty)); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
665 |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
666 // Spread out the array elements. |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3274
diff
changeset
|
667 Bytecodes::Code aload_op = Bytecodes::_nop; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3274
diff
changeset
|
668 switch (element_type) { |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3274
diff
changeset
|
669 case T_INT: aload_op = Bytecodes::_iaload; break; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3274
diff
changeset
|
670 case T_LONG: aload_op = Bytecodes::_laload; break; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3274
diff
changeset
|
671 case T_FLOAT: aload_op = Bytecodes::_faload; break; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3274
diff
changeset
|
672 case T_DOUBLE: aload_op = Bytecodes::_daload; break; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3274
diff
changeset
|
673 case T_OBJECT: aload_op = Bytecodes::_aaload; break; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3274
diff
changeset
|
674 case T_BOOLEAN: // fall through: |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3274
diff
changeset
|
675 case T_BYTE: aload_op = Bytecodes::_baload; break; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3274
diff
changeset
|
676 case T_CHAR: aload_op = Bytecodes::_caload; break; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3274
diff
changeset
|
677 case T_SHORT: aload_op = Bytecodes::_saload; break; |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3274
diff
changeset
|
678 default: lose("primitive array NYI", CHECK_(empty)); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
679 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
680 int ap = arg_slot; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
681 for (int i = 0; i < spread_length; i++) { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
682 jvalue offset_jvalue; offset_jvalue.i = i; |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
683 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
|
684 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
|
685 change_argument(T_VOID, ap, element_type, element_arg); |
3785
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
686 //ap += type2size[element_type]; // don't do this; insert next arg to *right* of previous |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
687 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
688 break; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
689 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
690 |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
691 default: |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
692 lose("bad adapter conversion", CHECK_(empty)); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
693 break; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
694 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
695 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
696 |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
697 if (chain().is_bound()) { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
698 // push a new argument |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
699 BasicType arg_type = chain().bound_arg_type(); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
700 jint arg_slot = chain().bound_arg_slot(); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
701 oop arg_oop = chain().bound_arg_oop(); |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
702 ArgToken arg; |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
703 if (arg_type == T_OBJECT) { |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
704 arg = make_oop_constant(arg_oop, CHECK_(empty)); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
705 } else { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
706 jvalue arg_value; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
707 BasicType bt = java_lang_boxing_object::get_value(arg_oop, &arg_value); |
3740
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
708 if (bt == arg_type || (bt == T_INT && is_subword_type(arg_type))) { |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
709 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
|
710 } else { |
3740
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
711 lose(err_msg("bad bound value: arg_type %s boxing %s", type2name(arg_type), type2name(bt)), CHECK_(empty)); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
712 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
713 } |
3371
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
714 DEBUG_ONLY(arg_oop = badOop); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
715 change_argument(T_VOID, arg_slot, arg_type, arg); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
716 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
717 |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
718 // 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
|
719 if (!chain().is_last()) { |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
720 chain().next(CHECK_(empty)); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
721 } else { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
722 break; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
723 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
724 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
725 |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
726 // 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
|
727 // 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
|
728 ArgToken* arglist = NEW_RESOURCE_ARRAY(ArgToken, _outgoing.length() + 1); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
729 int ap = 0; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
730 for (int i = _outgoing.length() - 1; i >= 0; i--) { |
3740
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
731 ArgToken arg_state = _outgoing.at(i); |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
732 if (arg_state.basic_type() == T_VOID) continue; |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
733 arglist[ap++] = _outgoing.at(i); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
734 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
735 assert(ap == _outgoing_argc, ""); |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
736 arglist[ap] = ArgToken(); // add a sentinel, for the sake of asserts |
3785
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
737 return make_invoke(chain().last_method(), |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
738 vmIntrinsics::_none, |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
739 chain().last_invoke_code(), true, |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
740 ap, arglist, THREAD); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
741 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
742 |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
743 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
744 // ----------------------------------------------------------------------------- |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
745 // MethodHandleWalker::walk_incoming_state |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
746 // |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
747 void MethodHandleWalker::walk_incoming_state(TRAPS) { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
748 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
|
749 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
|
750 _outgoing_argc = nptypes; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
751 int argp = nptypes - 1; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
752 if (argp >= 0) { |
3740
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
753 _outgoing.at_grow(argp, ArgToken(tt_void)); // presize |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
754 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
755 for (int i = 0; i < nptypes; i++) { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
756 klassOop arg_type_klass = NULL; |
3371
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
757 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
|
758 int index = new_local_index(arg_type); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
759 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
|
760 DEBUG_ONLY(arg_type_klass = (klassOop) NULL); |
3740
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
761 _outgoing.at_put(argp, arg); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
762 if (type2size[arg_type] == 2) { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
763 // add the extra slot, so we can model the JVM stack |
3740
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
764 _outgoing.insert_before(argp+1, ArgToken(tt_void)); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
765 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
766 --argp; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
767 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
768 // 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
|
769 klassOop ret_type_klass = NULL; |
3371
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
770 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
|
771 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
|
772 // ignore ret; client can catch it if needed |
3740
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
773 |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
774 assert(_outgoing_argc == argument_count_slow(), "empty slots under control"); |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
775 |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
776 verify_args_and_signature(CHECK); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
777 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
778 |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
779 |
3740
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
780 #ifdef ASSERT |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
781 void MethodHandleWalker::verify_args_and_signature(TRAPS) { |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
782 int index = _outgoing.length() - 1; |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
783 objArrayOop ptypes = java_lang_invoke_MethodType::ptypes(chain().method_type_oop()); |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
784 for (int i = 0, limit = ptypes->length(); i < limit; i++) { |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
785 BasicType t = java_lang_Class::as_BasicType(ptypes->obj_at(i)); |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
786 if (t == T_ARRAY) t = T_OBJECT; |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
787 if (t == T_LONG || t == T_DOUBLE) { |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
788 assert(T_VOID == _outgoing.at(index).basic_type(), "types must match"); |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
789 index--; |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
790 } |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
791 assert(t == _outgoing.at(index).basic_type(), "types must match"); |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
792 index--; |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
793 } |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
794 } |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
795 #endif |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
796 |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
797 |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
798 // ----------------------------------------------------------------------------- |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
799 // MethodHandleWalker::change_argument |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
800 // |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
801 // 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
|
802 // companion slots containing an empty value. |
3740
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
803 void MethodHandleWalker::change_argument(BasicType old_type, int slot, const ArgToken& new_arg) { |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
804 BasicType new_type = new_arg.basic_type(); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
805 int old_size = type2size[old_type]; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
806 int new_size = type2size[new_type]; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
807 if (old_size == new_size) { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
808 // simple case first |
3740
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
809 _outgoing.at_put(slot, new_arg); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
810 } else if (old_size > new_size) { |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
811 for (int i = old_size - 1; i >= new_size; i--) { |
3740
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
812 assert((i != 0) == (_outgoing.at(slot + i).basic_type() == T_VOID), ""); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
813 _outgoing.remove_at(slot + i); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
814 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
815 if (new_size > 0) |
3740
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
816 _outgoing.at_put(slot, new_arg); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
817 else |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
818 _outgoing_argc -= 1; // deleted a real argument |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
819 } else { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
820 for (int i = old_size; i < new_size; i++) { |
3740
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
821 _outgoing.insert_before(slot + i, ArgToken(tt_void)); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
822 } |
3740
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
823 _outgoing.at_put(slot, new_arg); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
824 if (old_size == 0) |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
825 _outgoing_argc += 1; // inserted a real argument |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
826 } |
3740
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
827 assert(_outgoing_argc == argument_count_slow(), "empty slots under control"); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
828 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
829 |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
830 |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
831 #ifdef ASSERT |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
832 int MethodHandleWalker::argument_count_slow() { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
833 int args_seen = 0; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
834 for (int i = _outgoing.length() - 1; i >= 0; i--) { |
3740
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
835 if (_outgoing.at(i).basic_type() != T_VOID) { |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
836 ++args_seen; |
3740
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
837 if (_outgoing.at(i).basic_type() == T_LONG || |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
838 _outgoing.at(i).basic_type() == T_DOUBLE) { |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
839 assert(_outgoing.at(i + 1).basic_type() == T_VOID, "should only follow two word"); |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
840 } |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
841 } else { |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
842 assert(_outgoing.at(i - 1).basic_type() == T_LONG || |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
843 _outgoing.at(i - 1).basic_type() == T_DOUBLE, "should only follow two word"); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
844 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
845 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
846 return args_seen; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
847 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
848 #endif |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
849 |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
850 |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
851 // ----------------------------------------------------------------------------- |
3371
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
852 // MethodHandleWalker::retype_raw_conversion |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
853 // |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
854 // 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
|
855 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
|
856 if (src != dst) { |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
857 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
|
858 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
|
859 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
|
860 if (iid == vmIntrinsics::_none) { |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
861 lose("no raw conversion method", CHECK); |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
862 } |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
863 ArgToken arglist[2]; |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
864 if (!for_return) { |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
865 // argument type conversion |
3740
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
866 ArgToken arg = _outgoing.at(slot); |
3371
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
867 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
|
868 arglist[0] = arg; // outgoing 'this' |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
869 arglist[1] = ArgToken(); // sentinel |
3785
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
870 arg = make_invoke(methodHandle(), iid, Bytecodes::_invokestatic, false, 1, &arglist[0], CHECK); |
3371
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
871 change_argument(src, slot, dst, arg); |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
872 } else { |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
873 // return type conversion |
3785
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
874 if (_return_conv == vmIntrinsics::_none) { |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
875 _return_conv = iid; |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
876 } else if (_return_conv == vmIntrinsics::for_raw_conversion(dst, src)) { |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
877 _return_conv = vmIntrinsics::_none; |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
878 } else if (_return_conv != zero_return_conv()) { |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
879 lose(err_msg("requested raw return conversion not allowed: %s -> %s (before %s)", type2name(src), type2name(dst), vmIntrinsics::name_at(_return_conv)), CHECK); |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
880 } |
3371
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
881 } |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
882 } else { |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
883 // Nothing to do. |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
884 } |
3785
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
885 } else if (for_return && (!is_subword_type(src) || !is_subword_type(dst))) { |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
886 // This can occur in exception-throwing MHs, which have a fictitious return value encoded as Void or Empty. |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
887 _return_conv = zero_return_conv(); |
3371
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
888 } 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
|
889 // 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
|
890 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
|
891 } else { |
3740
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
892 lose(err_msg("requested raw conversion not allowed: %s -> %s", type2name(src), type2name(dst)), CHECK); |
3371
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
893 } |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
894 } |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
895 } |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
896 |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
897 |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
898 // ----------------------------------------------------------------------------- |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
899 // MethodHandleCompiler |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
900 |
3388
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
901 MethodHandleCompiler::MethodHandleCompiler(Handle root, Symbol* name, Symbol* signature, int invoke_count, bool is_invokedynamic, TRAPS) |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
902 : MethodHandleWalker(root, is_invokedynamic, THREAD), |
3366
e2a92dd0d3d2
7042122: JSR 292: adjust various inline thresholds for JSR 292 API methods and method handle adapters
twisti
parents:
3363
diff
changeset
|
903 _invoke_count(invoke_count), |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
904 _thread(THREAD), |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
905 _bytecode(THREAD, 50), |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
906 _constants(THREAD, 10), |
3785
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
907 _non_bcp_klasses(THREAD, 5), |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
908 _cur_stack(0), |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
909 _max_stack(0), |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
910 _rtype(T_ILLEGAL) |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
911 { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
912 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
913 // Element zero is always the null constant. |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
914 (void) _constants.append(NULL); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
915 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
916 // Set name and signature index. |
3388
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
917 _name_index = cpool_symbol_put(name); |
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
918 _signature_index = cpool_symbol_put(signature); |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
919 |
3785
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
920 // To make the resulting methods more recognizable by |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
921 // stack walkers and compiler heuristics, |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
922 // we put them in holder class MethodHandle. |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
923 // See klass_is_method_handle_adapter_holder |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
924 // and methodOopDesc::is_method_handle_adapter. |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
925 _target_klass = SystemDictionaryHandles::MethodHandle_klass(); |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
926 |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
927 check_non_bcp_klasses(java_lang_invoke_MethodHandle::type(root()), CHECK); |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
928 |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
929 // Get return type klass. |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
930 Handle first_mtype(THREAD, chain().method_type_oop()); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
931 // _rklass is NULL for primitives. |
2357
8033953d67ff
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
2356
diff
changeset
|
932 _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
|
933 if (_rtype == T_ARRAY) _rtype = T_OBJECT; |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
934 |
3388
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
935 ArgumentSizeComputer args(signature); |
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
936 int params = args.size() + 1; // Incoming arguments plus receiver. |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
937 _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
|
938 } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
939 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
940 |
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 // MethodHandleCompiler::compile |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
943 // |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
944 // Compile this MethodHandle into a bytecode adapter and return a |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
945 // methodOop. |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
946 methodHandle MethodHandleCompiler::compile(TRAPS) { |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
947 assert(_thread == THREAD, "must be same thread"); |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
948 methodHandle nullHandle; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
949 (void) walk(CHECK_(nullHandle)); |
3785
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
950 record_non_bcp_klasses(); |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
951 return get_method_oop(CHECK_(nullHandle)); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
952 } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
953 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
954 |
3388
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
955 void MethodHandleCompiler::emit_bc(Bytecodes::Code op, int index, int args_size) { |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
956 Bytecodes::check(op); // Are we legal? |
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 switch (op) { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
959 // b |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
960 case Bytecodes::_aconst_null: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
961 case Bytecodes::_iconst_m1: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
962 case Bytecodes::_iconst_0: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
963 case Bytecodes::_iconst_1: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
964 case Bytecodes::_iconst_2: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
965 case Bytecodes::_iconst_3: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
966 case Bytecodes::_iconst_4: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
967 case Bytecodes::_iconst_5: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
968 case Bytecodes::_lconst_0: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
969 case Bytecodes::_lconst_1: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
970 case Bytecodes::_fconst_0: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
971 case Bytecodes::_fconst_1: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
972 case Bytecodes::_fconst_2: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
973 case Bytecodes::_dconst_0: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
974 case Bytecodes::_dconst_1: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
975 case Bytecodes::_iload_0: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
976 case Bytecodes::_iload_1: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
977 case Bytecodes::_iload_2: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
978 case Bytecodes::_iload_3: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
979 case Bytecodes::_lload_0: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
980 case Bytecodes::_lload_1: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
981 case Bytecodes::_lload_2: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
982 case Bytecodes::_lload_3: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
983 case Bytecodes::_fload_0: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
984 case Bytecodes::_fload_1: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
985 case Bytecodes::_fload_2: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
986 case Bytecodes::_fload_3: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
987 case Bytecodes::_dload_0: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
988 case Bytecodes::_dload_1: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
989 case Bytecodes::_dload_2: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
990 case Bytecodes::_dload_3: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
991 case Bytecodes::_aload_0: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
992 case Bytecodes::_aload_1: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
993 case Bytecodes::_aload_2: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
994 case Bytecodes::_aload_3: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
995 case Bytecodes::_istore_0: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
996 case Bytecodes::_istore_1: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
997 case Bytecodes::_istore_2: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
998 case Bytecodes::_istore_3: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
999 case Bytecodes::_lstore_0: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1000 case Bytecodes::_lstore_1: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1001 case Bytecodes::_lstore_2: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1002 case Bytecodes::_lstore_3: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1003 case Bytecodes::_fstore_0: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1004 case Bytecodes::_fstore_1: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1005 case Bytecodes::_fstore_2: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1006 case Bytecodes::_fstore_3: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1007 case Bytecodes::_dstore_0: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1008 case Bytecodes::_dstore_1: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1009 case Bytecodes::_dstore_2: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1010 case Bytecodes::_dstore_3: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1011 case Bytecodes::_astore_0: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1012 case Bytecodes::_astore_1: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1013 case Bytecodes::_astore_2: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1014 case Bytecodes::_astore_3: |
3371
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1015 case Bytecodes::_iand: |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1016 case Bytecodes::_i2l: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1017 case Bytecodes::_i2f: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1018 case Bytecodes::_i2d: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1019 case Bytecodes::_i2b: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1020 case Bytecodes::_i2c: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1021 case Bytecodes::_i2s: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1022 case Bytecodes::_l2i: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1023 case Bytecodes::_l2f: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1024 case Bytecodes::_l2d: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1025 case Bytecodes::_f2i: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1026 case Bytecodes::_f2l: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1027 case Bytecodes::_f2d: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1028 case Bytecodes::_d2i: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1029 case Bytecodes::_d2l: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1030 case Bytecodes::_d2f: |
3388
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
1031 case Bytecodes::_iaload: |
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
1032 case Bytecodes::_laload: |
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
1033 case Bytecodes::_faload: |
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
1034 case Bytecodes::_daload: |
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
1035 case Bytecodes::_aaload: |
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
1036 case Bytecodes::_baload: |
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
1037 case Bytecodes::_caload: |
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
1038 case Bytecodes::_saload: |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1039 case Bytecodes::_ireturn: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1040 case Bytecodes::_lreturn: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1041 case Bytecodes::_freturn: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1042 case Bytecodes::_dreturn: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1043 case Bytecodes::_areturn: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1044 case Bytecodes::_return: |
1565 | 1045 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
|
1046 _bytecode.push(op); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1047 break; |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1048 |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1049 // bi |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1050 case Bytecodes::_ldc: |
1662
e0ba4e04c839
6969574: invokedynamic call sites deoptimize instead of executing
jrose
parents:
1579
diff
changeset
|
1051 assert(Bytecodes::format_bits(op, false) == (Bytecodes::_fmt_b|Bytecodes::_fmt_has_k), "wrong bytecode format"); |
3388
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
1052 if (index == (index & 0xff)) { |
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
1053 _bytecode.push(op); |
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
1054 _bytecode.push(index); |
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
1055 } else { |
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
1056 _bytecode.push(Bytecodes::_ldc_w); |
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
1057 _bytecode.push(index >> 8); |
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
1058 _bytecode.push(index); |
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
1059 } |
1662
e0ba4e04c839
6969574: invokedynamic call sites deoptimize instead of executing
jrose
parents:
1579
diff
changeset
|
1060 break; |
e0ba4e04c839
6969574: invokedynamic call sites deoptimize instead of executing
jrose
parents:
1579
diff
changeset
|
1061 |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1062 case Bytecodes::_iload: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1063 case Bytecodes::_lload: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1064 case Bytecodes::_fload: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1065 case Bytecodes::_dload: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1066 case Bytecodes::_aload: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1067 case Bytecodes::_istore: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1068 case Bytecodes::_lstore: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1069 case Bytecodes::_fstore: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1070 case Bytecodes::_dstore: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1071 case Bytecodes::_astore: |
1565 | 1072 assert(Bytecodes::format_bits(op, false) == Bytecodes::_fmt_bi, "wrong bytecode format"); |
3388
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
1073 if (index == (index & 0xff)) { |
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
1074 _bytecode.push(op); |
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
1075 _bytecode.push(index); |
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
1076 } else { |
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
1077 // doesn't fit in a u2 |
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
1078 _bytecode.push(Bytecodes::_wide); |
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
1079 _bytecode.push(op); |
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
1080 _bytecode.push(index >> 8); |
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
1081 _bytecode.push(index); |
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
1082 } |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1083 break; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1084 |
1662
e0ba4e04c839
6969574: invokedynamic call sites deoptimize instead of executing
jrose
parents:
1579
diff
changeset
|
1085 // bkk |
e0ba4e04c839
6969574: invokedynamic call sites deoptimize instead of executing
jrose
parents:
1579
diff
changeset
|
1086 case Bytecodes::_ldc_w: |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1087 case Bytecodes::_ldc2_w: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1088 case Bytecodes::_checkcast: |
1565 | 1089 assert(Bytecodes::format_bits(op, false) == Bytecodes::_fmt_bkk, "wrong bytecode format"); |
3388
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
1090 assert((unsigned short) index == index, "index does not fit in 16-bit"); |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1091 _bytecode.push(op); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1092 _bytecode.push(index >> 8); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1093 _bytecode.push(index); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1094 break; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1095 |
1565 | 1096 // bJJ |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1097 case Bytecodes::_invokestatic: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1098 case Bytecodes::_invokespecial: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1099 case Bytecodes::_invokevirtual: |
1565 | 1100 assert(Bytecodes::format_bits(op, false) == Bytecodes::_fmt_bJJ, "wrong bytecode format"); |
3388
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
1101 assert((unsigned short) index == index, "index does not fit in 16-bit"); |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1102 _bytecode.push(op); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1103 _bytecode.push(index >> 8); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1104 _bytecode.push(index); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1105 break; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1106 |
3388
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
1107 case Bytecodes::_invokeinterface: |
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
1108 assert(Bytecodes::format_bits(op, false) == Bytecodes::_fmt_bJJ, "wrong bytecode format"); |
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
1109 assert((unsigned short) index == index, "index does not fit in 16-bit"); |
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
1110 assert(args_size > 0, "valid args_size"); |
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
1111 _bytecode.push(op); |
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
1112 _bytecode.push(index >> 8); |
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
1113 _bytecode.push(index); |
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
1114 _bytecode.push(args_size); |
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
1115 _bytecode.push(0); |
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
1116 break; |
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
1117 |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1118 default: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1119 ShouldNotReachHere(); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1120 } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1121 } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1122 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1123 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1124 void MethodHandleCompiler::emit_load(BasicType bt, int index) { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1125 if (index <= 3) { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1126 switch (bt) { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1127 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
|
1128 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
|
1129 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
|
1130 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
|
1131 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
|
1132 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
|
1133 default: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1134 ShouldNotReachHere(); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1135 } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1136 } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1137 else { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1138 switch (bt) { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1139 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
|
1140 case T_INT: emit_bc(Bytecodes::_iload, index); break; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1141 case T_LONG: emit_bc(Bytecodes::_lload, index); break; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1142 case T_FLOAT: emit_bc(Bytecodes::_fload, index); break; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1143 case T_DOUBLE: emit_bc(Bytecodes::_dload, index); break; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1144 case T_OBJECT: emit_bc(Bytecodes::_aload, index); break; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1145 default: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1146 ShouldNotReachHere(); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1147 } |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1148 } |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1149 stack_push(bt); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1150 } |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1151 |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1152 void MethodHandleCompiler::emit_store(BasicType bt, int index) { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1153 if (index <= 3) { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1154 switch (bt) { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1155 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
|
1156 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
|
1157 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
|
1158 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
|
1159 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
|
1160 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
|
1161 default: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1162 ShouldNotReachHere(); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1163 } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1164 } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1165 else { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1166 switch (bt) { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1167 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
|
1168 case T_INT: emit_bc(Bytecodes::_istore, index); break; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1169 case T_LONG: emit_bc(Bytecodes::_lstore, index); break; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1170 case T_FLOAT: emit_bc(Bytecodes::_fstore, index); break; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1171 case T_DOUBLE: emit_bc(Bytecodes::_dstore, index); break; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1172 case T_OBJECT: emit_bc(Bytecodes::_astore, index); break; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1173 default: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1174 ShouldNotReachHere(); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1175 } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1176 } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1177 stack_pop(bt); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1178 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1179 |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1180 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1181 void MethodHandleCompiler::emit_load_constant(ArgToken arg) { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1182 BasicType bt = arg.basic_type(); |
3740
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
1183 if (is_subword_type(bt)) bt = T_INT; |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1184 switch (bt) { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1185 case T_INT: { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1186 jint value = arg.get_jint(); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1187 if (-1 <= value && value <= 5) |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1188 emit_bc(Bytecodes::cast(Bytecodes::_iconst_0 + value)); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1189 else |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1190 emit_bc(Bytecodes::_ldc, cpool_int_put(value)); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1191 break; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1192 } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1193 case T_LONG: { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1194 jlong value = arg.get_jlong(); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1195 if (0 <= value && value <= 1) |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1196 emit_bc(Bytecodes::cast(Bytecodes::_lconst_0 + (int) value)); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1197 else |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1198 emit_bc(Bytecodes::_ldc2_w, cpool_long_put(value)); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1199 break; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1200 } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1201 case T_FLOAT: { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1202 jfloat value = arg.get_jfloat(); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1203 if (value == 0.0 || value == 1.0 || value == 2.0) |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1204 emit_bc(Bytecodes::cast(Bytecodes::_fconst_0 + (int) value)); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1205 else |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1206 emit_bc(Bytecodes::_ldc, cpool_float_put(value)); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1207 break; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1208 } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1209 case T_DOUBLE: { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1210 jdouble value = arg.get_jdouble(); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1211 if (value == 0.0 || value == 1.0) |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1212 emit_bc(Bytecodes::cast(Bytecodes::_dconst_0 + (int) value)); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1213 else |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1214 emit_bc(Bytecodes::_ldc2_w, cpool_double_put(value)); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1215 break; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1216 } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1217 case T_OBJECT: { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1218 Handle value = arg.object(); |
3785
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1219 if (value.is_null()) { |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1220 emit_bc(Bytecodes::_aconst_null); |
3785
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1221 break; |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1222 } |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1223 if (java_lang_Class::is_instance(value())) { |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1224 klassOop k = java_lang_Class::as_klassOop(value()); |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1225 if (k != NULL) { |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1226 emit_bc(Bytecodes::_ldc, cpool_klass_put(k)); |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1227 break; |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1228 } |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1229 } |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1230 emit_bc(Bytecodes::_ldc, cpool_object_put(value)); |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1231 break; |
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 default: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1234 ShouldNotReachHere(); |
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 stack_push(bt); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1237 } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1238 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1239 |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1240 MethodHandleWalker::ArgToken |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1241 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
|
1242 const ArgToken& src, TRAPS) { |
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 BasicType srctype = src.basic_type(); |
3388
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
1245 TokenType tt = src.token_type(); |
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
1246 int index = -1; |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1247 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1248 switch (op) { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1249 case Bytecodes::_i2l: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1250 case Bytecodes::_i2f: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1251 case Bytecodes::_i2d: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1252 case Bytecodes::_i2b: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1253 case Bytecodes::_i2c: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1254 case Bytecodes::_i2s: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1255 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1256 case Bytecodes::_l2i: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1257 case Bytecodes::_l2f: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1258 case Bytecodes::_l2d: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1259 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1260 case Bytecodes::_f2i: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1261 case Bytecodes::_f2l: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1262 case Bytecodes::_f2d: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1263 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1264 case Bytecodes::_d2i: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1265 case Bytecodes::_d2l: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1266 case Bytecodes::_d2f: |
3388
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
1267 if (tt == tt_constant) { |
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
1268 emit_load_constant(src); |
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
1269 } else { |
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
1270 emit_load(srctype, src.index()); |
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
1271 } |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1272 stack_pop(srctype); // pop the src type |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1273 emit_bc(op); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1274 stack_push(type); // push the dest value |
3388
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
1275 if (tt != tt_constant) |
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
1276 index = src.index(); |
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
1277 if (srctype != type || index == -1) |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1278 index = new_local_index(type); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1279 emit_store(type, index); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1280 break; |
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 case Bytecodes::_checkcast: |
3388
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
1283 if (tt == tt_constant) { |
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
1284 emit_load_constant(src); |
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
1285 } else { |
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
1286 emit_load(srctype, src.index()); |
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
1287 index = src.index(); |
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
1288 } |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1289 emit_bc(op, cpool_klass_put(tk)); |
3785
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1290 check_non_bcp_klass(tk, CHECK_(src)); |
3753
cba7b5c2d53f
7045514: SPARC assembly code for JSR 292 ricochet frames
never
parents:
3740
diff
changeset
|
1291 // Allocate a new local for the type so that we don't hide the |
cba7b5c2d53f
7045514: SPARC assembly code for JSR 292 ricochet frames
never
parents:
3740
diff
changeset
|
1292 // previous type from the verifier. |
cba7b5c2d53f
7045514: SPARC assembly code for JSR 292 ricochet frames
never
parents:
3740
diff
changeset
|
1293 index = new_local_index(type); |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1294 emit_store(srctype, index); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1295 break; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1296 |
3740
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
1297 case Bytecodes::_nop: |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
1298 // nothing to do |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
1299 return src; |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
1300 |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1301 default: |
3371
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1302 if (op == Bytecodes::_illegal) |
3740
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
1303 lose(err_msg("no such primitive conversion: %s -> %s", type2name(src.basic_type()), type2name(type)), THREAD); |
3371
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1304 else |
3740
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
1305 lose(err_msg("bad primitive conversion op: %s", Bytecodes::name(op)), THREAD); |
3371
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1306 return make_prim_constant(type, &zero_jvalue, THREAD); |
1138
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 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1309 return make_parameter(type, tk, index, THREAD); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1310 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1311 |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1312 |
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 // MethodHandleCompiler |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1315 // |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1316 |
3371
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1317 // Values used by the compiler. |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1318 jvalue MethodHandleCompiler::zero_jvalue = { 0 }; |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1319 jvalue MethodHandleCompiler::one_jvalue = { 1 }; |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1320 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1321 // Emit bytecodes for the given invoke instruction. |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1322 MethodHandleWalker::ArgToken |
3785
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1323 MethodHandleCompiler::make_invoke(methodHandle m, vmIntrinsics::ID iid, |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1324 Bytecodes::Code op, bool tailcall, |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1325 int argc, MethodHandleWalker::ArgToken* argv, |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1326 TRAPS) { |
3371
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1327 ArgToken zero; |
3785
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1328 if (m.is_null()) { |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1329 // Get the intrinsic methodOop. |
3785
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1330 m = methodHandle(THREAD, vmIntrinsics::method_for(iid)); |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1331 if (m.is_null()) { |
2356
72dee110246f
6839872: remove implementation inheritance from JSR 292 APIs
jrose
parents:
2226
diff
changeset
|
1332 lose(vmIntrinsics::name_at(iid), CHECK_(zero)); |
72dee110246f
6839872: remove implementation inheritance from JSR 292 APIs
jrose
parents:
2226
diff
changeset
|
1333 } |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1334 } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1335 |
3371
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1336 klassOop klass = m->method_holder(); |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1337 Symbol* name = m->name(); |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1338 Symbol* signature = m->signature(); |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1339 |
3785
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1340 if (iid == vmIntrinsics::_invokeGeneric && |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1341 argc >= 1 && argv[0].token_type() == tt_constant) { |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1342 assert(m->intrinsic_id() == vmIntrinsics::_invokeExact, ""); |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1343 Handle receiver = argv[0].object(); |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1344 Handle rtype(THREAD, java_lang_invoke_MethodHandle::type(receiver())); |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1345 Handle mtype(THREAD, m->method_handle_type()); |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1346 if (rtype() != mtype()) { |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1347 assert(java_lang_invoke_MethodType::form(rtype()) == |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1348 java_lang_invoke_MethodType::form(mtype()), |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1349 "must be the same shape"); |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1350 // customize m to the exact required rtype |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1351 bool has_non_bcp_klass = check_non_bcp_klasses(rtype(), CHECK_(zero)); |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1352 TempNewSymbol sig2 = java_lang_invoke_MethodType::as_signature(rtype(), true, CHECK_(zero)); |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1353 methodHandle m2; |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1354 if (!has_non_bcp_klass) { |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1355 methodOop m2_oop = SystemDictionary::find_method_handle_invoke(m->name(), sig2, |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1356 KlassHandle(), CHECK_(zero)); |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1357 m2 = methodHandle(THREAD, m2_oop); |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1358 } |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1359 if (m2.is_null()) { |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1360 // just build it fresh |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1361 m2 = methodOopDesc::make_invoke_method(klass, m->name(), sig2, rtype, CHECK_(zero)); |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1362 if (m2.is_null()) |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1363 lose(err_msg("no customized invoker %s", sig2->as_utf8()), CHECK_(zero)); |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1364 } |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1365 m = m2; |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1366 signature = m->signature(); |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1367 } |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1368 } |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1369 |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1370 check_non_bcp_klass(klass, CHECK_(zero)); |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1371 if (m->is_method_handle_invoke()) { |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1372 check_non_bcp_klasses(m->method_handle_type(), CHECK_(zero)); |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1373 } |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1374 |
3388
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
1375 // Count the number of arguments, not the size |
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
1376 ArgumentCount asc(signature); |
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
1377 assert(argc == asc.size() + ((op == Bytecodes::_invokestatic || op == Bytecodes::_invokedynamic) ? 0 : 1), |
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
1378 "argc mismatch"); |
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
1379 |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1380 // Inline the method. |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1381 InvocationCounter* ic = m->invocation_counter(); |
1783 | 1382 ic->set_carry_flag(); |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1383 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1384 for (int i = 0; i < argc; i++) { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1385 ArgToken arg = argv[i]; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1386 TokenType tt = arg.token_type(); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1387 BasicType bt = arg.basic_type(); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1388 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1389 switch (tt) { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1390 case tt_parameter: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1391 case tt_temporary: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1392 emit_load(bt, arg.index()); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1393 break; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1394 case tt_constant: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1395 emit_load_constant(arg); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1396 break; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1397 case tt_illegal: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1398 // Sentinel. |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1399 assert(i == (argc - 1), "sentinel must be last entry"); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1400 break; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1401 case tt_void: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1402 default: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1403 ShouldNotReachHere(); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1404 } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1405 } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1406 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1407 // Populate constant pool. |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1408 int name_index = cpool_symbol_put(name); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1409 int signature_index = cpool_symbol_put(signature); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1410 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
|
1411 int klass_index = cpool_klass_put(klass); |
3785
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1412 int methodref_index = cpool_methodref_put(op, klass_index, name_and_type_index, m); |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1413 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1414 // Generate invoke. |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1415 switch (op) { |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1416 case Bytecodes::_invokestatic: |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1417 case Bytecodes::_invokespecial: |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1418 case Bytecodes::_invokevirtual: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1419 emit_bc(op, methodref_index); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1420 break; |
3388
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
1421 |
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
1422 case Bytecodes::_invokeinterface: { |
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
1423 ArgumentSizeComputer asc(signature); |
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
1424 emit_bc(op, methodref_index, asc.size() + 1); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1425 break; |
3388
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
1426 } |
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
1427 |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1428 default: |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1429 ShouldNotReachHere(); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1430 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1431 |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1432 // 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
|
1433 // Otherwise, make a recursive call to some helper routine. |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1434 BasicType rbt = m->result_type(); |
1152
cd37471eaecc
6914206: change way of permission checking for generated MethodHandle adapters
twisti
parents:
1142
diff
changeset
|
1435 if (rbt == T_ARRAY) rbt = T_OBJECT; |
3388
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
1436 stack_push(rbt); // The return value is already pushed onto the stack. |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1437 ArgToken ret; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1438 if (tailcall) { |
3785
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1439 if (return_conv() == zero_return_conv()) { |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1440 rbt = T_VOID; // discard value |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1441 } else if (return_conv() != vmIntrinsics::_none) { |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1442 // return value conversion |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1443 int index = new_local_index(rbt); |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1444 emit_store(rbt, index); |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1445 ArgToken arglist[2]; |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1446 arglist[0] = ArgToken(tt_temporary, rbt, index); |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1447 arglist[1] = ArgToken(); // sentinel |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1448 ret = make_invoke(methodHandle(), return_conv(), Bytecodes::_invokestatic, false, 1, &arglist[0], CHECK_(zero)); |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1449 set_return_conv(vmIntrinsics::_none); |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1450 rbt = ret.basic_type(); |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1451 emit_load(rbt, ret.index()); |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1452 } |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1453 if (rbt != _rtype) { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1454 if (rbt == T_VOID) { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1455 // push a zero of the right sort |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1456 if (_rtype == T_OBJECT) { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1457 zero = make_oop_constant(NULL, CHECK_(zero)); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1458 } else { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1459 zero = make_prim_constant(_rtype, &zero_jvalue, CHECK_(zero)); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1460 } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1461 emit_load_constant(zero); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1462 } else if (_rtype == T_VOID) { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1463 // We'll emit a _return with something on the stack. |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1464 // 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
|
1465 } 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
|
1466 // Convert value to match return type. |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1467 switch (_rtype) { |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1468 case T_BOOLEAN: { |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1469 // 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
|
1470 // 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
|
1471 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
|
1472 emit_load_constant(one); |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1473 emit_bc(Bytecodes::_iand); |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1474 break; |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1475 } |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1476 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
|
1477 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
|
1478 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
|
1479 default: ShouldNotReachHere(); |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1480 } |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1481 } 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
|
1482 // 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
|
1483 // on as an int. |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1484 } else { |
3371
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1485 lose("unknown conversion", CHECK_(zero)); |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1486 } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1487 } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1488 switch (_rtype) { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1489 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
|
1490 case T_INT: emit_bc(Bytecodes::_ireturn); break; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1491 case T_LONG: emit_bc(Bytecodes::_lreturn); break; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1492 case T_FLOAT: emit_bc(Bytecodes::_freturn); break; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1493 case T_DOUBLE: emit_bc(Bytecodes::_dreturn); break; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1494 case T_VOID: emit_bc(Bytecodes::_return); break; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1495 case T_OBJECT: |
3757
f8c9417e3571
7052219: JSR 292: Crash in ~BufferBlob::MethodHandles adapters
never
parents:
3753
diff
changeset
|
1496 if (_rklass.not_null() && _rklass() != SystemDictionary::Object_klass() && !Klass::cast(_rklass())->is_interface()) { |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1497 emit_bc(Bytecodes::_checkcast, cpool_klass_put(_rklass())); |
3785
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1498 check_non_bcp_klass(_rklass(), CHECK_(zero)); |
3757
f8c9417e3571
7052219: JSR 292: Crash in ~BufferBlob::MethodHandles adapters
never
parents:
3753
diff
changeset
|
1499 } |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1500 emit_bc(Bytecodes::_areturn); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1501 break; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1502 default: ShouldNotReachHere(); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1503 } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1504 ret = ArgToken(); // Dummy return value. |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1505 } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1506 else { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1507 int index = new_local_index(rbt); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1508 switch (rbt) { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1509 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
|
1510 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
|
1511 case T_OBJECT: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1512 emit_store(rbt, index); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1513 ret = ArgToken(tt_temporary, rbt, index); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1514 break; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1515 case T_VOID: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1516 ret = ArgToken(tt_void); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1517 break; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1518 default: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1519 ShouldNotReachHere(); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1520 } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1521 } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1522 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1523 return ret; |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1524 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1525 |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1526 MethodHandleWalker::ArgToken |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1527 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
|
1528 const MethodHandleWalker::ArgToken& base, |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1529 const MethodHandleWalker::ArgToken& offset, |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1530 TRAPS) { |
3388
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
1531 switch (base.token_type()) { |
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
1532 case tt_parameter: |
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
1533 case tt_temporary: |
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
1534 emit_load(base.basic_type(), base.index()); |
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
1535 break; |
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
1536 case tt_constant: |
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
1537 emit_load_constant(base); |
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
1538 break; |
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
1539 default: |
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
1540 ShouldNotReachHere(); |
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
1541 } |
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
1542 switch (offset.token_type()) { |
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
1543 case tt_parameter: |
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
1544 case tt_temporary: |
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
1545 emit_load(offset.basic_type(), offset.index()); |
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
1546 break; |
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
1547 case tt_constant: |
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
1548 emit_load_constant(offset); |
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
1549 break; |
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
1550 default: |
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
1551 ShouldNotReachHere(); |
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
1552 } |
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
1553 emit_bc(op); |
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
1554 int index = new_local_index(type); |
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
1555 emit_store(type, index); |
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
1556 return ArgToken(tt_temporary, type, index); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1557 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1558 |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1559 |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1560 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
|
1561 jvalue con_copy; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1562 assert(bt < T_OBJECT, ""); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1563 if (type2aelembytes(bt) < jintSize) { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1564 // widen to int |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1565 con_copy = (*con); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1566 con = &con_copy; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1567 switch (bt) { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1568 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
|
1569 case T_BYTE: con->i = con->b; break; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1570 case T_CHAR: con->i = con->c; break; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1571 case T_SHORT: con->i = con->s; break; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1572 default: ShouldNotReachHere(); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1573 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1574 bt = T_INT; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1575 } |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1576 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1577 // for (int i = 1, imax = _constants.length(); i < imax; i++) { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1578 // ConstantValue* con = _constants.at(i); |
3740
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
1579 // if (con != NULL && con->is_primitive() && con.basic_type() == bt) { |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1580 // bool match = false; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1581 // switch (type2size[bt]) { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1582 // 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
|
1583 // 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
|
1584 // } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1585 // if (match) |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1586 // return i; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1587 // } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1588 // } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1589 ConstantValue* cv = new ConstantValue(bt, *con); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1590 int index = _constants.append(cv); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1591 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1592 // 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
|
1593 if (type2size[bt] == 2) |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1594 (void) _constants.append(NULL); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1595 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1596 return index; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1597 } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1598 |
3785
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1599 bool MethodHandleCompiler::check_non_bcp_klasses(Handle method_type, TRAPS) { |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1600 bool res = false; |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1601 for (int i = -1, len = java_lang_invoke_MethodType::ptype_count(method_type()); i < len; i++) { |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1602 oop ptype = (i == -1 |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1603 ? java_lang_invoke_MethodType::rtype(method_type()) |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1604 : java_lang_invoke_MethodType::ptype(method_type(), i)); |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1605 res |= check_non_bcp_klass(java_lang_Class::as_klassOop(ptype), CHECK_(false)); |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1606 } |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1607 return res; |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1608 } |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1609 |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1610 bool MethodHandleCompiler::check_non_bcp_klass(klassOop klass, TRAPS) { |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1611 klass = methodOopDesc::check_non_bcp_klass(klass); |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1612 if (klass != NULL) { |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1613 Symbol* name = Klass::cast(klass)->name(); |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1614 for (int i = _non_bcp_klasses.length() - 1; i >= 0; i--) { |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1615 klassOop k2 = _non_bcp_klasses.at(i)(); |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1616 if (Klass::cast(k2)->name() == name) { |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1617 if (k2 != klass) { |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1618 lose(err_msg("unsupported klass name alias %s", name->as_utf8()), THREAD); |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1619 } |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1620 return true; |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1621 } |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1622 } |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1623 _non_bcp_klasses.append(KlassHandle(THREAD, klass)); |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1624 return true; |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1625 } |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1626 return false; |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1627 } |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1628 |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1629 void MethodHandleCompiler::record_non_bcp_klasses() { |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1630 // Append extra klasses to constant pool, to guide klass lookup. |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1631 for (int k = 0; k < _non_bcp_klasses.length(); k++) { |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1632 klassOop non_bcp_klass = _non_bcp_klasses.at(k)(); |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1633 bool add_to_cp = true; |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1634 for (int j = 1; j < _constants.length(); j++) { |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1635 ConstantValue* cv = _constants.at(j); |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1636 if (cv != NULL && cv->tag() == JVM_CONSTANT_Class |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1637 && cv->klass_oop() == non_bcp_klass) { |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1638 add_to_cp = false; |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1639 break; |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1640 } |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1641 } |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1642 if (add_to_cp) cpool_klass_put(non_bcp_klass); |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1643 } |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1644 } |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1645 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1646 constantPoolHandle MethodHandleCompiler::get_constant_pool(TRAPS) const { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1647 constantPoolHandle nullHandle; |
2226
c5a923563727
6912621: iCMS: Error: assert(_markBitMap.isMarked(addr + 1),"Missing Printezis bit?")
ysr
parents:
2177
diff
changeset
|
1648 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
|
1649 oopDesc::IsSafeConc, |
c5a923563727
6912621: iCMS: Error: assert(_markBitMap.isMarked(addr + 1),"Missing Printezis bit?")
ysr
parents:
2177
diff
changeset
|
1650 CHECK_(nullHandle)); |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1651 constantPoolHandle cpool(THREAD, cpool_oop); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1652 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1653 // Fill the real constant pool skipping the zero element. |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1654 for (int i = 1; i < _constants.length(); i++) { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1655 ConstantValue* cv = _constants.at(i); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1656 switch (cv->tag()) { |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2117
diff
changeset
|
1657 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
|
1658 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
|
1659 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
|
1660 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
|
1661 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
|
1662 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
|
1663 case JVM_CONSTANT_Methodref: cpool->method_at_put( i, cv->first_index(), cv->second_index()); break; |
3785
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1664 case JVM_CONSTANT_InterfaceMethodref: |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1665 cpool->interface_method_at_put(i, cv->first_index(), cv->second_index()); break; |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1666 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
|
1667 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
|
1668 default: ShouldNotReachHere(); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1669 } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1670 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1671 switch (cv->tag()) { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1672 case JVM_CONSTANT_Long: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1673 case JVM_CONSTANT_Double: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1674 i++; // Skip empty entry. |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1675 assert(_constants.at(i) == NULL, "empty entry"); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1676 break; |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1677 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1678 } |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1679 |
3785
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1680 cpool->set_preresolution(); |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1681 |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1682 // 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
|
1683 cpool->set_pool_holder(_target_klass()); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1684 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1685 return cpool; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1686 } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1687 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1688 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1689 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
|
1690 methodHandle empty; |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1691 // Create a method that holds the generated bytecode. invokedynamic |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1692 // has no receiver, normal MH calls do. |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1693 int flags_bits; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1694 if (for_invokedynamic()) |
1507
cd5dbf694d45
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
1152
diff
changeset
|
1695 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
|
1696 else |
1507
cd5dbf694d45
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
1152
diff
changeset
|
1697 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
|
1698 |
3366
e2a92dd0d3d2
7042122: JSR 292: adjust various inline thresholds for JSR 292 API methods and method handle adapters
twisti
parents:
3363
diff
changeset
|
1699 // 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
|
1700 methodHandle m; |
e2a92dd0d3d2
7042122: JSR 292: adjust various inline thresholds for JSR 292 API methods and method handle adapters
twisti
parents:
3363
diff
changeset
|
1701 { |
e2a92dd0d3d2
7042122: JSR 292: adjust various inline thresholds for JSR 292 API methods and method handle adapters
twisti
parents:
3363
diff
changeset
|
1702 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
|
1703 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
|
1704 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
|
1705 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
|
1706 } |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1707 |
3366
e2a92dd0d3d2
7042122: JSR 292: adjust various inline thresholds for JSR 292 API methods and method handle adapters
twisti
parents:
3363
diff
changeset
|
1708 constantPoolHandle cpool = get_constant_pool(CHECK_(empty)); |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1709 m->set_constants(cpool()); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1710 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1711 m->set_name_index(_name_index); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1712 m->set_signature_index(_signature_index); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1713 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1714 m->set_code((address) bytecode()); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1715 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1716 m->set_max_stack(_max_stack); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1717 m->set_max_locals(max_locals()); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1718 m->set_size_of_parameters(_num_params); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1719 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1720 typeArrayHandle exception_handlers(THREAD, Universe::the_empty_int_array()); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1721 m->set_exception_table(exception_handlers()); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1722 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1723 // 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
|
1724 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
|
1725 objArrayHandle methods(THREAD, m_array); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1726 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
|
1727 Rewriter::rewrite(_target_klass(), cpool, methods, CHECK_(empty)); // Use fake class. |
3748 | 1728 Rewriter::relocate_and_link(_target_klass(), methods, CHECK_(empty)); // Use fake class. |
3366
e2a92dd0d3d2
7042122: JSR 292: adjust various inline thresholds for JSR 292 API methods and method handle adapters
twisti
parents:
3363
diff
changeset
|
1729 |
3785
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1730 // Pre-resolve selected CP cache entries, to avoid problems with class loader scoping. |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1731 constantPoolCacheHandle cpc(THREAD, cpool->cache()); |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1732 for (int i = 0; i < cpc->length(); i++) { |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1733 ConstantPoolCacheEntry* e = cpc->entry_at(i); |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1734 assert(!e->is_secondary_entry(), "no indy instructions in here, yet"); |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1735 int constant_pool_index = e->constant_pool_index(); |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1736 ConstantValue* cv = _constants.at(constant_pool_index); |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1737 if (!cv->has_linkage()) continue; |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1738 methodHandle m = cv->linkage(); |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1739 int index; |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1740 switch (cv->tag()) { |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1741 case JVM_CONSTANT_Methodref: |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1742 index = m->vtable_index(); |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1743 if (m->is_static()) { |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1744 e->set_method(Bytecodes::_invokestatic, m, index); |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1745 } else { |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1746 e->set_method(Bytecodes::_invokespecial, m, index); |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1747 e->set_method(Bytecodes::_invokevirtual, m, index); |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1748 } |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1749 break; |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1750 case JVM_CONSTANT_InterfaceMethodref: |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1751 index = klassItable::compute_itable_index(m()); |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1752 e->set_interface_call(m, index); |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1753 break; |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1754 } |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1755 } |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1756 |
3371
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1757 // 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
|
1758 // original call site. |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1759 InvocationCounter* ic = m->invocation_counter(); |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1760 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
|
1761 |
3366
e2a92dd0d3d2
7042122: JSR 292: adjust various inline thresholds for JSR 292 API methods and method handle adapters
twisti
parents:
3363
diff
changeset
|
1762 // 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
|
1763 { |
e2a92dd0d3d2
7042122: JSR 292: adjust various inline thresholds for JSR 292 API methods and method handle adapters
twisti
parents:
3363
diff
changeset
|
1764 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
|
1765 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
|
1766 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
|
1767 |
e2a92dd0d3d2
7042122: JSR 292: adjust various inline thresholds for JSR 292 API methods and method handle adapters
twisti
parents:
3363
diff
changeset
|
1768 // 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
|
1769 // 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
|
1770 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
|
1771 mdo->is_valid(profile_data); |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1772 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
|
1773 if (profile_data->is_CounterData()) { |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1774 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
|
1775 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
|
1776 } |
e2a92dd0d3d2
7042122: JSR 292: adjust various inline thresholds for JSR 292 API methods and method handle adapters
twisti
parents:
3363
diff
changeset
|
1777 } |
e2a92dd0d3d2
7042122: JSR 292: adjust various inline thresholds for JSR 292 API methods and method handle adapters
twisti
parents:
3363
diff
changeset
|
1778 } |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1779 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1780 #ifndef PRODUCT |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1781 if (TraceMethodHandles) { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1782 m->print(); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1783 m->print_codes(); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1784 } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1785 #endif //PRODUCT |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
1786 |
1507
cd5dbf694d45
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
1152
diff
changeset
|
1787 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
|
1788 return m; |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1789 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1790 |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1791 |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1792 #ifndef PRODUCT |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1793 |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1794 // MH printer for debugging. |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1795 |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1796 class MethodHandlePrinter : public MethodHandleWalker { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1797 private: |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1798 outputStream* _out; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1799 bool _verbose; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1800 int _temp_num; |
3371
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1801 int _param_state; |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1802 stringStream _strbuf; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1803 const char* strbuf() { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1804 const char* s = _strbuf.as_string(); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1805 _strbuf.reset(); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1806 return s; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1807 } |
3740
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
1808 ArgToken token(const char* str, BasicType type) { |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
1809 return ArgToken(str, type); |
3371
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1810 } |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1811 const char* string(ArgToken token) { |
3388
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3385
diff
changeset
|
1812 return token.str(); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1813 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1814 void start_params() { |
3371
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1815 _param_state <<= 1; |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1816 _out->print("("); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1817 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1818 void end_params() { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1819 if (_verbose) _out->print("\n"); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1820 _out->print(") => {"); |
3371
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1821 _param_state >>= 1; |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1822 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1823 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
|
1824 const char* kname = NULL; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1825 if (tk != NULL) |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1826 kname = Klass::cast(tk)->external_name(); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1827 s->print("%s", (kname != NULL) ? kname : type2name(type)); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1828 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1829 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
|
1830 const char* value = strbuf(); |
3740
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
1831 if (!_verbose) return token(value, type); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1832 // make an explicit binding for each separate value |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1833 _strbuf.print("%s%d", temp_name, ++_temp_num); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1834 const char* temp = strbuf(); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1835 _out->print("\n %s %s %s = %s;", statement_op, type2name(type), temp, value); |
3740
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
1836 return token(temp, type); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1837 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1838 |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1839 public: |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1840 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
|
1841 : MethodHandleWalker(root, false, THREAD), |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1842 _out(out), |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1843 _verbose(verbose), |
3371
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1844 _param_state(0), |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1845 _temp_num(0) |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1846 { |
3785
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1847 out->print("MethodHandle:"); |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1848 java_lang_invoke_MethodType::print_signature(java_lang_invoke_MethodHandle::type(root()), out); |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1849 out->print(" : #"); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1850 start_params(); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1851 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1852 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
|
1853 if (argnum < 0) { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1854 end_params(); |
3740
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
1855 return token("return", type); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1856 } |
3371
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1857 if ((_param_state & 1) == 0) { |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1858 _param_state |= 1; |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1859 _out->print(_verbose ? "\n " : ""); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1860 } else { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1861 _out->print(_verbose ? ",\n " : ", "); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1862 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1863 if (argnum >= _temp_num) |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1864 _temp_num = argnum; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1865 // generate an argument name |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1866 _strbuf.print("a%d", argnum); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1867 const char* arg = strbuf(); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1868 put_type_name(type, tk, _out); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1869 _out->print(" %s", arg); |
3740
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
1870 return token(arg, type); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1871 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1872 virtual ArgToken make_oop_constant(oop con, TRAPS) { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1873 if (con == NULL) |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1874 _strbuf.print("null"); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1875 else |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1876 con->print_value_on(&_strbuf); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1877 if (_strbuf.size() == 0) { // yuck |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1878 _strbuf.print("(a "); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1879 put_type_name(T_OBJECT, con->klass(), &_strbuf); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1880 _strbuf.print(")"); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1881 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1882 return maybe_make_temp("constant", T_OBJECT, "k"); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1883 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1884 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
|
1885 java_lang_boxing_object::print(type, con, &_strbuf); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1886 return maybe_make_temp("constant", type, "k"); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1887 } |
3371
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1888 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
|
1889 if (Bytecodes::is_defined(op)) |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1890 _strbuf.print("%s", Bytecodes::name(op)); |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1891 else |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1892 _strbuf.print("bytecode_%d", (int) op); |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1893 } |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1894 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
|
1895 print_bytecode_name(op); |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1896 _strbuf.print("(%s", string(src)); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1897 if (tk != NULL) { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1898 _strbuf.print(", "); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1899 put_type_name(type, tk, &_strbuf); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1900 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1901 _strbuf.print(")"); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1902 return maybe_make_temp("convert", type, "v"); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1903 } |
3371
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1904 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
|
1905 _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
|
1906 if (tk != NULL) { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1907 _strbuf.print(", "); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1908 put_type_name(type, tk, &_strbuf); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1909 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1910 _strbuf.print(")"); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1911 return maybe_make_temp("fetch", type, "x"); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1912 } |
3785
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1913 virtual ArgToken make_invoke(methodHandle m, vmIntrinsics::ID iid, |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1914 Bytecodes::Code op, bool tailcall, |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1915 int argc, ArgToken* argv, TRAPS) { |
3371
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1916 Symbol* name; |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1917 Symbol* sig; |
3785
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3759
diff
changeset
|
1918 if (m.not_null()) { |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1919 name = m->name(); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1920 sig = m->signature(); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1921 } else { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1922 name = vmSymbols::symbol_at(vmIntrinsics::name_for(iid)); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1923 sig = vmSymbols::symbol_at(vmIntrinsics::signature_for(iid)); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1924 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1925 _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
|
1926 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
|
1927 _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
|
1928 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1929 _strbuf.print(")"); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1930 if (!tailcall) { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1931 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
|
1932 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
|
1933 return maybe_make_temp("invoke", rt, "x"); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1934 } else { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1935 const char* ret = strbuf(); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1936 _out->print(_verbose ? "\n return " : " "); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1937 _out->print("%s", ret); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1938 _out->print(_verbose ? "\n}\n" : " }"); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1939 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1940 return ArgToken(); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1941 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1942 |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1943 virtual void set_method_handle(oop mh) { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1944 if (WizardMode && Verbose) { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1945 tty->print("\n--- next target: "); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1946 mh->print(); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1947 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1948 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1949 |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1950 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
|
1951 ResourceMark rm; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1952 MethodHandlePrinter printer(root, verbose, out, CHECK); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1953 printer.walk(CHECK); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1954 out->print("\n"); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1955 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1956 static void print(Handle root, bool verbose = Verbose, outputStream* out = tty) { |
3740
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
1957 Thread* THREAD = Thread::current(); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1958 ResourceMark rm; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1959 MethodHandlePrinter printer(root, verbose, out, THREAD); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1960 if (!HAS_PENDING_EXCEPTION) |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1961 printer.walk(THREAD); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1962 if (HAS_PENDING_EXCEPTION) { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1963 oop ex = PENDING_EXCEPTION; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1964 CLEAR_PENDING_EXCEPTION; |
3371
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1965 out->print(" *** "); |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1966 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
|
1967 out->print("}"); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1968 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1969 out->print("\n"); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1970 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1971 }; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1972 |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1973 extern "C" |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1974 void print_method_handle(oop mh) { |
1793
d257356e35f0
6939224: MethodHandle.invokeGeneric needs to perform the correct set of conversions
jrose
parents:
1783
diff
changeset
|
1975 if (!mh->is_oop()) { |
3371
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
1976 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
|
1977 } 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
|
1978 MethodHandlePrinter::print(mh); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1979 } else { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1980 tty->print("*** not a method handle: "); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1981 mh->print(); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1982 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1983 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1984 |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1985 #endif // PRODUCT |