Mercurial > hg > truffle
annotate src/share/vm/prims/methodHandleWalk.hpp @ 4530:6c6cb7be1324
bugfix
author | Christian Haeubl <christian.haeubl@oracle.com> |
---|---|
date | Wed, 08 Feb 2012 21:13:35 -0800 |
parents | c26de9aef2ed |
children |
rev | line source |
---|---|
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
1 /* |
2357
8033953d67ff
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
2177
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:
1152
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1152
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:
1152
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 #ifndef SHARE_VM_PRIMS_METHODHANDLEWALK_HPP |
26 #define SHARE_VM_PRIMS_METHODHANDLEWALK_HPP | |
27 | |
28 #include "prims/methodHandles.hpp" | |
29 | |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
30 // Low-level parser for method handle chains. |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
31 class MethodHandleChain : StackObj { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
32 public: |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
33 typedef MethodHandles::EntryKind EntryKind; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
34 |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
35 private: |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
36 Handle _root; // original target |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
37 Handle _method_handle; // current target |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
38 bool _is_last; // final guy in chain |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
39 bool _is_bound; // has a bound argument |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
40 BasicType _arg_type; // if is_bound, the bound argument type |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
41 int _arg_slot; // if is_bound or is_adapter, affected argument slot |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
42 jint _conversion; // conversion field of AMH or -1 |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
43 methodHandle _last_method; // if is_last, which method we target |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
44 Bytecodes::Code _last_invoke; // if is_last, type of invoke |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
45 const char* _lose_message; // saved argument to lose() |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
46 |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
47 void set_method_handle(Handle target, TRAPS); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
48 void set_last_method(oop target, TRAPS); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
49 static BasicType 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
|
50 |
2357
8033953d67ff
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
2177
diff
changeset
|
51 oop MethodHandle_type_oop() { return java_lang_invoke_MethodHandle::type(method_handle_oop()); } |
8033953d67ff
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
2177
diff
changeset
|
52 oop MethodHandle_vmtarget_oop() { return java_lang_invoke_MethodHandle::vmtarget(method_handle_oop()); } |
8033953d67ff
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
2177
diff
changeset
|
53 int MethodHandle_vmslots() { return java_lang_invoke_MethodHandle::vmslots(method_handle_oop()); } |
8033953d67ff
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
2177
diff
changeset
|
54 int DirectMethodHandle_vmindex() { return java_lang_invoke_DirectMethodHandle::vmindex(method_handle_oop()); } |
8033953d67ff
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
2177
diff
changeset
|
55 oop BoundMethodHandle_argument_oop() { return java_lang_invoke_BoundMethodHandle::argument(method_handle_oop()); } |
8033953d67ff
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
2177
diff
changeset
|
56 int BoundMethodHandle_vmargslot() { return java_lang_invoke_BoundMethodHandle::vmargslot(method_handle_oop()); } |
8033953d67ff
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
2177
diff
changeset
|
57 int AdapterMethodHandle_conversion() { return java_lang_invoke_AdapterMethodHandle::conversion(method_handle_oop()); } |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
58 |
3740
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
59 #ifdef ASSERT |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
60 void print_impl(TRAPS); |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
61 #endif |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
62 |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
63 public: |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
64 MethodHandleChain(Handle root, TRAPS) |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
65 : _root(root) |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
66 { set_method_handle(root, THREAD); } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
67 |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
68 bool is_adapter() { return _conversion != -1; } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
69 bool is_bound() { return _is_bound; } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
70 bool is_last() { return _is_last; } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
71 |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
72 void next(TRAPS) { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
73 assert(!is_last(), ""); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
74 set_method_handle(MethodHandle_vmtarget_oop(), THREAD); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
75 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
76 |
3905
c26de9aef2ed
7071307: MethodHandle bimorphic inlining should consider the frequency
never
parents:
3785
diff
changeset
|
77 Handle root() { return _root; } |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
78 Handle method_handle() { return _method_handle; } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
79 oop method_handle_oop() { return _method_handle(); } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
80 oop method_type_oop() { return MethodHandle_type_oop(); } |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
81 oop vmtarget_oop() { return MethodHandle_vmtarget_oop(); } |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
82 |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
83 jint adapter_conversion() { assert(is_adapter(), ""); return _conversion; } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
84 int adapter_conversion_op() { return MethodHandles::adapter_conversion_op(adapter_conversion()); } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
85 BasicType adapter_conversion_src_type() |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
86 { return MethodHandles::adapter_conversion_src_type(adapter_conversion()); } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
87 BasicType adapter_conversion_dest_type() |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
88 { return MethodHandles::adapter_conversion_dest_type(adapter_conversion()); } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
89 int adapter_conversion_stack_move() |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
90 { return MethodHandles::adapter_conversion_stack_move(adapter_conversion()); } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
91 int adapter_conversion_stack_pushes() |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
92 { return adapter_conversion_stack_move() / MethodHandles::stack_move_unit(); } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
93 int adapter_conversion_vminfo() |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
94 { return MethodHandles::adapter_conversion_vminfo(adapter_conversion()); } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
95 int adapter_arg_slot() { assert(is_adapter(), ""); return _arg_slot; } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
96 oop adapter_arg_oop() { assert(is_adapter(), ""); return BoundMethodHandle_argument_oop(); } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
97 |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
98 BasicType bound_arg_type() { assert(is_bound(), ""); return _arg_type; } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
99 int bound_arg_slot() { assert(is_bound(), ""); return _arg_slot; } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
100 oop bound_arg_oop() { assert(is_bound(), ""); return BoundMethodHandle_argument_oop(); } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
101 |
3785
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3753
diff
changeset
|
102 methodHandle last_method() { assert(is_last(), ""); return _last_method; } |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
103 methodOop last_method_oop() { assert(is_last(), ""); return _last_method(); } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
104 Bytecodes::Code last_invoke_code() { assert(is_last(), ""); return _last_invoke; } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
105 |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
106 void lose(const char* msg, TRAPS); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
107 const char* lose_message() { return _lose_message; } |
3740
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
108 |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
109 #ifdef ASSERT |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
110 // Print a symbolic description of a method handle chain, including |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
111 // the signature for each method. The signatures are printed in |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
112 // slot order to make it easier to understand. |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
113 void print(); |
3753
cba7b5c2d53f
7045514: SPARC assembly code for JSR 292 ricochet frames
never
parents:
3740
diff
changeset
|
114 static void print(oopDesc* mh); |
3740
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
115 #endif |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
116 }; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
117 |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
118 |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
119 // Structure walker for method handles. |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
120 // Does abstract interpretation on top of low-level parsing. |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
121 // You supply the tokens shuffled by the abstract interpretation. |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
122 class MethodHandleWalker : StackObj { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
123 public: |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
124 // Stack values: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
125 enum TokenType { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
126 tt_void, |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
127 tt_parameter, |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
128 tt_temporary, |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
129 tt_constant, |
3371
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
130 tt_symbolic, |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
131 tt_illegal |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
132 }; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
133 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
134 // Argument token: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
135 class ArgToken { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
136 private: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
137 TokenType _tt; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
138 BasicType _bt; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
139 jvalue _value; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
140 Handle _handle; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
141 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
142 public: |
3740
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
143 ArgToken(TokenType tt = tt_illegal) : _tt(tt), _bt(tt == tt_void ? T_VOID : T_ILLEGAL) { |
3388
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3371
diff
changeset
|
144 assert(tt == tt_illegal || tt == tt_void, "invalid token type"); |
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3371
diff
changeset
|
145 } |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
146 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
147 ArgToken(TokenType tt, BasicType bt, int index) : _tt(tt), _bt(bt) { |
3388
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3371
diff
changeset
|
148 assert(_tt == tt_parameter || _tt == tt_temporary, "must have index"); |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
149 _value.i = index; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
150 } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
151 |
3740
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
152 ArgToken(BasicType bt, jvalue value) : _tt(tt_constant), _bt(bt), _value(value) { assert(_bt != T_OBJECT, "wrong constructor"); } |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
153 ArgToken(Handle handle) : _tt(tt_constant), _bt(T_OBJECT), _handle(handle) {} |
3388
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3371
diff
changeset
|
154 |
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3371
diff
changeset
|
155 |
3740
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
156 ArgToken(const char* str, BasicType type) : _tt(tt_symbolic), _bt(type) { |
3388
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3371
diff
changeset
|
157 _value.j = (intptr_t)str; |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
158 } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
159 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
160 TokenType token_type() const { return _tt; } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
161 BasicType basic_type() const { return _bt; } |
3388
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3371
diff
changeset
|
162 bool has_index() const { return _tt == tt_parameter || _tt == tt_temporary; } |
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3371
diff
changeset
|
163 int index() const { assert(has_index(), "must have index");; return _value.i; } |
3740
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
164 Handle object() const { assert(_bt == T_OBJECT, "wrong accessor"); assert(_tt == tt_constant, "value type"); return _handle; } |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
165 const char* str() const { assert(_tt == tt_symbolic, "string type"); return (const char*)(intptr_t)_value.j; } |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
166 |
3740
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
167 jint get_jint() const { assert(_bt == T_INT || is_subword_type(_bt), "wrong accessor"); assert(_tt == tt_constant, "value types"); return _value.i; } |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
168 jlong get_jlong() const { assert(_bt == T_LONG, "wrong accessor"); assert(_tt == tt_constant, "value types"); return _value.j; } |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
169 jfloat get_jfloat() const { assert(_bt == T_FLOAT, "wrong accessor"); assert(_tt == tt_constant, "value types"); return _value.f; } |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
170 jdouble get_jdouble() const { assert(_bt == T_DOUBLE, "wrong accessor"); assert(_tt == tt_constant, "value types"); return _value.d; } |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
171 }; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
172 |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
173 private: |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
174 MethodHandleChain _chain; |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
175 bool _for_invokedynamic; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
176 int _local_index; |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
177 |
3371
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
178 // This array is kept in an unusual order, indexed by low-level "slot number". |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
179 // TOS is always _outgoing.at(0), so simple pushes and pops shift the whole _outgoing array. |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
180 // If there is a receiver in the current argument list, it is at _outgoing.at(_outgoing.length()-1). |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
181 // If a value at _outgoing.at(n) is T_LONG or T_DOUBLE, the value at _outgoing.at(n+1) is T_VOID. |
3740
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
182 GrowableArray<ArgToken> _outgoing; // current outgoing parameter slots |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
183 int _outgoing_argc; // # non-empty outgoing slots |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
184 |
3785
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3753
diff
changeset
|
185 vmIntrinsics::ID _return_conv; // Return conversion required by raw retypes. |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3753
diff
changeset
|
186 |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
187 // Replace a value of type old_type at slot (and maybe slot+1) with the new value. |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
188 // If old_type != T_VOID, remove the old argument at that point. |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
189 // If new_type != T_VOID, insert the new argument at that point. |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
190 // Insert or delete a second empty slot as needed. |
3740
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
191 void 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
|
192 void change_argument(BasicType old_type, int slot, BasicType type, 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
|
193 assert(type == new_arg.basic_type(), "must agree"); |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
194 change_argument(old_type, slot, new_arg); |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
195 } |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
196 |
3371
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
197 // Raw retype conversions for OP_RAW_RETYPE. |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
198 void 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
|
199 void retype_raw_argument_type(BasicType src, BasicType dst, int slot, TRAPS) { retype_raw_conversion(src, dst, false, slot, CHECK); } |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
200 void retype_raw_return_type( BasicType src, BasicType dst, TRAPS) { retype_raw_conversion(src, dst, true, -1, CHECK); } |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
201 |
3740
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
202 BasicType arg_type(int slot) { |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
203 return _outgoing.at(slot).basic_type(); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
204 } |
3740
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
205 bool has_argument(int slot) { |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
206 return arg_type(slot) < T_VOID; |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
207 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
208 |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
209 #ifdef ASSERT |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
210 int argument_count_slow(); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
211 #endif |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
212 |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
213 // Return a bytecode for converting src to dest, if one exists. |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
214 Bytecodes::Code conversion_code(BasicType src, BasicType dest); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
215 |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
216 void walk_incoming_state(TRAPS); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
217 |
3740
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
218 void verify_args_and_signature(TRAPS) NOT_DEBUG_RETURN; |
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
219 |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
220 public: |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
221 MethodHandleWalker(Handle root, bool for_invokedynamic, TRAPS) |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
222 : _chain(root, THREAD), |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
223 _for_invokedynamic(for_invokedynamic), |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
224 _outgoing(THREAD, 10), |
3785
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3753
diff
changeset
|
225 _outgoing_argc(0), |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3753
diff
changeset
|
226 _return_conv(vmIntrinsics::_none) |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
227 { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
228 _local_index = for_invokedynamic ? 0 : 1; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
229 } |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
230 |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
231 MethodHandleChain& chain() { return _chain; } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
232 |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
233 bool for_invokedynamic() const { return _for_invokedynamic; } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
234 |
3785
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3753
diff
changeset
|
235 vmIntrinsics::ID return_conv() const { return _return_conv; } |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3753
diff
changeset
|
236 void set_return_conv(vmIntrinsics::ID c) { _return_conv = c; } |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3753
diff
changeset
|
237 static vmIntrinsics::ID zero_return_conv() { return vmIntrinsics::_min; } |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3753
diff
changeset
|
238 |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
239 int new_local_index(BasicType bt) { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
240 //int index = _for_invokedynamic ? _local_index : _local_index - 1; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
241 int index = _local_index; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
242 _local_index += type2size[bt]; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
243 return index; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
244 } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
245 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
246 int max_locals() const { return _local_index; } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
247 |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
248 // plug-in abstract interpretation steps: |
3371
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
249 virtual ArgToken make_parameter(BasicType type, klassOop tk, int argnum, TRAPS) = 0; |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
250 virtual ArgToken make_prim_constant(BasicType type, jvalue* con, TRAPS) = 0; |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
251 virtual ArgToken make_oop_constant(oop con, TRAPS) = 0; |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
252 virtual ArgToken make_conversion(BasicType type, klassOop tk, Bytecodes::Code op, const ArgToken& src, TRAPS) = 0; |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
253 virtual ArgToken make_fetch(BasicType type, klassOop tk, Bytecodes::Code op, const ArgToken& base, const ArgToken& offset, TRAPS) = 0; |
3785
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3753
diff
changeset
|
254 virtual ArgToken make_invoke(methodHandle m, vmIntrinsics::ID iid, Bytecodes::Code op, bool tailcall, int argc, ArgToken* argv, TRAPS) = 0; |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
255 |
3785
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3753
diff
changeset
|
256 // For make_invoke, the methodHandle can be NULL if the intrinsic ID |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
257 // is something other than vmIntrinsics::_none. |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
258 |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
259 // and in case anyone cares to related the previous actions to the chain: |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
260 virtual void set_method_handle(oop mh) { } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
261 |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
262 void lose(const char* msg, TRAPS) { chain().lose(msg, THREAD); } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
263 const char* lose_message() { return chain().lose_message(); } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
264 |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
265 ArgToken walk(TRAPS); |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
266 }; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
267 |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
268 |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
269 // An abstract interpreter for method handle chains. |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
270 // Produces an account of the semantics of a chain, in terms of a static IR. |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
271 // The IR happens to be JVM bytecodes. |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
272 class MethodHandleCompiler : public MethodHandleWalker { |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
273 private: |
3366
e2a92dd0d3d2
7042122: JSR 292: adjust various inline thresholds for JSR 292 API methods and method handle adapters
twisti
parents:
2478
diff
changeset
|
274 int _invoke_count; // count the original call site has been executed |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
275 KlassHandle _rklass; // Return type for casting. |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
276 BasicType _rtype; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
277 KlassHandle _target_klass; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
278 Thread* _thread; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
279 |
3905
c26de9aef2ed
7071307: MethodHandle bimorphic inlining should consider the frequency
never
parents:
3785
diff
changeset
|
280 int _selectAlternative_bci; // These are used for capturing profiles from GWTs |
c26de9aef2ed
7071307: MethodHandle bimorphic inlining should consider the frequency
never
parents:
3785
diff
changeset
|
281 int _taken_count; |
c26de9aef2ed
7071307: MethodHandle bimorphic inlining should consider the frequency
never
parents:
3785
diff
changeset
|
282 int _not_taken_count; |
c26de9aef2ed
7071307: MethodHandle bimorphic inlining should consider the frequency
never
parents:
3785
diff
changeset
|
283 |
3371
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
284 // Values used by the compiler. |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
285 static jvalue zero_jvalue; |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
286 static jvalue one_jvalue; |
fabcf26ee72f
6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents:
3366
diff
changeset
|
287 |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
288 // Fake constant pool entry. |
3753
cba7b5c2d53f
7045514: SPARC assembly code for JSR 292 ricochet frames
never
parents:
3740
diff
changeset
|
289 class ConstantValue : public ResourceObj { |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
290 private: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
291 int _tag; // Constant pool tag type. |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
292 JavaValue _value; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
293 Handle _handle; |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2001
diff
changeset
|
294 Symbol* _sym; |
3785
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3753
diff
changeset
|
295 methodHandle _method; // pre-linkage |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
296 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
297 public: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
298 // Constructor for oop types. |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
299 ConstantValue(int tag, Handle con) : _tag(tag), _handle(con) { |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2001
diff
changeset
|
300 assert(tag == JVM_CONSTANT_Class || |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
301 tag == JVM_CONSTANT_String || |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
302 tag == JVM_CONSTANT_Object, "must be oop type"); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
303 } |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
304 |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2001
diff
changeset
|
305 ConstantValue(int tag, Symbol* con) : _tag(tag), _sym(con) { |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2001
diff
changeset
|
306 assert(tag == JVM_CONSTANT_Utf8, "must be symbol type"); |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2001
diff
changeset
|
307 } |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2001
diff
changeset
|
308 |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
309 // Constructor for oop reference types. |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
310 ConstantValue(int tag, int index) : _tag(tag) { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
311 assert(JVM_CONSTANT_Fieldref <= tag && tag <= JVM_CONSTANT_NameAndType, "must be ref type"); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
312 _value.set_jint(index); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
313 } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
314 ConstantValue(int tag, int first_index, int second_index) : _tag(tag) { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
315 assert(JVM_CONSTANT_Fieldref <= tag && tag <= JVM_CONSTANT_NameAndType, "must be ref type"); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
316 _value.set_jint(first_index << 16 | second_index); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
317 } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
318 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
319 // Constructor for primitive types. |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
320 ConstantValue(BasicType bt, jvalue con) { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
321 _value.set_type(bt); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
322 switch (bt) { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
323 case T_INT: _tag = JVM_CONSTANT_Integer; _value.set_jint( con.i); break; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
324 case T_LONG: _tag = JVM_CONSTANT_Long; _value.set_jlong( con.j); break; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
325 case T_FLOAT: _tag = JVM_CONSTANT_Float; _value.set_jfloat( con.f); break; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
326 case T_DOUBLE: _tag = JVM_CONSTANT_Double; _value.set_jdouble(con.d); break; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
327 default: ShouldNotReachHere(); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
328 } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
329 } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
330 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
331 int tag() const { return _tag; } |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2001
diff
changeset
|
332 Symbol* symbol() const { return _sym; } |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
333 klassOop klass_oop() const { return (klassOop) _handle(); } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
334 oop object_oop() const { return _handle(); } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
335 int index() const { return _value.get_jint(); } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
336 int first_index() const { return _value.get_jint() >> 16; } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
337 int second_index() const { return _value.get_jint() & 0x0000FFFF; } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
338 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
339 bool is_primitive() const { return is_java_primitive(_value.get_type()); } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
340 jint get_jint() const { return _value.get_jint(); } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
341 jlong get_jlong() const { return _value.get_jlong(); } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
342 jfloat get_jfloat() const { return _value.get_jfloat(); } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
343 jdouble get_jdouble() const { return _value.get_jdouble(); } |
3785
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3753
diff
changeset
|
344 |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3753
diff
changeset
|
345 void set_linkage(methodHandle method) { |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3753
diff
changeset
|
346 assert(_method.is_null(), ""); |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3753
diff
changeset
|
347 _method = method; |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3753
diff
changeset
|
348 } |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3753
diff
changeset
|
349 bool has_linkage() const { return _method.not_null(); } |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3753
diff
changeset
|
350 methodHandle linkage() const { return _method; } |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
351 }; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
352 |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
353 // Fake constant pool. |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
354 GrowableArray<ConstantValue*> _constants; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
355 |
3785
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3753
diff
changeset
|
356 // Non-BCP classes that appear in associated MethodTypes (require special handling). |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3753
diff
changeset
|
357 GrowableArray<KlassHandle> _non_bcp_klasses; |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3753
diff
changeset
|
358 |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
359 // Accumulated compiler state: |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
360 GrowableArray<unsigned char> _bytecode; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
361 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
362 int _cur_stack; |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
363 int _max_stack; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
364 int _num_params; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
365 int _name_index; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
366 int _signature_index; |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
367 |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
368 void stack_push(BasicType bt) { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
369 _cur_stack += type2size[bt]; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
370 if (_cur_stack > _max_stack) _max_stack = _cur_stack; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
371 } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
372 void stack_pop(BasicType bt) { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
373 _cur_stack -= type2size[bt]; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
374 assert(_cur_stack >= 0, "sanity"); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
375 } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
376 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
377 unsigned char* bytecode() const { return _bytecode.adr_at(0); } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
378 int bytecode_length() const { return _bytecode.length(); } |
3905
c26de9aef2ed
7071307: MethodHandle bimorphic inlining should consider the frequency
never
parents:
3785
diff
changeset
|
379 int cur_bci() const { return _bytecode.length(); } |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
380 |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
381 // Fake constant pool. |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
382 int cpool_oop_put(int tag, Handle con) { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
383 if (con.is_null()) return 0; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
384 ConstantValue* cv = new ConstantValue(tag, con); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
385 return _constants.append(cv); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
386 } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
387 |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2001
diff
changeset
|
388 int cpool_symbol_put(int tag, Symbol* con) { |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2001
diff
changeset
|
389 if (con == NULL) return 0; |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2001
diff
changeset
|
390 ConstantValue* cv = new ConstantValue(tag, con); |
2478
328926869b15
6987991: JSR 292 phpreboot test/testtracefun2.phpr segfaults
jrose
parents:
2357
diff
changeset
|
391 con->increment_refcount(); |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2001
diff
changeset
|
392 return _constants.append(cv); |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2001
diff
changeset
|
393 } |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2001
diff
changeset
|
394 |
3785
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3753
diff
changeset
|
395 int cpool_oop_reference_put(int tag, int first_index, int second_index, methodHandle method) { |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
396 if (first_index == 0 && second_index == 0) return 0; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
397 assert(first_index != 0 && second_index != 0, "no zero indexes"); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
398 ConstantValue* cv = new ConstantValue(tag, first_index, second_index); |
3785
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3753
diff
changeset
|
399 if (method.not_null()) cv->set_linkage(method); |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
400 return _constants.append(cv); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
401 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
402 |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
403 int cpool_primitive_put(BasicType type, jvalue* con); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
404 |
3785
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3753
diff
changeset
|
405 bool 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:
3753
diff
changeset
|
406 bool 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:
3753
diff
changeset
|
407 void record_non_bcp_klasses(); |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3753
diff
changeset
|
408 |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
409 int cpool_int_put(jint value) { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
410 jvalue con; con.i = value; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
411 return cpool_primitive_put(T_INT, &con); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
412 } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
413 int cpool_long_put(jlong value) { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
414 jvalue con; con.j = value; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
415 return cpool_primitive_put(T_LONG, &con); |
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 int cpool_float_put(jfloat value) { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
418 jvalue con; con.f = value; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
419 return cpool_primitive_put(T_FLOAT, &con); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
420 } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
421 int cpool_double_put(jdouble value) { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
422 jvalue con; con.d = value; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
423 return cpool_primitive_put(T_DOUBLE, &con); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
424 } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
425 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
426 int cpool_object_put(Handle obj) { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
427 return cpool_oop_put(JVM_CONSTANT_Object, obj); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
428 } |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2001
diff
changeset
|
429 int cpool_symbol_put(Symbol* sym) { |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2001
diff
changeset
|
430 return cpool_symbol_put(JVM_CONSTANT_Utf8, sym); |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
431 } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
432 int cpool_klass_put(klassOop klass) { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
433 return cpool_oop_put(JVM_CONSTANT_Class, klass); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
434 } |
3785
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3753
diff
changeset
|
435 int cpool_methodref_put(Bytecodes::Code op, int class_index, int name_and_type_index, methodHandle method) { |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3753
diff
changeset
|
436 int tag = (op == Bytecodes::_invokeinterface ? JVM_CONSTANT_InterfaceMethodref : JVM_CONSTANT_Methodref); |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3753
diff
changeset
|
437 return cpool_oop_reference_put(tag, class_index, name_and_type_index, method); |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
438 } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
439 int cpool_name_and_type_put(int name_index, int signature_index) { |
3785
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3753
diff
changeset
|
440 return cpool_oop_reference_put(JVM_CONSTANT_NameAndType, name_index, signature_index, methodHandle()); |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
441 } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
442 |
3388
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3371
diff
changeset
|
443 void emit_bc(Bytecodes::Code op, int index = 0, int args_size = -1); |
3905
c26de9aef2ed
7071307: MethodHandle bimorphic inlining should consider the frequency
never
parents:
3785
diff
changeset
|
444 void update_branch_dest(int src, int dst); |
c26de9aef2ed
7071307: MethodHandle bimorphic inlining should consider the frequency
never
parents:
3785
diff
changeset
|
445 void emit_load(ArgToken arg); |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
446 void emit_load(BasicType bt, int index); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
447 void emit_store(BasicType bt, int index); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
448 void emit_load_constant(ArgToken arg); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
449 |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
450 virtual ArgToken make_parameter(BasicType type, klassOop tk, int argnum, TRAPS) { |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
451 return ArgToken(tt_parameter, type, argnum); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
452 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
453 virtual ArgToken make_oop_constant(oop con, TRAPS) { |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
454 Handle h(THREAD, con); |
3740
5ac411b3b8fc
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3388
diff
changeset
|
455 return ArgToken(h); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
456 } |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
457 virtual ArgToken make_prim_constant(BasicType type, jvalue* con, TRAPS) { |
3388
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3371
diff
changeset
|
458 return ArgToken(type, *con); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
459 } |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
460 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
461 virtual ArgToken make_conversion(BasicType type, klassOop tk, Bytecodes::Code op, const ArgToken& src, TRAPS); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
462 virtual ArgToken make_fetch(BasicType type, klassOop tk, Bytecodes::Code op, const ArgToken& base, const ArgToken& offset, TRAPS); |
3785
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3753
diff
changeset
|
463 virtual ArgToken make_invoke(methodHandle m, vmIntrinsics::ID iid, Bytecodes::Code op, bool tailcall, int argc, ArgToken* argv, TRAPS); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
464 |
3905
c26de9aef2ed
7071307: MethodHandle bimorphic inlining should consider the frequency
never
parents:
3785
diff
changeset
|
465 // Check for profiling information on a GWT and return true if it's found |
c26de9aef2ed
7071307: MethodHandle bimorphic inlining should consider the frequency
never
parents:
3785
diff
changeset
|
466 bool fetch_counts(ArgToken a1, ArgToken a2); |
c26de9aef2ed
7071307: MethodHandle bimorphic inlining should consider the frequency
never
parents:
3785
diff
changeset
|
467 |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
468 // Get a real constant pool. |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
469 constantPoolHandle get_constant_pool(TRAPS) const; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
470 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
471 // Get a real methodOop. |
3905
c26de9aef2ed
7071307: MethodHandle bimorphic inlining should consider the frequency
never
parents:
3785
diff
changeset
|
472 methodHandle get_method_oop(TRAPS); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
473 |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
474 public: |
3388
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3371
diff
changeset
|
475 MethodHandleCompiler(Handle root, Symbol* name, Symbol* signature, int invoke_count, bool for_invokedynamic, TRAPS); |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
476 |
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
477 // Compile the given MH chain into bytecode. |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1133
diff
changeset
|
478 methodHandle compile(TRAPS); |
1152
cd37471eaecc
6914206: change way of permission checking for generated MethodHandle adapters
twisti
parents:
1138
diff
changeset
|
479 |
cd37471eaecc
6914206: change way of permission checking for generated MethodHandle adapters
twisti
parents:
1138
diff
changeset
|
480 // Tests if the given class is a MH adapter holder. |
cd37471eaecc
6914206: change way of permission checking for generated MethodHandle adapters
twisti
parents:
1138
diff
changeset
|
481 static bool klass_is_method_handle_adapter_holder(klassOop klass) { |
2001
f2da85a9b08e
7001363: java/dyn/InvokeDynamic should not be a well-known class in the JVM
twisti
parents:
1972
diff
changeset
|
482 return (klass == SystemDictionary::MethodHandle_klass()); |
1152
cd37471eaecc
6914206: change way of permission checking for generated MethodHandle adapters
twisti
parents:
1138
diff
changeset
|
483 } |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
diff
changeset
|
484 }; |
1972 | 485 |
486 #endif // SHARE_VM_PRIMS_METHODHANDLEWALK_HPP |