Bug 1155618 - Fix some more places we don't report allocation failure to the context r=terrence

This commit is contained in:
Jon Coppeard 2015-05-28 10:22:41 +01:00
parent 19d359076b
commit eb6861af9a
8 changed files with 34 additions and 9 deletions

View File

@ -1835,8 +1835,10 @@ TokenStream::getStringOrTemplateToken(int untilChar, Token** tp)
ungetCharIgnoreEOL(nc);
}
if (!tokenbuf.append(c))
if (!tokenbuf.append(c)) {
ReportOutOfMemory(cx);
return false;
}
}
JSAtom* atom = atomize(cx, tokenbuf);

View File

@ -54,7 +54,10 @@ AllocateObjectBuffer(ExclusiveContext* cx, JSObject* obj, uint32_t count)
if (cx->isJSContext()) {
Nursery& nursery = cx->asJSContext()->runtime()->gc.nursery;
size_t nbytes = JS_ROUNDUP(count * sizeof(T), sizeof(Value));
return static_cast<T*>(nursery.allocateBuffer(obj, nbytes));
T* buffer = static_cast<T*>(nursery.allocateBuffer(obj, nbytes));
if (!buffer)
ReportOutOfMemory(cx);
return buffer;
}
return obj->zone()->pod_malloc<T>(count);
}

View File

@ -151,8 +151,10 @@ BaselineCompiler::compile()
indexEntry.pcOffset = entry.pcOffset;
indexEntry.nativeOffset = entry.nativeOffset;
indexEntry.bufferOffset = pcEntries.length();
if (!pcMappingIndexEntries.append(indexEntry))
if (!pcMappingIndexEntries.append(indexEntry)) {
ReportOutOfMemory(cx);
return Method_Error;
}
previousOffset = entry.nativeOffset;
}

View File

@ -98,7 +98,11 @@ class BaselineCompilerShared
bool appendICEntry(ICEntry::Kind kind, uint32_t returnOffset) {
ICEntry entry(script->pcToOffset(pc), kind);
entry.setReturnOffset(CodeOffsetLabel(returnOffset));
return icEntries_.append(entry);
if (!icEntries_.append(entry)) {
ReportOutOfMemory(cx);
return false;
}
return true;
}
bool addICLoadLabel(CodeOffsetLabel label) {
@ -106,7 +110,11 @@ class BaselineCompilerShared
ICLoadLabel loadLabel;
loadLabel.label = label;
loadLabel.icEntry = icEntries_.length() - 1;
return icLoadLabels_.append(loadLabel);
if (!icLoadLabels_.append(loadLabel)) {
ReportOutOfMemory(cx);
return false;
}
return true;
}
JSFunction* function() const {

View File

@ -148,8 +148,10 @@ Bindings::initWithTemporaryStorage(ExclusiveContext* cx, InternalBindingsHandle
#ifdef DEBUG
HashSet<PropertyName*> added(cx);
if (!added.init())
if (!added.init()) {
ReportOutOfMemory(cx);
return false;
}
#endif
uint32_t slot = CallObject::RESERVED_SLOTS;
@ -160,8 +162,10 @@ Bindings::initWithTemporaryStorage(ExclusiveContext* cx, InternalBindingsHandle
#ifdef DEBUG
// The caller ensures no duplicate aliased names.
MOZ_ASSERT(!added.has(bi->name()));
if (!added.put(bi->name()))
if (!added.put(bi->name())) {
ReportOutOfMemory(cx);
return false;
}
#endif
StackBaseShape stackBase(cx, &CallObject::class_,

View File

@ -824,6 +824,7 @@ ObjectGroup::setGroupToHomogenousArray(ExclusiveContext* cx, JSObject* obj,
if (!table) {
table = cx->new_<ObjectGroupCompartment::ArrayObjectTable>();
if (!table || !table->init()) {
ReportOutOfMemory(cx);
js_delete(table);
table = nullptr;
return;
@ -947,6 +948,7 @@ ObjectGroup::newPlainObject(ExclusiveContext* cx, IdValuePair* properties, size_
if (!table) {
table = cx->new_<ObjectGroupCompartment::PlainObjectTable>();
if (!table || !table->init()) {
ReportOutOfMemory(cx);
js_delete(table);
table = nullptr;
return nullptr;
@ -1135,6 +1137,7 @@ ObjectGroup::allocationSiteGroup(JSContext* cx, JSScript* script, jsbytecode* pc
if (!table) {
table = cx->new_<ObjectGroupCompartment::AllocationSiteTable>();
if (!table || !table->init()) {
ReportOutOfMemory(cx);
js_delete(table);
table = nullptr;
return nullptr;

View File

@ -61,7 +61,7 @@ NewObjectCache::newObjectFromHit(JSContext* cx, EntryIndex entryIndex, gc::Initi
return nullptr;
NativeObject* obj = static_cast<NativeObject*>(Allocate<JSObject, NoGC>(cx, entry->kind, 0,
heap, group->clasp()));
heap, group->clasp()));
if (!obj)
return nullptr;

View File

@ -475,8 +475,11 @@ JSRope::flattenInternal(ExclusiveContext* maybecx)
}
}
if (!AllocChars(this, wholeLength, &wholeChars, &wholeCapacity))
if (!AllocChars(this, wholeLength, &wholeChars, &wholeCapacity)) {
if (maybecx)
ReportOutOfMemory(maybecx);
return nullptr;
}
pos = wholeChars;
first_visit_node: {