summaryrefslogtreecommitdiff
path: root/Source/JavaScriptCore
diff options
context:
space:
mode:
authorBalazs Kilvady <kilvadyb@homejinni.com>2014-08-25 15:33:09 +0200
committerJulien Brianceau <jbriance@cisco.com>2014-08-25 17:24:46 +0200
commitdc6883639e9d5955b9d69560f9e64e6e12a5e8b9 (patch)
treed97b90a91a7e6545507170c18df66c496d32c7ab /Source/JavaScriptCore
parent5f97dc40ec224e2a940e32501977ea7726323a77 (diff)
downloadqtwebkit-dc6883639e9d5955b9d69560f9e64e6e12a5e8b9.tar.gz
[mips] Use shorter j <address> jump in MacroAssembler::replaceWithJump
Patch taken from https://bugs.webkit.org/show_bug.cgi?id=125920 Change-Id: I6583ea37e00f4dff80971bd44906936229540171 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@digia.com>
Diffstat (limited to 'Source/JavaScriptCore')
-rw-r--r--Source/JavaScriptCore/assembler/MIPSAssembler.h59
-rw-r--r--Source/JavaScriptCore/assembler/MacroAssemblerMIPS.h4
-rw-r--r--Source/JavaScriptCore/jit/ExecutableAllocator.h2
3 files changed, 20 insertions, 45 deletions
diff --git a/Source/JavaScriptCore/assembler/MIPSAssembler.h b/Source/JavaScriptCore/assembler/MIPSAssembler.h
index 03ef23ba7..7e49e9fd6 100644
--- a/Source/JavaScriptCore/assembler/MIPSAssembler.h
+++ b/Source/JavaScriptCore/assembler/MIPSAssembler.h
@@ -730,35 +730,6 @@ public:
// writable region of memory; to modify the code in an execute-only execuable
// pool the 'repatch' and 'relink' methods should be used.
- static size_t linkDirectJump(void* code, void* to)
- {
- MIPSWord* insn = reinterpret_cast<MIPSWord*>(reinterpret_cast<intptr_t>(code));
- size_t ops = 0;
- int32_t slotAddr = reinterpret_cast<int>(insn) + 4;
- int32_t toAddr = reinterpret_cast<int>(to);
-
- if ((slotAddr & 0xf0000000) != (toAddr & 0xf0000000)) {
- // lui
- *insn = 0x3c000000 | (MIPSRegisters::t9 << OP_SH_RT) | ((toAddr >> 16) & 0xffff);
- ++insn;
- // ori
- *insn = 0x34000000 | (MIPSRegisters::t9 << OP_SH_RT) | (MIPSRegisters::t9 << OP_SH_RS) | (toAddr & 0xffff);
- ++insn;
- // jr
- *insn = 0x00000008 | (MIPSRegisters::t9 << OP_SH_RS);
- ++insn;
- ops = 4 * sizeof(MIPSWord);
- } else {
- // j
- *insn = 0x08000000 | ((toAddr & 0x0fffffff) >> 2);
- ++insn;
- ops = 2 * sizeof(MIPSWord);
- }
- // nop
- *insn = 0x00000000;
- return ops;
- }
-
void linkJump(AssemblerLabel from, AssemblerLabel to)
{
ASSERT(to.isSet());
@@ -898,34 +869,42 @@ public:
static ptrdiff_t maxJumpReplacementSize()
{
- return sizeof(MIPSWord) * 4;
+ return sizeof(MIPSWord) * 2;
}
static void revertJumpToMove(void* instructionStart, RegisterID rt, int imm)
{
MIPSWord* insn = static_cast<MIPSWord*>(instructionStart);
- size_t codeSize = 2 * sizeof(MIPSWord);
// lui
*insn = 0x3c000000 | (rt << OP_SH_RT) | ((imm >> 16) & 0xffff);
++insn;
// ori
*insn = 0x34000000 | (rt << OP_SH_RS) | (rt << OP_SH_RT) | (imm & 0xffff);
- ++insn;
- // if jr $t9
- if (*insn == 0x03200008) {
- *insn = 0x00000000;
- codeSize += sizeof(MIPSWord);
- }
- cacheFlush(insn, codeSize);
+ cacheFlush(insn, 2 * sizeof(MIPSWord));
+ }
+
+ static bool canJumpWithJ(void* instructionStart, void* to)
+ {
+ intptr_t slotAddr = reinterpret_cast<intptr_t>(instructionStart) + 4;
+ intptr_t toAddr = reinterpret_cast<intptr_t>(to);
+ return (slotAddr & 0xf0000000) == (toAddr & 0xf0000000);
}
static void replaceWithJump(void* instructionStart, void* to)
{
ASSERT(!(bitwise_cast<uintptr_t>(instructionStart) & 3));
ASSERT(!(bitwise_cast<uintptr_t>(to) & 3));
- size_t ops = linkDirectJump(instructionStart, to);
- cacheFlush(instructionStart, ops);
+ ASSERT(canJumpWithJ(instructionStart, to));
+ MIPSWord* insn = reinterpret_cast<MIPSWord*>(instructionStart);
+ int32_t toAddr = reinterpret_cast<int32_t>(to);
+
+ // j <to>
+ *insn = 0x08000000 | ((toAddr & 0x0fffffff) >> 2);
+ ++insn;
+ // nop
+ *insn = 0x00000000;
+ cacheFlush(instructionStart, 2 * sizeof(MIPSWord));
}
static void replaceWithLoad(void* instructionStart)
diff --git a/Source/JavaScriptCore/assembler/MacroAssemblerMIPS.h b/Source/JavaScriptCore/assembler/MacroAssemblerMIPS.h
index 669021965..754e5cf4e 100644
--- a/Source/JavaScriptCore/assembler/MacroAssemblerMIPS.h
+++ b/Source/JavaScriptCore/assembler/MacroAssemblerMIPS.h
@@ -2538,8 +2538,6 @@ public:
Jump branchEqual(RegisterID rs, RegisterID rt)
{
- m_assembler.nop();
- m_assembler.nop();
m_assembler.appendJump();
m_assembler.beq(rs, rt, 0);
m_assembler.nop();
@@ -2549,8 +2547,6 @@ public:
Jump branchNotEqual(RegisterID rs, RegisterID rt)
{
- m_assembler.nop();
- m_assembler.nop();
m_assembler.appendJump();
m_assembler.bne(rs, rt, 0);
m_assembler.nop();
diff --git a/Source/JavaScriptCore/jit/ExecutableAllocator.h b/Source/JavaScriptCore/jit/ExecutableAllocator.h
index 0ec4668fd..42e1f9594 100644
--- a/Source/JavaScriptCore/jit/ExecutableAllocator.h
+++ b/Source/JavaScriptCore/jit/ExecutableAllocator.h
@@ -102,7 +102,7 @@ class DemandExecutableAllocator;
#endif
#if ENABLE(EXECUTABLE_ALLOCATOR_FIXED)
-#if CPU(ARM)
+#if CPU(ARM) || CPU(MIPS)
static const size_t fixedExecutableMemoryPoolSize = 16 * 1024 * 1024;
#elif CPU(X86_64) && !CPU(X32)
static const size_t fixedExecutableMemoryPoolSize = 1024 * 1024 * 1024;