< prev index next >

src/cpu/x86/vm/templateInterpreterGenerator_x86_64.cpp

Print this page




 360 
 361   // mathematical functions inlined by compiler
 362   // (interpreter must provide identical implementation
 363   // in order to avoid monotonicity bugs when switching
 364   // from interpreter to compiler in the middle of some
 365   // computation)
 366   //
 367   // stack: [ ret adr ] <-- rsp
 368   //        [ lo(arg) ]
 369   //        [ hi(arg) ]
 370   //
 371 
 372 
 373   if (kind == Interpreter::java_lang_math_sqrt) {
 374     __ sqrtsd(xmm0, Address(rsp, wordSize));
 375   } else if (kind == Interpreter::java_lang_math_exp) {
 376     __ movdbl(xmm0, Address(rsp, wordSize));
 377     if (StubRoutines::dexp() != NULL) {
 378       __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dexp())));
 379     } else {
 380       __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, SharedRuntime::dexp)));
 381     }
 382   } else if (kind == Interpreter::java_lang_math_log) {
 383     __ movdbl(xmm0, Address(rsp, wordSize));
 384     if (StubRoutines::dlog() != NULL) {
 385       __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dlog())));
 386     } else {
 387       __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, SharedRuntime::dlog)));
 388     }
 389   } else if (kind == Interpreter::java_lang_math_log10) {
 390     __ movdbl(xmm0, Address(rsp, wordSize));
 391     if (StubRoutines::dlog10() != NULL) {
 392       __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dlog10())));
 393     } else {
 394       __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, SharedRuntime::dlog10)));
 395     }
 396   } else if (kind == Interpreter::java_lang_math_sin) {
 397     __ movdbl(xmm0, Address(rsp, wordSize));
 398     if (StubRoutines::dsin() != NULL) {
 399       __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dsin())));
 400     } else {
 401       __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, SharedRuntime::dsin)));
 402     }
 403   } else if (kind == Interpreter::java_lang_math_cos) {
 404     __ movdbl(xmm0, Address(rsp, wordSize));
 405     if (StubRoutines::dcos() != NULL) {
 406       __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dcos())));
 407     } else {
 408       __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, SharedRuntime::dcos)));
 409     }
 410   } else if (kind == Interpreter::java_lang_math_pow) {
 411     __ movdbl(xmm1, Address(rsp, wordSize));
 412     __ movdbl(xmm0, Address(rsp, 3 * wordSize));
 413     if (StubRoutines::dpow() != NULL) {
 414       __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dpow())));
 415     } else {
 416       __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, SharedRuntime::dpow)));
 417     }
 418   } else if (kind == Interpreter::java_lang_math_tan) {
 419     __ movdbl(xmm0, Address(rsp, wordSize));
 420     if (StubRoutines::dtan() != NULL) {
 421       __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dtan())));
 422     } else {
 423       __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, SharedRuntime::dtan)));
 424     }
 425   } else {
 426     __ fld_d(Address(rsp, wordSize));
 427     switch (kind) {
 428       case Interpreter::java_lang_math_abs:
 429           __ fabs();
 430           break;
 431       default                              :
 432           ShouldNotReachHere();
 433     }
 434 
 435     // return double result in xmm0 for interpreter and compilers.
 436     __ subptr(rsp, 2*wordSize);
 437     // Round to 64bit precision
 438     __ fstp_d(Address(rsp, 0));
 439     __ movdbl(xmm0, Address(rsp, 0));
 440     __ addptr(rsp, 2*wordSize);
 441   }
 442 
 443 
 444   __ pop(rax);
 445   __ mov(rsp, r13);
 446   __ jmp(rax);
 447 
 448   return entry_point;















 449 }


 360 
 361   // mathematical functions inlined by compiler
 362   // (interpreter must provide identical implementation
 363   // in order to avoid monotonicity bugs when switching
 364   // from interpreter to compiler in the middle of some
 365   // computation)
 366   //
 367   // stack: [ ret adr ] <-- rsp
 368   //        [ lo(arg) ]
 369   //        [ hi(arg) ]
 370   //
 371 
 372 
 373   if (kind == Interpreter::java_lang_math_sqrt) {
 374     __ sqrtsd(xmm0, Address(rsp, wordSize));
 375   } else if (kind == Interpreter::java_lang_math_exp) {
 376     __ movdbl(xmm0, Address(rsp, wordSize));
 377     if (StubRoutines::dexp() != NULL) {
 378       __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dexp())));
 379     } else {
 380       mathfunc(CAST_FROM_FN_PTR(address, SharedRuntime::dexp));
 381     }
 382   } else if (kind == Interpreter::java_lang_math_log) {
 383     __ movdbl(xmm0, Address(rsp, wordSize));
 384     if (StubRoutines::dlog() != NULL) {
 385       __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dlog())));
 386     } else {
 387       mathfunc(CAST_FROM_FN_PTR(address, SharedRuntime::dlog));
 388     }
 389   } else if (kind == Interpreter::java_lang_math_log10) {
 390     __ movdbl(xmm0, Address(rsp, wordSize));
 391     if (StubRoutines::dlog10() != NULL) {
 392       __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dlog10())));
 393     } else {
 394       mathfunc(CAST_FROM_FN_PTR(address, SharedRuntime::dlog10));
 395     }
 396   } else if (kind == Interpreter::java_lang_math_sin) {
 397     __ movdbl(xmm0, Address(rsp, wordSize));
 398     if (StubRoutines::dsin() != NULL) {
 399       __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dsin())));
 400     } else {
 401       mathfunc(CAST_FROM_FN_PTR(address, SharedRuntime::dsin));
 402     }
 403   } else if (kind == Interpreter::java_lang_math_cos) {
 404     __ movdbl(xmm0, Address(rsp, wordSize));
 405     if (StubRoutines::dcos() != NULL) {
 406       __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dcos())));
 407     } else {
 408       mathfunc(CAST_FROM_FN_PTR(address, SharedRuntime::dcos));
 409     }
 410   } else if (kind == Interpreter::java_lang_math_pow) {
 411     __ movdbl(xmm1, Address(rsp, wordSize));
 412     __ movdbl(xmm0, Address(rsp, 3 * wordSize));
 413     if (StubRoutines::dpow() != NULL) {
 414       __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dpow())));
 415     } else {
 416       mathfunc(CAST_FROM_FN_PTR(address, SharedRuntime::dpow));
 417     }
 418   } else if (kind == Interpreter::java_lang_math_tan) {
 419     __ movdbl(xmm0, Address(rsp, wordSize));
 420     if (StubRoutines::dtan() != NULL) {
 421       __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dtan())));
 422     } else {
 423       mathfunc(CAST_FROM_FN_PTR(address, SharedRuntime::dtan));
 424     }
 425   } else {
 426     __ fld_d(Address(rsp, wordSize));
 427     switch (kind) {
 428     case Interpreter::java_lang_math_abs:
 429       __ fabs();
 430       break;
 431     default:
 432       ShouldNotReachHere();
 433     }
 434 
 435     // return double result in xmm0 for interpreter and compilers.
 436     __ subptr(rsp, 2*wordSize);
 437     // Round to 64bit precision
 438     __ fstp_d(Address(rsp, 0));
 439     __ movdbl(xmm0, Address(rsp, 0));
 440     __ addptr(rsp, 2*wordSize);
 441   }
 442 
 443 
 444   __ pop(rax);
 445   __ mov(rsp, r13);
 446   __ jmp(rax);
 447 
 448   return entry_point;
 449 }
 450 
 451 void TemplateInterpreterGenerator::mathfunc(address runtime_entry) {
 452   Label E, L;
 453   __ subq(rsp, 0x20);
 454   __ testl(rsp, 15);
 455   __ jcc(Assembler::zero, L);
 456   __ subq(rsp, 8);
 457   __ call(RuntimeAddress(runtime_entry));
 458   __ addq(rsp, 8);
 459   __ jmp(E);
 460   __ bind(L);
 461   __ call(RuntimeAddress(runtime_entry));
 462   __ bind(E);
 463   __ addq(rsp, 0x20);
 464 }
< prev index next >