Extend the IC protection introduced by bug 614323. [Bug 615875] [r=cdleary]

This commit is contained in:
Jacob Bramley 2010-12-06 11:07:37 +00:00
Родитель fbf4aecada
Коммит c628dc78d7
4 изменённых файлов: 48 добавлений и 1 удалений

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

@ -932,6 +932,13 @@ namespace JSC {
return m_buffer.sizeOfConstantPool();
}
#ifdef DEBUG
void allowPoolFlush(bool allowFlush)
{
m_buffer.allowPoolFlush(allowFlush);
}
#endif
JmpDst label()
{
JmpDst label(m_buffer.size());

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

@ -37,6 +37,7 @@
#include "AssemblerBuffer.h"
#include "assembler/wtf/SegmentedVector.h"
#include "assembler/wtf/Assertions.h"
#define ASSEMBLER_HAS_CONSTANT_POOL 1
@ -103,6 +104,9 @@ public:
, m_numConsts(0)
, m_maxDistance(maxPoolSize)
, m_lastConstDelta(0)
#ifdef DEBUG
, m_allowFlush(true)
#endif
{
m_pool = static_cast<uint32_t*>(malloc(maxPoolSize));
m_mask = static_cast<char*>(malloc(maxPoolSize / sizeof(uint32_t)));
@ -235,6 +239,15 @@ public:
return m_numConsts;
}
#ifdef DEBUG
// Guard constant pool flushes to ensure that they don't occur during
// regions where offsets into the code have to be maintained (such as PICs).
void allowPoolFlush(bool allowFlush)
{
m_allowFlush = allowFlush;
}
#endif
private:
void correctDeltas(int insnSize)
{
@ -254,6 +267,7 @@ private:
void flushConstantPool(bool useBarrier = true)
{
ASSERT(m_allowFlush);
if (m_numConsts == 0)
return;
int alignPool = (AssemblerBuffer::size() + (useBarrier ? barrierSize : 0)) & (sizeof(uint64_t) - 1);
@ -313,6 +327,10 @@ private:
int m_numConsts;
int m_maxDistance;
int m_lastConstDelta;
#ifdef DEBUG
bool m_allowFlush;
#endif
};
} // namespace JSC

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

@ -1078,6 +1078,13 @@ public:
m_assembler.forceFlushConstantPool();
}
#ifdef DEBUG
void allowPoolFlush(bool allowFlush)
{
m_assembler.allowPoolFlush(allowFlush);
}
#endif
protected:
ARMAssembler::Condition ARMCondition(Condition cond)
{

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

@ -207,7 +207,7 @@ class Repatcher : public JSC::RepatchBuffer
#ifdef JS_CPU_ARM
class AutoReserveICSpace {
typedef Assembler::Label Label;
static const size_t reservedSpace = 64;
static const size_t reservedSpace = 68;
Assembler &masm;
#ifdef DEBUG
@ -219,6 +219,11 @@ class AutoReserveICSpace {
masm.ensureSpace(reservedSpace);
#ifdef DEBUG
startLabel = masm.label();
/* Assert that the constant pool is not flushed until we reach a safe point. */
masm.allowPoolFlush(false);
JaegerSpew(JSpew_Insns, " -- BEGIN CONSTANT-POOL-FREE REGION -- \n");
#endif
}
@ -226,8 +231,18 @@ class AutoReserveICSpace {
#ifdef DEBUG
Label endLabel = masm.label();
int spaceUsed = masm.differenceBetween(startLabel, endLabel);
/* Spew the space used, to help tuning of reservedSpace. */
JaegerSpew(JSpew_Insns,
" -- END CONSTANT-POOL-FREE REGION: %u bytes used of %u reserved. -- \n",
spaceUsed, reservedSpace);
/* Assert that we didn't emit more code than we protected. */
JS_ASSERT(spaceUsed >= 0);
JS_ASSERT(size_t(spaceUsed) <= reservedSpace);
/* Allow the pool to be flushed. */
masm.allowPoolFlush(true);
#endif
}
};