Bug 614323 - ARM: prevent constant pool from being dumped in the middle of MICs r=dvander a=blocking-fennec

--HG--
extra : rebase_source : f4e2a61bf0c2bbd200733f78fef818f3c344dca3
This commit is contained in:
Chris Leary 2010-11-23 15:27:00 -08:00
Родитель 7bf0cfae9f
Коммит aa1438f460
4 изменённых файлов: 56 добавлений и 0 удалений

Просмотреть файл

@ -922,6 +922,11 @@ namespace JSC {
m_buffer.ensureSpace(insnSpace, constSpace);
}
void ensureSpace(int space)
{
m_buffer.ensureSpace(space);
}
int sizeOfConstantPool()
{
return m_buffer.sizeOfConstantPool();

Просмотреть файл

@ -1056,6 +1056,11 @@ public:
convertInt32ToDouble(ARMRegisters::S0, srcDest);
}
void ensureSpace(int space)
{
m_assembler.ensureSpace(space);
}
void forceFlushConstantPool()
{
m_assembler.forceFlushConstantPool();

Просмотреть файл

@ -192,6 +192,50 @@ class Repatcher : public JSC::RepatchBuffer
{ }
};
/*
* On ARM, we periodically flush a constant pool into the instruction stream
* where constants are found using PC-relative addressing. This is necessary
* because the fixed-width instruction set doesn't support wide immediates.
*
* ICs perform repatching on the inline (fast) path by knowing small and
* generally fixed code location offset values where the patchable instructions
* live. Dumping a huge constant pool into the middle of an IC's inline path
* makes the distance between emitted instructions potentially variable and/or
* large, which makes the IC offsets invalid. We must reserve contiguous space
* up front to prevent this from happening.
*/
#ifdef JS_CPU_ARM
class AutoReserveICSpace {
typedef Assembler::Label Label;
static const size_t reservedSpace = 64;
Assembler &masm;
#ifdef DEBUG
Label startLabel;
#endif
public:
AutoReserveICSpace(Assembler &masm) : masm(masm) {
masm.ensureSpace(reservedSpace);
#ifdef DEBUG
startLabel = masm.label();
#endif
}
~AutoReserveICSpace() {
#ifdef DEBUG
Label endLabel = masm.label();
int spaceUsed = masm.differenceBetween(startLabel, endLabel);
JS_ASSERT(spaceUsed >= 0);
JS_ASSERT(size_t(spaceUsed) <= reservedSpace);
#endif
}
};
# define RESERVE_IC_SPACE(__masm) AutoReserveICSpace arics(__masm)
#else
# define RESERVE_IC_SPACE(__masm) /* Nothing. */
#endif
} /* namespace js */
} /* namespace mjit */

Просмотреть файл

@ -4325,6 +4325,7 @@ mjit::Compiler::jsop_getgname(uint32 index)
JS_ASSERT(fe->isTypeKnown() && fe->getKnownType() == JSVAL_TYPE_OBJECT);
MICGenInfo mic(ic::MICInfo::GET);
RESERVE_IC_SPACE(masm);
RegisterID objReg;
Jump shapeGuard;
@ -4427,6 +4428,7 @@ mjit::Compiler::jsop_setgname(uint32 index, bool usePropertyCache)
JS_ASSERT_IF(objFe->isTypeKnown(), objFe->getKnownType() == JSVAL_TYPE_OBJECT);
MICGenInfo mic(ic::MICInfo::SET);
RESERVE_IC_SPACE(masm);
RegisterID objReg;
Jump shapeGuard;