492 // generate code for exception handler 493 address handler_base = __ start_a_stub(deopt_handler_size); 494 if (handler_base == NULL) { 495 // not enough space left for the handler 496 bailout("deopt handler overflow"); 497 return -1; 498 } 499 500 int offset = code_offset(); 501 InternalAddress here(__ pc()); 502 503 __ pushptr(here.addr()); 504 __ jump(RuntimeAddress(SharedRuntime::deopt_blob()->unpack())); 505 guarantee(code_offset() - offset <= deopt_handler_size, "overflow"); 506 __ end_a_stub(); 507 508 return offset; 509 } 510 511 512 // This is the fast version of java.lang.String.compare; it has not 513 // OSR-entry and therefore, we generate a slow version for OSR's 514 void LIR_Assembler::emit_string_compare(LIR_Opr arg0, LIR_Opr arg1, LIR_Opr dst, CodeEmitInfo* info) { 515 __ movptr (rbx, rcx); // receiver is in rcx 516 __ movptr (rax, arg1->as_register()); 517 518 // Get addresses of first characters from both Strings 519 __ load_heap_oop(rsi, Address(rax, java_lang_String::value_offset_in_bytes())); 520 if (java_lang_String::has_offset_field()) { 521 __ movptr (rcx, Address(rax, java_lang_String::offset_offset_in_bytes())); 522 __ movl (rax, Address(rax, java_lang_String::count_offset_in_bytes())); 523 __ lea (rsi, Address(rsi, rcx, Address::times_2, arrayOopDesc::base_offset_in_bytes(T_CHAR))); 524 } else { 525 __ movl (rax, Address(rsi, arrayOopDesc::length_offset_in_bytes())); 526 __ lea (rsi, Address(rsi, arrayOopDesc::base_offset_in_bytes(T_CHAR))); 527 } 528 529 // rbx, may be NULL 530 add_debug_info_for_null_check_here(info); 531 __ load_heap_oop(rdi, Address(rbx, java_lang_String::value_offset_in_bytes())); 532 if (java_lang_String::has_offset_field()) { 533 __ movptr (rcx, Address(rbx, java_lang_String::offset_offset_in_bytes())); 534 __ movl (rbx, Address(rbx, java_lang_String::count_offset_in_bytes())); 535 __ lea (rdi, Address(rdi, rcx, Address::times_2, arrayOopDesc::base_offset_in_bytes(T_CHAR))); 536 } else { 537 __ movl (rbx, Address(rdi, arrayOopDesc::length_offset_in_bytes())); 538 __ lea (rdi, Address(rdi, arrayOopDesc::base_offset_in_bytes(T_CHAR))); 539 } 540 541 // compute minimum length (in rax) and difference of lengths (on top of stack) 542 __ mov (rcx, rbx); 543 __ subptr(rbx, rax); // subtract lengths 544 __ push (rbx); // result 545 __ cmov (Assembler::lessEqual, rax, rcx); 546 547 // is minimum length 0? 548 Label noLoop, haveResult; 549 __ testptr (rax, rax); 550 __ jcc (Assembler::zero, noLoop); 551 552 // compare first characters 553 __ load_unsigned_short(rcx, Address(rdi, 0)); 554 __ load_unsigned_short(rbx, Address(rsi, 0)); 555 __ subl(rcx, rbx); 556 __ jcc(Assembler::notZero, haveResult); 557 // starting loop 558 __ decrement(rax); // we already tested index: skip one 559 __ jcc(Assembler::zero, noLoop); 560 561 // set rsi.edi to the end of the arrays (arrays have same length) 562 // negate the index 563 564 __ lea(rsi, Address(rsi, rax, Address::times_2, type2aelembytes(T_CHAR))); 565 __ lea(rdi, Address(rdi, rax, Address::times_2, type2aelembytes(T_CHAR))); 566 __ negptr(rax); 567 568 // compare the strings in a loop 569 570 Label loop; 571 __ align(wordSize); 572 __ bind(loop); 573 __ load_unsigned_short(rcx, Address(rdi, rax, Address::times_2, 0)); 574 __ load_unsigned_short(rbx, Address(rsi, rax, Address::times_2, 0)); 575 __ subl(rcx, rbx); 576 __ jcc(Assembler::notZero, haveResult); 577 __ increment(rax); 578 __ jcc(Assembler::notZero, loop); 579 580 // strings are equal up to min length 581 582 __ bind(noLoop); 583 __ pop(rax); 584 return_op(LIR_OprFact::illegalOpr); 585 586 __ bind(haveResult); 587 // leave instruction is going to discard the TOS value 588 __ mov (rax, rcx); // result of call is in rax, 589 } 590 591 592 void LIR_Assembler::return_op(LIR_Opr result) { 593 assert(result->is_illegal() || !result->is_single_cpu() || result->as_register() == rax, "word returns are in rax,"); 594 if (!result->is_illegal() && result->is_float_kind() && !result->is_xmm_register()) { 595 assert(result->fpu() == 0, "result must already be on TOS"); 596 } 597 598 // Pop the stack before the safepoint code 599 __ remove_frame(initial_frame_size_in_bytes()); 600 601 bool result_is_oop = result->is_valid() ? result->is_oop() : false; 602 603 // Note: we do not need to round double result; float result has the right precision 604 // the poll sets the condition code, but no data registers 605 AddressLiteral polling_page(os::get_polling_page(), relocInfo::poll_return_type); 606 607 if (Assembler::is_polling_page_far()) { 608 __ lea(rscratch1, polling_page); 609 __ relocate(relocInfo::poll_return_type); 610 __ testl(rax, Address(rscratch1, 0)); 611 } else { | 492 // generate code for exception handler 493 address handler_base = __ start_a_stub(deopt_handler_size); 494 if (handler_base == NULL) { 495 // not enough space left for the handler 496 bailout("deopt handler overflow"); 497 return -1; 498 } 499 500 int offset = code_offset(); 501 InternalAddress here(__ pc()); 502 503 __ pushptr(here.addr()); 504 __ jump(RuntimeAddress(SharedRuntime::deopt_blob()->unpack())); 505 guarantee(code_offset() - offset <= deopt_handler_size, "overflow"); 506 __ end_a_stub(); 507 508 return offset; 509 } 510 511 512 void LIR_Assembler::return_op(LIR_Opr result) { 513 assert(result->is_illegal() || !result->is_single_cpu() || result->as_register() == rax, "word returns are in rax,"); 514 if (!result->is_illegal() && result->is_float_kind() && !result->is_xmm_register()) { 515 assert(result->fpu() == 0, "result must already be on TOS"); 516 } 517 518 // Pop the stack before the safepoint code 519 __ remove_frame(initial_frame_size_in_bytes()); 520 521 bool result_is_oop = result->is_valid() ? result->is_oop() : false; 522 523 // Note: we do not need to round double result; float result has the right precision 524 // the poll sets the condition code, but no data registers 525 AddressLiteral polling_page(os::get_polling_page(), relocInfo::poll_return_type); 526 527 if (Assembler::is_polling_page_far()) { 528 __ lea(rscratch1, polling_page); 529 __ relocate(relocInfo::poll_return_type); 530 __ testl(rax, Address(rscratch1, 0)); 531 } else { |