Bug 1239369 - Add some missing calls to ReportOutOfMemory r=terrence
authorJon Coppeard <jcoppeard@mozilla.com>
Fri, 15 Jan 2016 09:35:21 +0000
changeset 280187 a83f3effa2787e034df107b5f54cfca1aef36c3e
parent 280186 32a8c6a3be186bbc1f39da147eb09b087ed322e3
child 280188 df444117c7bea0a407387dca31ed54c3598b054a
push id29906
push userryanvm@gmail.com
push dateSun, 17 Jan 2016 19:40:11 +0000
treeherdermozilla-central@b92f5032b4fd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersterrence
bugs1239369
milestone46.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1239369 - Add some missing calls to ReportOutOfMemory r=terrence
js/src/builtin/ModuleObject.cpp
js/src/jit/BaselineBailouts.cpp
--- a/js/src/builtin/ModuleObject.cpp
+++ b/js/src/builtin/ModuleObject.cpp
@@ -231,17 +231,22 @@ IndirectBindingMap::trace(JSTracer* trc)
 }
 
 bool
 IndirectBindingMap::putNew(JSContext* cx, HandleId name,
                            HandleModuleEnvironmentObject environment, HandleId localName)
 {
     RootedShape shape(cx, environment->lookup(cx, localName));
     MOZ_ASSERT(shape);
-    return map_.putNew(name, Binding(environment, shape));
+    if (!map_.putNew(name, Binding(environment, shape))) {
+        ReportOutOfMemory(cx);
+        return false;
+    }
+
+    return true;
 }
 
 bool
 IndirectBindingMap::lookup(jsid name, ModuleEnvironmentObject** envOut, Shape** shapeOut) const
 {
     auto ptr = map_.lookup(name);
     if (!ptr)
         return false;
@@ -757,17 +762,22 @@ ModuleObject::createEnvironment()
     MOZ_ASSERT(getReservedSlot(EnvironmentSlot).isUndefined());
     setReservedSlot(EnvironmentSlot, getReservedSlot(InitialEnvironmentSlot));
 }
 
 bool
 ModuleObject::noteFunctionDeclaration(ExclusiveContext* cx, HandleAtom name, HandleFunction fun)
 {
     FunctionDeclarationVector* funDecls = functionDeclarations();
-    return funDecls->emplaceBack(name, fun);
+    if (!funDecls->emplaceBack(name, fun)) {
+        ReportOutOfMemory(cx);
+        return false;
+    }
+
+    return true;
 }
 
 /* static */ bool
 ModuleObject::instantiateFunctionDeclarations(JSContext* cx, HandleModuleObject self)
 {
     FunctionDeclarationVector* funDecls = self->functionDeclarations();
     if (!funDecls) {
         JS_ReportError(cx, "Module function declarations have already been instantiated");
--- a/js/src/jit/BaselineBailouts.cpp
+++ b/js/src/jit/BaselineBailouts.cpp
@@ -1144,18 +1144,20 @@ InitFromBailout(JSContext* cx, HandleScr
 
         if (cx->runtime()->spsProfiler.enabled()) {
             // Register bailout with profiler.
             const char* filename = script->filename();
             if (filename == nullptr)
                 filename = "<unknown>";
             unsigned len = strlen(filename) + 200;
             char* buf = js_pod_malloc<char>(len);
-            if (buf == nullptr)
+            if (buf == nullptr) {
+                ReportOutOfMemory(cx);
                 return false;
+            }
             JS_snprintf(buf, len, "%s %s %s on line %u of %s:%" PRIuSIZE,
                                   BailoutKindString(bailoutKind),
                                   resumeAfter ? "after" : "at",
                                   CodeName[op],
                                   PCToLineNumber(script, pc),
                                   filename,
                                   script->lineno());
             cx->runtime()->spsProfiler.markEvent(buf);