Bug 1264948 - Check for OOM when linking all break keywords of switch statements. r=h4writer
authorNicolas B. Pierron <nicolas.b.pierron@mozilla.com>
Mon, 04 Jul 2016 13:56:32 +0000
changeset 303503 7f6ff2e767e36e7b0f6edf15a44cfb948faa0eea
parent 303502 e28b6e2e44d1273e84f93ede285ba5d363023ba8
child 303504 98317a8a0ba441596e4a1064c7bbbdb95c0e42ac
push id79107
push usernpierron@mozilla.com
push dateMon, 04 Jul 2016 13:57:03 +0000
treeherdermozilla-inbound@7f6ff2e767e3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersh4writer
bugs1264948
milestone50.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 1264948 - Check for OOM when linking all break keywords of switch statements. r=h4writer
js/src/jit/IonBuilder.cpp
js/src/jit/MIR.cpp
js/src/jit/MIR.h
--- a/js/src/jit/IonBuilder.cpp
+++ b/js/src/jit/IonBuilder.cpp
@@ -2819,17 +2819,20 @@ IonBuilder::createBreakCatchBlock(Deferr
 
     // No need to use addPredecessor for first edge,
     // because it is already predecessor.
     edge->block->end(MGoto::New(alloc(), successor));
     edge = edge->next;
 
     // Finish up remaining breaks.
     while (edge) {
-        edge->block->end(MGoto::New(alloc(), successor));
+        MGoto* brk = MGoto::New(alloc().fallible(), successor);
+        if (!brk)
+            return nullptr;
+        edge->block->end(brk);
         if (!successor->addPredecessor(alloc(), edge->block))
             return nullptr;
         edge = edge->next;
     }
 
     return successor;
 }
 
--- a/js/src/jit/MIR.cpp
+++ b/js/src/jit/MIR.cpp
@@ -2080,16 +2080,23 @@ MTableSwitch::New(TempAllocator& alloc, 
 MGoto*
 MGoto::New(TempAllocator& alloc, MBasicBlock* target)
 {
     MOZ_ASSERT(target);
     return new(alloc) MGoto(target);
 }
 
 MGoto*
+MGoto::New(TempAllocator::Fallible alloc, MBasicBlock* target)
+{
+    MOZ_ASSERT(target);
+    return new(alloc) MGoto(target);
+}
+
+MGoto*
 MGoto::NewAsm(TempAllocator& alloc)
 {
     return new(alloc) MGoto(nullptr);
 }
 
 void
 MUnbox::printOpcode(GenericPrinter& out) const
 {
--- a/js/src/jit/MIR.h
+++ b/js/src/jit/MIR.h
@@ -2908,16 +2908,17 @@ class MGoto
 {
     explicit MGoto(MBasicBlock* target) {
         setSuccessor(0, target);
     }
 
   public:
     INSTRUCTION_HEADER(Goto)
     static MGoto* New(TempAllocator& alloc, MBasicBlock* target);
+    static MGoto* New(TempAllocator::Fallible alloc, MBasicBlock* target);
 
     // Factory for asm, which may patch the target later.
     static MGoto* NewAsm(TempAllocator& alloc);
 
     static const size_t TargetIndex = 0;
 
     MBasicBlock* target() {
         return getSuccessor(0);