< prev index next >

src/hotspot/cpu/x86/nativeInst_x86.cpp

Print this page




 659     n_jump->wrote(0);
 660 
 661    // Patch 4th byte
 662    instr_addr[4] = code_buffer[4];
 663 
 664     n_jump->wrote(4);
 665 
 666    // Patch bytes 0-3
 667    *(jint*)instr_addr = *(jint *)code_buffer;
 668 
 669     n_jump->wrote(0);
 670 
 671 #ifdef ASSERT
 672    // verify patching
 673    for ( int i = 0; i < instruction_size; i++) {
 674      address ptr = (address)((intptr_t)code_buffer + i);
 675      int a_byte = (*ptr) & 0xFF;
 676      assert(*((address)((intptr_t)instr_addr + i)) == a_byte, "mt safe patching failed");
 677    }
 678 #endif
 679 
 680 }
 681 
 682 
 683 
 684 address NativeGeneralJump::jump_destination() const {
 685   int op_code = ubyte_at(0);
 686   bool is_rel32off = (op_code == 0xE9 || op_code == 0x0F);
 687   int  offset  = (op_code == 0x0F)  ? 2 : 1;
 688   int  length  = offset + ((is_rel32off) ? 4 : 1);
 689 
 690   if (is_rel32off)
 691     return addr_at(0) + length + int_at(offset);
 692   else
 693     return addr_at(0) + length + sbyte_at(offset);
 694 }


























 659     n_jump->wrote(0);
 660 
 661    // Patch 4th byte
 662    instr_addr[4] = code_buffer[4];
 663 
 664     n_jump->wrote(4);
 665 
 666    // Patch bytes 0-3
 667    *(jint*)instr_addr = *(jint *)code_buffer;
 668 
 669     n_jump->wrote(0);
 670 
 671 #ifdef ASSERT
 672    // verify patching
 673    for ( int i = 0; i < instruction_size; i++) {
 674      address ptr = (address)((intptr_t)code_buffer + i);
 675      int a_byte = (*ptr) & 0xFF;
 676      assert(*((address)((intptr_t)instr_addr + i)) == a_byte, "mt safe patching failed");
 677    }
 678 #endif

 679 }
 680 
 681 
 682 
 683 address NativeGeneralJump::jump_destination() const {
 684   int op_code = ubyte_at(0);
 685   bool is_rel32off = (op_code == 0xE9 || op_code == 0x0F);
 686   int  offset  = (op_code == 0x0F)  ? 2 : 1;
 687   int  length  = offset + ((is_rel32off) ? 4 : 1);
 688 
 689   if (is_rel32off)
 690     return addr_at(0) + length + int_at(offset);
 691   else
 692     return addr_at(0) + length + sbyte_at(offset);
 693 }
 694 
 695 void NativePostCallNop::patch(jint diff) {
 696   assert(diff != 0, "must be");
 697   int32_t *code_pos = (int32_t *) addr_at(displacement_offset);
 698   *((int32_t *)(code_pos)) = (int32_t) diff;
 699 }
 700 
 701 #ifdef CONT_DOUBLE_NOP
 702 void NativePostCallNop::patch(uint32_t int1, uint32_t int2) {
 703   patch_int2(int2);
 704   patch_int1(int1); // order matters
 705 
 706   // *((uint8_t *)addr_at(3))  = (uint8_t) short1 >> 8;
 707   // *((uint8_t *)addr_at(11)) = (uint8_t) short1;
 708 }
 709 void NativePostCallNop::patch_int1(uint32_t int1) {
 710   *((uint32_t *)addr_at(4))  = (int32_t) int1;
 711   wrote(4);
 712 }
 713 void NativePostCallNop::patch_int2(uint32_t int2) {
 714   *((uint32_t *)addr_at(12)) = (int32_t) int2;
 715   wrote(12);
 716 }
 717 #endif
< prev index next >