From 583a2d7b8f7364d53863567ff61a5b61ac36ea61 Mon Sep 17 00:00:00 2001 From: Luke Wagner Date: Mon, 14 Mar 2016 10:19:30 -0500 Subject: [PATCH] Bug 1255954 - Odin: move asserts so they only run on successful validation (r=bbouvier) MozReview-Commit-ID: 9moOBWvSs7b --- js/src/asmjs/AsmJS.cpp | 15 +++++---------- js/src/jit-test/tests/asm.js/testBug1255954.js | 10 ++++++++++ 2 files changed, 15 insertions(+), 10 deletions(-) create mode 100644 js/src/jit-test/tests/asm.js/testBug1255954.js diff --git a/js/src/asmjs/AsmJS.cpp b/js/src/asmjs/AsmJS.cpp index f81894041258..652d0859c950 100644 --- a/js/src/asmjs/AsmJS.cpp +++ b/js/src/asmjs/AsmJS.cpp @@ -2630,16 +2630,6 @@ class MOZ_STACK_CLASS FunctionValidator hasAlreadyReturned_(false) {} - ~FunctionValidator() { - if (m_.hasAlreadyFailed()) - return; - MOZ_ASSERT(!blockDepth_); - MOZ_ASSERT(breakableStack_.empty()); - MOZ_ASSERT(continuableStack_.empty()); - MOZ_ASSERT(breakLabels_.empty()); - MOZ_ASSERT(continueLabels_.empty()); - } - ModuleValidator& m() const { return m_; } ExclusiveContext* cx() const { return m_.cx(); } ParseNode* fn() const { return fn_; } @@ -2656,6 +2646,11 @@ class MOZ_STACK_CLASS FunctionValidator } bool finish(uint32_t funcIndex, unsigned generateTime) { + MOZ_ASSERT(!blockDepth_); + MOZ_ASSERT(breakableStack_.empty()); + MOZ_ASSERT(continuableStack_.empty()); + MOZ_ASSERT(breakLabels_.empty()); + MOZ_ASSERT(continueLabels_.empty()); return m_.mg().finishFuncDef(funcIndex, generateTime, &fg_); } diff --git a/js/src/jit-test/tests/asm.js/testBug1255954.js b/js/src/jit-test/tests/asm.js/testBug1255954.js new file mode 100644 index 000000000000..7379a9b8aefe --- /dev/null +++ b/js/src/jit-test/tests/asm.js/testBug1255954.js @@ -0,0 +1,10 @@ +const USE_ASM = '"use asm";'; +function asmCompile() { + var f = Function.apply(null, arguments); +} +oomTest(() => { + try { + function f(b) {} + } catch (exc0) {} + f(asmCompile(USE_ASM + "function f() { var i=42; return i|0; for(;1;) {} return 0 } return f")); +});