Attempt to fix the issues by disabling IM when we run into a corner case (bug 805299, r=dvander)

This commit is contained in:
Marty Rosenberg 2012-12-02 22:21:57 -05:00
parent 6ed039437e
commit eeea3726f7
5 changed files with 20 additions and 4 deletions

View File

@ -55,6 +55,8 @@ class Linker
bytesNeeded - headerSize, pool);
if (!code)
return NULL;
if (masm.oom())
return fail(cx);
code->copyFrom(masm);
masm.link(code);
return code;

View File

@ -504,7 +504,7 @@ class MacroAssembler : public MacroAssemblerSpecific
}
void link(IonCode *code) {
JS_ASSERT(!m_buffer.oom());
// If this code can transition to C++ code and witness a GC, then we need to store
// the IonCode onto the stack in order to GC it correctly. exitCodePatch should
// be unset if the code never needed to push its IonCode*.

View File

@ -1637,6 +1637,10 @@ Assembler::as_b(BOffImm off, Condition c, bool isPatchable)
BufferOffset
Assembler::as_b(Label *l, Condition c, bool isPatchable)
{
if (m_buffer.oom()) {
BufferOffset ret;
return ret;
}
m_buffer.markNextAsBranch();
if (l->bound()) {
BufferOffset ret = as_nop();

View File

@ -77,7 +77,7 @@ struct BufferSlice : public InlineForwardListNode<BufferSlice<SliceSize> > {
template<int SliceSize, class Inst>
struct AssemblerBuffer {
public:
AssemblerBuffer() : head(NULL), tail(NULL), m_oom(false), bufferSize(0) {}
AssemblerBuffer() : head(NULL), tail(NULL), m_bail(false), m_oom(false), bufferSize(0) {}
protected:
typedef BufferSlice<SliceSize> Slice;
typedef AssemblerBuffer<SliceSize, Inst> AssemblerBuffer_;
@ -85,6 +85,7 @@ struct AssemblerBuffer {
Slice *tail;
public:
bool m_oom;
bool m_bail;
// How much data has been added to the buffer thusfar.
uint32 bufferSize;
uint32 lastInstSize;
@ -148,11 +149,17 @@ struct AssemblerBuffer {
return size();
}
bool oom() const {
return m_oom;
return m_oom || m_bail;
}
bool bail() const {
return m_bail;
}
void fail_oom() {
m_oom = true;
}
void fail_bail() {
m_bail = true;
}
Inst *getInst(BufferOffset off) {
unsigned int local_off = off.getOffset();
Slice *cur = NULL;

View File

@ -431,7 +431,7 @@ struct AssemblerBufferWithConstantPool : public AssemblerBuffer<SliceSize, Inst>
}
BufferOffset insertEntry(uint32 instSize, uint8 *inst, Pool *p, uint8 *data, PoolEntry *pe = NULL) {
if (this->oom())
if (this->oom() && !this->bail())
return BufferOffset();
int token;
if (p != NULL) {
@ -726,9 +726,12 @@ struct AssemblerBufferWithConstantPool : public AssemblerBuffer<SliceSize, Inst>
// the last pool, which means it cannot affect the alignment of any other
// Sub Pools.
IonSpew(IonSpew_Pools, "[%d]***Offset was still out of range!***", id, codeOffset - magicAlign);
IonSpew(IonSpew_Pools, "[%d] Too complicated; bailingp", id);
this->fail_bail();
outcasts[poolIdx].append(iter->getOffset());
memcpy(&outcastEntries[poolIdx][numSkips * p->immSize], &p->poolData[idx * p->immSize], p->immSize);
numSkips++;
return;
} else {
preservedEntries[idx] = true;
}