Mon, 01 Feb 2010 19:29:46 +0100
6921352: JSR 292 needs its own deopt handler
Summary: We need to introduce a new MH deopt handler so we can easily determine if the deopt happened at a MH call site or not.
Reviewed-by: never, jrose
1 /*
2 * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
20 * CA 95054 USA or visit www.sun.com if you need additional information or
21 * have any questions.
22 *
23 */
25 // This file specializes the assember with interpreter-specific macros
28 class InterpreterMacroAssembler: public MacroAssembler {
29 #ifndef CC_INTERP
30 protected:
31 // Interpreter specific version of call_VM_base
32 virtual void call_VM_leaf_base(
33 address entry_point,
34 int number_of_arguments
35 );
37 virtual void call_VM_base(
38 Register oop_result,
39 Register java_thread,
40 Register last_java_sp,
41 address entry_point,
42 int number_of_arguments,
43 bool check_exceptions
44 );
46 virtual void check_and_handle_popframe(Register java_thread);
47 virtual void check_and_handle_earlyret(Register java_thread);
49 // base routine for all dispatches
50 void dispatch_base(TosState state, address* table, bool verifyoop = true);
51 #endif /* CC_INTERP */
53 public:
54 InterpreterMacroAssembler(CodeBuffer* code) : MacroAssembler(code) {}
56 void load_earlyret_value(TosState state);
58 // Interpreter-specific registers
59 #ifdef CC_INTERP
60 void save_bcp() { /* not needed in c++ interpreter and harmless */ }
61 void restore_bcp() { /* not needed in c++ interpreter and harmless */ }
63 // Helpers for runtime call arguments/results
64 void get_method(Register reg);
66 #else
68 void save_bcp() { movptr(Address(rbp, frame::interpreter_frame_bcx_offset * wordSize), rsi); }
69 void restore_bcp() { movptr(rsi, Address(rbp, frame::interpreter_frame_bcx_offset * wordSize)); }
70 void restore_locals() { movptr(rdi, Address(rbp, frame::interpreter_frame_locals_offset * wordSize)); }
72 // Helpers for runtime call arguments/results
73 void get_method(Register reg) { movptr(reg, Address(rbp, frame::interpreter_frame_method_offset * wordSize)); }
74 void get_constant_pool(Register reg) { get_method(reg); movptr(reg, Address(reg, methodOopDesc::constants_offset())); }
75 void get_constant_pool_cache(Register reg) { get_constant_pool(reg); movptr(reg, Address(reg, constantPoolOopDesc::cache_offset_in_bytes())); }
76 void get_cpool_and_tags(Register cpool, Register tags) { get_constant_pool(cpool); movptr(tags, Address(cpool, constantPoolOopDesc::tags_offset_in_bytes()));
77 }
78 void get_unsigned_2_byte_index_at_bcp(Register reg, int bcp_offset);
79 void get_cache_and_index_at_bcp(Register cache, Register index, int bcp_offset, bool giant_index = false);
80 void get_cache_entry_pointer_at_bcp(Register cache, Register tmp, int bcp_offset, bool giant_index = false);
81 void get_cache_index_at_bcp(Register index, int bcp_offset, bool giant_index = false);
83 // Expression stack
84 void f2ieee(); // truncate ftos to 32bits
85 void d2ieee(); // truncate dtos to 64bits
87 void pop_ptr(Register r = rax);
88 void pop_ptr(Register r, Register tag);
89 void pop_i(Register r = rax);
90 void pop_l(Register lo = rax, Register hi = rdx);
91 void pop_f();
92 void pop_d();
93 void pop_ftos_to_rsp();
94 void pop_dtos_to_rsp();
96 void push_ptr(Register r = rax);
97 void push_ptr(Register r, Register tag);
98 void push_i(Register r = rax);
99 void push_l(Register lo = rax, Register hi = rdx);
100 void push_d(Register r = rax);
101 void push_f();
103 void pop(TosState state); // transition vtos -> state
104 void push(TosState state); // transition state -> vtos
106 void pop(Register r ) { ((MacroAssembler*)this)->pop(r); }
108 void push(Register r ) { ((MacroAssembler*)this)->push(r); }
109 void push(int32_t imm ) { ((MacroAssembler*)this)->push(imm); }
111 // These are dummies to prevent surprise implicit conversions to Register
112 void pop(void* v ); // Add unimplemented ambiguous method
113 void push(void* v ); // Add unimplemented ambiguous method
115 DEBUG_ONLY(void verify_stack_tag(frame::Tag t);)
117 #endif // CC_INTERP
119 #ifndef CC_INTERP
121 void empty_expression_stack() {
122 movptr(rsp, Address(rbp, frame::interpreter_frame_monitor_block_top_offset * wordSize));
123 // NULL last_sp until next java call
124 movptr(Address(rbp, frame::interpreter_frame_last_sp_offset * wordSize), NULL_WORD);
125 }
127 // Tagged stack helpers for swap and dup
128 void load_ptr_and_tag(int n, Register val, Register tag);
129 void store_ptr_and_tag(int n, Register val, Register tag);
131 // Tagged Local support
133 void tag_local(frame::Tag tag, int n);
134 void tag_local(Register tag, int n);
135 void tag_local(frame::Tag tag, Register idx);
136 void tag_local(Register tag, Register idx);
138 #ifdef ASSERT
139 void verify_local_tag(frame::Tag tag, int n);
140 void verify_local_tag(frame::Tag tag, Register idx);
141 #endif // ASSERT
143 // Super call_VM calls - correspond to MacroAssembler::call_VM(_leaf) calls
144 void super_call_VM_leaf(address entry_point);
145 void super_call_VM_leaf(address entry_point, Register arg_1);
146 void super_call_VM_leaf(address entry_point, Register arg_1, Register arg_2);
147 void super_call_VM_leaf(address entry_point, Register arg_1, Register arg_2, Register arg_3);
149 // Generate a subtype check: branch to ok_is_subtype if sub_klass is
150 // a subtype of super_klass. EAX holds the super_klass. Blows ECX
151 // and EDI. Register sub_klass cannot be any of the above.
152 void gen_subtype_check( Register sub_klass, Label &ok_is_subtype );
154 // Dispatching
155 void dispatch_prolog(TosState state, int step = 0);
156 void dispatch_epilog(TosState state, int step = 0);
157 void dispatch_only(TosState state); // dispatch via rbx, (assume rbx, is loaded already)
158 void dispatch_only_normal(TosState state); // dispatch normal table via rbx, (assume rbx, is loaded already)
159 void dispatch_only_noverify(TosState state);
160 void dispatch_next(TosState state, int step = 0); // load rbx, from [esi + step] and dispatch via rbx,
161 void dispatch_via (TosState state, address* table); // load rbx, from [esi] and dispatch via rbx, and table
164 // jump to an invoked target
165 void prepare_to_jump_from_interpreted();
166 void jump_from_interpreted(Register method, Register temp);
168 // Returning from interpreted functions
169 //
170 // Removes the current activation (incl. unlocking of monitors)
171 // and sets up the return address. This code is also used for
172 // exception unwindwing. In that case, we do not want to throw
173 // IllegalMonitorStateExceptions, since that might get us into an
174 // infinite rethrow exception loop.
175 // Additionally this code is used for popFrame and earlyReturn.
176 // In popFrame case we want to skip throwing an exception,
177 // installing an exception, and notifying jvmdi.
178 // In earlyReturn case we only want to skip throwing an exception
179 // and installing an exception.
180 void remove_activation(TosState state, Register ret_addr,
181 bool throw_monitor_exception = true,
182 bool install_monitor_exception = true,
183 bool notify_jvmdi = true);
184 #endif /* !CC_INTERP */
186 // Debugging
187 void verify_oop(Register reg, TosState state = atos); // only if +VerifyOops && state == atos
188 #ifndef CC_INTERP
189 void verify_FPU(int stack_depth, TosState state = ftos); // only if +VerifyFPU && (state == ftos || state == dtos)
191 #endif /* !CC_INTERP */
193 // Object locking
194 void lock_object (Register lock_reg);
195 void unlock_object(Register lock_reg);
197 #ifndef CC_INTERP
199 // Interpreter profiling operations
200 void set_method_data_pointer_for_bcp();
201 void test_method_data_pointer(Register mdp, Label& zero_continue);
202 void verify_method_data_pointer();
204 void set_mdp_data_at(Register mdp_in, int constant, Register value);
205 void increment_mdp_data_at(Address data, bool decrement = false);
206 void increment_mdp_data_at(Register mdp_in, int constant,
207 bool decrement = false);
208 void increment_mdp_data_at(Register mdp_in, Register reg, int constant,
209 bool decrement = false);
210 void set_mdp_flag_at(Register mdp_in, int flag_constant);
211 void test_mdp_data_at(Register mdp_in, int offset, Register value,
212 Register test_value_out,
213 Label& not_equal_continue);
215 void record_klass_in_profile(Register receiver, Register mdp,
216 Register reg2);
217 void record_klass_in_profile_helper(Register receiver, Register mdp,
218 Register reg2,
219 int start_row, Label& done);
221 void update_mdp_by_offset(Register mdp_in, int offset_of_offset);
222 void update_mdp_by_offset(Register mdp_in, Register reg, int offset_of_disp);
223 void update_mdp_by_constant(Register mdp_in, int constant);
224 void update_mdp_for_ret(Register return_bci);
226 void profile_taken_branch(Register mdp, Register bumped_count);
227 void profile_not_taken_branch(Register mdp);
228 void profile_call(Register mdp);
229 void profile_final_call(Register mdp);
230 void profile_virtual_call(Register receiver, Register mdp, Register scratch2,
231 bool receiver_can_be_null = false);
232 void profile_ret(Register return_bci, Register mdp);
233 void profile_null_seen(Register mdp);
234 void profile_typecheck(Register mdp, Register klass, Register scratch);
235 void profile_typecheck_failed(Register mdp);
236 void profile_switch_default(Register mdp);
237 void profile_switch_case(Register index_in_scratch, Register mdp, Register scratch2);
239 #endif /* !CC_INTERP */
241 typedef enum { NotifyJVMTI, SkipNotifyJVMTI } NotifyMethodExitMode;
243 // support for jvmti
244 void notify_method_entry();
245 void notify_method_exit(TosState state, NotifyMethodExitMode mode);
247 };