Bug 831754 part 2 - Add patchable call instruction, x86/x64 part. r=dvander a=nonlibxul

This commit is contained in:
Jan de Mooij 2013-01-22 14:33:36 +01:00
parent 97406e74ca
commit 7cad99bba1
3 changed files with 24 additions and 0 deletions

View File

@ -1246,6 +1246,12 @@ class AssemblerX86Shared
JS_ASSERT(*ptr == 0xE9);
*ptr = 0x3D;
}
static void ToggleCall(CodeLocationLabel inst, bool enabled) {
uint8_t *ptr = (uint8_t *)inst.raw();
JS_ASSERT(*ptr == 0x3D || // CMP
*ptr == 0xE8); // CALL
*ptr = enabled ? 0xE8 : 0x3D;
}
};
} // namespace ion

View File

@ -558,6 +558,15 @@ class Assembler : public AssemblerX86Shared
addPendingJump(src, target->raw(), Relocation::IONCODE);
}
// Emit a CALL or CMP (nop) instruction. ToggleCall can be used to patch
// this instruction.
CodeOffsetLabel toggledCall(IonCode *target, bool enabled) {
CodeOffsetLabel offset(size());
JmpSrc src = enabled ? masm.call() : masm.cmp_eax();
addPendingJump(src, target->raw(), Relocation::IONCODE);
return offset;
}
// Do not mask shared implementations.
using AssemblerX86Shared::call;

View File

@ -369,6 +369,15 @@ class Assembler : public AssemblerX86Shared
addPendingJump(src, target.asPointer(), Relocation::HARDCODED);
}
// Emit a CALL or CMP (nop) instruction. ToggleCall can be used to patch
// this instruction.
CodeOffsetLabel toggledCall(IonCode *target, bool enabled) {
CodeOffsetLabel offset(size());
JmpSrc src = enabled ? masm.call() : masm.cmp_eax();
addPendingJump(src, target->raw(), Relocation::IONCODE);
return offset;
}
// Re-routes pending jumps to an external target, flushing the label in the
// process.
void retarget(Label *label, void *target, Relocation::Kind reloc) {