1
|
1 |
/*
|
|
2 |
* Copyright 1997-2007 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 |
*/
|
|
24 |
|
|
25 |
// This file specializes the assember with interpreter-specific macros
|
|
26 |
|
|
27 |
|
|
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 |
);
|
|
36 |
|
|
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 |
);
|
|
45 |
|
|
46 |
virtual void check_and_handle_popframe(Register java_thread);
|
|
47 |
virtual void check_and_handle_earlyret(Register java_thread);
|
|
48 |
|
|
49 |
// base routine for all dispatches
|
|
50 |
void dispatch_base(TosState state, address* table, bool verifyoop = true);
|
|
51 |
#endif /* CC_INTERP */
|
|
52 |
|
|
53 |
public:
|
|
54 |
InterpreterMacroAssembler(CodeBuffer* code) : MacroAssembler(code) {}
|
|
55 |
|
|
56 |
void load_earlyret_value(TosState state);
|
|
57 |
|
|
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 */ }
|
|
62 |
|
|
63 |
// Helpers for runtime call arguments/results
|
|
64 |
void get_method(Register reg);
|
|
65 |
|
|
66 |
#else
|
|
67 |
|
|
68 |
void save_bcp() { movl(Address(rbp, frame::interpreter_frame_bcx_offset * wordSize), rsi); }
|
|
69 |
void restore_bcp() { movl(rsi, Address(rbp, frame::interpreter_frame_bcx_offset * wordSize)); }
|
|
70 |
void restore_locals() { movl(rdi, Address(rbp, frame::interpreter_frame_locals_offset * wordSize)); }
|
|
71 |
|
|
72 |
// Helpers for runtime call arguments/results
|
|
73 |
void get_method(Register reg) { movl(reg, Address(rbp, frame::interpreter_frame_method_offset * wordSize)); }
|
|
74 |
void get_constant_pool(Register reg) { get_method(reg); movl(reg, Address(reg, methodOopDesc::constants_offset())); }
|
|
75 |
void get_constant_pool_cache(Register reg) { get_constant_pool(reg); movl(reg, Address(reg, constantPoolOopDesc::cache_offset_in_bytes())); }
|
|
76 |
void get_cpool_and_tags(Register cpool, Register tags) { get_constant_pool(cpool); movl(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);
|
|
80 |
void get_cache_entry_pointer_at_bcp(Register cache, Register tmp, int bcp_offset);
|
|
81 |
|
|
82 |
// Expression stack
|
|
83 |
void f2ieee(); // truncate ftos to 32bits
|
|
84 |
void d2ieee(); // truncate dtos to 64bits
|
|
85 |
#endif // CC_INTERP
|
|
86 |
|
|
87 |
|
|
88 |
void pop_ptr(Register r = rax);
|
|
89 |
void pop_ptr(Register r, Register tag);
|
|
90 |
void pop_i(Register r = rax);
|
|
91 |
void pop_l(Register lo = rax, Register hi = rdx);
|
|
92 |
void pop_f();
|
|
93 |
void pop_d();
|
|
94 |
void pop_ftos_to_rsp();
|
|
95 |
void pop_dtos_to_rsp();
|
|
96 |
|
|
97 |
void push_ptr(Register r = rax);
|
|
98 |
void push_ptr(Register r, Register tag);
|
|
99 |
void push_i(Register r = rax);
|
|
100 |
void push_l(Register lo = rax, Register hi = rdx);
|
|
101 |
void push_d(Register r = rax);
|
|
102 |
void push_f();
|
|
103 |
|
|
104 |
void pop(TosState state); // transition vtos -> state
|
|
105 |
void push(TosState state); // transition state -> vtos
|
|
106 |
|
|
107 |
DEBUG_ONLY(void verify_stack_tag(frame::Tag t);)
|
|
108 |
|
|
109 |
#ifndef CC_INTERP
|
|
110 |
|
|
111 |
void empty_expression_stack() {
|
|
112 |
movl(rsp, Address(rbp, frame::interpreter_frame_monitor_block_top_offset * wordSize));
|
|
113 |
// NULL last_sp until next java call
|
|
114 |
movl(Address(rbp, frame::interpreter_frame_last_sp_offset * wordSize), NULL_WORD);
|
|
115 |
}
|
|
116 |
|
|
117 |
// Tagged stack helpers for swap and dup
|
|
118 |
void load_ptr_and_tag(int n, Register val, Register tag);
|
|
119 |
void store_ptr_and_tag(int n, Register val, Register tag);
|
|
120 |
|
|
121 |
// Tagged Local support
|
|
122 |
|
|
123 |
void tag_local(frame::Tag tag, int n);
|
|
124 |
void tag_local(Register tag, int n);
|
|
125 |
void tag_local(frame::Tag tag, Register idx);
|
|
126 |
void tag_local(Register tag, Register idx);
|
|
127 |
|
|
128 |
#ifdef ASSERT
|
|
129 |
void verify_local_tag(frame::Tag tag, int n);
|
|
130 |
void verify_local_tag(frame::Tag tag, Register idx);
|
|
131 |
#endif // ASSERT
|
|
132 |
|
|
133 |
// Super call_VM calls - correspond to MacroAssembler::call_VM(_leaf) calls
|
|
134 |
void super_call_VM_leaf(address entry_point);
|
|
135 |
void super_call_VM_leaf(address entry_point, Register arg_1);
|
|
136 |
void super_call_VM_leaf(address entry_point, Register arg_1, Register arg_2);
|
|
137 |
void super_call_VM_leaf(address entry_point, Register arg_1, Register arg_2, Register arg_3);
|
|
138 |
|
|
139 |
// Generate a subtype check: branch to ok_is_subtype if sub_klass is
|
|
140 |
// a subtype of super_klass. EAX holds the super_klass. Blows ECX
|
|
141 |
// and EDI. Register sub_klass cannot be any of the above.
|
|
142 |
void gen_subtype_check( Register sub_klass, Label &ok_is_subtype );
|
|
143 |
|
|
144 |
// Dispatching
|
|
145 |
void dispatch_prolog(TosState state, int step = 0);
|
|
146 |
void dispatch_epilog(TosState state, int step = 0);
|
|
147 |
void dispatch_only(TosState state); // dispatch via rbx, (assume rbx, is loaded already)
|
|
148 |
void dispatch_only_normal(TosState state); // dispatch normal table via rbx, (assume rbx, is loaded already)
|
|
149 |
void dispatch_only_noverify(TosState state);
|
|
150 |
void dispatch_next(TosState state, int step = 0); // load rbx, from [esi + step] and dispatch via rbx,
|
|
151 |
void dispatch_via (TosState state, address* table); // load rbx, from [esi] and dispatch via rbx, and table
|
|
152 |
|
|
153 |
|
|
154 |
// jump to an invoked target
|
|
155 |
void jump_from_interpreted(Register method, Register temp);
|
|
156 |
|
|
157 |
// Returning from interpreted functions
|
|
158 |
//
|
|
159 |
// Removes the current activation (incl. unlocking of monitors)
|
|
160 |
// and sets up the return address. This code is also used for
|
|
161 |
// exception unwindwing. In that case, we do not want to throw
|
|
162 |
// IllegalMonitorStateExceptions, since that might get us into an
|
|
163 |
// infinite rethrow exception loop.
|
|
164 |
// Additionally this code is used for popFrame and earlyReturn.
|
|
165 |
// In popFrame case we want to skip throwing an exception,
|
|
166 |
// installing an exception, and notifying jvmdi.
|
|
167 |
// In earlyReturn case we only want to skip throwing an exception
|
|
168 |
// and installing an exception.
|
|
169 |
void remove_activation(TosState state, Register ret_addr,
|
|
170 |
bool throw_monitor_exception = true,
|
|
171 |
bool install_monitor_exception = true,
|
|
172 |
bool notify_jvmdi = true);
|
|
173 |
#endif /* !CC_INTERP */
|
|
174 |
|
|
175 |
// Debugging
|
|
176 |
void verify_oop(Register reg, TosState state = atos); // only if +VerifyOops && state == atos
|
|
177 |
#ifndef CC_INTERP
|
|
178 |
void verify_FPU(int stack_depth, TosState state = ftos); // only if +VerifyFPU && (state == ftos || state == dtos)
|
|
179 |
|
|
180 |
#endif /* !CC_INTERP */
|
|
181 |
|
|
182 |
// Object locking
|
|
183 |
void lock_object (Register lock_reg);
|
|
184 |
void unlock_object(Register lock_reg);
|
|
185 |
|
|
186 |
#ifndef CC_INTERP
|
|
187 |
|
|
188 |
// Interpreter profiling operations
|
|
189 |
void set_method_data_pointer_for_bcp();
|
|
190 |
void test_method_data_pointer(Register mdp, Label& zero_continue);
|
|
191 |
void verify_method_data_pointer();
|
|
192 |
|
|
193 |
void set_mdp_data_at(Register mdp_in, int constant, Register value);
|
|
194 |
void increment_mdp_data_at(Address data, bool decrement = false);
|
|
195 |
void increment_mdp_data_at(Register mdp_in, int constant,
|
|
196 |
bool decrement = false);
|
|
197 |
void increment_mdp_data_at(Register mdp_in, Register reg, int constant,
|
|
198 |
bool decrement = false);
|
|
199 |
void set_mdp_flag_at(Register mdp_in, int flag_constant);
|
|
200 |
void test_mdp_data_at(Register mdp_in, int offset, Register value,
|
|
201 |
Register test_value_out,
|
|
202 |
Label& not_equal_continue);
|
|
203 |
|
|
204 |
void record_klass_in_profile(Register receiver, Register mdp,
|
|
205 |
Register reg2);
|
|
206 |
void record_klass_in_profile_helper(Register receiver, Register mdp,
|
|
207 |
Register reg2,
|
|
208 |
int start_row, Label& done);
|
|
209 |
|
|
210 |
void update_mdp_by_offset(Register mdp_in, int offset_of_offset);
|
|
211 |
void update_mdp_by_offset(Register mdp_in, Register reg, int offset_of_disp);
|
|
212 |
void update_mdp_by_constant(Register mdp_in, int constant);
|
|
213 |
void update_mdp_for_ret(Register return_bci);
|
|
214 |
|
|
215 |
void profile_taken_branch(Register mdp, Register bumped_count);
|
|
216 |
void profile_not_taken_branch(Register mdp);
|
|
217 |
void profile_call(Register mdp);
|
|
218 |
void profile_final_call(Register mdp);
|
|
219 |
void profile_virtual_call(Register receiver, Register mdp, Register scratch2);
|
|
220 |
void profile_ret(Register return_bci, Register mdp);
|
|
221 |
void profile_null_seen(Register mdp);
|
|
222 |
void profile_typecheck(Register mdp, Register klass, Register scratch);
|
|
223 |
void profile_typecheck_failed(Register mdp);
|
|
224 |
void profile_switch_default(Register mdp);
|
|
225 |
void profile_switch_case(Register index_in_scratch, Register mdp, Register scratch2);
|
|
226 |
|
|
227 |
#endif /* !CC_INTERP */
|
|
228 |
|
|
229 |
typedef enum { NotifyJVMTI, SkipNotifyJVMTI } NotifyMethodExitMode;
|
|
230 |
|
|
231 |
// support for jvmti
|
|
232 |
void notify_method_entry();
|
|
233 |
void notify_method_exit(TosState state, NotifyMethodExitMode mode);
|
|
234 |
|
|
235 |
};
|