Skip to content

Commit de022c9

Browse files
authored
Update Binaryen to latest and enable fast math by default (#1481)
1 parent 3223f76 commit de022c9

37 files changed

+158
-286
lines changed

package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"url": "https://github.com/AssemblyScript/assemblyscript/issues"
2222
},
2323
"dependencies": {
24-
"binaryen": "97.0.0-nightly.20200929",
24+
"binaryen": "97.0.0-nightly.20201006",
2525
"long": "^4.0.0",
2626
"source-map-support": "^0.5.19",
2727
"ts-node": "^6.2.0"

src/glue/binaryen.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -970,6 +970,8 @@ export declare function _BinaryenGetDebugInfo(): bool;
970970
export declare function _BinaryenSetDebugInfo(on: bool): void;
971971
export declare function _BinaryenGetLowMemoryUnused(): bool;
972972
export declare function _BinaryenSetLowMemoryUnused(on: bool): void;
973+
export declare function _BinaryenGetFastMath(): bool;
974+
export declare function _BinaryenSetFastMath(on: bool): void;
973975
export declare function _BinaryenGetPassArgument(key: BinaryenString): BinaryenString;
974976
export declare function _BinaryenSetPassArgument(key: BinaryenString, value: BinaryenString): void;
975977
export declare function _BinaryenClearPassArguments(): void;

src/module.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1386,6 +1386,14 @@ export class Module {
13861386
binaryen._BinaryenSetLowMemoryUnused(on);
13871387
}
13881388

1389+
getFastMath(): bool {
1390+
return binaryen._BinaryenGetFastMath();
1391+
}
1392+
1393+
setFastMath(on: bool): void {
1394+
binaryen._BinaryenSetFastMath(on);
1395+
}
1396+
13891397
getPassArgument(key: string): string | null {
13901398
var cStr = this.allocStringCached(key);
13911399
var ptr = binaryen._BinaryenGetPassArgument(cStr);
@@ -1477,6 +1485,7 @@ export class Module {
14771485
this.setOptimizeLevel(optimizeLevel);
14781486
this.setShrinkLevel(shrinkLevel);
14791487
this.setDebugInfo(debugInfo);
1488+
this.setFastMath(true);
14801489
this.clearPassArguments();
14811490

14821491
// Tweak inlining limits based on optimization levels

tests/compiler/do.optimized.wat

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -238,11 +238,9 @@
238238
i32.add
239239
local.tee $4
240240
i32.load offset=4
241-
i32.const 1
241+
i32.const -2
242242
local.get $2
243-
i32.shl
244-
i32.const -1
245-
i32.xor
243+
i32.rotl
246244
i32.and
247245
local.set $1
248246
local.get $4
@@ -254,11 +252,9 @@
254252
local.get $0
255253
local.get $0
256254
i32.load
257-
i32.const 1
255+
i32.const -2
258256
local.get $3
259-
i32.shl
260-
i32.const -1
261-
i32.xor
257+
i32.rotl
262258
i32.and
263259
i32.store
264260
end

tests/compiler/extends-baseaggregate.optimized.wat

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -163,11 +163,9 @@
163163
i32.add
164164
local.tee $4
165165
i32.load offset=4
166-
i32.const 1
166+
i32.const -2
167167
local.get $2
168-
i32.shl
169-
i32.const -1
170-
i32.xor
168+
i32.rotl
171169
i32.and
172170
local.set $1
173171
local.get $4
@@ -179,11 +177,9 @@
179177
local.get $0
180178
local.get $0
181179
i32.load
182-
i32.const 1
180+
i32.const -2
183181
local.get $3
184-
i32.shl
185-
i32.const -1
186-
i32.xor
182+
i32.rotl
187183
i32.and
188184
i32.store
189185
end

tests/compiler/for.optimized.wat

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -235,11 +235,9 @@
235235
i32.add
236236
local.tee $4
237237
i32.load offset=4
238-
i32.const 1
238+
i32.const -2
239239
local.get $2
240-
i32.shl
241-
i32.const -1
242-
i32.xor
240+
i32.rotl
243241
i32.and
244242
local.set $1
245243
local.get $4
@@ -251,11 +249,9 @@
251249
local.get $0
252250
local.get $0
253251
i32.load
254-
i32.const 1
252+
i32.const -2
255253
local.get $3
256-
i32.shl
257-
i32.const -1
258-
i32.xor
254+
i32.rotl
259255
i32.and
260256
i32.store
261257
end

tests/compiler/implicit-getter-setter.optimized.wat

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -170,11 +170,9 @@
170170
i32.add
171171
local.tee $4
172172
i32.load offset=4
173-
i32.const 1
173+
i32.const -2
174174
local.get $2
175-
i32.shl
176-
i32.const -1
177-
i32.xor
175+
i32.rotl
178176
i32.and
179177
local.set $1
180178
local.get $4
@@ -186,11 +184,9 @@
186184
local.get $0
187185
local.get $0
188186
i32.load
189-
i32.const 1
187+
i32.const -2
190188
local.get $3
191-
i32.shl
192-
i32.const -1
193-
i32.xor
189+
i32.rotl
194190
i32.and
195191
i32.store
196192
end

tests/compiler/issues/1095.optimized.wat

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -155,11 +155,9 @@
155155
i32.add
156156
local.tee $4
157157
i32.load offset=4
158-
i32.const 1
158+
i32.const -2
159159
local.get $2
160-
i32.shl
161-
i32.const -1
162-
i32.xor
160+
i32.rotl
163161
i32.and
164162
local.set $1
165163
local.get $4
@@ -171,11 +169,9 @@
171169
local.get $0
172170
local.get $0
173171
i32.load
174-
i32.const 1
172+
i32.const -2
175173
local.get $3
176-
i32.shl
177-
i32.const -1
178-
i32.xor
174+
i32.rotl
179175
i32.and
180176
i32.store
181177
end

tests/compiler/issues/1225.optimized.wat

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -156,11 +156,9 @@
156156
i32.add
157157
local.tee $4
158158
i32.load offset=4
159-
i32.const 1
159+
i32.const -2
160160
local.get $2
161-
i32.shl
162-
i32.const -1
163-
i32.xor
161+
i32.rotl
164162
i32.and
165163
local.set $1
166164
local.get $4
@@ -172,11 +170,9 @@
172170
local.get $0
173171
local.get $0
174172
i32.load
175-
i32.const 1
173+
i32.const -2
176174
local.get $3
177-
i32.shl
178-
i32.const -1
179-
i32.xor
175+
i32.rotl
180176
i32.and
181177
i32.store
182178
end

tests/compiler/logical.optimized.wat

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,9 @@
153153
i32.add
154154
local.tee $4
155155
i32.load offset=4
156-
i32.const 1
156+
i32.const -2
157157
local.get $2
158-
i32.shl
159-
i32.const -1
160-
i32.xor
158+
i32.rotl
161159
i32.and
162160
local.set $1
163161
local.get $4
@@ -169,11 +167,9 @@
169167
local.get $0
170168
local.get $0
171169
i32.load
172-
i32.const 1
170+
i32.const -2
173171
local.get $3
174-
i32.shl
175-
i32.const -1
176-
i32.xor
172+
i32.rotl
177173
i32.and
178174
i32.store
179175
end

tests/compiler/managed-cast.optimized.wat

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -158,11 +158,9 @@
158158
i32.add
159159
local.tee $4
160160
i32.load offset=4
161-
i32.const 1
161+
i32.const -2
162162
local.get $2
163-
i32.shl
164-
i32.const -1
165-
i32.xor
163+
i32.rotl
166164
i32.and
167165
local.set $1
168166
local.get $4
@@ -174,11 +172,9 @@
174172
local.get $0
175173
local.get $0
176174
i32.load
177-
i32.const 1
175+
i32.const -2
178176
local.get $3
179-
i32.shl
180-
i32.const -1
181-
i32.xor
177+
i32.rotl
182178
i32.and
183179
i32.store
184180
end

tests/compiler/object-literal.optimized.wat

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -162,11 +162,9 @@
162162
i32.add
163163
local.tee $4
164164
i32.load offset=4
165-
i32.const 1
165+
i32.const -2
166166
local.get $2
167-
i32.shl
168-
i32.const -1
169-
i32.xor
167+
i32.rotl
170168
i32.and
171169
local.set $1
172170
local.get $4
@@ -178,11 +176,9 @@
178176
local.get $0
179177
local.get $0
180178
i32.load
181-
i32.const 1
179+
i32.const -2
182180
local.get $3
183-
i32.shl
184-
i32.const -1
185-
i32.xor
181+
i32.rotl
186182
i32.and
187183
i32.store
188184
end

tests/compiler/rc/local-init.optimized.wat

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,9 @@
153153
i32.add
154154
local.tee $4
155155
i32.load offset=4
156-
i32.const 1
156+
i32.const -2
157157
local.get $2
158-
i32.shl
159-
i32.const -1
160-
i32.xor
158+
i32.rotl
161159
i32.and
162160
local.set $1
163161
local.get $4
@@ -169,11 +167,9 @@
169167
local.get $0
170168
local.get $0
171169
i32.load
172-
i32.const 1
170+
i32.const -2
173171
local.get $3
174-
i32.shl
175-
i32.const -1
176-
i32.xor
172+
i32.rotl
177173
i32.and
178174
i32.store
179175
end

tests/compiler/rc/logical-and-mismatch.optimized.wat

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,9 @@
153153
i32.add
154154
local.tee $4
155155
i32.load offset=4
156-
i32.const 1
156+
i32.const -2
157157
local.get $2
158-
i32.shl
159-
i32.const -1
160-
i32.xor
158+
i32.rotl
161159
i32.and
162160
local.set $1
163161
local.get $4
@@ -169,11 +167,9 @@
169167
local.get $0
170168
local.get $0
171169
i32.load
172-
i32.const 1
170+
i32.const -2
173171
local.get $3
174-
i32.shl
175-
i32.const -1
176-
i32.xor
172+
i32.rotl
177173
i32.and
178174
i32.store
179175
end

tests/compiler/rc/logical-or-mismatch.optimized.wat

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,9 @@
153153
i32.add
154154
local.tee $4
155155
i32.load offset=4
156-
i32.const 1
156+
i32.const -2
157157
local.get $2
158-
i32.shl
159-
i32.const -1
160-
i32.xor
158+
i32.rotl
161159
i32.and
162160
local.set $1
163161
local.get $4
@@ -169,11 +167,9 @@
169167
local.get $0
170168
local.get $0
171169
i32.load
172-
i32.const 1
170+
i32.const -2
173171
local.get $3
174-
i32.shl
175-
i32.const -1
176-
i32.xor
172+
i32.rotl
177173
i32.and
178174
i32.store
179175
end

0 commit comments

Comments
 (0)