< prev index next >

src/cpu/x86/vm/templateInterpreterGenerator_x86_32.cpp

Print this page




 333 
 334   // mathematical functions inlined by compiler
 335   // (interpreter must provide identical implementation
 336   // in order to avoid monotonicity bugs when switching
 337   // from interpreter to compiler in the middle of some
 338   // computation)
 339   //
 340   // stack: [ ret adr ] <-- rsp
 341   //        [ lo(arg) ]
 342   //        [ hi(arg) ]
 343   //
 344 
 345   __ fld_d(Address(rsp, 1*wordSize));
 346   switch (kind) {
 347     case Interpreter::java_lang_math_sin :
 348         __ subptr(rsp, 2 * wordSize);
 349         __ fstp_d(Address(rsp, 0));
 350         if (VM_Version::supports_sse2() && StubRoutines::dsin() != NULL) {
 351           __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dsin())));
 352         } else {
 353           __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, SharedRuntime::dsin)));
 354         }
 355         __ addptr(rsp, 2 * wordSize);
 356         break;
 357     case Interpreter::java_lang_math_cos :
 358         __ subptr(rsp, 2 * wordSize);
 359         __ fstp_d(Address(rsp, 0));
 360         if (VM_Version::supports_sse2() && StubRoutines::dcos() != NULL) {
 361           __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dcos())));
 362         } else {
 363           __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, SharedRuntime::dcos)));
 364         }
 365         __ addptr(rsp, 2 * wordSize);
 366         break;
 367     case Interpreter::java_lang_math_tan :
 368         __ subptr(rsp, 2 * wordSize);
 369         __ fstp_d(Address(rsp, 0));
 370         if (StubRoutines::dtan() != NULL) {
 371           __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dtan())));
 372         } else {
 373           __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, SharedRuntime::dtan)));
 374         }
 375         __ addptr(rsp, 2 * wordSize);
 376         break;
 377     case Interpreter::java_lang_math_sqrt:
 378         __ fsqrt();
 379         break;
 380     case Interpreter::java_lang_math_abs:
 381         __ fabs();
 382         break;
 383     case Interpreter::java_lang_math_log:
 384         __ subptr(rsp, 2 * wordSize);
 385         __ fstp_d(Address(rsp, 0));
 386         if (StubRoutines::dlog() != NULL) {
 387           __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dlog())));
 388         } else {
 389           __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, SharedRuntime::dlog)));
 390         }
 391         __ addptr(rsp, 2 * wordSize);
 392         break;
 393     case Interpreter::java_lang_math_log10:
 394         __ subptr(rsp, 2 * wordSize);
 395         __ fstp_d(Address(rsp, 0));
 396         if (StubRoutines::dlog10() != NULL) {
 397           __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dlog10())));
 398         } else {
 399           __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, SharedRuntime::dlog10)));
 400         }
 401         __ addptr(rsp, 2 * wordSize);
 402         break;
 403     case Interpreter::java_lang_math_pow:
 404       __ fld_d(Address(rsp, 3*wordSize)); // second argument
 405       __ subptr(rsp, 4 * wordSize);
 406       __ fstp_d(Address(rsp, 0));
 407       __ fstp_d(Address(rsp, 2 * wordSize));
 408       if (StubRoutines::dpow() != NULL) {
 409         __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dpow())));
 410       } else {
 411         __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, SharedRuntime::dpow)));
 412       }
 413       __ addptr(rsp, 4 * wordSize);
 414       break;
 415     case Interpreter::java_lang_math_exp:
 416       __ subptr(rsp, 2*wordSize);
 417       __ fstp_d(Address(rsp, 0));
 418       if (StubRoutines::dexp() != NULL) {
 419         __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dexp())));
 420       } else {
 421         __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, SharedRuntime::dexp)));
 422       }
 423       __ addptr(rsp, 2*wordSize);
 424     break;
 425     default                              :
 426         ShouldNotReachHere();
 427   }
 428 
 429   // return double result in xmm0 for interpreter and compilers.
 430   if (UseSSE >= 2) {
 431     __ subptr(rsp, 2*wordSize);
 432     __ fstp_d(Address(rsp, 0));
 433     __ movdbl(xmm0, Address(rsp, 0));
 434     __ addptr(rsp, 2*wordSize);
 435   }
 436 
 437   // done, result in FPU ST(0) or XMM0
 438   __ pop(rdi);                               // get return address
 439   __ mov(rsp, rsi);                          // set sp to sender sp
 440   __ jmp(rdi);
 441 


 333 
 334   // mathematical functions inlined by compiler
 335   // (interpreter must provide identical implementation
 336   // in order to avoid monotonicity bugs when switching
 337   // from interpreter to compiler in the middle of some
 338   // computation)
 339   //
 340   // stack: [ ret adr ] <-- rsp
 341   //        [ lo(arg) ]
 342   //        [ hi(arg) ]
 343   //
 344 
 345   __ fld_d(Address(rsp, 1*wordSize));
 346   switch (kind) {
 347     case Interpreter::java_lang_math_sin :
 348         __ subptr(rsp, 2 * wordSize);
 349         __ fstp_d(Address(rsp, 0));
 350         if (VM_Version::supports_sse2() && StubRoutines::dsin() != NULL) {
 351           __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dsin())));
 352         } else {
 353           __ mathfunc(CAST_FROM_FN_PTR(address, SharedRuntime::dsin));
 354         }
 355         __ addptr(rsp, 2 * wordSize);
 356         break;
 357     case Interpreter::java_lang_math_cos :
 358         __ subptr(rsp, 2 * wordSize);
 359         __ fstp_d(Address(rsp, 0));
 360         if (VM_Version::supports_sse2() && StubRoutines::dcos() != NULL) {
 361           __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dcos())));
 362         } else {
 363           __ mathfunc(CAST_FROM_FN_PTR(address, SharedRuntime::dcos));
 364         }
 365         __ addptr(rsp, 2 * wordSize);
 366         break;
 367     case Interpreter::java_lang_math_tan :
 368         __ subptr(rsp, 2 * wordSize);
 369         __ fstp_d(Address(rsp, 0));
 370         if (StubRoutines::dtan() != NULL) {
 371           __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dtan())));
 372         } else {
 373           __ mathfunc(CAST_FROM_FN_PTR(address, SharedRuntime::dtan));
 374         }
 375         __ addptr(rsp, 2 * wordSize);
 376         break;
 377     case Interpreter::java_lang_math_sqrt:
 378         __ fsqrt();
 379         break;
 380     case Interpreter::java_lang_math_abs:
 381         __ fabs();
 382         break;
 383     case Interpreter::java_lang_math_log:
 384         __ subptr(rsp, 2 * wordSize);
 385         __ fstp_d(Address(rsp, 0));
 386         if (StubRoutines::dlog() != NULL) {
 387           __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dlog())));
 388         } else {
 389           __ mathfunc(CAST_FROM_FN_PTR(address, SharedRuntime::dlog));
 390         }
 391         __ addptr(rsp, 2 * wordSize);
 392         break;
 393     case Interpreter::java_lang_math_log10:
 394         __ subptr(rsp, 2 * wordSize);
 395         __ fstp_d(Address(rsp, 0));
 396         if (StubRoutines::dlog10() != NULL) {
 397           __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dlog10())));
 398         } else {
 399           __ mathfunc(CAST_FROM_FN_PTR(address, SharedRuntime::dlog10));
 400         }
 401         __ addptr(rsp, 2 * wordSize);
 402         break;
 403     case Interpreter::java_lang_math_pow:
 404       __ fld_d(Address(rsp, 3*wordSize)); // second argument
 405       __ subptr(rsp, 4 * wordSize);
 406       __ fstp_d(Address(rsp, 0));
 407       __ fstp_d(Address(rsp, 2 * wordSize));
 408       if (StubRoutines::dpow() != NULL) {
 409         __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dpow())));
 410       } else {
 411         __ mathfunc(CAST_FROM_FN_PTR(address, SharedRuntime::dpow));
 412       }
 413       __ addptr(rsp, 4 * wordSize);
 414       break;
 415     case Interpreter::java_lang_math_exp:
 416       __ subptr(rsp, 2*wordSize);
 417       __ fstp_d(Address(rsp, 0));
 418       if (StubRoutines::dexp() != NULL) {
 419         __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dexp())));
 420       } else {
 421         __ mathfunc(CAST_FROM_FN_PTR(address, SharedRuntime::dexp));
 422       }
 423       __ addptr(rsp, 2*wordSize);
 424     break;
 425     default                              :
 426         ShouldNotReachHere();
 427   }
 428 
 429   // return double result in xmm0 for interpreter and compilers.
 430   if (UseSSE >= 2) {
 431     __ subptr(rsp, 2*wordSize);
 432     __ fstp_d(Address(rsp, 0));
 433     __ movdbl(xmm0, Address(rsp, 0));
 434     __ addptr(rsp, 2*wordSize);
 435   }
 436 
 437   // done, result in FPU ST(0) or XMM0
 438   __ pop(rdi);                               // get return address
 439   __ mov(rsp, rsi);                          // set sp to sender sp
 440   __ jmp(rdi);
 441 
< prev index next >