From e4f99f6c81a5f23318787adba6fea1137dc755bb Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Thu, 14 Jul 2016 17:59:33 -0700 Subject: emit safe calls for i32 div/rem when in precise mode in asm2wasm, as they can trap (#637) --- src/js/wasm.js-post.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/js/wasm.js-post.js') diff --git a/src/js/wasm.js-post.js b/src/js/wasm.js-post.js index 6d73981f1..ae42ef175 100644 --- a/src/js/wasm.js-post.js +++ b/src/js/wasm.js-post.js @@ -45,6 +45,18 @@ function integrateWasmJS(Module) { "f64-to-int": function(x) { return x | 0; }, + "i32s-div": function(x, y) { + return ((x | 0) / (y | 0)) | 0; + }, + "i32u-div": function(x, y) { + return ((x >>> 0) / (y >>> 0)) >>> 0; + }, + "i32s-rem": function(x, y) { + return ((x | 0) % (y | 0)) | 0; + }, + "i32u-rem": function(x, y) { + return ((x >>> 0) % (y >>> 0)) >>> 0; + }, "debugger": function() { debugger; }, -- cgit v1.2.3