< prev index next >

src/hotspot/cpu/x86/nativeInst_x86.hpp

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


 687 };
 688 
 689 inline bool NativeInstruction::is_illegal()      { return (short)int_at(0) == (short)NativeIllegalInstruction::instruction_code; }
 690 inline bool NativeInstruction::is_call()         { return ubyte_at(0) == NativeCall::instruction_code; }
 691 inline bool NativeInstruction::is_call_reg()     { return ubyte_at(0) == NativeCallReg::instruction_code ||
 692                                                           (ubyte_at(1) == NativeCallReg::instruction_code &&
 693                                                            (ubyte_at(0) == Assembler::REX || ubyte_at(0) == Assembler::REX_B)); }
 694 inline bool NativeInstruction::is_return()       { return ubyte_at(0) == NativeReturn::instruction_code ||
 695                                                           ubyte_at(0) == NativeReturnX::instruction_code; }
 696 inline bool NativeInstruction::is_jump()         { return ubyte_at(0) == NativeJump::instruction_code ||
 697                                                           ubyte_at(0) == 0xEB; /* short jump */ }
 698 inline bool NativeInstruction::is_jump_reg()     {
 699   int pos = 0;
 700   if (ubyte_at(0) == Assembler::REX_B) pos = 1;
 701   return ubyte_at(pos) == 0xFF && (ubyte_at(pos + 1) & 0xF0) == 0xE0;
 702 }
 703 inline bool NativeInstruction::is_far_jump()     { return is_mov_literal64(); }
 704 inline bool NativeInstruction::is_cond_jump()    { return (int_at(0) & 0xF0FF) == 0x800F /* long jump */ ||
 705                                                           (ubyte_at(0) & 0xF0) == 0x70;  /* short jump */ }
 706 inline bool NativeInstruction::is_safepoint_poll() {
 707 #ifdef AMD64
 708   if (SafepointMechanism::uses_thread_local_poll()) {

 709     const bool has_rex_prefix = ubyte_at(0) == NativeTstRegMem::instruction_rex_b_prefix;
 710     const int test_offset = has_rex_prefix ? 1 : 0;



 711     const bool is_test_opcode = ubyte_at(test_offset) == NativeTstRegMem::instruction_code_memXregl;
 712     const bool is_rax_target = (ubyte_at(test_offset + 1) & NativeTstRegMem::modrm_mask) == NativeTstRegMem::modrm_reg;
 713     return is_test_opcode && is_rax_target;
 714   }

 715   // Try decoding a near safepoint first:
 716   if (ubyte_at(0) == NativeTstRegMem::instruction_code_memXregl &&
 717       ubyte_at(1) == 0x05) { // 00 rax 101
 718     address fault = addr_at(6) + int_at(2);
 719     NOT_JVMCI(assert(!Assembler::is_polling_page_far(), "unexpected poll encoding");)
 720     return os::is_poll_address(fault);
 721   }
 722   // Now try decoding a far safepoint:
 723   // two cases, depending on the choice of the base register in the address.
 724   if (((ubyte_at(0) & NativeTstRegMem::instruction_rex_prefix_mask) == NativeTstRegMem::instruction_rex_prefix &&
 725        ubyte_at(1) == NativeTstRegMem::instruction_code_memXregl &&
 726        (ubyte_at(2) & NativeTstRegMem::modrm_mask) == NativeTstRegMem::modrm_reg) ||
 727       (ubyte_at(0) == NativeTstRegMem::instruction_code_memXregl &&
 728        (ubyte_at(1) & NativeTstRegMem::modrm_mask) == NativeTstRegMem::modrm_reg)) {
 729     NOT_JVMCI(assert(Assembler::is_polling_page_far(), "unexpected poll encoding");)
 730     return true;
 731   }
 732   return false;
 733 #else
 734   return ( ubyte_at(0) == NativeMovRegMem::instruction_code_mem2reg ||


 687 };
 688 
 689 inline bool NativeInstruction::is_illegal()      { return (short)int_at(0) == (short)NativeIllegalInstruction::instruction_code; }
 690 inline bool NativeInstruction::is_call()         { return ubyte_at(0) == NativeCall::instruction_code; }
 691 inline bool NativeInstruction::is_call_reg()     { return ubyte_at(0) == NativeCallReg::instruction_code ||
 692                                                           (ubyte_at(1) == NativeCallReg::instruction_code &&
 693                                                            (ubyte_at(0) == Assembler::REX || ubyte_at(0) == Assembler::REX_B)); }
 694 inline bool NativeInstruction::is_return()       { return ubyte_at(0) == NativeReturn::instruction_code ||
 695                                                           ubyte_at(0) == NativeReturnX::instruction_code; }
 696 inline bool NativeInstruction::is_jump()         { return ubyte_at(0) == NativeJump::instruction_code ||
 697                                                           ubyte_at(0) == 0xEB; /* short jump */ }
 698 inline bool NativeInstruction::is_jump_reg()     {
 699   int pos = 0;
 700   if (ubyte_at(0) == Assembler::REX_B) pos = 1;
 701   return ubyte_at(pos) == 0xFF && (ubyte_at(pos + 1) & 0xF0) == 0xE0;
 702 }
 703 inline bool NativeInstruction::is_far_jump()     { return is_mov_literal64(); }
 704 inline bool NativeInstruction::is_cond_jump()    { return (int_at(0) & 0xF0FF) == 0x800F /* long jump */ ||
 705                                                           (ubyte_at(0) & 0xF0) == 0x70;  /* short jump */ }
 706 inline bool NativeInstruction::is_safepoint_poll() {

 707   if (SafepointMechanism::uses_thread_local_poll()) {
 708 #ifdef AMD64
 709     const bool has_rex_prefix = ubyte_at(0) == NativeTstRegMem::instruction_rex_b_prefix;
 710     const int test_offset = has_rex_prefix ? 1 : 0;
 711 #else
 712     const int test_offset = 0;
 713 #endif
 714     const bool is_test_opcode = ubyte_at(test_offset) == NativeTstRegMem::instruction_code_memXregl;
 715     const bool is_rax_target = (ubyte_at(test_offset + 1) & NativeTstRegMem::modrm_mask) == NativeTstRegMem::modrm_reg;
 716     return is_test_opcode && is_rax_target;
 717   }
 718 #ifdef AMD64
 719   // Try decoding a near safepoint first:
 720   if (ubyte_at(0) == NativeTstRegMem::instruction_code_memXregl &&
 721       ubyte_at(1) == 0x05) { // 00 rax 101
 722     address fault = addr_at(6) + int_at(2);
 723     NOT_JVMCI(assert(!Assembler::is_polling_page_far(), "unexpected poll encoding");)
 724     return os::is_poll_address(fault);
 725   }
 726   // Now try decoding a far safepoint:
 727   // two cases, depending on the choice of the base register in the address.
 728   if (((ubyte_at(0) & NativeTstRegMem::instruction_rex_prefix_mask) == NativeTstRegMem::instruction_rex_prefix &&
 729        ubyte_at(1) == NativeTstRegMem::instruction_code_memXregl &&
 730        (ubyte_at(2) & NativeTstRegMem::modrm_mask) == NativeTstRegMem::modrm_reg) ||
 731       (ubyte_at(0) == NativeTstRegMem::instruction_code_memXregl &&
 732        (ubyte_at(1) & NativeTstRegMem::modrm_mask) == NativeTstRegMem::modrm_reg)) {
 733     NOT_JVMCI(assert(Assembler::is_polling_page_far(), "unexpected poll encoding");)
 734     return true;
 735   }
 736   return false;
 737 #else
 738   return ( ubyte_at(0) == NativeMovRegMem::instruction_code_mem2reg ||
< prev index next >