Bug 727326 - Add missing js_ReportOutOfMemory calls in methodjit code. r=bhackett

This commit is contained in:
Christian Holler 2012-03-10 15:52:28 -05:00
parent d0f8c765b5
commit 6f0c96a025
6 changed files with 32 additions and 13 deletions

View File

@ -3846,10 +3846,9 @@ mjit::stubs::NewDenseUnallocatedArray(VMFrame &f, uint32_t length)
{
JSObject *proto = (JSObject *) f.scratch;
JSObject *obj = NewArray<false>(f.cx, length, proto);
if (!obj) {
js_ReportOutOfMemory(f.cx);
if (!obj)
THROWV(NULL);
}
return obj;
}
#endif

View File

@ -1076,8 +1076,10 @@ JSObject::createDenseArray(JSContext *cx, js::gc::AllocKind kind,
uint32_t capacity = js::gc::GetGCKindSlots(kind) - js::ObjectElements::VALUES_PER_HEADER;
JSObject *obj = js_NewGCObject(cx, kind);
if (!obj)
if (!obj) {
js_ReportOutOfMemory(cx);
return NULL;
}
obj->shape_.init(shape);
obj->type_.init(type);

View File

@ -451,8 +451,10 @@ JSObject::toDictionaryMode(JSContext *cx)
JS_ASSERT(!shape->inDictionary());
Shape *dprop = js_NewGCShape(cx);
if (!dprop)
if (!dprop) {
js_ReportOutOfMemory(cx);
return false;
}
HeapPtrShape *listp = dictionaryShape
? &dictionaryShape->parent
@ -466,8 +468,10 @@ JSObject::toDictionaryMode(JSContext *cx)
shape = shape->previous();
}
if (!root->hashify(cx))
if (!root->hashify(cx)) {
js_ReportOutOfMemory(cx);
return false;
}
JS_ASSERT((Shape **) root->listp == root.address());
root->listp = &self->shape_;

View File

@ -408,8 +408,10 @@ mjit::Compiler::pushActiveFrame(JSScript *script, uint32_t argc)
script->initCounts(cx);
ActiveFrame *newa = OffTheBooks::new_<ActiveFrame>(cx);
if (!newa)
if (!newa) {
js_ReportOutOfMemory(cx);
return Compile_Error;
}
newa->parent = a;
if (a)
@ -624,8 +626,10 @@ mjit::Compiler::prepareInferenceTypes(JSScript *script, ActiveFrame *a)
a->varTypes = (VarType *)
OffTheBooks::calloc_(TotalSlots(script) * sizeof(VarType));
if (!a->varTypes)
if (!a->varTypes) {
js_ReportOutOfMemory(cx);
return Compile_Error;
}
for (uint32_t slot = ArgSlot(0); slot < TotalSlots(script); slot++) {
VarType &vt = a->varTypes[slot];
@ -6998,8 +7002,10 @@ mjit::Compiler::startLoop(jsbytecode *head, Jump entry, jsbytecode *entryTarget)
}
LoopState *nloop = OffTheBooks::new_<LoopState>(cx, &ssa, this, &frame);
if (!nloop || !nloop->init(head, entry, entryTarget))
if (!nloop || !nloop->init(head, entry, entryTarget)) {
js_ReportOutOfMemory(cx);
return false;
}
nloop->outer = loop;
loop = nloop;
@ -7175,8 +7181,10 @@ mjit::Compiler::jumpAndRun(Jump j, jsbytecode *target, Jump *slow, bool *trampol
RegisterAllocation *&alloc = analysis->getAllocation(target);
if (!alloc) {
alloc = cx->typeLifoAlloc().new_<RegisterAllocation>(false);
if (!alloc)
if (!alloc) {
js_ReportOutOfMemory(cx);
return false;
}
}
lvtarget = alloc;
consistent = frame.consistentRegisters(target);

View File

@ -575,8 +575,10 @@ FrameState::computeAllocation(jsbytecode *target)
{
JS_ASSERT(cx->typeInferenceEnabled());
RegisterAllocation *alloc = cx->typeLifoAlloc().new_<RegisterAllocation>(false);
if (!alloc)
if (!alloc) {
js_ReportOutOfMemory(cx);
return NULL;
}
/*
* State must be synced at exception and switch targets, at traps and when
@ -856,8 +858,10 @@ FrameState::discardForJoin(RegisterAllocation *&alloc, uint32_t stackDepth)
* loop head, and for exception, switch target and trap safe points.
*/
alloc = cx->typeLifoAlloc().new_<RegisterAllocation>(false);
if (!alloc)
if (!alloc) {
js_ReportOutOfMemory(cx);
return false;
}
}
resetInternalState();

View File

@ -158,8 +158,10 @@ LoopState::init(jsbytecode *head, Jump entry, jsbytecode *entryTarget)
JS_ASSERT(!alloc);
alloc = cx->typeLifoAlloc().new_<RegisterAllocation>(true);
if (!alloc)
if (!alloc) {
js_ReportOutOfMemory(cx);
return false;
}
this->alloc = alloc;
this->loopRegs = Registers::AvailAnyRegs;