Skip to content

Commit ed2490b

Browse files
authored
Update Binaryen (#1401)
1 parent 5eb99ee commit ed2490b

10 files changed

+319
-182
lines changed

Diff for: package-lock.json

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: package.json

+1-1
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": "94.0.0-nightly.20200716",
24+
"binaryen": "95.0.0-nightly.20200723",
2525
"long": "^4.0.0",
2626
"source-map-support": "^0.5.19",
2727
"ts-node": "^6.2.0"

Diff for: src/compiler.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ import {
3939
getConstValueF32,
4040
getConstValueF64,
4141
getBlockChildCount,
42-
getBlockChild,
42+
getBlockChildAt,
4343
getBlockName,
4444
getLocalGetIndex,
4545
isLocalTee,
@@ -2194,7 +2194,7 @@ export class Compiler extends DiagnosticEmitter {
21942194
switch (getExpressionId(stmt)) {
21952195
case ExpressionId.Block: {
21962196
if (!getBlockName(stmt)) {
2197-
for (let j: Index = 0, k = getBlockChildCount(stmt); j < k; ++j) stmts.push(getBlockChild(stmt, j));
2197+
for (let j: Index = 0, k = getBlockChildCount(stmt); j < k; ++j) stmts.push(getBlockChildAt(stmt, j));
21982198
break;
21992199
}
22002200
// fall-through
@@ -7635,7 +7635,7 @@ export class Compiler extends DiagnosticEmitter {
76357635
if (getBlockName(expr) === null) { // must not be a break target
76367636
let count = getBlockChildCount(expr);
76377637
if (count) {
7638-
return this.tryUndoAutorelease(getBlockChild(expr, count - 1), flow);
7638+
return this.tryUndoAutorelease(getBlockChildAt(expr, count - 1), flow);
76397639
}
76407640
}
76417641
break;

Diff for: src/flow.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ import {
5656
isLoadSigned,
5757
getBlockName,
5858
getBlockChildCount,
59-
getBlockChild,
59+
getBlockChildAt,
6060
getIfTrue,
6161
getIfFalse,
6262
getSelectThen,
@@ -66,7 +66,7 @@ import {
6666
getIfCondition,
6767
getConstValueI64High,
6868
getUnaryValue,
69-
getCallOperand,
69+
getCallOperandAt,
7070
traverse
7171
} from "./module";
7272

@@ -1114,7 +1114,7 @@ export class Flow {
11141114
let program = this.parentFunction.program;
11151115
if (name == program.retainInstance.internalName) {
11161116
// __retain just passes through the argument
1117-
this.inheritNonnullIfTrue(getCallOperand(expr, 0), iff);
1117+
this.inheritNonnullIfTrue(getCallOperandAt(expr, 0), iff);
11181118
}
11191119
break;
11201120
}
@@ -1423,7 +1423,7 @@ export class Flow {
14231423
case ExpressionId.Block: {
14241424
if (!getBlockName(expr)) {
14251425
let size = assert(getBlockChildCount(expr));
1426-
let last = getBlockChild(expr, size - 1);
1426+
let last = getBlockChildAt(expr, size - 1);
14271427
return this.canOverflow(last, type);
14281428
}
14291429
break;

Diff for: src/glue/binaryen.d.ts

+290-138
Large diffs are not rendered by default.

Diff for: src/module.ts

+15-15
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,7 @@ export class Module {
626626
offset: Index = 0,
627627
align: Index = bytes // naturally aligned by default
628628
): ExpressionRef {
629-
return binaryen._BinaryenLoad(this.ref, bytes, signed ? 1 : 0, offset, align, type, ptr);
629+
return binaryen._BinaryenLoad(this.ref, bytes, signed, offset, align, type, ptr);
630630
}
631631

632632
store(
@@ -1797,7 +1797,7 @@ export class Module {
17971797
)
17981798
: binaryen._BinaryenLoad(this.ref,
17991799
binaryen._BinaryenLoadGetBytes(expr),
1800-
binaryen._BinaryenLoadIsSigned(expr) ? 1 : 0,
1800+
binaryen._BinaryenLoadIsSigned(expr),
18011801
binaryen._BinaryenLoadGetOffset(expr),
18021802
binaryen._BinaryenLoadGetAlign(expr),
18031803
binaryen._BinaryenExpressionGetType(expr),
@@ -2013,8 +2013,8 @@ export function getBlockChildCount(expr: ExpressionRef): Index {
20132013
return binaryen._BinaryenBlockGetNumChildren(expr);
20142014
}
20152015

2016-
export function getBlockChild(expr: ExpressionRef, index: Index): ExpressionRef {
2017-
return binaryen._BinaryenBlockGetChild(expr, index);
2016+
export function getBlockChildAt(expr: ExpressionRef, index: Index): ExpressionRef {
2017+
return binaryen._BinaryenBlockGetChildAt(expr, index);
20182018
}
20192019

20202020
export function getIfCondition(expr: ExpressionRef): ExpressionRef {
@@ -2073,8 +2073,8 @@ export function getCallOperandCount(expr: ExpressionRef): i32 {
20732073
return binaryen._BinaryenCallGetNumOperands(expr);
20742074
}
20752075

2076-
export function getCallOperand(expr: ExpressionRef, index: Index): ExpressionRef {
2077-
return binaryen._BinaryenCallGetOperand(expr, index);
2076+
export function getCallOperandAt(expr: ExpressionRef, index: Index): ExpressionRef {
2077+
return binaryen._BinaryenCallGetOperandAt(expr, index);
20782078
}
20792079

20802080
export function getHostOp(expr: ExpressionRef): ExpressionRef {
@@ -2085,8 +2085,8 @@ export function getHostOperandCount(expr: ExpressionRef): Index {
20852085
return binaryen._BinaryenHostGetNumOperands(expr);
20862086
}
20872087

2088-
export function getHostOperand(expr: ExpressionRef, index: Index): ExpressionRef {
2089-
return binaryen._BinaryenHostGetOperand(expr, index);
2088+
export function getHostOperandAt(expr: ExpressionRef, index: Index): ExpressionRef {
2089+
return binaryen._BinaryenHostGetOperandAt(expr, index);
20902090
}
20912091

20922092
export function getHostName(expr: ExpressionRef): string | null {
@@ -2495,7 +2495,7 @@ export function needsExplicitUnreachable(expr: ExpressionRef): bool {
24952495
let numChildren = binaryen._BinaryenBlockGetNumChildren(expr); // last child needs unreachable
24962496
return (
24972497
numChildren > 0 &&
2498-
needsExplicitUnreachable(binaryen._BinaryenBlockGetChild(expr, numChildren - 1))
2498+
needsExplicitUnreachable(binaryen._BinaryenBlockGetChildAt(expr, numChildren - 1))
24992499
);
25002500
}
25012501
}
@@ -2512,7 +2512,7 @@ export function traverse<T>(
25122512
switch (getExpressionId(expr)) {
25132513
case ExpressionId.Block: {
25142514
for (let i: Index = 0, n = binaryen._BinaryenBlockGetNumChildren(expr); i < n; ++i) {
2515-
visit(binaryen._BinaryenBlockGetChild(expr, i), data);
2515+
visit(binaryen._BinaryenBlockGetChildAt(expr, i), data);
25162516
}
25172517
break;
25182518
}
@@ -2538,13 +2538,13 @@ export function traverse<T>(
25382538
}
25392539
case ExpressionId.Call: {
25402540
for (let i: Index = 0, n = binaryen._BinaryenCallGetNumOperands(expr); i < n; ++i) {
2541-
visit(binaryen._BinaryenCallGetOperand(expr, i), data);
2541+
visit(binaryen._BinaryenCallGetOperandAt(expr, i), data);
25422542
}
25432543
break;
25442544
}
25452545
case ExpressionId.CallIndirect: {
25462546
for (let i: Index = 0, n = binaryen._BinaryenCallIndirectGetNumOperands(expr); i < n; ++i) {
2547-
visit(binaryen._BinaryenCallIndirectGetOperand(expr, i), data);
2547+
visit(binaryen._BinaryenCallIndirectGetOperandAt(expr, i), data);
25482548
}
25492549
break;
25502550
}
@@ -2599,7 +2599,7 @@ export function traverse<T>(
25992599
}
26002600
case ExpressionId.Host: {
26012601
for (let i: Index = 0, n = binaryen._BinaryenHostGetNumOperands(expr); i < n; ++i) {
2602-
visit(binaryen._BinaryenHostGetOperand(expr, i), data);
2602+
visit(binaryen._BinaryenHostGetOperandAt(expr, i), data);
26032603
}
26042604
break;
26052605
}
@@ -2703,7 +2703,7 @@ export function traverse<T>(
27032703
}
27042704
case ExpressionId.Throw: {
27052705
for (let i: Index = 0, n = binaryen._BinaryenThrowGetNumOperands(expr); i < n; ++i) {
2706-
visit(binaryen._BinaryenThrowGetOperand(expr, i), data);
2706+
visit(binaryen._BinaryenThrowGetOperandAt(expr, i), data);
27072707
}
27082708
break;
27092709
}
@@ -2717,7 +2717,7 @@ export function traverse<T>(
27172717
}
27182718
case ExpressionId.TupleMake: {
27192719
for (let i: Index = 0, n = binaryen._BinaryenTupleMakeGetNumOperands(expr); i < n; ++i) {
2720-
visit(binaryen._BinaryenTupleMakeGetOperand(expr, i), data);
2720+
visit(binaryen._BinaryenTupleMakeGetOperandAt(expr, i), data);
27212721
}
27222722
break;
27232723
}

Diff for: tests/compiler/binary.optimized.wat

-6
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@
4747
(local $2 i32)
4848
(local $3 i32)
4949
(local $4 i32)
50-
i32.const 1
51-
i32.const 0
5250
local.get $0
5351
i32.reinterpret_f32
5452
local.tee $1
@@ -59,7 +57,6 @@
5957
local.tee $2
6058
i32.const 255
6159
i32.eq
62-
select
6360
if
6461
local.get $0
6562
local.get $0
@@ -191,8 +188,6 @@
191188
(local $2 i64)
192189
(local $3 i64)
193190
(local $4 i64)
194-
i32.const 1
195-
i32.const 0
196191
local.get $0
197192
i64.reinterpret_f64
198193
local.tee $1
@@ -203,7 +198,6 @@
203198
local.tee $2
204199
i64.const 2047
205200
i64.eq
206-
select
207201
if
208202
local.get $0
209203
local.get $0

Diff for: tests/compiler/if.optimized.wat

+2-3
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,9 @@
1313
(export "ifAlwaysReturns" (func $if/ifAlwaysReturns))
1414
(start $~start)
1515
(func $if/ifThenElse (param $0 i32) (result i32)
16-
i32.const 1
17-
i32.const 0
1816
local.get $0
19-
select
17+
i32.eqz
18+
i32.eqz
2019
)
2120
(func $if/ifThen (param $0 i32) (result i32)
2221
local.get $0

Diff for: tests/compiler/resolve-function-expression.optimized.wat

+1-3
Original file line numberDiff line numberDiff line change
@@ -348,10 +348,8 @@
348348
br_if $__inlined_func$~lib/string/String.__eq
349349
drop
350350
block $folding-inner0
351-
i32.const 0
352-
i32.const 1
353351
local.get $1
354-
select
352+
i32.eqz
355353
br_if $folding-inner0
356354
local.get $1
357355
call $~lib/string/String#get:length

Diff for: tests/compiler/std/typedarray.optimized.wat

-6
Original file line numberDiff line numberDiff line change
@@ -9475,8 +9475,6 @@
94759475
(local $2 i32)
94769476
(local $3 i32)
94779477
(local $4 i32)
9478-
i32.const 1
9479-
i32.const 0
94809478
local.get $0
94819479
i32.reinterpret_f32
94829480
local.tee $1
@@ -9487,7 +9485,6 @@
94879485
local.tee $2
94889486
i32.const 255
94899487
i32.eq
9490-
select
94919488
if
94929489
local.get $0
94939490
f32.const 2
@@ -9702,8 +9699,6 @@
97029699
(local $2 i64)
97039700
(local $3 i64)
97049701
(local $4 i64)
9705-
i32.const 1
9706-
i32.const 0
97079702
local.get $0
97089703
i64.reinterpret_f64
97099704
local.tee $1
@@ -9714,7 +9709,6 @@
97149709
local.tee $2
97159710
i64.const 2047
97169711
i64.eq
9717-
select
97189712
if
97199713
local.get $0
97209714
f64.const 2

0 commit comments

Comments
 (0)