Mercurial > hg > graal-compiler
comparison src/cpu/x86/vm/interp_masm_x86_64.hpp @ 0:a61af66fc99e jdk7-b24
Initial load
author | duke |
---|---|
date | Sat, 01 Dec 2007 00:00:00 +0000 |
parents | |
children | dc7f315e41f7 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:a61af66fc99e |
---|---|
1 /* | |
2 * Copyright 2003-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 | |
29 : public MacroAssembler { | |
30 protected: | |
31 // Interpreter specific version of call_VM_base | |
32 virtual void call_VM_leaf_base(address entry_point, | |
33 int number_of_arguments); | |
34 | |
35 virtual void call_VM_base(Register oop_result, | |
36 Register java_thread, | |
37 Register last_java_sp, | |
38 address entry_point, | |
39 int number_of_arguments, | |
40 bool check_exceptions); | |
41 | |
42 virtual void check_and_handle_popframe(Register java_thread); | |
43 virtual void check_and_handle_earlyret(Register java_thread); | |
44 | |
45 // base routine for all dispatches | |
46 void dispatch_base(TosState state, address* table, bool verifyoop = true); | |
47 | |
48 public: | |
49 InterpreterMacroAssembler(CodeBuffer* code) | |
50 : MacroAssembler(code) | |
51 {} | |
52 | |
53 void load_earlyret_value(TosState state); | |
54 | |
55 // Interpreter-specific registers | |
56 void save_bcp() | |
57 { | |
58 movq(Address(rbp, frame::interpreter_frame_bcx_offset * wordSize), r13); | |
59 } | |
60 | |
61 void restore_bcp() | |
62 { | |
63 movq(r13, Address(rbp, frame::interpreter_frame_bcx_offset * wordSize)); | |
64 } | |
65 | |
66 void restore_locals() | |
67 { | |
68 movq(r14, Address(rbp, frame::interpreter_frame_locals_offset * wordSize)); | |
69 } | |
70 | |
71 // Helpers for runtime call arguments/results | |
72 void get_method(Register reg) | |
73 { | |
74 movq(reg, Address(rbp, frame::interpreter_frame_method_offset * wordSize)); | |
75 } | |
76 | |
77 void get_constant_pool(Register reg) | |
78 { | |
79 get_method(reg); | |
80 movq(reg, Address(reg, methodOopDesc::constants_offset())); | |
81 } | |
82 | |
83 void get_constant_pool_cache(Register reg) | |
84 { | |
85 get_constant_pool(reg); | |
86 movq(reg, Address(reg, constantPoolOopDesc::cache_offset_in_bytes())); | |
87 } | |
88 | |
89 void get_cpool_and_tags(Register cpool, Register tags) | |
90 { | |
91 get_constant_pool(cpool); | |
92 movq(tags, Address(cpool, constantPoolOopDesc::tags_offset_in_bytes())); | |
93 } | |
94 | |
95 void get_unsigned_2_byte_index_at_bcp(Register reg, int bcp_offset); | |
96 void get_cache_and_index_at_bcp(Register cache, Register index, | |
97 int bcp_offset); | |
98 void get_cache_entry_pointer_at_bcp(Register cache, Register tmp, | |
99 int bcp_offset); | |
100 | |
101 void pop_ptr(Register r = rax); | |
102 void pop_i(Register r = rax); | |
103 void pop_l(Register r = rax); | |
104 void pop_f(XMMRegister r = xmm0); | |
105 void pop_d(XMMRegister r = xmm0); | |
106 void push_ptr(Register r = rax); | |
107 void push_i(Register r = rax); | |
108 void push_l(Register r = rax); | |
109 void push_f(XMMRegister r = xmm0); | |
110 void push_d(XMMRegister r = xmm0); | |
111 | |
112 void pop(TosState state); // transition vtos -> state | |
113 void push(TosState state); // transition state -> vtos | |
114 | |
115 // Tagged stack support, pop and push both tag and value. | |
116 void pop_ptr(Register r, Register tag); | |
117 void push_ptr(Register r, Register tag); | |
118 | |
119 DEBUG_ONLY(void verify_stack_tag(frame::Tag t);) | |
120 | |
121 // Tagged stack helpers for swap and dup | |
122 void load_ptr_and_tag(int n, Register val, Register tag); | |
123 void store_ptr_and_tag(int n, Register val, Register tag); | |
124 | |
125 // Tagged Local support | |
126 void tag_local(frame::Tag tag, int n); | |
127 void tag_local(Register tag, int n); | |
128 void tag_local(frame::Tag tag, Register idx); | |
129 void tag_local(Register tag, Register idx); | |
130 | |
131 #ifdef ASSERT | |
132 void verify_local_tag(frame::Tag tag, int n); | |
133 void verify_local_tag(frame::Tag tag, Register idx); | |
134 #endif // ASSERT | |
135 | |
136 void empty_expression_stack() | |
137 { | |
138 movq(rsp, Address(rbp, frame::interpreter_frame_monitor_block_top_offset * | |
139 wordSize)); | |
140 // NULL last_sp until next java call | |
141 movptr(Address(rbp, frame::interpreter_frame_last_sp_offset * wordSize), NULL_WORD); | |
142 } | |
143 | |
144 // Super call_VM calls - correspond to MacroAssembler::call_VM(_leaf) calls | |
145 void super_call_VM_leaf(address entry_point); | |
146 void super_call_VM_leaf(address entry_point, Register arg_1); | |
147 void super_call_VM_leaf(address entry_point, Register arg_1, Register arg_2); | |
148 void super_call_VM_leaf(address entry_point, | |
149 Register arg_1, Register arg_2, Register arg_3); | |
150 | |
151 // Generate a subtype check: branch to ok_is_subtype if sub_klass is | |
152 // a subtype of super_klass. | |
153 void gen_subtype_check( Register sub_klass, Label &ok_is_subtype ); | |
154 | |
155 // Dispatching | |
156 void dispatch_prolog(TosState state, int step = 0); | |
157 void dispatch_epilog(TosState state, int step = 0); | |
158 // dispatch via ebx (assume ebx is loaded already) | |
159 void dispatch_only(TosState state); | |
160 // dispatch normal table via ebx (assume ebx is loaded already) | |
161 void dispatch_only_normal(TosState state); | |
162 void dispatch_only_noverify(TosState state); | |
163 // load ebx from [esi + step] and dispatch via ebx | |
164 void dispatch_next(TosState state, int step = 0); | |
165 // load ebx from [esi] and dispatch via ebx and table | |
166 void dispatch_via (TosState state, address* table); | |
167 | |
168 // jump to an invoked target | |
169 void jump_from_interpreted(Register method, Register temp); | |
170 | |
171 | |
172 // Returning from interpreted functions | |
173 // | |
174 // Removes the current activation (incl. unlocking of monitors) | |
175 // and sets up the return address. This code is also used for | |
176 // exception unwindwing. In that case, we do not want to throw | |
177 // IllegalMonitorStateExceptions, since that might get us into an | |
178 // infinite rethrow exception loop. | |
179 // Additionally this code is used for popFrame and earlyReturn. | |
180 // In popFrame case we want to skip throwing an exception, | |
181 // installing an exception, and notifying jvmdi. | |
182 // In earlyReturn case we only want to skip throwing an exception | |
183 // and installing an exception. | |
184 void remove_activation(TosState state, Register ret_addr, | |
185 bool throw_monitor_exception = true, | |
186 bool install_monitor_exception = true, | |
187 bool notify_jvmdi = true); | |
188 | |
189 // Object locking | |
190 void lock_object (Register lock_reg); | |
191 void unlock_object(Register lock_reg); | |
192 | |
193 // Interpreter profiling operations | |
194 void set_method_data_pointer_for_bcp(); | |
195 void test_method_data_pointer(Register mdp, Label& zero_continue); | |
196 void verify_method_data_pointer(); | |
197 | |
198 void set_mdp_data_at(Register mdp_in, int constant, Register value); | |
199 void increment_mdp_data_at(Address data, bool decrement = false); | |
200 void increment_mdp_data_at(Register mdp_in, int constant, | |
201 bool decrement = false); | |
202 void increment_mdp_data_at(Register mdp_in, Register reg, int constant, | |
203 bool decrement = false); | |
204 void set_mdp_flag_at(Register mdp_in, int flag_constant); | |
205 void test_mdp_data_at(Register mdp_in, int offset, Register value, | |
206 Register test_value_out, | |
207 Label& not_equal_continue); | |
208 | |
209 void record_klass_in_profile(Register receiver, Register mdp, | |
210 Register reg2); | |
211 void record_klass_in_profile_helper(Register receiver, Register mdp, | |
212 Register reg2, | |
213 int start_row, Label& done); | |
214 | |
215 void update_mdp_by_offset(Register mdp_in, int offset_of_offset); | |
216 void update_mdp_by_offset(Register mdp_in, Register reg, int offset_of_disp); | |
217 void update_mdp_by_constant(Register mdp_in, int constant); | |
218 void update_mdp_for_ret(Register return_bci); | |
219 | |
220 void profile_taken_branch(Register mdp, Register bumped_count); | |
221 void profile_not_taken_branch(Register mdp); | |
222 void profile_call(Register mdp); | |
223 void profile_final_call(Register mdp); | |
224 void profile_virtual_call(Register receiver, Register mdp, | |
225 Register scratch2); | |
226 void profile_ret(Register return_bci, Register mdp); | |
227 void profile_null_seen(Register mdp); | |
228 void profile_typecheck(Register mdp, Register klass, Register scratch); | |
229 void profile_typecheck_failed(Register mdp); | |
230 void profile_switch_default(Register mdp); | |
231 void profile_switch_case(Register index_in_scratch, Register mdp, | |
232 Register scratch2); | |
233 | |
234 // Debugging | |
235 // only if +VerifyOops && state == atos | |
236 void verify_oop(Register reg, TosState state = atos); | |
237 // only if +VerifyFPU && (state == ftos || state == dtos) | |
238 void verify_FPU(int stack_depth, TosState state = ftos); | |
239 | |
240 typedef enum { NotifyJVMTI, SkipNotifyJVMTI } NotifyMethodExitMode; | |
241 | |
242 // support for jvmti/dtrace | |
243 void notify_method_entry(); | |
244 void notify_method_exit(TosState state, NotifyMethodExitMode mode); | |
245 }; |