< prev index next >
src/cpu/x86/vm/templateInterpreterGenerator_x86_32.cpp
Print this page
@@ -24,16 +24,30 @@
#include "precompiled.hpp"
#include "asm/macroAssembler.hpp"
#include "interpreter/interp_masm.hpp"
#include "interpreter/interpreter.hpp"
+#include "interpreter/interpreterRuntime.hpp"
#include "interpreter/templateInterpreterGenerator.hpp"
#include "runtime/arguments.hpp"
+#include "runtime/sharedRuntime.hpp"
#define __ _masm->
+address TemplateInterpreterGenerator::generate_slow_signature_handler() {
+ address entry = __ pc();
+ // rbx,: method
+ // rcx: temporary
+ // rdi: pointer to locals
+ // rsp: end of copied parameters area
+ __ mov(rcx, rsp);
+ __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::slow_signature_handler), rbx, rdi, rcx);
+ __ ret(0);
+ return entry;
+}
+
/**
* Method entry for static native methods:
* int java.util.zip.CRC32.update(int crc, int b)
*/
address TemplateInterpreterGenerator::generate_CRC32_update_entry() {
@@ -299,5 +313,102 @@
return entry;
}
return NULL;
}
+
+address TemplateInterpreterGenerator::generate_math_entry(AbstractInterpreter::MethodKind kind) {
+
+ // rbx,: Method*
+ // rcx: scratrch
+ // rsi: sender sp
+
+ if (!InlineIntrinsics) return NULL; // Generate a vanilla entry
+
+ address entry_point = __ pc();
+
+ // These don't need a safepoint check because they aren't virtually
+ // callable. We won't enter these intrinsics from compiled code.
+ // If in the future we added an intrinsic which was virtually callable
+ // we'd have to worry about how to safepoint so that this code is used.
+
+ // mathematical functions inlined by compiler
+ // (interpreter must provide identical implementation
+ // in order to avoid monotonicity bugs when switching
+ // from interpreter to compiler in the middle of some
+ // computation)
+ //
+ // stack: [ ret adr ] <-- rsp
+ // [ lo(arg) ]
+ // [ hi(arg) ]
+ //
+
+ __ fld_d(Address(rsp, 1*wordSize));
+ switch (kind) {
+ case Interpreter::java_lang_math_sin :
+ __ trigfunc('s');
+ break;
+ case Interpreter::java_lang_math_cos :
+ __ trigfunc('c');
+ break;
+ case Interpreter::java_lang_math_tan :
+ __ trigfunc('t');
+ break;
+ case Interpreter::java_lang_math_sqrt:
+ __ fsqrt();
+ break;
+ case Interpreter::java_lang_math_abs:
+ __ fabs();
+ break;
+ case Interpreter::java_lang_math_log:
+ __ subptr(rsp, 2 * wordSize);
+ __ fstp_d(Address(rsp, 0));
+ if (VM_Version::supports_sse2()) {
+ __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dlog())));
+ }
+ else {
+ __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, SharedRuntime::dlog)));
+ }
+ __ addptr(rsp, 2 * wordSize);
+ break;
+ case Interpreter::java_lang_math_log10:
+ __ flog10();
+ // Store to stack to convert 80bit precision back to 64bits
+ __ push_fTOS();
+ __ pop_fTOS();
+ break;
+ case Interpreter::java_lang_math_pow:
+ __ fld_d(Address(rsp, 3*wordSize)); // second argument
+ __ pow_with_fallback(0);
+ // Store to stack to convert 80bit precision back to 64bits
+ __ push_fTOS();
+ __ pop_fTOS();
+ break;
+ case Interpreter::java_lang_math_exp:
+ __ subptr(rsp, 2*wordSize);
+ __ fstp_d(Address(rsp, 0));
+ if (VM_Version::supports_sse2()) {
+ __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dexp())));
+ } else {
+ __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, SharedRuntime::dexp)));
+ }
+ __ addptr(rsp, 2*wordSize);
+ break;
+ default :
+ ShouldNotReachHere();
+ }
+
+ // return double result in xmm0 for interpreter and compilers.
+ if (UseSSE >= 2) {
+ __ subptr(rsp, 2*wordSize);
+ __ fstp_d(Address(rsp, 0));
+ __ movdbl(xmm0, Address(rsp, 0));
+ __ addptr(rsp, 2*wordSize);
+ }
+
+ // done, result in FPU ST(0) or XMM0
+ __ pop(rdi); // get return address
+ __ mov(rsp, rsi); // set sp to sender sp
+ __ jmp(rdi);
+
+ return entry_point;
+}
< prev index next >