10 * This code is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * version 2 for more details (a copy is included in the LICENSE file that
14 * accompanied this code).
15 *
16 * You should have received a copy of the GNU General Public License version
17 * 2 along with this work; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19 *
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21 * or visit www.oracle.com if you need additional information or have any
22 * questions.
23 *
24 */
25
26 #include "precompiled.hpp"
27 #include "asm/macroAssembler.hpp"
28 #include "interpreter/bytecodeHistogram.hpp"
29 #include "interpreter/interpreter.hpp"
30 #include "interpreter/interpreterGenerator.hpp"
31 #include "interpreter/interpreterRuntime.hpp"
32 #include "interpreter/interp_masm.hpp"
33 #include "interpreter/templateTable.hpp"
34 #include "oops/arrayOop.hpp"
35 #include "oops/methodData.hpp"
36 #include "oops/method.hpp"
37 #include "oops/oop.inline.hpp"
38 #include "prims/jvmtiExport.hpp"
39 #include "prims/jvmtiThreadState.hpp"
40 #include "prims/methodHandles.hpp"
41 #include "runtime/arguments.hpp"
42 #include "runtime/frame.inline.hpp"
43 #include "runtime/sharedRuntime.hpp"
44 #include "runtime/stubRoutines.hpp"
45 #include "runtime/synchronizer.hpp"
46 #include "runtime/timer.hpp"
47 #include "runtime/vframeArray.hpp"
48 #include "utilities/debug.hpp"
49 #ifdef COMPILER1
50 #include "c1/c1_Runtime1.hpp"
51 #endif
52
106 // c_rarg0 contains the result from the call of
107 // InterpreterRuntime::slow_signature_handler so we don't touch it
108 // here. It will be loaded with the JNIEnv* later.
109 __ ldr(c_rarg1, Address(sp, 1 * wordSize));
110 for (int i = c_rarg2->encoding(); i <= c_rarg7->encoding(); i += 2) {
111 Register rm = as_Register(i), rn = as_Register(i+1);
112 __ ldp(rm, rn, Address(sp, i * wordSize));
113 }
114
115 __ add(sp, sp, 18 * wordSize);
116 __ ret(lr);
117
118 return entry;
119 }
120
121
122 //
123 // Various method entries
124 //
125
126 address InterpreterGenerator::generate_math_entry(AbstractInterpreter::MethodKind kind) {
127 // rmethod: Method*
128 // r13: sender sp
129 // esp: args
130
131 if (!InlineIntrinsics) return NULL; // Generate a vanilla entry
132
133 // These don't need a safepoint check because they aren't virtually
134 // callable. We won't enter these intrinsics from compiled code.
135 // If in the future we added an intrinsic which was virtually callable
136 // we'd have to worry about how to safepoint so that this code is used.
137
138 // mathematical functions inlined by compiler
139 // (interpreter must provide identical implementation
140 // in order to avoid monotonicity bugs when switching
141 // from interpreter to compiler in the middle of some
142 // computation)
143 //
144 // stack:
145 // [ arg ] <-- esp
146 // [ arg ]
185 break;
186 default:
187 ;
188 }
189 if (entry_point) {
190 __ br(continuation);
191 }
192
193 return entry_point;
194 }
195
196 // double trigonometrics and transcendentals
197 // static jdouble dsin(jdouble x);
198 // static jdouble dcos(jdouble x);
199 // static jdouble dtan(jdouble x);
200 // static jdouble dlog(jdouble x);
201 // static jdouble dlog10(jdouble x);
202 // static jdouble dexp(jdouble x);
203 // static jdouble dpow(jdouble x, jdouble y);
204
205 void InterpreterGenerator::generate_transcendental_entry(AbstractInterpreter::MethodKind kind, int fpargs) {
206 address fn;
207 switch (kind) {
208 case Interpreter::java_lang_math_sin :
209 fn = CAST_FROM_FN_PTR(address, SharedRuntime::dsin);
210 break;
211 case Interpreter::java_lang_math_cos :
212 fn = CAST_FROM_FN_PTR(address, SharedRuntime::dcos);
213 break;
214 case Interpreter::java_lang_math_tan :
215 fn = CAST_FROM_FN_PTR(address, SharedRuntime::dtan);
216 break;
217 case Interpreter::java_lang_math_log :
218 fn = CAST_FROM_FN_PTR(address, SharedRuntime::dlog);
219 break;
220 case Interpreter::java_lang_math_log10 :
221 fn = CAST_FROM_FN_PTR(address, SharedRuntime::dlog10);
222 break;
223 case Interpreter::java_lang_math_exp :
224 fn = CAST_FROM_FN_PTR(address, SharedRuntime::dexp);
225 break;
226 case Interpreter::java_lang_math_pow :
227 fpargs = 2;
228 fn = CAST_FROM_FN_PTR(address, SharedRuntime::dpow);
229 break;
230 default:
231 ShouldNotReachHere();
232 }
233 const int gpargs = 0, rtype = 3;
234 __ mov(rscratch1, fn);
235 __ blrt(rscratch1, gpargs, fpargs, rtype);
236 }
237
238 // Abstract method entry
239 // Attempt to execute abstract method. Throw exception
240 address InterpreterGenerator::generate_abstract_entry(void) {
241 // rmethod: Method*
242 // r13: sender SP
243
244 address entry_point = __ pc();
245
246 // abstract method entry
247
248 // pop return address, reset last_sp to NULL
249 __ empty_expression_stack();
250 __ restore_bcp(); // bcp must be correct for exception handler (was destroyed)
251 __ restore_locals(); // make sure locals pointer is correct as well (was destroyed)
252
253 // throw exception
254 __ call_VM(noreg, CAST_FROM_FN_PTR(address,
255 InterpreterRuntime::throw_AbstractMethodError));
256 // the call_VM checks for exception, so we should never return here.
257 __ should_not_reach_here();
258
259 return entry_point;
260 }
|
10 * This code is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * version 2 for more details (a copy is included in the LICENSE file that
14 * accompanied this code).
15 *
16 * You should have received a copy of the GNU General Public License version
17 * 2 along with this work; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19 *
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21 * or visit www.oracle.com if you need additional information or have any
22 * questions.
23 *
24 */
25
26 #include "precompiled.hpp"
27 #include "asm/macroAssembler.hpp"
28 #include "interpreter/bytecodeHistogram.hpp"
29 #include "interpreter/interpreter.hpp"
30 #include "interpreter/interpreterRuntime.hpp"
31 #include "interpreter/interp_masm.hpp"
32 #include "interpreter/templateInterpreterGenerator.hpp"
33 #include "interpreter/templateTable.hpp"
34 #include "oops/arrayOop.hpp"
35 #include "oops/methodData.hpp"
36 #include "oops/method.hpp"
37 #include "oops/oop.inline.hpp"
38 #include "prims/jvmtiExport.hpp"
39 #include "prims/jvmtiThreadState.hpp"
40 #include "prims/methodHandles.hpp"
41 #include "runtime/arguments.hpp"
42 #include "runtime/frame.inline.hpp"
43 #include "runtime/sharedRuntime.hpp"
44 #include "runtime/stubRoutines.hpp"
45 #include "runtime/synchronizer.hpp"
46 #include "runtime/timer.hpp"
47 #include "runtime/vframeArray.hpp"
48 #include "utilities/debug.hpp"
49 #ifdef COMPILER1
50 #include "c1/c1_Runtime1.hpp"
51 #endif
52
106 // c_rarg0 contains the result from the call of
107 // InterpreterRuntime::slow_signature_handler so we don't touch it
108 // here. It will be loaded with the JNIEnv* later.
109 __ ldr(c_rarg1, Address(sp, 1 * wordSize));
110 for (int i = c_rarg2->encoding(); i <= c_rarg7->encoding(); i += 2) {
111 Register rm = as_Register(i), rn = as_Register(i+1);
112 __ ldp(rm, rn, Address(sp, i * wordSize));
113 }
114
115 __ add(sp, sp, 18 * wordSize);
116 __ ret(lr);
117
118 return entry;
119 }
120
121
122 //
123 // Various method entries
124 //
125
126 address TemplateInterpreterGenerator::generate_math_entry(AbstractInterpreter::MethodKind kind) {
127 // rmethod: Method*
128 // r13: sender sp
129 // esp: args
130
131 if (!InlineIntrinsics) return NULL; // Generate a vanilla entry
132
133 // These don't need a safepoint check because they aren't virtually
134 // callable. We won't enter these intrinsics from compiled code.
135 // If in the future we added an intrinsic which was virtually callable
136 // we'd have to worry about how to safepoint so that this code is used.
137
138 // mathematical functions inlined by compiler
139 // (interpreter must provide identical implementation
140 // in order to avoid monotonicity bugs when switching
141 // from interpreter to compiler in the middle of some
142 // computation)
143 //
144 // stack:
145 // [ arg ] <-- esp
146 // [ arg ]
185 break;
186 default:
187 ;
188 }
189 if (entry_point) {
190 __ br(continuation);
191 }
192
193 return entry_point;
194 }
195
196 // double trigonometrics and transcendentals
197 // static jdouble dsin(jdouble x);
198 // static jdouble dcos(jdouble x);
199 // static jdouble dtan(jdouble x);
200 // static jdouble dlog(jdouble x);
201 // static jdouble dlog10(jdouble x);
202 // static jdouble dexp(jdouble x);
203 // static jdouble dpow(jdouble x, jdouble y);
204
205 void TemplateInterpreterGenerator::generate_transcendental_entry(AbstractInterpreter::MethodKind kind, int fpargs) {
206 address fn;
207 switch (kind) {
208 case Interpreter::java_lang_math_sin :
209 fn = CAST_FROM_FN_PTR(address, SharedRuntime::dsin);
210 break;
211 case Interpreter::java_lang_math_cos :
212 fn = CAST_FROM_FN_PTR(address, SharedRuntime::dcos);
213 break;
214 case Interpreter::java_lang_math_tan :
215 fn = CAST_FROM_FN_PTR(address, SharedRuntime::dtan);
216 break;
217 case Interpreter::java_lang_math_log :
218 fn = CAST_FROM_FN_PTR(address, SharedRuntime::dlog);
219 break;
220 case Interpreter::java_lang_math_log10 :
221 fn = CAST_FROM_FN_PTR(address, SharedRuntime::dlog10);
222 break;
223 case Interpreter::java_lang_math_exp :
224 fn = CAST_FROM_FN_PTR(address, SharedRuntime::dexp);
225 break;
226 case Interpreter::java_lang_math_pow :
227 fpargs = 2;
228 fn = CAST_FROM_FN_PTR(address, SharedRuntime::dpow);
229 break;
230 default:
231 ShouldNotReachHere();
232 }
233 const int gpargs = 0, rtype = 3;
234 __ mov(rscratch1, fn);
235 __ blrt(rscratch1, gpargs, fpargs, rtype);
236 }
237
238 // Abstract method entry
239 // Attempt to execute abstract method. Throw exception
240 address TemplateInterpreterGenerator::generate_abstract_entry(void) {
241 // rmethod: Method*
242 // r13: sender SP
243
244 address entry_point = __ pc();
245
246 // abstract method entry
247
248 // pop return address, reset last_sp to NULL
249 __ empty_expression_stack();
250 __ restore_bcp(); // bcp must be correct for exception handler (was destroyed)
251 __ restore_locals(); // make sure locals pointer is correct as well (was destroyed)
252
253 // throw exception
254 __ call_VM(noreg, CAST_FROM_FN_PTR(address,
255 InterpreterRuntime::throw_AbstractMethodError));
256 // the call_VM checks for exception, so we should never return here.
257 __ should_not_reach_here();
258
259 return entry_point;
260 }
|