Extract portable AS to its own definition and polyfill; Try running flatten/ssa before default optimizations, see WebAssembly/binaryen#1331

This commit is contained in:
dcodeIO
2017-12-08 19:08:03 +01:00
parent d6b94d4c33
commit 0ebb99a33c
23 changed files with 1515 additions and 1231 deletions

29
portable-assembly.js Normal file
View File

@ -0,0 +1,29 @@
var globalScope = typeof window !== "undefined" && window || typeof global !== "undefined" && global || self;
globalScope["clz"] = Math.clz32;
globalScope["abs"] = Math.abs;
globalScope["max"] = Math.max;
globalScope["min"] = Math.min;
globalScope["ceil"] = Math.ceil;
globalScope["floor"] = Math.floor;
globalScope["select"] = function select(ifTrue, ifFalse, condition) { return condition ? ifTrue : ifFalse; };
globalScope["sqrt"] = Math.sqrt;
globalScope["trunc"] = Math.trunc;
function UnreachableError() {
this.stack = new Error().stack;
}
UnreachableError.prototype = new Error;
UnreachableError.prototype.name = "UnreachableError";
UnreachableError.prototype.message = "unreachable";
globalScope["unreachable"] = function unreachable() { throw new UnreachableError(); };
function AssertionError() {
this.stack = new Error().stack;
}
AssertionError.prototype = new Error;
AssertionError.prototype.name = "AssertionError";
AssertionError.prototype.message = "assertion failed";
globalScope["assert"] = function assert(isTrue) { if (!isTrue) throw new AssertionError(); };