|
1 /* |
|
2 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. |
|
3 * Copyright (c) 2016 SAP SE. All rights reserved. |
|
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
5 * |
|
6 * This code is free software; you can redistribute it and/or modify it |
|
7 * under the terms of the GNU General Public License version 2 only, as |
|
8 * published by the Free Software Foundation. |
|
9 * |
|
10 * This code is distributed in the hope that it will be useful, but WITHOUT |
|
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
13 * version 2 for more details (a copy is included in the LICENSE file that |
|
14 * accompanied this code). |
|
15 * |
|
16 * You should have received a copy of the GNU General Public License version |
|
17 * 2 along with this work; if not, write to the Free Software Foundation, |
|
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
19 * |
|
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
21 * or visit www.oracle.com if you need additional information or have any |
|
22 * questions. |
|
23 * |
|
24 */ |
|
25 |
|
26 #ifndef CPU_S390_VM_INTERP_MASM_ZARCH_64_64_HPP |
|
27 #define CPU_S390_VM_INTERP_MASM_ZARCH_64_64_HPP |
|
28 |
|
29 #include "asm/macroAssembler.hpp" |
|
30 #include "interpreter/invocationCounter.hpp" |
|
31 |
|
32 // This file specializes the assember with interpreter-specific macros. |
|
33 |
|
34 class InterpreterMacroAssembler: public MacroAssembler { |
|
35 |
|
36 protected: |
|
37 // Interpreter specific version of call_VM_base(). |
|
38 virtual void call_VM_leaf_base(address entry_point); |
|
39 virtual void call_VM_leaf_base(address entry_point, bool allow_relocation); |
|
40 |
|
41 virtual void call_VM_base(Register oop_result, |
|
42 Register last_java_sp, |
|
43 address entry_point, |
|
44 bool check_exceptions); |
|
45 virtual void call_VM_base(Register oop_result, |
|
46 Register last_java_sp, |
|
47 address entry_point, |
|
48 bool allow_relocation, |
|
49 bool check_exceptions); |
|
50 |
|
51 virtual void check_and_handle_popframe(Register java_thread); |
|
52 virtual void check_and_handle_earlyret(Register java_thread); |
|
53 |
|
54 // Base routine for all dispatches. |
|
55 void dispatch_base(TosState state, address* table); |
|
56 |
|
57 public: |
|
58 InterpreterMacroAssembler(CodeBuffer* c) |
|
59 : MacroAssembler(c) {} |
|
60 |
|
61 void jump_to_entry(address entry, Register Rscratch); |
|
62 |
|
63 virtual void load_earlyret_value(TosState state); |
|
64 |
|
65 static const Address l_tmp; |
|
66 static const Address d_tmp; |
|
67 |
|
68 // Handy address generation macros. |
|
69 #define thread_(field_name) Address(Z_thread, JavaThread::field_name ## _offset()) |
|
70 #define method_(field_name) Address(Z_method, Method::field_name ## _offset()) |
|
71 #define method2_(Rmethod, field_name) Address(Rmethod, Method::field_name ## _offset()) |
|
72 |
|
73 // Helper routine for frame allocation/deallocation. |
|
74 // Compute the delta by which the caller's SP has to |
|
75 // be adjusted to accomodate for the non-argument locals. |
|
76 void compute_extra_locals_size_in_bytes(Register args_size, Register locals_size, Register delta); |
|
77 |
|
78 // dispatch routines |
|
79 void dispatch_prolog(TosState state, int step = 0); |
|
80 void dispatch_epilog(TosState state, int step = 0); |
|
81 void dispatch_only(TosState state); |
|
82 // Dispatch normal table via Z_bytecode (assume Z_bytecode is loaded already). |
|
83 void dispatch_only_normal(TosState state); |
|
84 void dispatch_normal(TosState state); |
|
85 void dispatch_next(TosState state, int step = 0); |
|
86 void dispatch_next_noverify_oop(TosState state, int step = 0); |
|
87 void dispatch_via(TosState state, address* table); |
|
88 |
|
89 // Jump to an invoked target. |
|
90 void prepare_to_jump_from_interpreted(Register method); |
|
91 void jump_from_interpreted(Register method, Register temp); |
|
92 |
|
93 // Removes the current activation (incl. unlocking of monitors). |
|
94 // Additionally this code is used for earlyReturn in which case we |
|
95 // want to skip throwing an exception and installing an exception. |
|
96 void remove_activation(TosState state, |
|
97 Register return_pc, |
|
98 bool throw_monitor_exception = true, |
|
99 bool install_monitor_exception = true, |
|
100 bool notify_jvmti = true); |
|
101 |
|
102 public: |
|
103 // Super call_VM calls - correspond to MacroAssembler::call_VM(_leaf) calls. |
|
104 void super_call_VM_leaf(address entry_point, Register arg_1, Register arg_2); |
|
105 void super_call_VM(Register thread_cache, Register oop_result, Register last_java_sp, |
|
106 address entry_point, Register arg_1, Register arg_2, bool check_exception = true); |
|
107 |
|
108 // Generate a subtype check: branch to ok_is_subtype if sub_klass is |
|
109 // a subtype of super_klass. Blows registers tmp1, tmp2 and tmp3. |
|
110 void gen_subtype_check(Register sub_klass, Register super_klass, Register tmp1, Register tmp2, Label &ok_is_subtype); |
|
111 |
|
112 void get_cache_and_index_at_bcp(Register cache, Register cpe_offset, int bcp_offset, size_t index_size = sizeof(u2)); |
|
113 void get_cache_and_index_and_bytecode_at_bcp(Register cache, Register cpe_offset, Register bytecode, |
|
114 int byte_no, int bcp_offset, size_t index_size = sizeof(u2)); |
|
115 void get_cache_entry_pointer_at_bcp(Register cache, Register tmp, int bcp_offset, size_t index_size = sizeof(u2)); |
|
116 void get_cache_index_at_bcp(Register index, int bcp_offset, size_t index_size = sizeof(u2)); |
|
117 void load_resolved_reference_at_index(Register result, Register index); |
|
118 |
|
119 // Pop topmost element from stack. It just disappears. Useful if |
|
120 // consumed previously by access via stackTop(). |
|
121 void popx(int len); |
|
122 void pop_i() { popx(1); } |
|
123 void pop_ptr() { popx(1); } |
|
124 void pop_l() { popx(2); } |
|
125 void pop_f() { popx(1); } |
|
126 void pop_d() { popx(2); } |
|
127 // Get Address object of stack top. No checks. No pop. |
|
128 // Purpose: provide address of stack operand to exploit reg-mem operations. |
|
129 // Avoid RISC-like mem2reg - reg-reg-op sequence. |
|
130 Address stackTop(); |
|
131 |
|
132 // Helpers for expression stack. |
|
133 void pop_i( Register r); |
|
134 void pop_ptr( Register r); |
|
135 void pop_l( Register r); |
|
136 void pop_f(FloatRegister f); |
|
137 void pop_d(FloatRegister f); |
|
138 |
|
139 void push_i( Register r = Z_tos); |
|
140 void push_ptr( Register r = Z_tos); |
|
141 void push_l( Register r = Z_tos); |
|
142 void push_f(FloatRegister f = Z_ftos); |
|
143 void push_d(FloatRegister f = Z_ftos); |
|
144 |
|
145 // Helpers for swap and dup. |
|
146 void load_ptr(int n, Register val); |
|
147 void store_ptr(int n, Register val); |
|
148 |
|
149 void pop (TosState state); // transition vtos -> state |
|
150 void push(TosState state); // transition state -> vtos |
|
151 void empty_expression_stack(void); |
|
152 |
|
153 #ifdef ASSERT |
|
154 void verify_sp(Register Rsp, Register Rtemp); |
|
155 void verify_esp(Register Resp, Register Rtemp); // Verify that Resp points to a word in the operand stack. |
|
156 #endif // ASSERT |
|
157 |
|
158 public: |
|
159 void if_cmp(Condition cc, bool ptr_compare); |
|
160 |
|
161 // Accessors to the template interpreter state. |
|
162 |
|
163 void asm_assert_ijava_state_magic(Register tmp) PRODUCT_RETURN; |
|
164 |
|
165 void save_bcp(); |
|
166 |
|
167 void restore_bcp(); |
|
168 |
|
169 void save_esp(); |
|
170 |
|
171 void restore_esp(); |
|
172 |
|
173 void get_monitors(Register reg); |
|
174 |
|
175 void save_monitors(Register reg); |
|
176 |
|
177 void get_mdp(Register mdp); |
|
178 |
|
179 void save_mdp(Register mdp); |
|
180 |
|
181 // Values that are only read (besides initialization). |
|
182 void restore_locals(); |
|
183 |
|
184 void get_method(Register reg); |
|
185 |
|
186 // Load values from bytecode stream: |
|
187 |
|
188 enum signedOrNot { Signed, Unsigned }; |
|
189 enum setCCOrNot { set_CC, dont_set_CC }; |
|
190 |
|
191 void get_2_byte_integer_at_bcp(Register Rdst, |
|
192 int bcp_offset, |
|
193 signedOrNot is_signed ); |
|
194 |
|
195 void get_4_byte_integer_at_bcp(Register Rdst, |
|
196 int bcp_offset, |
|
197 setCCOrNot should_set_CC = dont_set_CC); |
|
198 |
|
199 // common code |
|
200 |
|
201 void field_offset_at(int n, Register tmp, Register dest, Register base); |
|
202 int field_offset_at(Register object, address bcp, int offset); |
|
203 void fast_iaaccess(int n, address bcp); |
|
204 void fast_iaputfield(address bcp, bool do_store_check); |
|
205 |
|
206 void index_check(Register array, Register index, int index_shift, Register tmp, Register res); |
|
207 void index_check_without_pop(Register array, Register index, int index_shift, Register tmp, Register res); |
|
208 |
|
209 void get_constant_pool(Register Rdst); |
|
210 void get_constant_pool_cache(Register Rdst); |
|
211 void get_cpool_and_tags(Register Rcpool, Register Rtags); |
|
212 void is_a(Label& L); |
|
213 |
|
214 |
|
215 // -------------------------------------------------- |
|
216 |
|
217 void unlock_if_synchronized_method(TosState state, bool throw_monitor_exception = true, bool install_monitor_exception = true); |
|
218 |
|
219 void add_monitor_to_stack(bool stack_is_empty, |
|
220 Register Rtemp, |
|
221 Register Rtemp2, |
|
222 Register Rtemp3); |
|
223 |
|
224 void access_local_int(Register index, Register dst); |
|
225 void access_local_ptr(Register index, Register dst); |
|
226 void access_local_long(Register index, Register dst); |
|
227 void access_local_float(Register index, FloatRegister dst); |
|
228 void access_local_double(Register index, FloatRegister dst); |
|
229 #ifdef ASSERT |
|
230 void check_for_regarea_stomp(Register Rindex, int offset, Register Rlimit, Register Rscratch, Register Rscratch1); |
|
231 #endif // ASSERT |
|
232 void store_local_int(Register index, Register src); |
|
233 void store_local_ptr(Register index, Register src); |
|
234 void store_local_long(Register index, Register src); |
|
235 void store_local_float(Register index, FloatRegister src); |
|
236 void store_local_double(Register index, FloatRegister src); |
|
237 |
|
238 |
|
239 Address first_local_in_stack(); |
|
240 static int top_most_monitor_byte_offset(); // Offset in bytes to top of monitor block. |
|
241 Address top_most_monitor(); |
|
242 void compute_stack_base(Register Rdest); |
|
243 |
|
244 enum LoadOrStore { load, store }; |
|
245 void static_iload_or_store(int which_local, LoadOrStore direction, Register Rtmp); |
|
246 void static_aload_or_store(int which_local, LoadOrStore direction, Register Rtmp); |
|
247 void static_dload_or_store(int which_local, LoadOrStore direction); |
|
248 |
|
249 void static_iinc( int which_local, jint increment, Register Rtmp, Register Rtmp2); |
|
250 |
|
251 void get_method_counters(Register Rmethod, Register Rcounters, Label& skip); |
|
252 void increment_invocation_counter(Register Rcounters, Register RctrSum); |
|
253 void increment_backedge_counter(Register Rcounters, Register RctrSum); |
|
254 void test_backedge_count_for_osr(Register backedge_count, Register branch_bcp, Register Rtmp); |
|
255 |
|
256 void record_static_call_in_profile(Register Rentry, Register Rtmp); |
|
257 void record_receiver_call_in_profile(Register Rklass, Register Rentry, Register Rtmp); |
|
258 |
|
259 // Object locking |
|
260 void lock_object (Register lock_reg, Register obj_reg); |
|
261 void unlock_object(Register lock_reg, Register obj_reg=noreg); |
|
262 |
|
263 // Interpreter profiling operations |
|
264 void set_method_data_pointer_for_bcp(); |
|
265 void test_method_data_pointer(Register mdp, Label& zero_continue); |
|
266 void verify_method_data_pointer(); |
|
267 |
|
268 void set_mdp_data_at(Register mdp_in, int constant, Register value); |
|
269 void increment_mdp_data_at(Register mdp_in, int constant, |
|
270 Register tmp = Z_R1_scratch, bool decrement = false); |
|
271 void increment_mask_and_jump(Address counter_addr, |
|
272 int increment, Address mask, |
|
273 Register scratch, bool preloaded, |
|
274 branch_condition cond, Label* where); |
|
275 void set_mdp_flag_at(Register mdp_in, int flag_constant); |
|
276 void test_mdp_data_at(Register mdp_in, int offset, Register value, |
|
277 Register test_value_out, |
|
278 Label& not_equal_continue); |
|
279 |
|
280 void record_klass_in_profile(Register receiver, Register mdp, |
|
281 Register reg2, bool is_virtual_call); |
|
282 void record_klass_in_profile_helper(Register receiver, Register mdp, |
|
283 Register reg2, int start_row, |
|
284 Label& done, bool is_virtual_call); |
|
285 |
|
286 void update_mdp_by_offset(Register mdp_in, int offset_of_offset); |
|
287 void update_mdp_by_offset(Register mdp_in, Register dataidx, int offset_of_disp); |
|
288 void update_mdp_by_constant(Register mdp_in, int constant); |
|
289 void update_mdp_for_ret(Register return_bci); |
|
290 |
|
291 void profile_taken_branch(Register mdp, Register bumped_count); |
|
292 void profile_not_taken_branch(Register mdp); |
|
293 void profile_call(Register mdp); |
|
294 void profile_final_call(Register mdp); |
|
295 void profile_virtual_call(Register receiver, Register mdp, |
|
296 Register scratch2, |
|
297 bool receiver_can_be_null = false); |
|
298 void profile_ret(Register return_bci, Register mdp); |
|
299 void profile_null_seen(Register mdp); |
|
300 void profile_typecheck(Register mdp, Register klass, Register scratch); |
|
301 void profile_typecheck_failed(Register mdp, Register tmp); |
|
302 void profile_switch_default(Register mdp); |
|
303 void profile_switch_case(Register index_in_scratch, Register mdp, |
|
304 Register scratch1, Register scratch2); |
|
305 |
|
306 void profile_obj_type(Register obj, Address mdo_addr, Register klass, bool cmp_done = false); |
|
307 void profile_arguments_type(Register mdp, Register callee, Register tmp, bool is_virtual); |
|
308 void profile_return_type(Register mdp, Register ret, Register tmp); |
|
309 void profile_parameters_type(Register mdp, Register tmp1, Register tmp2); |
|
310 |
|
311 // Debugging |
|
312 void verify_oop(Register reg, TosState state = atos); // Only if +VerifyOops && state == atos. |
|
313 void verify_oop_or_return_address(Register reg, Register rtmp); // for astore |
|
314 void verify_FPU(int stack_depth, TosState state = ftos); |
|
315 |
|
316 // JVMTI helpers |
|
317 void skip_if_jvmti_mode(Label &Lskip, Register Rscratch = Z_R0); |
|
318 |
|
319 // support for JVMTI/Dtrace |
|
320 typedef enum { NotifyJVMTI, SkipNotifyJVMTI } NotifyMethodExitMode; |
|
321 void notify_method_entry(); |
|
322 void notify_method_exit(bool native_method, TosState state, NotifyMethodExitMode mode); |
|
323 |
|
324 // Pop the topmost TOP_IJAVA_FRAME and set it's sender_sp as new Z_SP. |
|
325 // The return pc is loaded into the Register return_pc. |
|
326 void pop_interpreter_frame(Register return_pc, Register tmp1, Register tmp2); |
|
327 }; |
|
328 |
|
329 #endif // CPU_S390_VM_INTERP_MASM_ZARCH_64_64_HPP |