comparison src/cpu/ppc/vm/interp_masm_ppc_64.hpp @ 17804:fd1b9f02cc91

8036976: PPC64: implement the template interpreter Reviewed-by: kvn, coleenp Contributed-by: axel.siebenborn@sap.com, martin.doerr@sap.com
author goetz
date Mon, 10 Mar 2014 12:58:02 +0100
parents 67fa91961822
children 92aa6797d639 63c5920a038d
comparison
equal deleted inserted replaced
17803:31e80afe3fed 17804:fd1b9f02cc91
1 /* 1 /*
2 * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
3 * Copyright 2012, 2013 SAP AG. All rights reserved. 3 * Copyright 2012, 2014 SAP AG. All rights reserved.
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * 5 *
6 * This code is free software; you can redistribute it and/or modify it 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 7 * under the terms of the GNU General Public License version 2 only, as
8 * published by the Free Software Foundation. 8 * published by the Free Software Foundation.
27 #define CPU_PPC_VM_INTERP_MASM_PPC_64_HPP 27 #define CPU_PPC_VM_INTERP_MASM_PPC_64_HPP
28 28
29 #include "assembler_ppc.inline.hpp" 29 #include "assembler_ppc.inline.hpp"
30 #include "interpreter/invocationCounter.hpp" 30 #include "interpreter/invocationCounter.hpp"
31 31
32 // This file specializes the assembler with interpreter-specific macros 32 // This file specializes the assembler with interpreter-specific macros.
33 33
34 34
35 class InterpreterMacroAssembler: public MacroAssembler { 35 class InterpreterMacroAssembler: public MacroAssembler {
36 36
37 public: 37 public:
38 InterpreterMacroAssembler(CodeBuffer* code) : MacroAssembler(code) {} 38 InterpreterMacroAssembler(CodeBuffer* code) : MacroAssembler(code) {}
39 39
40 void null_check_throw(Register a, int offset, Register temp_reg); 40 void null_check_throw(Register a, int offset, Register temp_reg);
41 41
42 // Handy address generation macros 42 void branch_to_entry(address entry, Register Rscratch);
43
44 // Handy address generation macros.
43 #define thread_(field_name) in_bytes(JavaThread::field_name ## _offset()), R16_thread 45 #define thread_(field_name) in_bytes(JavaThread::field_name ## _offset()), R16_thread
44 #define method_(field_name) in_bytes(Method::field_name ## _offset()), R19_method 46 #define method_(field_name) in_bytes(Method::field_name ## _offset()), R19_method
45 47
46 #ifdef CC_INTERP 48 #ifdef CC_INTERP
47 #define state_(field_name) in_bytes(byte_offset_of(BytecodeInterpreter, field_name)), R14_state 49 #define state_(field_name) in_bytes(byte_offset_of(BytecodeInterpreter, field_name)), R14_state
48 #define prev_state_(field_name) in_bytes(byte_offset_of(BytecodeInterpreter, field_name)), R15_prev_state 50 #define prev_state_(field_name) in_bytes(byte_offset_of(BytecodeInterpreter, field_name)), R15_prev_state
51 void pop (TosState state) {}; // Not needed.
52 void push(TosState state) {}; // Not needed.
49 #endif 53 #endif
54
55 #ifndef CC_INTERP
56 virtual void check_and_handle_popframe(Register java_thread);
57 virtual void check_and_handle_earlyret(Register java_thread);
58
59 // Base routine for all dispatches.
60 void dispatch_base(TosState state, address* table);
61
62 void load_earlyret_value(TosState state, Register Rscratch1);
63
64 static const Address l_tmp;
65 static const Address d_tmp;
66
67 // dispatch routines
68 void dispatch_next(TosState state, int step = 0);
69 void dispatch_via (TosState state, address* table);
70 void load_dispatch_table(Register dst, address* table);
71 void dispatch_Lbyte_code(TosState state, Register bytecode, address* table, bool verify = false);
72
73 // Called by shared interpreter generator.
74 void dispatch_prolog(TosState state, int step = 0);
75 void dispatch_epilog(TosState state, int step = 0);
76
77 // Super call_VM calls - correspond to MacroAssembler::call_VM(_leaf) calls.
78 void super_call_VM_leaf(Register thread_cache, address entry_point, Register arg_1);
79 void super_call_VM(Register thread_cache, Register oop_result, Register last_java_sp,
80 address entry_point, Register arg_1, Register arg_2, bool check_exception = true);
81
82 // Generate a subtype check: branch to ok_is_subtype if sub_klass is
83 // a subtype of super_klass. Blows registers tmp1, tmp2 and tmp3.
84 void gen_subtype_check(Register sub_klass, Register super_klass,
85 Register tmp1, Register tmp2, Register tmp3, Label &ok_is_subtype);
86
87 // Load object from cpool->resolved_references(index).
88 void load_resolved_reference_at_index(Register result, Register index);
89
90 void generate_stack_overflow_check_with_compare_and_throw(Register Rmem_frame_size, Register Rscratch1);
91 void load_receiver(Register Rparam_count, Register Rrecv_dst);
92
93 // helpers for expression stack
94 void pop_i( Register r = R17_tos);
95 void pop_ptr( Register r = R17_tos);
96 void pop_l( Register r = R17_tos);
97 void pop_f(FloatRegister f = F15_ftos);
98 void pop_d(FloatRegister f = F15_ftos );
99
100 void push_i( Register r = R17_tos);
101 void push_ptr( Register r = R17_tos);
102 void push_l( Register r = R17_tos);
103 void push_f(FloatRegister f = F15_ftos );
104 void push_d(FloatRegister f = F15_ftos);
105
106 void push_2ptrs(Register first, Register second);
107
108 void push_l_pop_d(Register l = R17_tos, FloatRegister d = F15_ftos);
109 void push_d_pop_l(FloatRegister d = F15_ftos, Register l = R17_tos);
110
111 void pop (TosState state); // transition vtos -> state
112 void push(TosState state); // transition state -> vtos
113 void empty_expression_stack(); // Resets both Lesp and SP.
114
115 public:
116 // Load values from bytecode stream:
117
118 enum signedOrNot { Signed, Unsigned };
119 enum setCCOrNot { set_CC, dont_set_CC };
120
121 void get_2_byte_integer_at_bcp(int bcp_offset,
122 Register Rdst,
123 signedOrNot is_signed);
124
125 void get_4_byte_integer_at_bcp(int bcp_offset,
126 Register Rdst,
127 signedOrNot is_signed = Unsigned);
128
129 void get_cache_index_at_bcp(Register Rdst, int bcp_offset, size_t index_size);
130
131 void get_cache_and_index_at_bcp(Register cache, int bcp_offset, size_t index_size = sizeof(u2));
132
133
134 // common code
135
136 void field_offset_at(int n, Register tmp, Register dest, Register base);
137 int field_offset_at(Register object, address bcp, int offset);
138 void fast_iaaccess(int n, address bcp);
139 void fast_iagetfield(address bcp);
140 void fast_iaputfield(address bcp, bool do_store_check);
141
142 void index_check(Register array, Register index, int index_shift, Register tmp, Register res);
143 void index_check_without_pop(Register array, Register index, int index_shift, Register tmp, Register res);
144
145 void get_const(Register Rdst);
146 void get_constant_pool(Register Rdst);
147 void get_constant_pool_cache(Register Rdst);
148 void get_cpool_and_tags(Register Rcpool, Register Rtags);
149 void is_a(Label& L);
150
151 // Java Call Helpers
152 void call_from_interpreter(Register Rtarget_method, Register Rret_addr, Register Rscratch1, Register Rscratch2);
153
154 // --------------------------------------------------
155
156 void unlock_if_synchronized_method(TosState state, bool throw_monitor_exception = true,
157 bool install_monitor_exception = true);
158
159 // Removes the current activation (incl. unlocking of monitors).
160 // Additionally this code is used for earlyReturn in which case we
161 // want to skip throwing an exception and installing an exception.
162 void remove_activation(TosState state,
163 bool throw_monitor_exception = true,
164 bool install_monitor_exception = true);
165 void merge_frames(Register Rtop_frame_sp, Register return_pc, Register Rscratch1, Register Rscratch2); // merge top frames
166
167 void add_monitor_to_stack(bool stack_is_empty, Register Rtemp1, Register Rtemp2);
168
169 // Local variable access helpers
170 void load_local_int(Register Rdst_value, Register Rdst_address, Register Rindex);
171 void load_local_long(Register Rdst_value, Register Rdst_address, Register Rindex);
172 void load_local_ptr(Register Rdst_value, Register Rdst_address, Register Rindex);
173 void load_local_float(FloatRegister Rdst_value, Register Rdst_address, Register Rindex);
174 void load_local_double(FloatRegister Rdst_value, Register Rdst_address, Register Rindex);
175 void store_local_int(Register Rvalue, Register Rindex);
176 void store_local_long(Register Rvalue, Register Rindex);
177 void store_local_ptr(Register Rvalue, Register Rindex);
178 void store_local_float(FloatRegister Rvalue, Register Rindex);
179 void store_local_double(FloatRegister Rvalue, Register Rindex);
180
181 // Call VM for std frames
182 // Special call VM versions that check for exceptions and forward exception
183 // via short cut (not via expensive forward exception stub).
184 void check_and_forward_exception(Register Rscratch1, Register Rscratch2);
185 void call_VM(Register oop_result, address entry_point, bool check_exceptions = true);
186 void call_VM(Register oop_result, address entry_point, Register arg_1, bool check_exceptions = true);
187 void call_VM(Register oop_result, address entry_point, Register arg_1, Register arg_2, bool check_exceptions = true);
188 void call_VM(Register oop_result, address entry_point, Register arg_1, Register arg_2, Register arg_3, bool check_exceptions = true);
189 // Should not be used:
190 void call_VM(Register oop_result, Register last_java_sp, address entry_point, bool check_exceptions = true) {ShouldNotReachHere();}
191 void call_VM(Register oop_result, Register last_java_sp, address entry_point, Register arg_1, bool check_exceptions = true) {ShouldNotReachHere();}
192 void call_VM(Register oop_result, Register last_java_sp, address entry_point, Register arg_1, Register arg_2, bool check_exceptions = true) {ShouldNotReachHere();}
193 void call_VM(Register oop_result, Register last_java_sp, address entry_point, Register arg_1, Register arg_2, Register arg_3, bool check_exceptions = true) {ShouldNotReachHere();}
194
195 Address first_local_in_stack();
196
197 enum LoadOrStore { load, store };
198 void static_iload_or_store(int which_local, LoadOrStore direction, Register Rtmp);
199 void static_aload_or_store(int which_local, LoadOrStore direction, Register Rtmp);
200 void static_dload_or_store(int which_local, LoadOrStore direction);
201
202 void save_interpreter_state(Register scratch);
203 void restore_interpreter_state(Register scratch, bool bcp_and_mdx_only = false);
204
205 void increment_backedge_counter(const Register Rcounters, Register Rtmp, Register Rtmp2, Register Rscratch);
206 void test_backedge_count_for_osr(Register backedge_count, Register branch_bcp, Register Rtmp);
207
208 void record_static_call_in_profile(Register Rentry, Register Rtmp);
209 void record_receiver_call_in_profile(Register Rklass, Register Rentry, Register Rtmp);
210 #endif // !CC_INTERP
50 211
51 void get_method_counters(Register method, Register Rcounters, Label& skip); 212 void get_method_counters(Register method, Register Rcounters, Label& skip);
52 void increment_invocation_counter(Register iv_be_count, Register Rtmp1, Register Rtmp2_r0); 213 void increment_invocation_counter(Register iv_be_count, Register Rtmp1, Register Rtmp2_r0);
53 214
54 // Object locking 215 // Object locking
55 void lock_object (Register lock_reg, Register obj_reg); 216 void lock_object (Register lock_reg, Register obj_reg);
56 void unlock_object(Register lock_reg, bool check_for_exceptions = true); 217 void unlock_object(Register lock_reg, bool check_for_exceptions = true);
57 218
219 #ifndef CC_INTERP
220
221 // Interpreter profiling operations
222 void set_method_data_pointer_for_bcp();
223 void test_method_data_pointer(Label& zero_continue);
224 void verify_method_data_pointer();
225 void test_invocation_counter_for_mdp(Register invocation_count, Register Rscratch, Label &profile_continue);
226
227 void set_mdp_data_at(int constant, Register value);
228
229 void increment_mdp_data_at(int constant, Register counter_addr, Register Rbumped_count, bool decrement = false);
230
231 void increment_mdp_data_at(Register counter_addr, Register Rbumped_count, bool decrement = false);
232 void increment_mdp_data_at(Register reg, int constant, Register scratch, Register Rbumped_count, bool decrement = false);
233
234 void set_mdp_flag_at(int flag_constant, Register scratch);
235 void test_mdp_data_at(int offset, Register value, Label& not_equal_continue, Register test_out);
236
237 void update_mdp_by_offset(int offset_of_disp, Register scratch);
238 void update_mdp_by_offset(Register reg, int offset_of_disp,
239 Register scratch);
240 void update_mdp_by_constant(int constant);
241 void update_mdp_for_ret(TosState state, Register return_bci);
242
243 void profile_taken_branch(Register scratch, Register bumped_count);
244 void profile_not_taken_branch(Register scratch1, Register scratch2);
245 void profile_call(Register scratch1, Register scratch2);
246 void profile_final_call(Register scratch1, Register scratch2);
247 void profile_virtual_call(Register Rreceiver, Register Rscratch1, Register Rscratch2, bool receiver_can_be_null);
248 void profile_typecheck(Register Rklass, Register Rscratch1, Register Rscratch2);
249 void profile_typecheck_failed(Register Rscratch1, Register Rscratch2);
250 void profile_ret(TosState state, Register return_bci, Register scratch1, Register scratch2);
251 void profile_switch_default(Register scratch1, Register scratch2);
252 void profile_switch_case(Register index, Register scratch1,Register scratch2, Register scratch3);
253 void profile_null_seen(Register Rscratch1, Register Rscratch2);
254 void record_klass_in_profile(Register receiver, Register scratch1, Register scratch2, bool is_virtual_call);
255 void record_klass_in_profile_helper(Register receiver, Register scratch1, Register scratch2, int start_row, Label& done, bool is_virtual_call);
256
257 #endif // !CC_INTERP
258
58 // Debugging 259 // Debugging
59 void verify_oop(Register reg, TosState state = atos); // only if +VerifyOops && state == atos 260 void verify_oop(Register reg, TosState state = atos); // only if +VerifyOops && state == atos
60 261 #ifndef CC_INTERP
61 // support for jvmdi/jvmpi 262 void verify_oop_or_return_address(Register reg, Register rtmp); // for astore
263 void verify_FPU(int stack_depth, TosState state = ftos);
264 #endif // !CC_INTERP
265
266 typedef enum { NotifyJVMTI, SkipNotifyJVMTI } NotifyMethodExitMode;
267
268 // Support for jvmdi/jvmpi.
62 void notify_method_entry(); 269 void notify_method_entry();
63 void notify_method_exit(bool is_native_method, TosState state); 270 void notify_method_exit(bool is_native_method, TosState state,
271 NotifyMethodExitMode mode, bool check_exceptions);
64 272
65 #ifdef CC_INTERP 273 #ifdef CC_INTERP
66 // Convert the current TOP_IJAVA_FRAME into a PARENT_IJAVA_FRAME 274 // Convert the current TOP_IJAVA_FRAME into a PARENT_IJAVA_FRAME
67 // (using parent_frame_resize) and push a new interpreter 275 // (using parent_frame_resize) and push a new interpreter
68 // TOP_IJAVA_FRAME (using frame_size). 276 // TOP_IJAVA_FRAME (using frame_size).