author | bdelsart |
Tue, 24 Jan 2012 15:41:17 +0100 | |
changeset 11565 | 713a0398ca58 |
parent 10983 | 9ab65f4cec18 |
child 11571 | 23f825a42a85 |
permissions | -rw-r--r-- |
9976 | 1 |
/* |
11565
713a0398ca58
7120450: complete information dumped by frame_describe
bdelsart
parents:
10983
diff
changeset
|
2 |
* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. |
9976 | 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
22 |
* |
|
23 |
*/ |
|
24 |
||
25 |
// Platform-specific definitions for method handles. |
|
26 |
// These definitions are inlined into class MethodHandles. |
|
27 |
||
28 |
// Adapters |
|
29 |
enum /* platform_dependent_constants */ { |
|
10983
9ab65f4cec18
7104960: JSR 292: +VerifyMethodHandles in product JVM can overflow buffer
never
parents:
10031
diff
changeset
|
30 |
adapter_code_size = NOT_LP64(23000 DEBUG_ONLY(+ 40000)) LP64_ONLY(35000 DEBUG_ONLY(+ 50000)) |
9976 | 31 |
}; |
32 |
||
33 |
public: |
|
34 |
||
35 |
class RicochetFrame : public ResourceObj { |
|
36 |
friend class MethodHandles; |
|
37 |
||
38 |
private: |
|
39 |
/* |
|
40 |
RF field x86 SPARC |
|
41 |
sender_pc *(rsp+0) I7-0x8 |
|
42 |
sender_link rbp I6+BIAS |
|
43 |
exact_sender_sp rsi/r13 I5_savedSP |
|
44 |
conversion *(rcx+&amh_conv) L5_conv |
|
45 |
saved_args_base rax L4_sab (cf. Gargs = G4) |
|
46 |
saved_args_layout #NULL L3_sal |
|
47 |
saved_target *(rcx+&mh_vmtgt) L2_stgt |
|
48 |
continuation #STUB_CON L1_cont |
|
49 |
*/ |
|
50 |
static const Register L1_continuation ; // what to do when control gets back here |
|
51 |
static const Register L2_saved_target ; // target method handle to invoke on saved_args |
|
52 |
static const Register L3_saved_args_layout; // caching point for MethodTypeForm.vmlayout cookie |
|
53 |
static const Register L4_saved_args_base ; // base of pushed arguments (slot 0, arg N) (-3) |
|
54 |
static const Register L5_conversion ; // misc. information from original AdapterMethodHandle (-2) |
|
55 |
||
56 |
frame _fr; |
|
57 |
||
58 |
RicochetFrame(const frame& fr) : _fr(fr) { } |
|
59 |
||
60 |
intptr_t* register_addr(Register reg) const { |
|
61 |
assert((_fr.sp() + reg->sp_offset_in_saved_window()) == _fr.register_addr(reg), "must agree"); |
|
62 |
return _fr.register_addr(reg); |
|
63 |
} |
|
64 |
intptr_t register_value(Register reg) const { return *register_addr(reg); } |
|
65 |
||
66 |
public: |
|
67 |
intptr_t* continuation() const { return (intptr_t*) register_value(L1_continuation); } |
|
68 |
oop saved_target() const { return (oop) register_value(L2_saved_target); } |
|
69 |
oop saved_args_layout() const { return (oop) register_value(L3_saved_args_layout); } |
|
70 |
intptr_t* saved_args_base() const { return (intptr_t*) register_value(L4_saved_args_base); } |
|
71 |
intptr_t conversion() const { return register_value(L5_conversion); } |
|
72 |
intptr_t* exact_sender_sp() const { return (intptr_t*) register_value(I5_savedSP); } |
|
73 |
intptr_t* sender_link() const { return _fr.sender_sp(); } // XXX |
|
74 |
address sender_pc() const { return _fr.sender_pc(); } |
|
75 |
||
76 |
// This value is not used for much, but it apparently must be nonzero. |
|
77 |
static int frame_size_in_bytes() { return wordSize * 4; } |
|
78 |
||
79 |
intptr_t* extended_sender_sp() const { return saved_args_base(); } |
|
80 |
||
81 |
intptr_t return_value_slot_number() const { |
|
82 |
return adapter_conversion_vminfo(conversion()); |
|
83 |
} |
|
84 |
BasicType return_value_type() const { |
|
85 |
return adapter_conversion_dest_type(conversion()); |
|
86 |
} |
|
87 |
bool has_return_value_slot() const { |
|
88 |
return return_value_type() != T_VOID; |
|
89 |
} |
|
90 |
intptr_t* return_value_slot_addr() const { |
|
91 |
assert(has_return_value_slot(), ""); |
|
92 |
return saved_arg_slot_addr(return_value_slot_number()); |
|
93 |
} |
|
94 |
intptr_t* saved_target_slot_addr() const { |
|
95 |
return saved_arg_slot_addr(saved_args_length()); |
|
96 |
} |
|
97 |
intptr_t* saved_arg_slot_addr(int slot) const { |
|
98 |
assert(slot >= 0, ""); |
|
99 |
return (intptr_t*)( (address)saved_args_base() + (slot * Interpreter::stackElementSize) ); |
|
100 |
} |
|
101 |
||
102 |
jint saved_args_length() const; |
|
103 |
jint saved_arg_offset(int arg) const; |
|
104 |
||
105 |
// GC interface |
|
106 |
oop* saved_target_addr() { return (oop*)register_addr(L2_saved_target); } |
|
107 |
oop* saved_args_layout_addr() { return (oop*)register_addr(L3_saved_args_layout); } |
|
108 |
||
109 |
oop compute_saved_args_layout(bool read_cache, bool write_cache); |
|
110 |
||
111 |
#ifdef ASSERT |
|
112 |
// The magic number is supposed to help find ricochet frames within the bytes of stack dumps. |
|
113 |
enum { MAGIC_NUMBER_1 = 0xFEED03E, MAGIC_NUMBER_2 = 0xBEEF03E }; |
|
114 |
static const Register L0_magic_number_1 ; // cookie for debugging, at start of RSA |
|
115 |
static Address magic_number_2_addr() { return Address(L4_saved_args_base, -wordSize); } |
|
116 |
intptr_t magic_number_1() const { return register_value(L0_magic_number_1); } |
|
117 |
intptr_t magic_number_2() const { return saved_args_base()[-1]; } |
|
118 |
#endif //ASSERT |
|
119 |
||
120 |
public: |
|
121 |
enum { RETURN_VALUE_PLACEHOLDER = (NOT_DEBUG(0) DEBUG_ONLY(42)) }; |
|
122 |
||
123 |
void verify() const NOT_DEBUG_RETURN; // check for MAGIC_NUMBER, etc. |
|
124 |
||
125 |
static void generate_ricochet_blob(MacroAssembler* _masm, |
|
126 |
// output params: |
|
127 |
int* bounce_offset, |
|
128 |
int* exception_offset, |
|
129 |
int* frame_size_in_words); |
|
130 |
||
131 |
static void enter_ricochet_frame(MacroAssembler* _masm, |
|
132 |
Register recv_reg, |
|
133 |
Register argv_reg, |
|
134 |
address return_handler); |
|
135 |
||
136 |
static void leave_ricochet_frame(MacroAssembler* _masm, |
|
137 |
Register recv_reg, |
|
138 |
Register new_sp_reg, |
|
139 |
Register sender_pc_reg); |
|
140 |
||
141 |
static RicochetFrame* from_frame(const frame& fr) { |
|
142 |
RicochetFrame* rf = new RicochetFrame(fr); |
|
143 |
rf->verify(); |
|
144 |
return rf; |
|
145 |
} |
|
146 |
||
147 |
static void verify_clean(MacroAssembler* _masm) NOT_DEBUG_RETURN; |
|
11565
713a0398ca58
7120450: complete information dumped by frame_describe
bdelsart
parents:
10983
diff
changeset
|
148 |
|
713a0398ca58
7120450: complete information dumped by frame_describe
bdelsart
parents:
10983
diff
changeset
|
149 |
static void describe(const frame* fr, FrameValues& values, int frame_no) NOT_DEBUG_RETURN; |
9976 | 150 |
}; |
151 |
||
152 |
// Additional helper methods for MethodHandles code generation: |
|
153 |
public: |
|
154 |
static void load_klass_from_Class(MacroAssembler* _masm, Register klass_reg, Register temp_reg, Register temp2_reg); |
|
155 |
static void load_conversion_vminfo(MacroAssembler* _masm, Address conversion_field_addr, Register reg); |
|
156 |
static void extract_conversion_vminfo(MacroAssembler* _masm, Register conversion_field_reg, Register reg); |
|
157 |
static void extract_conversion_dest_type(MacroAssembler* _masm, Register conversion_field_reg, Register reg); |
|
158 |
||
159 |
static void load_stack_move(MacroAssembler* _masm, |
|
160 |
Address G3_amh_conversion, |
|
161 |
Register G5_stack_move); |
|
162 |
||
163 |
static void insert_arg_slots(MacroAssembler* _masm, |
|
164 |
RegisterOrConstant arg_slots, |
|
165 |
Register argslot_reg, |
|
166 |
Register temp_reg, Register temp2_reg, Register temp3_reg); |
|
167 |
||
168 |
static void remove_arg_slots(MacroAssembler* _masm, |
|
169 |
RegisterOrConstant arg_slots, |
|
170 |
Register argslot_reg, |
|
171 |
Register temp_reg, Register temp2_reg, Register temp3_reg); |
|
172 |
||
173 |
static void push_arg_slots(MacroAssembler* _masm, |
|
174 |
Register argslot_reg, |
|
175 |
RegisterOrConstant slot_count, |
|
176 |
Register temp_reg, Register temp2_reg); |
|
177 |
||
178 |
static void move_arg_slots_up(MacroAssembler* _masm, |
|
179 |
Register bottom_reg, // invariant |
|
180 |
Address top_addr, // can use temp_reg |
|
181 |
RegisterOrConstant positive_distance_in_slots, |
|
182 |
Register temp_reg, Register temp2_reg); |
|
183 |
||
184 |
static void move_arg_slots_down(MacroAssembler* _masm, |
|
185 |
Address bottom_addr, // can use temp_reg |
|
186 |
Register top_reg, // invariant |
|
187 |
RegisterOrConstant negative_distance_in_slots, |
|
188 |
Register temp_reg, Register temp2_reg); |
|
189 |
||
190 |
static void move_typed_arg(MacroAssembler* _masm, |
|
191 |
BasicType type, bool is_element, |
|
192 |
Address value_src, Address slot_dest, |
|
193 |
Register temp_reg); |
|
194 |
||
195 |
static void move_return_value(MacroAssembler* _masm, BasicType type, |
|
196 |
Address return_slot); |
|
197 |
||
198 |
static void verify_argslot(MacroAssembler* _masm, Register argslot_reg, |
|
199 |
Register temp_reg, |
|
200 |
const char* error_message) NOT_DEBUG_RETURN; |
|
201 |
||
202 |
static void verify_argslots(MacroAssembler* _masm, |
|
203 |
RegisterOrConstant argslot_count, |
|
204 |
Register argslot_reg, |
|
205 |
Register temp_reg, |
|
206 |
Register temp2_reg, |
|
207 |
bool negate_argslot, |
|
208 |
const char* error_message) NOT_DEBUG_RETURN; |
|
209 |
||
210 |
static void verify_stack_move(MacroAssembler* _masm, |
|
211 |
RegisterOrConstant arg_slots, |
|
212 |
int direction) NOT_DEBUG_RETURN; |
|
213 |
||
214 |
static void verify_klass(MacroAssembler* _masm, |
|
215 |
Register obj_reg, KlassHandle klass, |
|
216 |
Register temp_reg, Register temp2_reg, |
|
217 |
const char* error_message = "wrong klass") NOT_DEBUG_RETURN; |
|
218 |
||
219 |
static void verify_method_handle(MacroAssembler* _masm, Register mh_reg, |
|
220 |
Register temp_reg, Register temp2_reg) { |
|
221 |
verify_klass(_masm, mh_reg, SystemDictionaryHandles::MethodHandle_klass(), |
|
222 |
temp_reg, temp2_reg, |
|
223 |
"reference is a MH"); |
|
224 |
} |
|
225 |
||
10031
e81ae8b523dc
6990212: JSR 292 JVMTI MethodEnter hook is not called for JSR 292 bootstrap and target methods
never
parents:
9976
diff
changeset
|
226 |
// Similar to InterpreterMacroAssembler::jump_from_interpreted. |
e81ae8b523dc
6990212: JSR 292 JVMTI MethodEnter hook is not called for JSR 292 bootstrap and target methods
never
parents:
9976
diff
changeset
|
227 |
// Takes care of special dispatch from single stepping too. |
e81ae8b523dc
6990212: JSR 292 JVMTI MethodEnter hook is not called for JSR 292 bootstrap and target methods
never
parents:
9976
diff
changeset
|
228 |
static void jump_from_method_handle(MacroAssembler* _masm, Register method, Register temp, Register temp2); |
e81ae8b523dc
6990212: JSR 292 JVMTI MethodEnter hook is not called for JSR 292 bootstrap and target methods
never
parents:
9976
diff
changeset
|
229 |
|
9976 | 230 |
static void trace_method_handle(MacroAssembler* _masm, const char* adaptername) PRODUCT_RETURN; |