summaryrefslogtreecommitdiffstats
path: root/JavaScriptCore/assembler
diff options
context:
space:
mode:
authorAndrei Popescu <andreip@google.com>2009-08-19 14:09:30 +0100
committerAndrei Popescu <andreip@google.com>2009-08-19 14:09:30 +0100
commit058ccc7ba0a4d59b9f6e92808332aa9895425fc7 (patch)
tree276aad5a2bbc2fd7d65d21bfca42c9de88b3dd20 /JavaScriptCore/assembler
parent2796dd1bf3b4b01e7e1d96ea91bd3a212f647579 (diff)
downloadexternal_webkit-058ccc7ba0a4d59b9f6e92808332aa9895425fc7.zip
external_webkit-058ccc7ba0a4d59b9f6e92808332aa9895425fc7.tar.gz
external_webkit-058ccc7ba0a4d59b9f6e92808332aa9895425fc7.tar.bz2
Revert "Merge WebKit r47420"
This reverts commit d227fc870c7a697500a3c900c31baf05fb9a8524.
Diffstat (limited to 'JavaScriptCore/assembler')
-rw-r--r--JavaScriptCore/assembler/ARMAssembler.cpp21
-rw-r--r--JavaScriptCore/assembler/ARMAssembler.h24
-rw-r--r--JavaScriptCore/assembler/ARMv7Assembler.h1
-rw-r--r--JavaScriptCore/assembler/AbstractMacroAssembler.h10
-rw-r--r--JavaScriptCore/assembler/AssemblerBufferWithConstantPool.h25
-rw-r--r--JavaScriptCore/assembler/MacroAssemblerARM.h30
-rw-r--r--JavaScriptCore/assembler/X86Assembler.h1
7 files changed, 46 insertions, 66 deletions
diff --git a/JavaScriptCore/assembler/ARMAssembler.cpp b/JavaScriptCore/assembler/ARMAssembler.cpp
index c8b07fc..69daa16 100644
--- a/JavaScriptCore/assembler/ARMAssembler.cpp
+++ b/JavaScriptCore/assembler/ARMAssembler.cpp
@@ -49,11 +49,11 @@ ARMWord* ARMAssembler::getLdrImmAddress(ARMWord* insn, uint32_t* constPool)
return reinterpret_cast<ARMWord*>(addr - (*insn & SDT_OFFSET_MASK));
}
-void ARMAssembler::linkBranch(void* code, JmpSrc from, void* to, int useConstantPool)
+void ARMAssembler::linkBranch(void* code, JmpSrc from, void* to)
{
ARMWord* insn = reinterpret_cast<ARMWord*>(code) + (from.m_offset / sizeof(ARMWord));
- if (!useConstantPool) {
+ if (!from.m_latePatch) {
int diff = reinterpret_cast<ARMWord*>(to) - reinterpret_cast<ARMWord*>(insn + 2);
if ((diff <= BOFFSET_MAX && diff >= BOFFSET_MIN)) {
@@ -367,22 +367,13 @@ void ARMAssembler::doubleTransfer(bool isLoad, FPRegisterID srcDst, RegisterID b
void* ARMAssembler::executableCopy(ExecutablePool* allocator)
{
- // 64-bit alignment is required for next constant pool and JIT code as well
- m_buffer.flushWithoutBarrier(true);
- if (m_buffer.uncheckedSize() & 0x7)
- bkpt(0);
-
char* data = reinterpret_cast<char*>(m_buffer.executableCopy(allocator));
for (Jumps::Iterator iter = m_jumps.begin(); iter != m_jumps.end(); ++iter) {
- // The last bit is set if the constant must be placed on constant pool.
- int pos = (*iter) & (~0x1);
- ARMWord* ldrAddr = reinterpret_cast<ARMWord*>(data + pos);
- ARMWord offset = *getLdrImmAddress(ldrAddr);
- if (offset != 0xffffffff) {
- JmpSrc jmpSrc(pos);
- linkBranch(data, jmpSrc, data + offset, ((*iter) & 1));
- }
+ ARMWord* ldrAddr = reinterpret_cast<ARMWord*>(data + *iter);
+ ARMWord* offset = getLdrImmAddress(ldrAddr);
+ if (*offset != 0xffffffff)
+ linkBranch(data, JmpSrc(*iter), data + *offset);
}
return data;
diff --git a/JavaScriptCore/assembler/ARMAssembler.h b/JavaScriptCore/assembler/ARMAssembler.h
index 0206770..d3fe782 100644
--- a/JavaScriptCore/assembler/ARMAssembler.h
+++ b/JavaScriptCore/assembler/ARMAssembler.h
@@ -77,7 +77,7 @@ namespace ARM {
typedef ARM::RegisterID RegisterID;
typedef ARM::FPRegisterID FPRegisterID;
typedef AssemblerBufferWithConstantPool<2048, 4, 4, ARMAssembler> ARMBuffer;
- typedef SegmentedVector<int, 64> Jumps;
+ typedef WTF::SegmentedVector<int, 64> Jumps;
ARMAssembler() { }
@@ -180,16 +180,20 @@ namespace ARM {
public:
JmpSrc()
: m_offset(-1)
+ , m_latePatch(false)
{
}
+ void enableLatePatch() { m_latePatch = true; }
private:
JmpSrc(int offset)
: m_offset(offset)
+ , m_latePatch(false)
{
}
- int m_offset;
+ int m_offset : 31;
+ int m_latePatch : 1;
};
class JmpDst {
@@ -563,11 +567,6 @@ namespace ARM {
m_buffer.ensureSpace(insnSpace, constSpace);
}
- int sizeOfConstantPool()
- {
- return m_buffer.sizeOfConstantPool();
- }
-
JmpDst label()
{
return JmpDst(m_buffer.size());
@@ -581,12 +580,11 @@ namespace ARM {
return label();
}
- JmpSrc jmp(Condition cc = AL, int useConstantPool = 0)
+ JmpSrc jmp(Condition cc = AL)
{
- ensureSpace(sizeof(ARMWord), sizeof(ARMWord));
- int s = m_buffer.uncheckedSize();
+ int s = size();
ldr_un_imm(ARM::pc, 0xffffffff, cc);
- m_jumps.append(s | (useConstantPool & 0x1));
+ m_jumps.append(s);
return JmpSrc(s);
}
@@ -595,7 +593,7 @@ namespace ARM {
// Patching helpers
static ARMWord* getLdrImmAddress(ARMWord* insn, uint32_t* constPool = 0);
- static void linkBranch(void* code, JmpSrc from, void* to, int useConstantPool = 0);
+ static void linkBranch(void* code, JmpSrc from, void* to);
static void patchPointerInternal(intptr_t from, void* to)
{
@@ -662,7 +660,7 @@ namespace ARM {
static void linkCall(void* code, JmpSrc from, void* to)
{
- linkBranch(code, from, to, true);
+ linkBranch(code, from, to);
}
static void relinkCall(void* from, void* to)
diff --git a/JavaScriptCore/assembler/ARMv7Assembler.h b/JavaScriptCore/assembler/ARMv7Assembler.h
index 7cf8873..f7e2fb4 100644
--- a/JavaScriptCore/assembler/ARMv7Assembler.h
+++ b/JavaScriptCore/assembler/ARMv7Assembler.h
@@ -442,6 +442,7 @@ public:
{
}
+ void enableLatePatch() { }
private:
JmpSrc(int offset)
: m_offset(offset)
diff --git a/JavaScriptCore/assembler/AbstractMacroAssembler.h b/JavaScriptCore/assembler/AbstractMacroAssembler.h
index 525fe98..f927ed2 100644
--- a/JavaScriptCore/assembler/AbstractMacroAssembler.h
+++ b/JavaScriptCore/assembler/AbstractMacroAssembler.h
@@ -320,6 +320,11 @@ public:
return Call(jump.m_jmp, Linkable);
}
+ void enableLatePatch()
+ {
+ m_jmp.enableLatePatch();
+ }
+
JmpSrc m_jmp;
private:
Flags m_flags;
@@ -356,6 +361,11 @@ public:
masm->m_assembler.linkJump(m_jmp, label.m_label);
}
+ void enableLatePatch()
+ {
+ m_jmp.enableLatePatch();
+ }
+
private:
JmpSrc m_jmp;
};
diff --git a/JavaScriptCore/assembler/AssemblerBufferWithConstantPool.h b/JavaScriptCore/assembler/AssemblerBufferWithConstantPool.h
index af3c3be..f15b7f3 100644
--- a/JavaScriptCore/assembler/AssemblerBufferWithConstantPool.h
+++ b/JavaScriptCore/assembler/AssemblerBufferWithConstantPool.h
@@ -34,8 +34,6 @@
#include "AssemblerBuffer.h"
#include <wtf/SegmentedVector.h>
-#define ASSEMBLER_HAS_CONSTANT_POOL 1
-
namespace JSC {
/*
@@ -86,7 +84,7 @@ namespace JSC {
template <int maxPoolSize, int barrierSize, int maxInstructionSize, class AssemblerType>
class AssemblerBufferWithConstantPool: public AssemblerBuffer {
- typedef SegmentedVector<uint32_t, 512> LoadOffsets;
+ typedef WTF::SegmentedVector<uint32_t, 512> LoadOffsets;
public:
enum {
UniqueConst,
@@ -179,11 +177,6 @@ public:
return AssemblerBuffer::size();
}
- int uncheckedSize()
- {
- return AssemblerBuffer::size();
- }
-
void* executableCopy(ExecutablePool* allocator)
{
flushConstantPool(false);
@@ -214,10 +207,10 @@ public:
}
// This flushing mechanism can be called after any unconditional jumps.
- void flushWithoutBarrier(bool isForced = false)
+ void flushWithoutBarrier()
{
// Flush if constant pool is more than 60% full to avoid overuse of this function.
- if (isForced || 5 * m_numConsts > 3 * maxPoolSize / sizeof(uint32_t))
+ if (5 * m_numConsts > 3 * maxPoolSize / sizeof(uint32_t))
flushConstantPool(false);
}
@@ -226,11 +219,6 @@ public:
return m_pool;
}
- int sizeOfConstantPool()
- {
- return m_numConsts;
- }
-
private:
void correctDeltas(int insnSize)
{
@@ -288,8 +276,7 @@ private:
{
if (m_numConsts == 0)
return;
- int lastConstDelta = m_lastConstDelta > nextInsnSize ? m_lastConstDelta - nextInsnSize : 0;
- if ((m_maxDistance < nextInsnSize + lastConstDelta + barrierSize + (int)sizeof(uint32_t)))
+ if ((m_maxDistance < nextInsnSize + m_lastConstDelta + barrierSize + (int)sizeof(uint32_t)))
flushConstantPool();
}
@@ -297,8 +284,8 @@ private:
{
if (m_numConsts == 0)
return;
- if ((m_maxDistance < nextInsnSize + m_lastConstDelta + nextConstSize + barrierSize + (int)sizeof(uint32_t)) ||
- (m_numConsts * sizeof(uint32_t) + nextConstSize >= maxPoolSize))
+ if ((m_maxDistance < nextInsnSize + m_lastConstDelta + barrierSize + (int)sizeof(uint32_t)) ||
+ (m_numConsts + nextConstSize / sizeof(uint32_t) >= maxPoolSize))
flushConstantPool();
}
diff --git a/JavaScriptCore/assembler/MacroAssemblerARM.h b/JavaScriptCore/assembler/MacroAssemblerARM.h
index 19cbfcb..b04ed13 100644
--- a/JavaScriptCore/assembler/MacroAssemblerARM.h
+++ b/JavaScriptCore/assembler/MacroAssemblerARM.h
@@ -324,20 +324,20 @@ public:
move(src, dest);
}
- Jump branch32(Condition cond, RegisterID left, RegisterID right, int useConstantPool = 0)
+ Jump branch32(Condition cond, RegisterID left, RegisterID right)
{
m_assembler.cmp_r(left, right);
- return Jump(m_assembler.jmp(ARMCondition(cond), useConstantPool));
+ return Jump(m_assembler.jmp(ARMCondition(cond)));
}
- Jump branch32(Condition cond, RegisterID left, Imm32 right, int useConstantPool = 0)
+ Jump branch32(Condition cond, RegisterID left, Imm32 right)
{
if (right.m_isPointer) {
m_assembler.ldr_un_imm(ARM::S0, right.m_value);
m_assembler.cmp_r(left, ARM::S0);
} else
m_assembler.cmp_r(left, m_assembler.getImm(right.m_value, ARM::S0));
- return Jump(m_assembler.jmp(ARMCondition(cond), useConstantPool));
+ return Jump(m_assembler.jmp(ARMCondition(cond)));
}
Jump branch32(Condition cond, RegisterID left, Address right)
@@ -497,7 +497,7 @@ public:
Call nearCall()
{
prepareCall();
- return Call(m_assembler.jmp(ARMAssembler::AL, true), Call::LinkableNear);
+ return Call(m_assembler.jmp(), Call::LinkableNear);
}
Call call(RegisterID target)
@@ -587,7 +587,7 @@ public:
Call call()
{
prepareCall();
- return Call(m_assembler.jmp(ARMAssembler::AL, true), Call::Linkable);
+ return Call(m_assembler.jmp(), Call::Linkable);
}
Call tailRecursiveCall()
@@ -610,7 +610,8 @@ public:
Jump branchPtrWithPatch(Condition cond, RegisterID left, DataLabelPtr& dataLabel, ImmPtr initialRightValue = ImmPtr(0))
{
dataLabel = moveWithPatch(initialRightValue, ARM::S1);
- Jump jump = branch32(cond, left, ARM::S1, true);
+ Jump jump = branch32(cond, left, ARM::S1);
+ jump.enableLatePatch();
return jump;
}
@@ -618,7 +619,8 @@ public:
{
load32(left, ARM::S1);
dataLabel = moveWithPatch(initialRightValue, ARM::S0);
- Jump jump = branch32(cond, ARM::S0, ARM::S1, true);
+ Jump jump = branch32(cond, ARM::S0, ARM::S1);
+ jump.enableLatePatch();
return jump;
}
@@ -720,19 +722,9 @@ protected:
return static_cast<ARMAssembler::Condition>(cond);
}
- void ensureSpace(int insnSpace, int constSpace)
- {
- m_assembler.ensureSpace(insnSpace, constSpace);
- }
-
- int sizeOfConstantPool()
- {
- return m_assembler.sizeOfConstantPool();
- }
-
void prepareCall()
{
- ensureSpace(3 * sizeof(ARMWord), sizeof(ARMWord));
+ m_assembler.ensureSpace(3 * sizeof(ARMWord), sizeof(ARMWord));
// S0 might be used for parameter passing
m_assembler.add_r(ARM::S1, ARM::pc, ARMAssembler::OP2_IMM | 0x4);
diff --git a/JavaScriptCore/assembler/X86Assembler.h b/JavaScriptCore/assembler/X86Assembler.h
index b5b8808..fb58361 100644
--- a/JavaScriptCore/assembler/X86Assembler.h
+++ b/JavaScriptCore/assembler/X86Assembler.h
@@ -231,6 +231,7 @@ public:
{
}
+ void enableLatePatch() { }
private:
JmpSrc(int offset)
: m_offset(offset)