Fixed AMD64 loop branch patching for >32-bit offstes.

This commit is contained in:
David Anderson 2008-08-27 16:52:28 -07:00
parent 98306ccb74
commit bc995a482b
2 changed files with 17 additions and 4 deletions

View File

@ -950,9 +950,11 @@ namespace nanojit
#define JMPc 0xe9
#define JMP_long_placeholder() do {\
underrunProtect(5); \
JMP_long_nochk_offset(-1); } while(0)
#define JMP_long_placeholder() do { \
underrunProtect(14); \
IMM64(-1); \
JMPm_nochk(0); \
} while (0)
// this should only be used when you can guarantee there is enough room on the page
#define JMP_long_nochk_offset(o) do {\

View File

@ -372,11 +372,22 @@ namespace nanojit
void Assembler::nPatchBranch(NIns* branch, NIns* location)
{
uint32_t offset = location - branch;
#if defined NANOJIT_IA32
intptr_t offset = intptr_t(location) - intptr_t(branch);
if (branch[0] == JMPc)
*(uint32_t*)&branch[1] = offset - 5;
else
*(uint32_t*)&branch[2] = offset - 6;
#else
if (branch[0] == 0xFF && branch[1] == 0x25) {
NIns *mem;
mem = &branch[6] + *(int32_t *)&branch[2];
*(intptr_t *)mem = intptr_t(location);
} else {
NanoAssert(0);
}
#endif
}
RegisterMask Assembler::hint(LIns* i, RegisterMask allow)