< prev index next >

src/hotspot/cpu/x86/c1_LIRAssembler_x86.cpp

Print this page
rev 47415 : Add Thread Local handshakes and thread local polling


 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   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   AddressLiteral polling_page(os::get_polling_page(), relocInfo::poll_return_type);
 530 
 531   if (Assembler::is_polling_page_far()) {
 532     __ lea(rscratch1, polling_page);
 533     __ relocate(relocInfo::poll_return_type);
 534     __ testl(rax, Address(rscratch1, 0));
 535   } else {
 536     __ testl(rax, polling_page);
 537   }

 538   __ ret(0);
 539 }
 540 
 541 
 542 int LIR_Assembler::safepoint_poll(LIR_Opr tmp, CodeEmitInfo* info) {
 543   AddressLiteral polling_page(os::get_polling_page(), relocInfo::poll_type);
 544   guarantee(info != NULL, "Shouldn't be NULL");
 545   int offset = __ offset();














 546   if (Assembler::is_polling_page_far()) {
 547     __ lea(rscratch1, polling_page);
 548     offset = __ offset();
 549     add_debug_info_for_branch(info);
 550     __ relocate(relocInfo::poll_type);
 551     __ testl(rax, Address(rscratch1, 0));
 552   } else {
 553     add_debug_info_for_branch(info);
 554     __ testl(rax, polling_page);

 555   }
 556   return offset;
 557 }
 558 
 559 
 560 void LIR_Assembler::move_regs(Register from_reg, Register to_reg) {
 561   if (from_reg != to_reg) __ mov(to_reg, from_reg);
 562 }
 563 
 564 void LIR_Assembler::swap_reg(Register a, Register b) {
 565   __ xchgptr(a, b);
 566 }
 567 
 568 
 569 void LIR_Assembler::const2reg(LIR_Opr src, LIR_Opr dest, LIR_PatchCode patch_code, CodeEmitInfo* info) {
 570   assert(src->is_constant(), "should not call otherwise");
 571   assert(dest->is_register(), "should not call otherwise");
 572   LIR_Const* c = src->as_constant_ptr();
 573 
 574   switch (c->type()) {




 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   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 }
 588 
 589 void LIR_Assembler::swap_reg(Register a, Register b) {
 590   __ xchgptr(a, b);
 591 }
 592 
 593 
 594 void LIR_Assembler::const2reg(LIR_Opr src, LIR_Opr dest, LIR_PatchCode patch_code, CodeEmitInfo* info) {
 595   assert(src->is_constant(), "should not call otherwise");
 596   assert(dest->is_register(), "should not call otherwise");
 597   LIR_Const* c = src->as_constant_ptr();
 598 
 599   switch (c->type()) {


< prev index next >