Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"url": "https://github.com/AssemblyScript/assemblyscript/issues"
},
"dependencies": {
"binaryen": "97.0.0-nightly.20200929",
"binaryen": "97.0.0-nightly.20201006",
"long": "^4.0.0",
"source-map-support": "^0.5.19",
"ts-node": "^6.2.0"
Expand Down
2 changes: 2 additions & 0 deletions src/glue/binaryen.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -970,6 +970,8 @@ export declare function _BinaryenGetDebugInfo(): bool;
export declare function _BinaryenSetDebugInfo(on: bool): void;
export declare function _BinaryenGetLowMemoryUnused(): bool;
export declare function _BinaryenSetLowMemoryUnused(on: bool): void;
export declare function _BinaryenGetFastMath(): bool;
export declare function _BinaryenSetFastMath(on: bool): void;
export declare function _BinaryenGetPassArgument(key: BinaryenString): BinaryenString;
export declare function _BinaryenSetPassArgument(key: BinaryenString, value: BinaryenString): void;
export declare function _BinaryenClearPassArguments(): void;
Expand Down
9 changes: 9 additions & 0 deletions src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1386,6 +1386,14 @@ export class Module {
binaryen._BinaryenSetLowMemoryUnused(on);
}

getFastMath(): bool {
return binaryen._BinaryenGetFastMath();
}

setFastMath(on: bool): void {
binaryen._BinaryenSetFastMath(on);
}

getPassArgument(key: string): string | null {
var cStr = this.allocStringCached(key);
var ptr = binaryen._BinaryenGetPassArgument(cStr);
Expand Down Expand Up @@ -1477,6 +1485,7 @@ export class Module {
this.setOptimizeLevel(optimizeLevel);
this.setShrinkLevel(shrinkLevel);
this.setDebugInfo(debugInfo);
this.setFastMath(true);
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Compare with clang's ffast-math It's much safer and just don't care about NaN bits consistency for non-canonical NaNs and accept only safe optimizations like x * 1.0 -> x, x / 1.0 -> x, x * -1.0 -> -x, x - 0.0 -> x, and still doesn't allow unsafe ones like x + 0.0 -> x, x - x -> 0 and etc.

So always turn it on by default.

this.clearPassArguments();

// Tweak inlining limits based on optimization levels
Expand Down
12 changes: 4 additions & 8 deletions tests/compiler/do.optimized.wat
Original file line number Diff line number Diff line change
Expand Up @@ -238,11 +238,9 @@
i32.add
local.tee $4
i32.load offset=4
i32.const 1
i32.const -2
local.get $2
i32.shl
i32.const -1
i32.xor
i32.rotl
i32.and
local.set $1
local.get $4
Expand All @@ -254,11 +252,9 @@
local.get $0
local.get $0
i32.load
i32.const 1
i32.const -2
local.get $3
i32.shl
i32.const -1
i32.xor
i32.rotl
i32.and
i32.store
end
Expand Down
12 changes: 4 additions & 8 deletions tests/compiler/extends-baseaggregate.optimized.wat
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,9 @@
i32.add
local.tee $4
i32.load offset=4
i32.const 1
i32.const -2
local.get $2
i32.shl
i32.const -1
i32.xor
i32.rotl
i32.and
local.set $1
local.get $4
Expand All @@ -179,11 +177,9 @@
local.get $0
local.get $0
i32.load
i32.const 1
i32.const -2
local.get $3
i32.shl
i32.const -1
i32.xor
i32.rotl
i32.and
i32.store
end
Expand Down
12 changes: 4 additions & 8 deletions tests/compiler/for.optimized.wat
Original file line number Diff line number Diff line change
Expand Up @@ -235,11 +235,9 @@
i32.add
local.tee $4
i32.load offset=4
i32.const 1
i32.const -2
local.get $2
i32.shl
i32.const -1
i32.xor
i32.rotl
i32.and
local.set $1
local.get $4
Expand All @@ -251,11 +249,9 @@
local.get $0
local.get $0
i32.load
i32.const 1
i32.const -2
local.get $3
i32.shl
i32.const -1
i32.xor
i32.rotl
i32.and
i32.store
end
Expand Down
12 changes: 4 additions & 8 deletions tests/compiler/implicit-getter-setter.optimized.wat
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,9 @@
i32.add
local.tee $4
i32.load offset=4
i32.const 1
i32.const -2
local.get $2
i32.shl
i32.const -1
i32.xor
i32.rotl
i32.and
local.set $1
local.get $4
Expand All @@ -186,11 +184,9 @@
local.get $0
local.get $0
i32.load
i32.const 1
i32.const -2
local.get $3
i32.shl
i32.const -1
i32.xor
i32.rotl
i32.and
i32.store
end
Expand Down
12 changes: 4 additions & 8 deletions tests/compiler/issues/1095.optimized.wat
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,9 @@
i32.add
local.tee $4
i32.load offset=4
i32.const 1
i32.const -2
local.get $2
i32.shl
i32.const -1
i32.xor
i32.rotl
i32.and
local.set $1
local.get $4
Expand All @@ -171,11 +169,9 @@
local.get $0
local.get $0
i32.load
i32.const 1
i32.const -2
local.get $3
i32.shl
i32.const -1
i32.xor
i32.rotl
i32.and
i32.store
end
Expand Down
12 changes: 4 additions & 8 deletions tests/compiler/issues/1225.optimized.wat
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,9 @@
i32.add
local.tee $4
i32.load offset=4
i32.const 1
i32.const -2
local.get $2
i32.shl
i32.const -1
i32.xor
i32.rotl
i32.and
local.set $1
local.get $4
Expand All @@ -172,11 +170,9 @@
local.get $0
local.get $0
i32.load
i32.const 1
i32.const -2
local.get $3
i32.shl
i32.const -1
i32.xor
i32.rotl
i32.and
i32.store
end
Expand Down
12 changes: 4 additions & 8 deletions tests/compiler/logical.optimized.wat
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,9 @@
i32.add
local.tee $4
i32.load offset=4
i32.const 1
i32.const -2
local.get $2
i32.shl
i32.const -1
i32.xor
i32.rotl
i32.and
local.set $1
local.get $4
Expand All @@ -169,11 +167,9 @@
local.get $0
local.get $0
i32.load
i32.const 1
i32.const -2
local.get $3
i32.shl
i32.const -1
i32.xor
i32.rotl
i32.and
i32.store
end
Expand Down
12 changes: 4 additions & 8 deletions tests/compiler/managed-cast.optimized.wat
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,9 @@
i32.add
local.tee $4
i32.load offset=4
i32.const 1
i32.const -2
local.get $2
i32.shl
i32.const -1
i32.xor
i32.rotl
i32.and
local.set $1
local.get $4
Expand All @@ -174,11 +172,9 @@
local.get $0
local.get $0
i32.load
i32.const 1
i32.const -2
local.get $3
i32.shl
i32.const -1
i32.xor
i32.rotl
i32.and
i32.store
end
Expand Down
12 changes: 4 additions & 8 deletions tests/compiler/object-literal.optimized.wat
Original file line number Diff line number Diff line change
Expand Up @@ -162,11 +162,9 @@
i32.add
local.tee $4
i32.load offset=4
i32.const 1
i32.const -2
local.get $2
i32.shl
i32.const -1
i32.xor
i32.rotl
i32.and
local.set $1
local.get $4
Expand All @@ -178,11 +176,9 @@
local.get $0
local.get $0
i32.load
i32.const 1
i32.const -2
local.get $3
i32.shl
i32.const -1
i32.xor
i32.rotl
i32.and
i32.store
end
Expand Down
12 changes: 4 additions & 8 deletions tests/compiler/rc/local-init.optimized.wat
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,9 @@
i32.add
local.tee $4
i32.load offset=4
i32.const 1
i32.const -2
local.get $2
i32.shl
i32.const -1
i32.xor
i32.rotl
i32.and
local.set $1
local.get $4
Expand All @@ -169,11 +167,9 @@
local.get $0
local.get $0
i32.load
i32.const 1
i32.const -2
local.get $3
i32.shl
i32.const -1
i32.xor
i32.rotl
i32.and
i32.store
end
Expand Down
12 changes: 4 additions & 8 deletions tests/compiler/rc/logical-and-mismatch.optimized.wat
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,9 @@
i32.add
local.tee $4
i32.load offset=4
i32.const 1
i32.const -2
local.get $2
i32.shl
i32.const -1
i32.xor
i32.rotl
i32.and
local.set $1
local.get $4
Expand All @@ -169,11 +167,9 @@
local.get $0
local.get $0
i32.load
i32.const 1
i32.const -2
local.get $3
i32.shl
i32.const -1
i32.xor
i32.rotl
i32.and
i32.store
end
Expand Down
12 changes: 4 additions & 8 deletions tests/compiler/rc/logical-or-mismatch.optimized.wat
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,9 @@
i32.add
local.tee $4
i32.load offset=4
i32.const 1
i32.const -2
local.get $2
i32.shl
i32.const -1
i32.xor
i32.rotl
i32.and
local.set $1
local.get $4
Expand All @@ -169,11 +167,9 @@
local.get $0
local.get $0
i32.load
i32.const 1
i32.const -2
local.get $3
i32.shl
i32.const -1
i32.xor
i32.rotl
i32.and
i32.store
end
Expand Down
Loading