1 #ifdef USE_PRAGMA_IDENT_SRC
2 #pragma ident "@(#)interpreter_x86_32.cpp 1.378 07/09/17 09:26:02 JVM"
3 #endif
4 /*
5 * Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved.
6 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7 *
8 * This code is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License version 2 only, as
10 * published by the Free Software Foundation.
11 *
12 * This code is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 * version 2 for more details (a copy is included in the LICENSE file that
16 * accompanied this code).
17 *
18 * You should have received a copy of the GNU General Public License version
19 * 2 along with this work; if not, write to the Free Software Foundation,
20 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
21 *
22 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
23 * CA 95054 USA or visit www.sun.com if you need additional information or
24 * have any questions.
25 *
26 */
27
28 #include "incls/_precompiled.incl"
29 #include "incls/_interpreter_x86_32.cpp.incl"
30
31 #define __ _masm->
32
33 // Initialize the sentinel used to distinguish an interpreter return address.
34 const int Interpreter::return_sentinel = 0xfeedbeed;
35
36 //------------------------------------------------------------------------------------------------------------------------
37
38 address AbstractInterpreterGenerator::generate_slow_signature_handler() {
39 address entry = __ pc();
40 // rbx,: method
41 // rcx: temporary
42 // rdi: pointer to locals
43 // rsp: end of copied parameters area
44 __ movl(rcx, rsp);
45 __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::slow_signature_handler), rbx, rdi, rcx);
46 __ ret(0);
47 return entry;
48 }
49
50
51 //
52 // Various method entries (that c++ and asm interpreter agree upon)
53 //------------------------------------------------------------------------------------------------------------------------
54 //
55 //
56
57 // Empty method, generate a very fast return.
58
59 address InterpreterGenerator::generate_empty_entry(void) {
60
61 // rbx,: methodOop
62 // rcx: receiver (unused)
63 // rsi: previous interpreter state (C++ interpreter) must preserve
64 // rsi: sender sp must set sp to this value on return
65
66 if (!UseFastEmptyMethods) return NULL;
67
68 address entry_point = __ pc();
69
70 // If we need a safepoint check, generate full interpreter entry.
71 Label slow_path;
72 ExternalAddress state(SafepointSynchronize::address_of_state());
73 __ cmp32(ExternalAddress(SafepointSynchronize::address_of_state()),
74 SafepointSynchronize::_not_synchronized);
75 __ jcc(Assembler::notEqual, slow_path);
76
77 // do nothing for empty methods (do not even increment invocation counter)
78 // Code: _return
79 // _return
80 // return w/o popping parameters
81 __ popl(rax);
82 __ movl(rsp, rsi);
83 __ jmp(rax);
84
85 __ bind(slow_path);
86 (void) generate_normal_entry(false);
87 return entry_point;
88 }
89
90 address InterpreterGenerator::generate_math_entry(AbstractInterpreter::MethodKind kind) {
91
92 // rbx,: methodOop
93 // rcx: scratrch
94 // rsi: sender sp
95
96 if (!InlineIntrinsics) return NULL; // Generate a vanilla entry
97
98 address entry_point = __ pc();
99
100 // These don't need a safepoint check because they aren't virtually
101 // callable. We won't enter these intrinsics from compiled code.
102 // If in the future we added an intrinsic which was virtually callable
121 // not work for JDK 1.2.
122 //
123 // We no longer need to check for JDK 1.2 since it's EOL'ed.
124 // The following check existed in pre 1.6 implementation,
125 // if (Universe::is_jdk12x_version()) {
126 // __ should_not_reach_here();
127 // }
128 // Universe::is_jdk12x_version() always returns false since
129 // the JDK version is not yet determined when this method is called.
130 // This method is called during interpreter_init() whereas
131 // JDK version is only determined when universe2_init() is called.
132
133 // Note: For JDK 1.3 StrictMath exists and Math.sin/cos/sqrt are
134 // java methods. Interpreter::method_kind(...) will select
135 // this entry point for the corresponding methods in JDK 1.3.
136 // get argument
137 if (TaggedStackInterpreter) {
138 __ pushl(Address(rsp, 3*wordSize)); // push hi (and note rsp -= wordSize)
139 __ pushl(Address(rsp, 2*wordSize)); // push lo
140 __ fld_d(Address(rsp, 0)); // get double in ST0
141 __ addl(rsp, 2*wordSize);
142 } else {
143 __ fld_d(Address(rsp, 1*wordSize));
144 }
145 switch (kind) {
146 case Interpreter::java_lang_math_sin :
147 __ trigfunc('s');
148 break;
149 case Interpreter::java_lang_math_cos :
150 __ trigfunc('c');
151 break;
152 case Interpreter::java_lang_math_tan :
153 __ trigfunc('t');
154 break;
155 case Interpreter::java_lang_math_sqrt:
156 __ fsqrt();
157 break;
158 case Interpreter::java_lang_math_abs:
159 __ fabs();
160 break;
161 case Interpreter::java_lang_math_log:
162 __ flog();
163 // Store to stack to convert 80bit precision back to 64bits
164 __ push_fTOS();
165 __ pop_fTOS();
166 break;
167 case Interpreter::java_lang_math_log10:
168 __ flog10();
169 // Store to stack to convert 80bit precision back to 64bits
170 __ push_fTOS();
171 __ pop_fTOS();
172 break;
173 default :
174 ShouldNotReachHere();
175 }
176
177 // return double result in xmm0 for interpreter and compilers.
178 if (UseSSE >= 2) {
179 __ subl(rsp, 2*wordSize);
180 __ fstp_d(Address(rsp, 0));
181 __ movdbl(xmm0, Address(rsp, 0));
182 __ addl(rsp, 2*wordSize);
183 }
184
185 // done, result in FPU ST(0) or XMM0
186 __ popl(rdi); // get return address
187 __ movl(rsp, rsi); // set sp to sender sp
188 __ jmp(rdi);
189
190 return entry_point;
191 }
192
193
194 // Abstract method entry
195 // Attempt to execute abstract method. Throw exception
196 address InterpreterGenerator::generate_abstract_entry(void) {
197
198 // rbx,: methodOop
199 // rcx: receiver (unused)
200 // rsi: previous interpreter state (C++ interpreter) must preserve
201
202 // rsi: sender SP
203
204 address entry_point = __ pc();
205
206 // abstract method entry
207 // remove return address. Not really needed, since exception handling throws away expression stack
208 __ popl(rbx);
209
210 // adjust stack to what a normal return would do
211 __ movl(rsp, rsi);
212 // throw exception
213 __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::throw_AbstractMethodError));
214 // the call_VM checks for exception, so we should never return here.
215 __ should_not_reach_here();
216
217 return entry_point;
218 }
219
220 // This method tells the deoptimizer how big an interpreted frame must be:
221 int AbstractInterpreter::size_activation(methodOop method,
222 int tempcount,
223 int popframe_extra_args,
224 int moncount,
225 int callee_param_count,
226 int callee_locals,
227 bool is_top_frame) {
228 return layout_activation(method,
229 tempcount,
230 popframe_extra_args,
231 moncount,
234 (frame*) NULL,
235 (frame*) NULL,
236 is_top_frame);
237 }
238
239 void Deoptimization::unwind_callee_save_values(frame* f, vframeArray* vframe_array) {
240
241 // This code is sort of the equivalent of C2IAdapter::setup_stack_frame back in
242 // the days we had adapter frames. When we deoptimize a situation where a
243 // compiled caller calls a compiled caller will have registers it expects
244 // to survive the call to the callee. If we deoptimize the callee the only
245 // way we can restore these registers is to have the oldest interpreter
246 // frame that we create restore these values. That is what this routine
247 // will accomplish.
248
249 // At the moment we have modified c2 to not have any callee save registers
250 // so this problem does not exist and this routine is just a place holder.
251
252 assert(f->is_interpreted_frame(), "must be interpreted");
253 }
254
255
|
1 /*
2 * Copyright 1997-2008 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 #include "incls/_precompiled.incl"
26 #include "incls/_interpreter_x86_32.cpp.incl"
27
28 #define __ _masm->
29
30 // Initialize the sentinel used to distinguish an interpreter return address.
31 const int Interpreter::return_sentinel = 0xfeedbeed;
32
33 //------------------------------------------------------------------------------------------------------------------------
34
35 address AbstractInterpreterGenerator::generate_slow_signature_handler() {
36 address entry = __ pc();
37 // rbx,: method
38 // rcx: temporary
39 // rdi: pointer to locals
40 // rsp: end of copied parameters area
41 __ mov(rcx, rsp);
42 __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::slow_signature_handler), rbx, rdi, rcx);
43 __ ret(0);
44 return entry;
45 }
46
47
48 //
49 // Various method entries (that c++ and asm interpreter agree upon)
50 //------------------------------------------------------------------------------------------------------------------------
51 //
52 //
53
54 // Empty method, generate a very fast return.
55
56 address InterpreterGenerator::generate_empty_entry(void) {
57
58 // rbx,: methodOop
59 // rcx: receiver (unused)
60 // rsi: previous interpreter state (C++ interpreter) must preserve
61 // rsi: sender sp must set sp to this value on return
62
63 if (!UseFastEmptyMethods) return NULL;
64
65 address entry_point = __ pc();
66
67 // If we need a safepoint check, generate full interpreter entry.
68 Label slow_path;
69 ExternalAddress state(SafepointSynchronize::address_of_state());
70 __ cmp32(ExternalAddress(SafepointSynchronize::address_of_state()),
71 SafepointSynchronize::_not_synchronized);
72 __ jcc(Assembler::notEqual, slow_path);
73
74 // do nothing for empty methods (do not even increment invocation counter)
75 // Code: _return
76 // _return
77 // return w/o popping parameters
78 __ pop(rax);
79 __ mov(rsp, rsi);
80 __ jmp(rax);
81
82 __ bind(slow_path);
83 (void) generate_normal_entry(false);
84 return entry_point;
85 }
86
87 address InterpreterGenerator::generate_math_entry(AbstractInterpreter::MethodKind kind) {
88
89 // rbx,: methodOop
90 // rcx: scratrch
91 // rsi: sender sp
92
93 if (!InlineIntrinsics) return NULL; // Generate a vanilla entry
94
95 address entry_point = __ pc();
96
97 // These don't need a safepoint check because they aren't virtually
98 // callable. We won't enter these intrinsics from compiled code.
99 // If in the future we added an intrinsic which was virtually callable
118 // not work for JDK 1.2.
119 //
120 // We no longer need to check for JDK 1.2 since it's EOL'ed.
121 // The following check existed in pre 1.6 implementation,
122 // if (Universe::is_jdk12x_version()) {
123 // __ should_not_reach_here();
124 // }
125 // Universe::is_jdk12x_version() always returns false since
126 // the JDK version is not yet determined when this method is called.
127 // This method is called during interpreter_init() whereas
128 // JDK version is only determined when universe2_init() is called.
129
130 // Note: For JDK 1.3 StrictMath exists and Math.sin/cos/sqrt are
131 // java methods. Interpreter::method_kind(...) will select
132 // this entry point for the corresponding methods in JDK 1.3.
133 // get argument
134 if (TaggedStackInterpreter) {
135 __ pushl(Address(rsp, 3*wordSize)); // push hi (and note rsp -= wordSize)
136 __ pushl(Address(rsp, 2*wordSize)); // push lo
137 __ fld_d(Address(rsp, 0)); // get double in ST0
138 __ addptr(rsp, 2*wordSize);
139 } else {
140 __ fld_d(Address(rsp, 1*wordSize));
141 }
142 switch (kind) {
143 case Interpreter::java_lang_math_sin :
144 __ trigfunc('s');
145 break;
146 case Interpreter::java_lang_math_cos :
147 __ trigfunc('c');
148 break;
149 case Interpreter::java_lang_math_tan :
150 __ trigfunc('t');
151 break;
152 case Interpreter::java_lang_math_sqrt:
153 __ fsqrt();
154 break;
155 case Interpreter::java_lang_math_abs:
156 __ fabs();
157 break;
158 case Interpreter::java_lang_math_log:
159 __ flog();
160 // Store to stack to convert 80bit precision back to 64bits
161 __ push_fTOS();
162 __ pop_fTOS();
163 break;
164 case Interpreter::java_lang_math_log10:
165 __ flog10();
166 // Store to stack to convert 80bit precision back to 64bits
167 __ push_fTOS();
168 __ pop_fTOS();
169 break;
170 default :
171 ShouldNotReachHere();
172 }
173
174 // return double result in xmm0 for interpreter and compilers.
175 if (UseSSE >= 2) {
176 __ subptr(rsp, 2*wordSize);
177 __ fstp_d(Address(rsp, 0));
178 __ movdbl(xmm0, Address(rsp, 0));
179 __ addptr(rsp, 2*wordSize);
180 }
181
182 // done, result in FPU ST(0) or XMM0
183 __ pop(rdi); // get return address
184 __ mov(rsp, rsi); // set sp to sender sp
185 __ jmp(rdi);
186
187 return entry_point;
188 }
189
190
191 // Abstract method entry
192 // Attempt to execute abstract method. Throw exception
193 address InterpreterGenerator::generate_abstract_entry(void) {
194
195 // rbx,: methodOop
196 // rcx: receiver (unused)
197 // rsi: previous interpreter state (C++ interpreter) must preserve
198
199 // rsi: sender SP
200
201 address entry_point = __ pc();
202
203 // abstract method entry
204 // remove return address. Not really needed, since exception handling throws away expression stack
205 __ pop(rbx);
206
207 // adjust stack to what a normal return would do
208 __ mov(rsp, rsi);
209 // throw exception
210 __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::throw_AbstractMethodError));
211 // the call_VM checks for exception, so we should never return here.
212 __ should_not_reach_here();
213
214 return entry_point;
215 }
216
217 // This method tells the deoptimizer how big an interpreted frame must be:
218 int AbstractInterpreter::size_activation(methodOop method,
219 int tempcount,
220 int popframe_extra_args,
221 int moncount,
222 int callee_param_count,
223 int callee_locals,
224 bool is_top_frame) {
225 return layout_activation(method,
226 tempcount,
227 popframe_extra_args,
228 moncount,
231 (frame*) NULL,
232 (frame*) NULL,
233 is_top_frame);
234 }
235
236 void Deoptimization::unwind_callee_save_values(frame* f, vframeArray* vframe_array) {
237
238 // This code is sort of the equivalent of C2IAdapter::setup_stack_frame back in
239 // the days we had adapter frames. When we deoptimize a situation where a
240 // compiled caller calls a compiled caller will have registers it expects
241 // to survive the call to the callee. If we deoptimize the callee the only
242 // way we can restore these registers is to have the oldest interpreter
243 // frame that we create restore these values. That is what this routine
244 // will accomplish.
245
246 // At the moment we have modified c2 to not have any callee save registers
247 // so this problem does not exist and this routine is just a place holder.
248
249 assert(f->is_interpreted_frame(), "must be interpreted");
250 }
|