Mercurial > hg > truffle
comparison src/share/vm/prims/methodHandles.hpp @ 1330:4a9cc99938e3
Merge
author | acorn |
---|---|
date | Fri, 26 Mar 2010 11:10:26 -0400 |
parents | 76c1d7d13ec5 |
children | c640000b7cc1 |
comparison
equal
deleted
inserted
replaced
1329:84043c7507b9 | 1330:4a9cc99938e3 |
---|---|
1 /* | 1 /* |
2 * Copyright 2008-2009 Sun Microsystems, Inc. All Rights Reserved. | 2 * Copyright 2008-2010 Sun Microsystems, Inc. All Rights Reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | 4 * |
5 * This code is free software; you can redistribute it and/or modify it | 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 | 6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
113 static bool _enabled; | 113 static bool _enabled; |
114 static MethodHandleEntry* _entries[_EK_LIMIT]; | 114 static MethodHandleEntry* _entries[_EK_LIMIT]; |
115 static const char* _entry_names[_EK_LIMIT+1]; | 115 static const char* _entry_names[_EK_LIMIT+1]; |
116 static jobject _raise_exception_method; | 116 static jobject _raise_exception_method; |
117 | 117 |
118 // Adapters. | |
119 static MethodHandlesAdapterBlob* _adapter_code; | |
120 static int _adapter_code_size; | |
121 | |
118 static bool ek_valid(EntryKind ek) { return (uint)ek < (uint)_EK_LIMIT; } | 122 static bool ek_valid(EntryKind ek) { return (uint)ek < (uint)_EK_LIMIT; } |
119 static bool conv_op_valid(int op) { return (uint)op < (uint)CONV_OP_LIMIT; } | 123 static bool conv_op_valid(int op) { return (uint)op < (uint)CONV_OP_LIMIT; } |
120 | 124 |
121 public: | 125 public: |
122 static bool have_entry(EntryKind ek) { return ek_valid(ek) && _entries[ek] != NULL; } | 126 static bool have_entry(EntryKind ek) { return ek_valid(ek) && _entries[ek] != NULL; } |
129 | 133 |
130 static void init_entry(EntryKind ek, MethodHandleEntry* me) { | 134 static void init_entry(EntryKind ek, MethodHandleEntry* me) { |
131 assert(ek_valid(ek), "oob"); | 135 assert(ek_valid(ek), "oob"); |
132 assert(_entries[ek] == NULL, "no double initialization"); | 136 assert(_entries[ek] == NULL, "no double initialization"); |
133 _entries[ek] = me; | 137 _entries[ek] = me; |
138 } | |
139 | |
140 // Some adapter helper functions. | |
141 static void get_ek_bound_mh_info(EntryKind ek, BasicType& arg_type, int& arg_mask, int& arg_slots) { | |
142 switch (ek) { | |
143 case _bound_int_mh : // fall-thru | |
144 case _bound_int_direct_mh : arg_type = T_INT; arg_mask = _INSERT_INT_MASK; break; | |
145 case _bound_long_mh : // fall-thru | |
146 case _bound_long_direct_mh: arg_type = T_LONG; arg_mask = _INSERT_LONG_MASK; break; | |
147 case _bound_ref_mh : // fall-thru | |
148 case _bound_ref_direct_mh : arg_type = T_OBJECT; arg_mask = _INSERT_REF_MASK; break; | |
149 default: ShouldNotReachHere(); | |
150 } | |
151 arg_slots = type2size[arg_type]; | |
152 } | |
153 | |
154 static void get_ek_adapter_opt_swap_rot_info(EntryKind ek, int& swap_bytes, int& rotate) { | |
155 int swap_slots = 0; | |
156 switch (ek) { | |
157 case _adapter_opt_swap_1: swap_slots = 1; rotate = 0; break; | |
158 case _adapter_opt_swap_2: swap_slots = 2; rotate = 0; break; | |
159 case _adapter_opt_rot_1_up: swap_slots = 1; rotate = 1; break; | |
160 case _adapter_opt_rot_1_down: swap_slots = 1; rotate = -1; break; | |
161 case _adapter_opt_rot_2_up: swap_slots = 2; rotate = 1; break; | |
162 case _adapter_opt_rot_2_down: swap_slots = 2; rotate = -1; break; | |
163 default: ShouldNotReachHere(); | |
164 } | |
165 // Return the size of the stack slots to move in bytes. | |
166 swap_bytes = swap_slots * Interpreter::stackElementSize(); | |
167 } | |
168 | |
169 static int get_ek_adapter_opt_spread_info(EntryKind ek) { | |
170 switch (ek) { | |
171 case _adapter_opt_spread_0: return 0; | |
172 case _adapter_opt_spread_1: return 1; | |
173 default : return -1; | |
174 } | |
134 } | 175 } |
135 | 176 |
136 static methodOop raise_exception_method() { | 177 static methodOop raise_exception_method() { |
137 oop rem = JNIHandles::resolve(_raise_exception_method); | 178 oop rem = JNIHandles::resolve(_raise_exception_method); |
138 assert(rem == NULL || rem->is_method(), ""); | 179 assert(rem == NULL || rem->is_method(), ""); |
228 int mflags, klassOop caller, | 269 int mflags, klassOop caller, |
229 int skip, objArrayOop results); | 270 int skip, objArrayOop results); |
230 // bit values for suppress argument to expand_MemberName: | 271 // bit values for suppress argument to expand_MemberName: |
231 enum { _suppress_defc = 1, _suppress_name = 2, _suppress_type = 4 }; | 272 enum { _suppress_defc = 1, _suppress_name = 2, _suppress_type = 4 }; |
232 | 273 |
233 // called from InterpreterGenerator and StubGenerator | 274 // Generate MethodHandles adapters. |
275 static void generate_adapters(); | |
276 | |
277 // Called from InterpreterGenerator and MethodHandlesAdapterGenerator. | |
234 static address generate_method_handle_interpreter_entry(MacroAssembler* _masm); | 278 static address generate_method_handle_interpreter_entry(MacroAssembler* _masm); |
235 static void generate_method_handle_stub(MacroAssembler* _masm, EntryKind ek); | 279 static void generate_method_handle_stub(MacroAssembler* _masm, EntryKind ek); |
236 | 280 |
237 // argument list parsing | 281 // argument list parsing |
238 static int argument_slot(oop method_type, int arg); | 282 static int argument_slot(oop method_type, int arg); |
383 _INSERT_LONG_MASK = 3 | 427 _INSERT_LONG_MASK = 3 |
384 }; | 428 }; |
385 static void insert_arg_slots(MacroAssembler* _masm, | 429 static void insert_arg_slots(MacroAssembler* _masm, |
386 RegisterOrConstant arg_slots, | 430 RegisterOrConstant arg_slots, |
387 int arg_mask, | 431 int arg_mask, |
388 Register rax_argslot, | 432 Register argslot_reg, |
389 Register rbx_temp, Register rdx_temp); | 433 Register temp_reg, Register temp2_reg); |
390 | 434 |
391 static void remove_arg_slots(MacroAssembler* _masm, | 435 static void remove_arg_slots(MacroAssembler* _masm, |
392 RegisterOrConstant arg_slots, | 436 RegisterOrConstant arg_slots, |
393 Register rax_argslot, | 437 Register argslot_reg, |
394 Register rbx_temp, Register rdx_temp); | 438 Register temp_reg, Register temp2_reg); |
395 }; | 439 }; |
396 | 440 |
397 | 441 |
398 // Access methods for the "entry" field of a java.dyn.MethodHandle. | 442 // Access methods for the "entry" field of a java.dyn.MethodHandle. |
399 // The field is primarily a jump target for compiled calls. | 443 // The field is primarily a jump target for compiled calls. |
445 static MethodHandleEntry* finish_compiled_entry(MacroAssembler* masm, address start_addr); | 489 static MethodHandleEntry* finish_compiled_entry(MacroAssembler* masm, address start_addr); |
446 }; | 490 }; |
447 | 491 |
448 address MethodHandles::from_compiled_entry(EntryKind ek) { return entry(ek)->from_compiled_entry(); } | 492 address MethodHandles::from_compiled_entry(EntryKind ek) { return entry(ek)->from_compiled_entry(); } |
449 address MethodHandles::from_interpreted_entry(EntryKind ek) { return entry(ek)->from_interpreted_entry(); } | 493 address MethodHandles::from_interpreted_entry(EntryKind ek) { return entry(ek)->from_interpreted_entry(); } |
494 | |
495 | |
496 //------------------------------------------------------------------------------ | |
497 // MethodHandlesAdapterGenerator | |
498 // | |
499 class MethodHandlesAdapterGenerator : public StubCodeGenerator { | |
500 public: | |
501 MethodHandlesAdapterGenerator(CodeBuffer* code) : StubCodeGenerator(code) {} | |
502 | |
503 void generate(); | |
504 }; |