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