summaryrefslogtreecommitdiff
path: root/src/js/wasm.js-post.js
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2016-07-14 17:59:33 -0700
committerGitHub <noreply@github.com>2016-07-14 17:59:33 -0700
commite4f99f6c81a5f23318787adba6fea1137dc755bb (patch)
tree2fff27409e894cbfb0d473c4e768455795903505 /src/js/wasm.js-post.js
parent4994da80284c337e5395ad836948ee38ffb967f1 (diff)
downloadbinaryen-e4f99f6c81a5f23318787adba6fea1137dc755bb.tar.gz
binaryen-e4f99f6c81a5f23318787adba6fea1137dc755bb.tar.bz2
binaryen-e4f99f6c81a5f23318787adba6fea1137dc755bb.zip
emit safe calls for i32 div/rem when in precise mode in asm2wasm, as they can trap (#637)
Diffstat (limited to 'src/js/wasm.js-post.js')
-rw-r--r--src/js/wasm.js-post.js12
1 files changed, 12 insertions, 0 deletions
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;
},