Bug 990787, part 1 - When JSObject::shrinkElements can't reallocate the array to shrink it, clear the OOM exception, as we are not going to propagate the error. r=shu.

This commit is contained in:
Jason Orendorff
2014-04-08 12:35:17 -05:00
parent 2fb2be7339
commit 7d97c455f3
3 changed files with 31 additions and 6 deletions

View File

@@ -3055,8 +3055,9 @@ ReallocateElements(ThreadSafeContext *cx, JSObject *obj, ObjectElements *oldHead
{
#ifdef JSGC_GENERATIONAL
if (cx->isJSContext()) {
return cx->asJSContext()->runtime()-> gcNursery.reallocateElements(cx->asJSContext(), obj, oldHeader,
oldCount, newCount);
return cx->asJSContext()->runtime()->gcNursery.reallocateElements(cx->asJSContext(), obj,
oldHeader, oldCount,
newCount);
}
#endif
@@ -3140,7 +3141,7 @@ JSObject::shrinkElements(ThreadSafeContext *cx, uint32_t newcap)
uint32_t oldcap = getDenseCapacity();
JS_ASSERT(newcap <= oldcap);
/* Don't shrink elements below the minimum capacity. */
// Don't shrink elements below the minimum capacity.
if (oldcap <= SLOT_CAPACITY_MIN || !hasDynamicElements())
return;
@@ -3151,8 +3152,10 @@ JSObject::shrinkElements(ThreadSafeContext *cx, uint32_t newcap)
ObjectElements *newheader = ReallocateElements(cx, this, getElementsHeader(),
oldAllocated, newAllocated);
if (!newheader)
return; /* Leave elements at its old size. */
if (!newheader) {
cx->recoverFromOutOfMemory();
return; // Leave elements at its old size.
}
newheader->capacity = newcap;
elements = newheader->elements();