< prev index next >

src/hotspot/cpu/x86/nativeInst_x86.cpp

Print this page

614     n_jump->wrote(0);
615 
616    // Patch 4th byte
617    instr_addr[4] = code_buffer[4];
618 
619     n_jump->wrote(4);
620 
621    // Patch bytes 0-3
622    *(jint*)instr_addr = *(jint *)code_buffer;
623 
624     n_jump->wrote(0);
625 
626 #ifdef ASSERT
627    // verify patching
628    for ( int i = 0; i < instruction_size; i++) {
629      address ptr = (address)((intptr_t)code_buffer + i);
630      int a_byte = (*ptr) & 0xFF;
631      assert(*((address)((intptr_t)instr_addr + i)) == a_byte, "mt safe patching failed");
632    }
633 #endif
634 
635 }
636 
637 
638 
639 address NativeGeneralJump::jump_destination() const {
640   int op_code = ubyte_at(0);
641   bool is_rel32off = (op_code == 0xE9 || op_code == 0x0F);
642   int  offset  = (op_code == 0x0F)  ? 2 : 1;
643   int  length  = offset + ((is_rel32off) ? 4 : 1);
644 
645   if (is_rel32off)
646     return addr_at(0) + length + int_at(offset);
647   else
648     return addr_at(0) + length + sbyte_at(offset);
649 }




























614     n_jump->wrote(0);
615 
616    // Patch 4th byte
617    instr_addr[4] = code_buffer[4];
618 
619     n_jump->wrote(4);
620 
621    // Patch bytes 0-3
622    *(jint*)instr_addr = *(jint *)code_buffer;
623 
624     n_jump->wrote(0);
625 
626 #ifdef ASSERT
627    // verify patching
628    for ( int i = 0; i < instruction_size; i++) {
629      address ptr = (address)((intptr_t)code_buffer + i);
630      int a_byte = (*ptr) & 0xFF;
631      assert(*((address)((intptr_t)instr_addr + i)) == a_byte, "mt safe patching failed");
632    }
633 #endif

634 }
635 
636 
637 
638 address NativeGeneralJump::jump_destination() const {
639   int op_code = ubyte_at(0);
640   bool is_rel32off = (op_code == 0xE9 || op_code == 0x0F);
641   int  offset  = (op_code == 0x0F)  ? 2 : 1;
642   int  length  = offset + ((is_rel32off) ? 4 : 1);
643 
644   if (is_rel32off)
645     return addr_at(0) + length + int_at(offset);
646   else
647     return addr_at(0) + length + sbyte_at(offset);
648 }
649 
650 void NativePostCallNop::make_deopt() {
651   NativeDeoptInstruction::insert(addr_at(0));
652   // makes the first 2 bytes into UD, the rest is thrash. Make NOPs to help debugging.
653   set_char_at(2, 0x90);
654   set_char_at(3, 0x90);
655   set_char_at(4, 0x90);
656   set_char_at(5, 0x90);
657   set_char_at(6, 0x90);
658   set_char_at(7, 0x90);
659 }
660 
661 void NativePostCallNop::patch(jint diff) {
662   assert(diff != 0, "must be");
663   int32_t *code_pos = (int32_t *) addr_at(displacement_offset);
664   *((int32_t *)(code_pos)) = (int32_t) diff;
665 }
666 
667 void NativeDeoptInstruction::verify() {
668 }
669 
670 // Inserts an undefined instruction at a given pc
671 void NativeDeoptInstruction::insert(address code_pos) {
672   *code_pos = instruction_prefix;
673   *(code_pos+1) = instruction_code;
674   ICache::invalidate_range(code_pos, instruction_size);
675 }
< prev index next >