2534
|
1 |
/*
|
|
2 |
* Copyright 2008-2009 Sun Microsystems, Inc. All Rights Reserved.
|
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
4 |
*
|
|
5 |
* This code is free software; you can redistribute it and/or modify it
|
|
6 |
* under the terms of the GNU General Public License version 2 only, as
|
|
7 |
* published by the Free Software Foundation.
|
|
8 |
*
|
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that
|
|
13 |
* accompanied this code).
|
|
14 |
*
|
|
15 |
* You should have received a copy of the GNU General Public License version
|
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
18 |
*
|
|
19 |
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
|
20 |
* CA 95054 USA or visit www.sun.com if you need additional information or
|
|
21 |
* have any questions.
|
|
22 |
*
|
|
23 |
*/
|
|
24 |
|
|
25 |
class MacroAssembler;
|
|
26 |
class Label;
|
|
27 |
class MethodHandleEntry;
|
|
28 |
|
|
29 |
class MethodHandles: AllStatic {
|
|
30 |
// JVM support for MethodHandle, MethodType, and related types
|
|
31 |
// in java.dyn and java.dyn.hotspot.
|
|
32 |
// See also javaClasses for layouts java_dyn_Method{Handle,Type,Type::Form}.
|
|
33 |
public:
|
|
34 |
enum EntryKind {
|
|
35 |
_check_mtype, // how a caller calls a MH
|
|
36 |
_wrong_method_type, // what happens when there is a type mismatch
|
|
37 |
_invokestatic_mh, // how a MH emulates invokestatic
|
|
38 |
_invokespecial_mh, // ditto for the other invokes...
|
|
39 |
_invokevirtual_mh,
|
|
40 |
_invokeinterface_mh,
|
|
41 |
_bound_ref_mh, // reference argument is bound
|
|
42 |
_bound_int_mh, // int argument is bound (via an Integer or Float)
|
|
43 |
_bound_long_mh, // long argument is bound (via a Long or Double)
|
|
44 |
_bound_ref_direct_mh, // same as above, with direct linkage to methodOop
|
|
45 |
_bound_int_direct_mh,
|
|
46 |
_bound_long_direct_mh,
|
|
47 |
|
|
48 |
_adapter_mh_first, // adapter sequence goes here...
|
|
49 |
_adapter_retype_only = _adapter_mh_first + sun_dyn_AdapterMethodHandle::OP_RETYPE_ONLY,
|
|
50 |
_adapter_check_cast = _adapter_mh_first + sun_dyn_AdapterMethodHandle::OP_CHECK_CAST,
|
|
51 |
_adapter_prim_to_prim = _adapter_mh_first + sun_dyn_AdapterMethodHandle::OP_PRIM_TO_PRIM,
|
|
52 |
_adapter_ref_to_prim = _adapter_mh_first + sun_dyn_AdapterMethodHandle::OP_REF_TO_PRIM,
|
|
53 |
_adapter_prim_to_ref = _adapter_mh_first + sun_dyn_AdapterMethodHandle::OP_PRIM_TO_REF,
|
|
54 |
_adapter_swap_args = _adapter_mh_first + sun_dyn_AdapterMethodHandle::OP_SWAP_ARGS,
|
|
55 |
_adapter_rot_args = _adapter_mh_first + sun_dyn_AdapterMethodHandle::OP_ROT_ARGS,
|
|
56 |
_adapter_dup_args = _adapter_mh_first + sun_dyn_AdapterMethodHandle::OP_DUP_ARGS,
|
|
57 |
_adapter_drop_args = _adapter_mh_first + sun_dyn_AdapterMethodHandle::OP_DROP_ARGS,
|
|
58 |
_adapter_collect_args = _adapter_mh_first + sun_dyn_AdapterMethodHandle::OP_COLLECT_ARGS,
|
|
59 |
_adapter_spread_args = _adapter_mh_first + sun_dyn_AdapterMethodHandle::OP_SPREAD_ARGS,
|
|
60 |
_adapter_flyby = _adapter_mh_first + sun_dyn_AdapterMethodHandle::OP_FLYBY,
|
|
61 |
_adapter_ricochet = _adapter_mh_first + sun_dyn_AdapterMethodHandle::OP_RICOCHET,
|
|
62 |
_adapter_mh_last = _adapter_mh_first + sun_dyn_AdapterMethodHandle::CONV_OP_LIMIT - 1,
|
|
63 |
|
|
64 |
// Optimized adapter types
|
|
65 |
|
|
66 |
// argument list reordering
|
|
67 |
_adapter_opt_swap_1,
|
|
68 |
_adapter_opt_swap_2,
|
|
69 |
_adapter_opt_rot_1_up,
|
|
70 |
_adapter_opt_rot_1_down,
|
|
71 |
_adapter_opt_rot_2_up,
|
|
72 |
_adapter_opt_rot_2_down,
|
|
73 |
// primitive single to single:
|
|
74 |
_adapter_opt_i2i, // i2c, i2z, i2b, i2s
|
|
75 |
// primitive double to single:
|
|
76 |
_adapter_opt_l2i,
|
|
77 |
_adapter_opt_d2f,
|
|
78 |
// primitive single to double:
|
|
79 |
_adapter_opt_i2l,
|
|
80 |
_adapter_opt_f2d,
|
|
81 |
// conversion between floating point and integer type is handled by Java
|
|
82 |
|
|
83 |
// reference to primitive:
|
|
84 |
_adapter_opt_unboxi,
|
|
85 |
_adapter_opt_unboxl,
|
|
86 |
|
|
87 |
// spreading (array length cases 0, 1, >=2)
|
|
88 |
_adapter_opt_spread_0,
|
|
89 |
_adapter_opt_spread_1,
|
|
90 |
_adapter_opt_spread_more,
|
|
91 |
|
|
92 |
_EK_LIMIT,
|
|
93 |
_EK_FIRST = 0
|
|
94 |
};
|
|
95 |
|
|
96 |
public:
|
|
97 |
static bool enabled() { return _enabled; }
|
|
98 |
static void set_enabled(bool z);
|
|
99 |
|
|
100 |
private:
|
|
101 |
enum { // import sun_dyn_AdapterMethodHandle::CONV_OP_*
|
|
102 |
CONV_OP_LIMIT = sun_dyn_AdapterMethodHandle::CONV_OP_LIMIT,
|
|
103 |
CONV_OP_MASK = sun_dyn_AdapterMethodHandle::CONV_OP_MASK,
|
|
104 |
CONV_VMINFO_MASK = sun_dyn_AdapterMethodHandle::CONV_VMINFO_MASK,
|
|
105 |
CONV_VMINFO_SHIFT = sun_dyn_AdapterMethodHandle::CONV_VMINFO_SHIFT,
|
|
106 |
CONV_OP_SHIFT = sun_dyn_AdapterMethodHandle::CONV_OP_SHIFT,
|
|
107 |
CONV_DEST_TYPE_SHIFT = sun_dyn_AdapterMethodHandle::CONV_DEST_TYPE_SHIFT,
|
|
108 |
CONV_SRC_TYPE_SHIFT = sun_dyn_AdapterMethodHandle::CONV_SRC_TYPE_SHIFT,
|
|
109 |
CONV_STACK_MOVE_SHIFT = sun_dyn_AdapterMethodHandle::CONV_STACK_MOVE_SHIFT,
|
|
110 |
CONV_STACK_MOVE_MASK = sun_dyn_AdapterMethodHandle::CONV_STACK_MOVE_MASK
|
|
111 |
};
|
|
112 |
|
|
113 |
static bool _enabled;
|
|
114 |
static MethodHandleEntry* _entries[_EK_LIMIT];
|
|
115 |
static const char* _entry_names[_EK_LIMIT+1];
|
|
116 |
static bool ek_valid(EntryKind ek) { return (uint)ek < (uint)_EK_LIMIT; }
|
|
117 |
static bool conv_op_valid(int op) { return (uint)op < (uint)CONV_OP_LIMIT; }
|
|
118 |
|
|
119 |
public:
|
|
120 |
static bool have_entry(EntryKind ek) { return ek_valid(ek) && _entries[ek] != NULL; }
|
|
121 |
static MethodHandleEntry* entry(EntryKind ek) { assert(ek_valid(ek), "initialized");
|
|
122 |
return _entries[ek]; }
|
|
123 |
static const char* entry_name(EntryKind ek) { assert(ek_valid(ek), "oob");
|
|
124 |
return _entry_names[ek]; }
|
|
125 |
static EntryKind adapter_entry_kind(int op) { assert(conv_op_valid(op), "oob");
|
|
126 |
return EntryKind(_adapter_mh_first + op); }
|
|
127 |
|
|
128 |
static void init_entry(EntryKind ek, MethodHandleEntry* me) {
|
|
129 |
assert(ek_valid(ek), "oob");
|
|
130 |
assert(_entries[ek] == NULL, "no double initialization");
|
|
131 |
_entries[ek] = me;
|
|
132 |
}
|
|
133 |
|
|
134 |
static jint adapter_conversion(int conv_op, BasicType src, BasicType dest,
|
|
135 |
int stack_move = 0, int vminfo = 0) {
|
|
136 |
assert(conv_op_valid(conv_op), "oob");
|
|
137 |
jint conv = ((conv_op << CONV_OP_SHIFT)
|
|
138 |
| (src << CONV_SRC_TYPE_SHIFT)
|
|
139 |
| (dest << CONV_DEST_TYPE_SHIFT)
|
|
140 |
| (stack_move << CONV_STACK_MOVE_SHIFT)
|
|
141 |
| (vminfo << CONV_VMINFO_SHIFT)
|
|
142 |
);
|
|
143 |
assert(adapter_conversion_op(conv) == conv_op, "decode conv_op");
|
|
144 |
assert(adapter_conversion_src_type(conv) == src, "decode src");
|
|
145 |
assert(adapter_conversion_dest_type(conv) == dest, "decode dest");
|
|
146 |
assert(adapter_conversion_stack_move(conv) == stack_move, "decode stack_move");
|
|
147 |
assert(adapter_conversion_vminfo(conv) == vminfo, "decode vminfo");
|
|
148 |
return conv;
|
|
149 |
}
|
|
150 |
static int adapter_conversion_op(jint conv) {
|
|
151 |
return ((conv >> CONV_OP_SHIFT) & 0xF);
|
|
152 |
}
|
|
153 |
static BasicType adapter_conversion_src_type(jint conv) {
|
|
154 |
return (BasicType)((conv >> CONV_SRC_TYPE_SHIFT) & 0xF);
|
|
155 |
}
|
|
156 |
static BasicType adapter_conversion_dest_type(jint conv) {
|
|
157 |
return (BasicType)((conv >> CONV_DEST_TYPE_SHIFT) & 0xF);
|
|
158 |
}
|
|
159 |
static int adapter_conversion_stack_move(jint conv) {
|
|
160 |
return (conv >> CONV_STACK_MOVE_SHIFT);
|
|
161 |
}
|
|
162 |
static int adapter_conversion_vminfo(jint conv) {
|
|
163 |
return (conv >> CONV_VMINFO_SHIFT) & CONV_VMINFO_MASK;
|
|
164 |
}
|
|
165 |
|
|
166 |
// Offset in words that the interpreter stack pointer moves when an argument is pushed.
|
|
167 |
// The stack_move value must always be a multiple of this.
|
|
168 |
static int stack_move_unit() {
|
|
169 |
return frame::interpreter_frame_expression_stack_direction() * Interpreter::stackElementWords();
|
|
170 |
}
|
|
171 |
|
|
172 |
enum { CONV_VMINFO_SIGN_FLAG = 0x80 };
|
|
173 |
static int adapter_subword_vminfo(BasicType dest) {
|
|
174 |
if (dest == T_BOOLEAN) return (BitsPerInt - 1);
|
|
175 |
if (dest == T_CHAR) return (BitsPerInt - 16);
|
|
176 |
if (dest == T_BYTE) return (BitsPerInt - 8) | CONV_VMINFO_SIGN_FLAG;
|
|
177 |
if (dest == T_SHORT) return (BitsPerInt - 16) | CONV_VMINFO_SIGN_FLAG;
|
|
178 |
return 0; // case T_INT
|
|
179 |
}
|
|
180 |
// Here is the transformation the i2i adapter must perform:
|
|
181 |
static int truncate_subword_from_vminfo(jint value, int vminfo) {
|
|
182 |
jint tem = value << vminfo;
|
|
183 |
if ((vminfo & CONV_VMINFO_SIGN_FLAG) != 0) {
|
|
184 |
return (jint)tem >> vminfo;
|
|
185 |
} else {
|
|
186 |
return (juint)tem >> vminfo;
|
|
187 |
}
|
|
188 |
}
|
|
189 |
|
|
190 |
static inline address from_compiled_entry(EntryKind ek);
|
|
191 |
static inline address from_interpreted_entry(EntryKind ek);
|
|
192 |
|
|
193 |
// helpers for decode_method.
|
|
194 |
static methodOop decode_methodOop(methodOop m, int& decode_flags_result);
|
|
195 |
static methodOop decode_vmtarget(oop vmtarget, int vmindex, oop mtype, klassOop& receiver_limit_result, int& decode_flags_result);
|
|
196 |
static methodOop decode_MemberName(oop mname, klassOop& receiver_limit_result, int& decode_flags_result);
|
|
197 |
static methodOop decode_MethodHandle(oop mh, klassOop& receiver_limit_result, int& decode_flags_result);
|
|
198 |
static methodOop decode_DirectMethodHandle(oop mh, klassOop& receiver_limit_result, int& decode_flags_result);
|
|
199 |
static methodOop decode_BoundMethodHandle(oop mh, klassOop& receiver_limit_result, int& decode_flags_result);
|
|
200 |
static methodOop decode_AdapterMethodHandle(oop mh, klassOop& receiver_limit_result, int& decode_flags_result);
|
|
201 |
|
|
202 |
// Find out how many stack slots an mh pushes or pops.
|
|
203 |
// The result is *not* reported as a multiple of stack_move_unit();
|
|
204 |
// It is a signed net number of pushes (a difference in vmslots).
|
|
205 |
// To compare with a stack_move value, first multiply by stack_move_unit().
|
|
206 |
static int decode_MethodHandle_stack_pushes(oop mh);
|
|
207 |
|
|
208 |
public:
|
|
209 |
// working with member names
|
|
210 |
static void resolve_MemberName(Handle mname, TRAPS); // compute vmtarget/vmindex from name/type
|
|
211 |
static void expand_MemberName(Handle mname, int suppress, TRAPS); // expand defc/name/type if missing
|
|
212 |
static void init_MemberName(oop mname_oop, oop target); // compute vmtarget/vmindex from target
|
|
213 |
static void init_MemberName(oop mname_oop, methodOop m, bool do_dispatch);
|
|
214 |
static void init_MemberName(oop mname_oop, klassOop field_holder, AccessFlags mods, int offset);
|
|
215 |
static int find_MemberNames(klassOop k, symbolOop name, symbolOop sig,
|
|
216 |
int mflags, klassOop caller,
|
|
217 |
int skip, objArrayOop results);
|
|
218 |
// bit values for suppress argument to expand_MemberName:
|
|
219 |
enum { _suppress_defc = 1, _suppress_name = 2, _suppress_type = 4 };
|
|
220 |
|
|
221 |
// called from InterpreterGenerator and StubGenerator
|
|
222 |
static address generate_method_handle_interpreter_entry(MacroAssembler* _masm);
|
|
223 |
static void generate_method_handle_stub(MacroAssembler* _masm, EntryKind ek);
|
|
224 |
|
|
225 |
// argument list parsing
|
|
226 |
static int argument_slot(oop method_type, int arg);
|
|
227 |
static int argument_slot_count(oop method_type) { return argument_slot(method_type, -1); }
|
|
228 |
static int argument_slot_to_argnum(oop method_type, int argslot);
|
|
229 |
|
|
230 |
// Runtime support
|
|
231 |
enum { // bit-encoded flags from decode_method or decode_vmref
|
|
232 |
_dmf_has_receiver = 0x01, // target method has leading reference argument
|
|
233 |
_dmf_does_dispatch = 0x02, // method handle performs virtual or interface dispatch
|
|
234 |
_dmf_from_interface = 0x04, // peforms interface dispatch
|
|
235 |
_DMF_DIRECT_MASK = (_dmf_from_interface*2 - _dmf_has_receiver),
|
|
236 |
_dmf_binds_method = 0x08,
|
|
237 |
_dmf_binds_argument = 0x10,
|
|
238 |
_DMF_BOUND_MASK = (_dmf_binds_argument*2 - _dmf_binds_method),
|
|
239 |
_dmf_adapter_lsb = 0x20,
|
|
240 |
_DMF_ADAPTER_MASK = (_dmf_adapter_lsb << CONV_OP_LIMIT) - _dmf_adapter_lsb
|
|
241 |
};
|
|
242 |
static methodOop decode_method(oop x, klassOop& receiver_limit_result, int& decode_flags_result);
|
|
243 |
enum {
|
|
244 |
// format of query to getConstant:
|
|
245 |
GC_JVM_PUSH_LIMIT = 0,
|
|
246 |
GC_JVM_STACK_MOVE_LIMIT = 1,
|
|
247 |
|
|
248 |
// format of result from getTarget / encode_target:
|
|
249 |
ETF_HANDLE_OR_METHOD_NAME = 0, // all available data (immediate MH or method)
|
|
250 |
ETF_DIRECT_HANDLE = 1, // ultimate method handle (will be a DMH, may be self)
|
|
251 |
ETF_METHOD_NAME = 2, // ultimate method as MemberName
|
|
252 |
ETF_REFLECT_METHOD = 3 // ultimate method as java.lang.reflect object (sans refClass)
|
|
253 |
};
|
|
254 |
static int get_named_constant(int which, Handle name_box, TRAPS);
|
|
255 |
static oop encode_target(Handle mh, int format, TRAPS); // report vmtarget (to Java code)
|
|
256 |
static bool class_cast_needed(klassOop src, klassOop dst);
|
|
257 |
|
|
258 |
private:
|
|
259 |
// These checkers operate on a pair of whole MethodTypes:
|
|
260 |
static const char* check_method_type_change(oop src_mtype, int src_beg, int src_end,
|
|
261 |
int insert_argnum, oop insert_type,
|
|
262 |
int change_argnum, oop change_type,
|
|
263 |
int delete_argnum,
|
|
264 |
oop dst_mtype, int dst_beg, int dst_end);
|
|
265 |
static const char* check_method_type_insertion(oop src_mtype,
|
|
266 |
int insert_argnum, oop insert_type,
|
|
267 |
oop dst_mtype) {
|
|
268 |
oop no_ref = NULL;
|
|
269 |
return check_method_type_change(src_mtype, 0, -1,
|
|
270 |
insert_argnum, insert_type,
|
|
271 |
-1, no_ref, -1, dst_mtype, 0, -1);
|
|
272 |
}
|
|
273 |
static const char* check_method_type_conversion(oop src_mtype,
|
|
274 |
int change_argnum, oop change_type,
|
|
275 |
oop dst_mtype) {
|
|
276 |
oop no_ref = NULL;
|
|
277 |
return check_method_type_change(src_mtype, 0, -1, -1, no_ref,
|
|
278 |
change_argnum, change_type,
|
|
279 |
-1, dst_mtype, 0, -1);
|
|
280 |
}
|
|
281 |
static const char* check_method_type_passthrough(oop src_mtype, oop dst_mtype) {
|
|
282 |
oop no_ref = NULL;
|
|
283 |
return check_method_type_change(src_mtype, 0, -1,
|
|
284 |
-1, no_ref, -1, no_ref, -1,
|
|
285 |
dst_mtype, 0, -1);
|
|
286 |
}
|
|
287 |
|
|
288 |
// These checkers operate on pairs of argument or return types:
|
|
289 |
static const char* check_argument_type_change(BasicType src_type, klassOop src_klass,
|
|
290 |
BasicType dst_type, klassOop dst_klass,
|
|
291 |
int argnum);
|
|
292 |
|
|
293 |
static const char* check_argument_type_change(oop src_type, oop dst_type,
|
|
294 |
int argnum) {
|
|
295 |
klassOop src_klass = NULL, dst_klass = NULL;
|
|
296 |
BasicType src_bt = java_lang_Class::as_BasicType(src_type, &src_klass);
|
|
297 |
BasicType dst_bt = java_lang_Class::as_BasicType(dst_type, &dst_klass);
|
|
298 |
return check_argument_type_change(src_bt, src_klass,
|
|
299 |
dst_bt, dst_klass, argnum);
|
|
300 |
}
|
|
301 |
|
|
302 |
static const char* check_return_type_change(oop src_type, oop dst_type) {
|
|
303 |
return check_argument_type_change(src_type, dst_type, -1);
|
|
304 |
}
|
|
305 |
|
|
306 |
static const char* check_return_type_change(BasicType src_type, klassOop src_klass,
|
|
307 |
BasicType dst_type, klassOop dst_klass) {
|
|
308 |
return check_argument_type_change(src_type, src_klass, dst_type, dst_klass, -1);
|
|
309 |
}
|
|
310 |
|
|
311 |
static const char* check_method_receiver(methodOop m, klassOop passed_recv_type);
|
|
312 |
|
|
313 |
// These verifiers can block, and will throw an error if the checking fails:
|
|
314 |
static void verify_vmslots(Handle mh, TRAPS);
|
|
315 |
static void verify_vmargslot(Handle mh, int argnum, int argslot, TRAPS);
|
|
316 |
|
|
317 |
static void verify_method_type(methodHandle m, Handle mtype,
|
|
318 |
bool has_bound_oop,
|
|
319 |
KlassHandle bound_oop_type,
|
|
320 |
TRAPS);
|
|
321 |
|
|
322 |
static void verify_method_signature(methodHandle m, Handle mtype,
|
|
323 |
int first_ptype_pos,
|
|
324 |
KlassHandle insert_ptype, TRAPS);
|
|
325 |
|
|
326 |
static void verify_DirectMethodHandle(Handle mh, methodHandle m, TRAPS);
|
|
327 |
static void verify_BoundMethodHandle(Handle mh, Handle target, int argnum,
|
|
328 |
bool direct_to_method, TRAPS);
|
|
329 |
static void verify_BoundMethodHandle_with_receiver(Handle mh, methodHandle m, TRAPS);
|
|
330 |
static void verify_AdapterMethodHandle(Handle mh, int argnum, TRAPS);
|
|
331 |
|
|
332 |
public:
|
|
333 |
|
|
334 |
// Fill in the fields of a DirectMethodHandle mh. (MH.type must be pre-filled.)
|
|
335 |
static void init_DirectMethodHandle(Handle mh, methodHandle method, bool do_dispatch, TRAPS);
|
|
336 |
|
|
337 |
// Fill in the fields of a BoundMethodHandle mh. (MH.type, BMH.argument must be pre-filled.)
|
|
338 |
static void init_BoundMethodHandle(Handle mh, Handle target, int argnum, TRAPS);
|
|
339 |
static void init_BoundMethodHandle_with_receiver(Handle mh,
|
|
340 |
methodHandle original_m,
|
|
341 |
KlassHandle receiver_limit,
|
|
342 |
int decode_flags,
|
|
343 |
TRAPS);
|
|
344 |
|
|
345 |
// Fill in the fields of an AdapterMethodHandle mh. (MH.type must be pre-filled.)
|
|
346 |
static void init_AdapterMethodHandle(Handle mh, Handle target, int argnum, TRAPS);
|
|
347 |
|
|
348 |
#ifdef ASSERT
|
|
349 |
static bool spot_check_entry_names();
|
|
350 |
#endif
|
|
351 |
|
|
352 |
private:
|
|
353 |
static methodHandle dispatch_decoded_method(methodHandle m,
|
|
354 |
KlassHandle receiver_limit,
|
|
355 |
int decode_flags,
|
|
356 |
KlassHandle receiver_klass,
|
|
357 |
TRAPS);
|
|
358 |
|
|
359 |
static bool same_basic_type_for_arguments(BasicType src, BasicType dst,
|
|
360 |
bool for_return = false);
|
|
361 |
static bool same_basic_type_for_returns(BasicType src, BasicType dst) {
|
|
362 |
return same_basic_type_for_arguments(src, dst, true);
|
|
363 |
}
|
|
364 |
|
|
365 |
enum { // arg_mask values
|
|
366 |
_INSERT_NO_MASK = -1,
|
|
367 |
_INSERT_REF_MASK = 0,
|
|
368 |
_INSERT_INT_MASK = 1,
|
|
369 |
_INSERT_LONG_MASK = 3
|
|
370 |
};
|
|
371 |
static void insert_arg_slots(MacroAssembler* _masm,
|
|
372 |
RegisterOrConstant arg_slots,
|
|
373 |
int arg_mask,
|
|
374 |
Register rax_argslot,
|
|
375 |
Register rbx_temp, Register rdx_temp);
|
|
376 |
|
|
377 |
static void remove_arg_slots(MacroAssembler* _masm,
|
|
378 |
RegisterOrConstant arg_slots,
|
|
379 |
Register rax_argslot,
|
|
380 |
Register rbx_temp, Register rdx_temp);
|
|
381 |
};
|
|
382 |
|
|
383 |
|
|
384 |
// Access methods for the "entry" field of a java.dyn.MethodHandle.
|
|
385 |
// The field is primarily a jump target for compiled calls.
|
|
386 |
// However, we squirrel away some nice pointers for other uses,
|
|
387 |
// just before the jump target.
|
|
388 |
// Aspects of a method handle entry:
|
|
389 |
// - from_compiled_entry - stub used when compiled code calls the MH
|
|
390 |
// - from_interpreted_entry - stub used when the interpreter calls the MH
|
|
391 |
// - type_checking_entry - stub for runtime casting between MHForm siblings (NYI)
|
|
392 |
class MethodHandleEntry {
|
|
393 |
public:
|
|
394 |
class Data {
|
|
395 |
friend class MethodHandleEntry;
|
|
396 |
size_t _total_size; // size including Data and code stub
|
|
397 |
MethodHandleEntry* _type_checking_entry;
|
|
398 |
address _from_interpreted_entry;
|
|
399 |
MethodHandleEntry* method_entry() { return (MethodHandleEntry*)(this + 1); }
|
|
400 |
};
|
|
401 |
|
|
402 |
Data* data() { return (Data*)this - 1; }
|
|
403 |
|
|
404 |
address start_address() { return (address) data(); }
|
|
405 |
address end_address() { return start_address() + data()->_total_size; }
|
|
406 |
|
|
407 |
address from_compiled_entry() { return (address) this; }
|
|
408 |
|
|
409 |
address from_interpreted_entry() { return data()->_from_interpreted_entry; }
|
|
410 |
void set_from_interpreted_entry(address e) { data()->_from_interpreted_entry = e; }
|
|
411 |
|
|
412 |
MethodHandleEntry* type_checking_entry() { return data()->_type_checking_entry; }
|
|
413 |
void set_type_checking_entry(MethodHandleEntry* e) { data()->_type_checking_entry = e; }
|
|
414 |
|
|
415 |
void set_end_address(address end_addr) {
|
|
416 |
size_t total_size = end_addr - start_address();
|
|
417 |
assert(total_size > 0 && total_size < 0x1000, "reasonable end address");
|
|
418 |
data()->_total_size = total_size;
|
|
419 |
}
|
|
420 |
|
|
421 |
// Compiler support:
|
|
422 |
static int from_interpreted_entry_offset_in_bytes() {
|
|
423 |
return (int)( offset_of(Data, _from_interpreted_entry) - sizeof(Data) );
|
|
424 |
}
|
|
425 |
static int type_checking_entry_offset_in_bytes() {
|
|
426 |
return (int)( offset_of(Data, _from_interpreted_entry) - sizeof(Data) );
|
|
427 |
}
|
|
428 |
|
|
429 |
static address start_compiled_entry(MacroAssembler* _masm,
|
|
430 |
address interpreted_entry = NULL);
|
|
431 |
static MethodHandleEntry* finish_compiled_entry(MacroAssembler* masm, address start_addr);
|
|
432 |
};
|
|
433 |
|
|
434 |
address MethodHandles::from_compiled_entry(EntryKind ek) { return entry(ek)->from_compiled_entry(); }
|
|
435 |
address MethodHandles::from_interpreted_entry(EntryKind ek) { return entry(ek)->from_interpreted_entry(); }
|