From cfeab082c91fc04c8d45a2dfc861622c67f76cb6 Mon Sep 17 00:00:00 2001 From: "Nicolas B. Pierron" Date: Mon, 4 Jul 2016 13:56:32 +0000 Subject: [PATCH] Bug 1264948 - Check for OOM when linking all break keywords of switch statements. r=h4writer --- js/src/jit/IonBuilder.cpp | 5 ++++- js/src/jit/MIR.cpp | 7 +++++++ js/src/jit/MIR.h | 1 + 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/js/src/jit/IonBuilder.cpp b/js/src/jit/IonBuilder.cpp index 6fb5cf66361d..0a554ff0d077 100644 --- a/js/src/jit/IonBuilder.cpp +++ b/js/src/jit/IonBuilder.cpp @@ -2824,7 +2824,10 @@ IonBuilder::createBreakCatchBlock(DeferredEdge* edge, jsbytecode* pc) // 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; diff --git a/js/src/jit/MIR.cpp b/js/src/jit/MIR.cpp index cd3cea8160b1..d3ad39a98321 100644 --- a/js/src/jit/MIR.cpp +++ b/js/src/jit/MIR.cpp @@ -2084,6 +2084,13 @@ MGoto::New(TempAllocator& alloc, MBasicBlock* 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) { diff --git a/js/src/jit/MIR.h b/js/src/jit/MIR.h index eb7bd6f2f254..396b0450b7b6 100644 --- a/js/src/jit/MIR.h +++ b/js/src/jit/MIR.h @@ -2913,6 +2913,7 @@ class MGoto 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);