equal
deleted
inserted
replaced
311 assert(a_byte == *start++, "should be the same code"); |
311 assert(a_byte == *start++, "should be the same code"); |
312 } |
312 } |
313 #endif |
313 #endif |
314 } else { |
314 } else { |
315 // make a copy the code which is going to be patched. |
315 // make a copy the code which is going to be patched. |
316 for ( int i = 0; i < _bytes_to_copy; i++) { |
316 for (int i = 0; i < _bytes_to_copy; i++) { |
317 address ptr = (address)(_pc_start + i); |
317 address ptr = (address)(_pc_start + i); |
318 int a_byte = (*ptr) & 0xFF; |
318 int a_byte = (*ptr) & 0xFF; |
319 __ a_byte (a_byte); |
319 __ emit_int8(a_byte); |
320 *ptr = 0x90; // make the site look like a nop |
320 *ptr = 0x90; // make the site look like a nop |
321 } |
321 } |
322 } |
322 } |
323 |
323 |
324 address end_of_patch = __ pc(); |
324 address end_of_patch = __ pc(); |
361 bytes_to_skip += sizeof_patch_record; |
361 bytes_to_skip += sizeof_patch_record; |
362 |
362 |
363 // emit the offsets needed to find the code to patch |
363 // emit the offsets needed to find the code to patch |
364 int being_initialized_entry_offset = __ pc() - being_initialized_entry + sizeof_patch_record; |
364 int being_initialized_entry_offset = __ pc() - being_initialized_entry + sizeof_patch_record; |
365 |
365 |
366 __ a_byte(0xB8); |
366 __ emit_int8((unsigned char)0xB8); |
367 __ a_byte(0); |
367 __ emit_int8(0); |
368 __ a_byte(being_initialized_entry_offset); |
368 __ emit_int8(being_initialized_entry_offset); |
369 __ a_byte(bytes_to_skip); |
369 __ emit_int8(bytes_to_skip); |
370 __ a_byte(_bytes_to_copy); |
370 __ emit_int8(_bytes_to_copy); |
371 address patch_info_pc = __ pc(); |
371 address patch_info_pc = __ pc(); |
372 assert(patch_info_pc - end_of_patch == bytes_to_skip, "incorrect patch info"); |
372 assert(patch_info_pc - end_of_patch == bytes_to_skip, "incorrect patch info"); |
373 |
373 |
374 address entry = __ pc(); |
374 address entry = __ pc(); |
375 NativeGeneralJump::insert_unconditional((address)_pc_start, entry); |
375 NativeGeneralJump::insert_unconditional((address)_pc_start, entry); |