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
Родитель 3a84fa3dfd
Коммит 7165060946
8 изменённых файлов: 34 добавлений и 9 удалений

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

@ -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);

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

@ -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);
}

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

@ -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;
}

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

@ -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 {

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

@ -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_,

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

@ -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;

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

@ -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;

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

@ -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: {