< prev index next >

src/cpu/x86/vm/templateInterpreterGenerator_x86_32.cpp

Print this page




 328 
 329   // These don't need a safepoint check because they aren't virtually
 330   // callable. We won't enter these intrinsics from compiled code.
 331   // If in the future we added an intrinsic which was virtually callable
 332   // we'd have to worry about how to safepoint so that this code is used.
 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         __ trigfunc('s');







 349         break;
 350     case Interpreter::java_lang_math_cos :
 351         __ trigfunc('c');







 352         break;
 353     case Interpreter::java_lang_math_tan :
 354         __ trigfunc('t');







 355         break;
 356     case Interpreter::java_lang_math_sqrt:
 357         __ fsqrt();
 358         break;
 359     case Interpreter::java_lang_math_abs:
 360         __ fabs();
 361         break;
 362     case Interpreter::java_lang_math_log:
 363         __ subptr(rsp, 2 * wordSize);
 364         __ fstp_d(Address(rsp, 0));
 365         if (VM_Version::supports_sse2()) {
 366           __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dlog())));
 367         }
 368         else {
 369           __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, SharedRuntime::dlog)));
 370         }
 371         __ addptr(rsp, 2 * wordSize);
 372         break;
 373     case Interpreter::java_lang_math_log10:
 374         __ flog10();
 375         // Store to stack to convert 80bit precision back to 64bits
 376         __ push_fTOS();
 377         __ pop_fTOS();




 378         break;
 379     case Interpreter::java_lang_math_pow:
 380       __ fld_d(Address(rsp, 3*wordSize)); // second argument
 381       __ subptr(rsp, 4 * wordSize);
 382       __ fstp_d(Address(rsp, 0));
 383       __ fstp_d(Address(rsp, 2 * wordSize));
 384       if (VM_Version::supports_sse2()) {
 385         __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dpow())));
 386       } else {
 387         __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, SharedRuntime::dpow)));
 388       }
 389       __ addptr(rsp, 4 * wordSize);
 390       break;
 391     case Interpreter::java_lang_math_exp:
 392       __ subptr(rsp, 2*wordSize);
 393       __ fstp_d(Address(rsp, 0));
 394       if (VM_Version::supports_sse2()) {
 395         __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dexp())));
 396       } else {
 397         __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, SharedRuntime::dexp)));
 398       }
 399       __ addptr(rsp, 2*wordSize);
 400     break;
 401     default                              :
 402         ShouldNotReachHere();
 403   }
 404 
 405   // return double result in xmm0 for interpreter and compilers.
 406   if (UseSSE >= 2) {
 407     __ subptr(rsp, 2*wordSize);
 408     __ fstp_d(Address(rsp, 0));
 409     __ movdbl(xmm0, Address(rsp, 0));
 410     __ addptr(rsp, 2*wordSize);
 411   }
 412 
 413   // done, result in FPU ST(0) or XMM0
 414   __ pop(rdi);                               // get return address


 328 
 329   // These don't need a safepoint check because they aren't virtually
 330   // callable. We won't enter these intrinsics from compiled code.
 331   // If in the future we added an intrinsic which was virtually callable
 332   // we'd have to worry about how to safepoint so that this code is used.
 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
< prev index next >