Bug 1240583 - Odin: add MacroAssembler::repatchThunk (r=bbouvier)

MozReview-Commit-ID: Blj499Wb0Hb
This commit is contained in:
Luke Wagner 2016-02-10 09:22:36 -06:00
parent c8f3af3386
commit 44cd16281c
7 changed files with 39 additions and 4 deletions

View File

@ -41,6 +41,8 @@ reAfterArg = "(?=[,)])"
reMatchArg = re.compile(reBeforeArg + reArgType + reArgName + reArgDefault + reAfterArg) reMatchArg = re.compile(reBeforeArg + reArgType + reArgName + reArgDefault + reAfterArg)
def get_normalized_signatures(signature, fileAnnot = None): def get_normalized_signatures(signature, fileAnnot = None):
# Remove static
signature = signature.replace('static', '')
# Remove semicolon. # Remove semicolon.
signature = signature.replace(';', ' ') signature = signature.replace(';', ' ')
# Normalize spaces. # Normalize spaces.

View File

@ -509,6 +509,7 @@ class MacroAssembler : public MacroAssemblerSpecific
// CodeOffset instead of a CodeOffsetJump). // CodeOffset instead of a CodeOffsetJump).
CodeOffset thunkWithPatch() PER_SHARED_ARCH; CodeOffset thunkWithPatch() PER_SHARED_ARCH;
void patchThunk(uint32_t thunkOffset, uint32_t targetOffset) PER_SHARED_ARCH; void patchThunk(uint32_t thunkOffset, uint32_t targetOffset) PER_SHARED_ARCH;
static void repatchThunk(uint8_t* code, uint32_t thunkOffset, uint32_t targetOffset) PER_SHARED_ARCH;
// Push the return address and make a call. On platforms where this function // Push the return address and make a call. On platforms where this function
// is not defined, push the link register (pushReturnAddress) at the entry // is not defined, push the link register (pushReturnAddress) at the entry

View File

@ -4996,6 +4996,17 @@ MacroAssembler::patchThunk(uint32_t u32Offset, uint32_t targetOffset)
*u32 = (targetOffset - addOffset) - 8; *u32 = (targetOffset - addOffset) - 8;
} }
void
MacroAssembler::repatchThunk(uint8_t* code, uint32_t u32Offset, uint32_t targetOffset)
{
uint32_t* u32 = reinterpret_cast<uint32_t*>(code + u32Offset);
uint32_t addOffset = u32Offset - 4;
MOZ_ASSERT(reinterpret_cast<Instruction*>(code + addOffset)->is<InstALU>());
*u32 = (targetOffset - addOffset) - 8;
}
void void
MacroAssembler::pushReturnAddress() MacroAssembler::pushReturnAddress()
{ {

View File

@ -578,6 +578,12 @@ MacroAssembler::patchThunk(uint32_t thunkOffset, uint32_t targetOffset)
MOZ_CRASH("NYI"); MOZ_CRASH("NYI");
} }
void
MacroAssembler::repatchThunk(uint8_t* code, uint32_t thunkOffset, uint32_t targetOffset)
{
MOZ_CRASH("NYI");
}
void void
MacroAssembler::pushReturnAddress() MacroAssembler::pushReturnAddress()
{ {

View File

@ -1168,6 +1168,12 @@ MacroAssembler::patchThunk(uint32_t callerOffset, uint32_t calleeOffset)
MOZ_CRASH("NYI"); MOZ_CRASH("NYI");
} }
void
MacroAssembler::repatchThunk(uint8_t* code, uint32_t callerOffset, uint32_t calleeOffset)
{
MOZ_CRASH("NYI");
}
void void
MacroAssembler::call(wasm::SymbolicAddress target) MacroAssembler::call(wasm::SymbolicAddress target)
{ {

View File

@ -1028,9 +1028,12 @@ class AssemblerX86Shared : public AssemblerShared
CodeOffset thunkWithPatch() { CodeOffset thunkWithPatch() {
return CodeOffset(masm.jmp().offset()); return CodeOffset(masm.jmp().offset());
} }
void patchThunk(uint32_t jumpOffset, uint32_t targetOffset) { void patchThunk(uint32_t thunkOffset, uint32_t targetOffset) {
unsigned char* code = masm.data(); unsigned char* code = masm.data();
X86Encoding::SetRel32(code + jumpOffset, code + targetOffset); X86Encoding::SetRel32(code + thunkOffset, code + targetOffset);
}
static void repatchThunk(uint8_t* code, uint32_t thunkOffset, uint32_t targetOffset) {
X86Encoding::SetRel32(code + thunkOffset, code + targetOffset);
} }
void breakpoint() { void breakpoint() {

View File

@ -551,9 +551,15 @@ MacroAssembler::thunkWithPatch()
} }
void void
MacroAssembler::patchThunk(uint32_t jumpOffset, uint32_t targetOffset) MacroAssembler::patchThunk(uint32_t thunkOffset, uint32_t targetOffset)
{ {
Assembler::patchThunk(jumpOffset, targetOffset); Assembler::patchThunk(thunkOffset, targetOffset);
}
void
MacroAssembler::repatchThunk(uint8_t* code, uint32_t thunkOffset, uint32_t targetOffset)
{
Assembler::repatchThunk(code, thunkOffset, targetOffset);
} }
void void