Bug 1349871: Check for masm OOM at the end of baseline codegen; r?lth draft
authorBenjamin Bouvier <benj@benj.me>
Thu, 23 Mar 2017 10:27:05 +0100
changeset 503549 4e7351d42f0ed9874c6df47edc4556b3424434e8
parent 502389 6804841ffca5bcdc8785735ef93b516249828497
child 550463 44201468be8001e92be723b6594ed38d8b5e7776
push id50614
push userbbouvier@mozilla.com
push dateThu, 23 Mar 2017 09:27:37 +0000
reviewerslth
bugs1349871
milestone55.0a1
Bug 1349871: Check for masm OOM at the end of baseline codegen; r?lth MozReview-Commit-ID: 8BEsRLsDCwS
js/src/jit-test/tests/wasm/regress/oom-masm-baseline.js
js/src/wasm/WasmBaselineCompile.cpp
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/wasm/regress/oom-masm-baseline.js
@@ -0,0 +1,31 @@
+if (typeof oomTest === 'undefined')
+    quit();
+
+try {
+    oomTest(Function(`
+        new WebAssembly.Module(wasmTextToBinary(\`
+            (module (func (result i32) (param f64) (param f32)
+                i64.const 0
+                get_local 0
+                drop
+                i32.wrap/i64
+                f64.const 0
+                f64.const 0
+                i32.const 0
+                select
+                f32.const 0
+                f32.const 0
+                f32.const 0
+                i32.const 0
+                select
+                i32.const 0
+                i32.const 0
+                i32.const 0
+                select
+                select
+                drop
+                drop
+            ))
+        \`))
+    `));
+} catch(e) { }
--- a/js/src/wasm/WasmBaselineCompile.cpp
+++ b/js/src/wasm/WasmBaselineCompile.cpp
@@ -2410,17 +2410,17 @@ class BaseCompiler
         offsets_.end = masm.currentOffset();
 
         // A frame greater than 256KB is implausible, probably an attack,
         // so fail the compilation.
 
         if (maxFramePushed_ > 256 * 1024)
             return false;
 
-        return true;
+        return !masm.oom();
     }
 
     //////////////////////////////////////////////////////////////////////
     //
     // Calls.
 
     struct FunctionCall
     {