< prev index next >

src/hotspot/cpu/x86/c1_LIRAssembler_x86.cpp

Print this page
rev 48494 : 8195112: x86 (32 bit): implementation for Thread-local handshakes
Reviewed-by:


 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   if (StackReservedPages > 0 && compilation()->has_reserved_stack_access()) {
 522     __ reserved_stack_check();
 523   }
 524 
 525   bool result_is_oop = result->is_valid() ? result->is_oop() : false;
 526 
 527   // Note: we do not need to round double result; float result has the right precision
 528   // the poll sets the condition code, but no data registers
 529 
 530   if (SafepointMechanism::uses_thread_local_poll()) {
 531 #ifdef _LP64
 532     __ movptr(rscratch1, Address(r15_thread, Thread::polling_page_offset()));
 533     __ relocate(relocInfo::poll_return_type);
 534     __ testl(rax, Address(rscratch1, 0));
 535 #else
 536     ShouldNotReachHere();



 537 #endif


 538   } else {
 539     AddressLiteral polling_page(os::get_polling_page(), relocInfo::poll_return_type);
 540 
 541     if (Assembler::is_polling_page_far()) {
 542       __ lea(rscratch1, polling_page);
 543       __ relocate(relocInfo::poll_return_type);
 544       __ testl(rax, Address(rscratch1, 0));
 545     } else {
 546       __ testl(rax, polling_page);
 547     }
 548   }
 549   __ ret(0);
 550 }
 551 
 552 
 553 int LIR_Assembler::safepoint_poll(LIR_Opr tmp, CodeEmitInfo* info) {
 554   guarantee(info != NULL, "Shouldn't be NULL");
 555   int offset = __ offset();
 556   if (SafepointMechanism::uses_thread_local_poll()) {
 557 #ifdef _LP64
 558     __ movptr(rscratch1, Address(r15_thread, Thread::polling_page_offset()));







 559     add_debug_info_for_branch(info);
 560     __ relocate(relocInfo::poll_type);
 561     address pre_pc = __ pc();
 562     __ testl(rax, Address(rscratch1, 0));
 563     address post_pc = __ pc();
 564     guarantee(pointer_delta(post_pc, pre_pc, 1) == 3, "must be exact length");
 565 #else
 566     ShouldNotReachHere();
 567 #endif
 568   } else {
 569     AddressLiteral polling_page(os::get_polling_page(), relocInfo::poll_type);
 570     if (Assembler::is_polling_page_far()) {
 571       __ lea(rscratch1, polling_page);
 572       offset = __ offset();
 573       add_debug_info_for_branch(info);
 574       __ relocate(relocInfo::poll_type);
 575       __ testl(rax, Address(rscratch1, 0));
 576     } else {
 577       add_debug_info_for_branch(info);
 578       __ testl(rax, polling_page);
 579     }
 580   }
 581   return offset;
 582 }
 583 
 584 
 585 void LIR_Assembler::move_regs(Register from_reg, Register to_reg) {
 586   if (from_reg != to_reg) __ mov(to_reg, from_reg);
 587 }




 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   if (StackReservedPages > 0 && compilation()->has_reserved_stack_access()) {
 522     __ reserved_stack_check();
 523   }
 524 
 525   bool result_is_oop = result->is_valid() ? result->is_oop() : false;
 526 
 527   // Note: we do not need to round double result; float result has the right precision
 528   // the poll sets the condition code, but no data registers
 529 
 530   if (SafepointMechanism::uses_thread_local_poll()) {
 531 #ifdef _LP64
 532     const Register poll_addr = rscratch1;
 533     __ movptr(poll_addr, Address(r15_thread, Thread::polling_page_offset()));

 534 #else
 535     const Register poll_addr = rbx;
 536     assert(FrameMap::is_caller_save_register(poll_addr), "will overwrite");
 537     __ get_thread(poll_addr);
 538     __ movptr(poll_addr, Address(poll_addr, in_bytes(Thread::polling_page_offset())));
 539 #endif
 540     __ relocate(relocInfo::poll_return_type);
 541     __ testl(rax, Address(poll_addr, 0));
 542   } else {
 543     AddressLiteral polling_page(os::get_polling_page(), relocInfo::poll_return_type);
 544 
 545     if (Assembler::is_polling_page_far()) {
 546       __ lea(rscratch1, polling_page);
 547       __ relocate(relocInfo::poll_return_type);
 548       __ testl(rax, Address(rscratch1, 0));
 549     } else {
 550       __ testl(rax, polling_page);
 551     }
 552   }
 553   __ ret(0);
 554 }
 555 
 556 
 557 int LIR_Assembler::safepoint_poll(LIR_Opr tmp, CodeEmitInfo* info) {
 558   guarantee(info != NULL, "Shouldn't be NULL");
 559   int offset = __ offset();
 560   if (SafepointMechanism::uses_thread_local_poll()) {
 561 #ifdef _LP64
 562     const Register poll_addr = rscratch1;
 563     __ movptr(poll_addr, Address(r15_thread, Thread::polling_page_offset()));
 564 #else
 565     assert(tmp->is_cpu_register(), "needed");
 566     const Register poll_addr = tmp->as_register();
 567     __ get_thread(poll_addr);
 568     __ movptr(poll_addr, Address(poll_addr, in_bytes(Thread::polling_page_offset())));
 569 #endif
 570     add_debug_info_for_branch(info);
 571     __ relocate(relocInfo::poll_type);
 572     address pre_pc = __ pc();
 573     __ testl(rax, Address(poll_addr, 0));
 574     address post_pc = __ pc();
 575     guarantee(pointer_delta(post_pc, pre_pc, 1) == 2 LP64_ONLY(+1), "must be exact length");



 576   } else {
 577     AddressLiteral polling_page(os::get_polling_page(), relocInfo::poll_type);
 578     if (Assembler::is_polling_page_far()) {
 579       __ lea(rscratch1, polling_page);
 580       offset = __ offset();
 581       add_debug_info_for_branch(info);
 582       __ relocate(relocInfo::poll_type);
 583       __ testl(rax, Address(rscratch1, 0));
 584     } else {
 585       add_debug_info_for_branch(info);
 586       __ testl(rax, polling_page);
 587     }
 588   }
 589   return offset;
 590 }
 591 
 592 
 593 void LIR_Assembler::move_regs(Register from_reg, Register to_reg) {
 594   if (from_reg != to_reg) __ mov(to_reg, from_reg);
 595 }


< prev index next >