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