Skip to content

Update Binaryen #1401

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 24, 2020
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": "94.0.0-nightly.20200716",
"binaryen": "95.0.0-nightly.20200723",
"long": "^4.0.0",
"source-map-support": "^0.5.19",
"ts-node": "^6.2.0"
Expand Down
6 changes: 3 additions & 3 deletions src/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import {
getConstValueF32,
getConstValueF64,
getBlockChildCount,
getBlockChild,
getBlockChildAt,
getBlockName,
getLocalGetIndex,
isLocalTee,
Expand Down Expand Up @@ -2194,7 +2194,7 @@ export class Compiler extends DiagnosticEmitter {
switch (getExpressionId(stmt)) {
case ExpressionId.Block: {
if (!getBlockName(stmt)) {
for (let j: Index = 0, k = getBlockChildCount(stmt); j < k; ++j) stmts.push(getBlockChild(stmt, j));
for (let j: Index = 0, k = getBlockChildCount(stmt); j < k; ++j) stmts.push(getBlockChildAt(stmt, j));
break;
}
// fall-through
Expand Down Expand Up @@ -7635,7 +7635,7 @@ export class Compiler extends DiagnosticEmitter {
if (getBlockName(expr) === null) { // must not be a break target
let count = getBlockChildCount(expr);
if (count) {
return this.tryUndoAutorelease(getBlockChild(expr, count - 1), flow);
return this.tryUndoAutorelease(getBlockChildAt(expr, count - 1), flow);
}
}
break;
Expand Down
8 changes: 4 additions & 4 deletions src/flow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ import {
isLoadSigned,
getBlockName,
getBlockChildCount,
getBlockChild,
getBlockChildAt,
getIfTrue,
getIfFalse,
getSelectThen,
Expand All @@ -66,7 +66,7 @@ import {
getIfCondition,
getConstValueI64High,
getUnaryValue,
getCallOperand,
getCallOperandAt,
traverse
} from "./module";

Expand Down Expand Up @@ -1114,7 +1114,7 @@ export class Flow {
let program = this.parentFunction.program;
if (name == program.retainInstance.internalName) {
// __retain just passes through the argument
this.inheritNonnullIfTrue(getCallOperand(expr, 0), iff);
this.inheritNonnullIfTrue(getCallOperandAt(expr, 0), iff);
}
break;
}
Expand Down Expand Up @@ -1423,7 +1423,7 @@ export class Flow {
case ExpressionId.Block: {
if (!getBlockName(expr)) {
let size = assert(getBlockChildCount(expr));
let last = getBlockChild(expr, size - 1);
let last = getBlockChildAt(expr, size - 1);
return this.canOverflow(last, type);
}
break;
Expand Down
428 changes: 290 additions & 138 deletions src/glue/binaryen.d.ts

Large diffs are not rendered by default.

30 changes: 15 additions & 15 deletions src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ export class Module {
offset: Index = 0,
align: Index = bytes // naturally aligned by default
): ExpressionRef {
return binaryen._BinaryenLoad(this.ref, bytes, signed ? 1 : 0, offset, align, type, ptr);
return binaryen._BinaryenLoad(this.ref, bytes, signed, offset, align, type, ptr);
}

store(
Expand Down Expand Up @@ -1797,7 +1797,7 @@ export class Module {
)
: binaryen._BinaryenLoad(this.ref,
binaryen._BinaryenLoadGetBytes(expr),
binaryen._BinaryenLoadIsSigned(expr) ? 1 : 0,
binaryen._BinaryenLoadIsSigned(expr),
binaryen._BinaryenLoadGetOffset(expr),
binaryen._BinaryenLoadGetAlign(expr),
binaryen._BinaryenExpressionGetType(expr),
Expand Down Expand Up @@ -2013,8 +2013,8 @@ export function getBlockChildCount(expr: ExpressionRef): Index {
return binaryen._BinaryenBlockGetNumChildren(expr);
}

export function getBlockChild(expr: ExpressionRef, index: Index): ExpressionRef {
return binaryen._BinaryenBlockGetChild(expr, index);
export function getBlockChildAt(expr: ExpressionRef, index: Index): ExpressionRef {
return binaryen._BinaryenBlockGetChildAt(expr, index);
}

export function getIfCondition(expr: ExpressionRef): ExpressionRef {
Expand Down Expand Up @@ -2073,8 +2073,8 @@ export function getCallOperandCount(expr: ExpressionRef): i32 {
return binaryen._BinaryenCallGetNumOperands(expr);
}

export function getCallOperand(expr: ExpressionRef, index: Index): ExpressionRef {
return binaryen._BinaryenCallGetOperand(expr, index);
export function getCallOperandAt(expr: ExpressionRef, index: Index): ExpressionRef {
return binaryen._BinaryenCallGetOperandAt(expr, index);
}

export function getHostOp(expr: ExpressionRef): ExpressionRef {
Expand All @@ -2085,8 +2085,8 @@ export function getHostOperandCount(expr: ExpressionRef): Index {
return binaryen._BinaryenHostGetNumOperands(expr);
}

export function getHostOperand(expr: ExpressionRef, index: Index): ExpressionRef {
return binaryen._BinaryenHostGetOperand(expr, index);
export function getHostOperandAt(expr: ExpressionRef, index: Index): ExpressionRef {
return binaryen._BinaryenHostGetOperandAt(expr, index);
}

export function getHostName(expr: ExpressionRef): string | null {
Expand Down Expand Up @@ -2495,7 +2495,7 @@ export function needsExplicitUnreachable(expr: ExpressionRef): bool {
let numChildren = binaryen._BinaryenBlockGetNumChildren(expr); // last child needs unreachable
return (
numChildren > 0 &&
needsExplicitUnreachable(binaryen._BinaryenBlockGetChild(expr, numChildren - 1))
needsExplicitUnreachable(binaryen._BinaryenBlockGetChildAt(expr, numChildren - 1))
);
}
}
Expand All @@ -2512,7 +2512,7 @@ export function traverse<T>(
switch (getExpressionId(expr)) {
case ExpressionId.Block: {
for (let i: Index = 0, n = binaryen._BinaryenBlockGetNumChildren(expr); i < n; ++i) {
visit(binaryen._BinaryenBlockGetChild(expr, i), data);
visit(binaryen._BinaryenBlockGetChildAt(expr, i), data);
}
break;
}
Expand All @@ -2538,13 +2538,13 @@ export function traverse<T>(
}
case ExpressionId.Call: {
for (let i: Index = 0, n = binaryen._BinaryenCallGetNumOperands(expr); i < n; ++i) {
visit(binaryen._BinaryenCallGetOperand(expr, i), data);
visit(binaryen._BinaryenCallGetOperandAt(expr, i), data);
}
break;
}
case ExpressionId.CallIndirect: {
for (let i: Index = 0, n = binaryen._BinaryenCallIndirectGetNumOperands(expr); i < n; ++i) {
visit(binaryen._BinaryenCallIndirectGetOperand(expr, i), data);
visit(binaryen._BinaryenCallIndirectGetOperandAt(expr, i), data);
}
break;
}
Expand Down Expand Up @@ -2599,7 +2599,7 @@ export function traverse<T>(
}
case ExpressionId.Host: {
for (let i: Index = 0, n = binaryen._BinaryenHostGetNumOperands(expr); i < n; ++i) {
visit(binaryen._BinaryenHostGetOperand(expr, i), data);
visit(binaryen._BinaryenHostGetOperandAt(expr, i), data);
}
break;
}
Expand Down Expand Up @@ -2703,7 +2703,7 @@ export function traverse<T>(
}
case ExpressionId.Throw: {
for (let i: Index = 0, n = binaryen._BinaryenThrowGetNumOperands(expr); i < n; ++i) {
visit(binaryen._BinaryenThrowGetOperand(expr, i), data);
visit(binaryen._BinaryenThrowGetOperandAt(expr, i), data);
}
break;
}
Expand All @@ -2717,7 +2717,7 @@ export function traverse<T>(
}
case ExpressionId.TupleMake: {
for (let i: Index = 0, n = binaryen._BinaryenTupleMakeGetNumOperands(expr); i < n; ++i) {
visit(binaryen._BinaryenTupleMakeGetOperand(expr, i), data);
visit(binaryen._BinaryenTupleMakeGetOperandAt(expr, i), data);
}
break;
}
Expand Down
6 changes: 0 additions & 6 deletions tests/compiler/binary.optimized.wat
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@
(local $2 i32)
(local $3 i32)
(local $4 i32)
i32.const 1
i32.const 0
local.get $0
i32.reinterpret_f32
local.tee $1
Expand All @@ -59,7 +57,6 @@
local.tee $2
i32.const 255
i32.eq
select
if
local.get $0
local.get $0
Expand Down Expand Up @@ -191,8 +188,6 @@
(local $2 i64)
(local $3 i64)
(local $4 i64)
i32.const 1
i32.const 0
local.get $0
i64.reinterpret_f64
local.tee $1
Expand All @@ -203,7 +198,6 @@
local.tee $2
i64.const 2047
i64.eq
select
if
local.get $0
local.get $0
Expand Down
5 changes: 2 additions & 3 deletions tests/compiler/if.optimized.wat
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@
(export "ifAlwaysReturns" (func $if/ifAlwaysReturns))
(start $~start)
(func $if/ifThenElse (param $0 i32) (result i32)
i32.const 1
i32.const 0
local.get $0
select
i32.eqz
i32.eqz
)
(func $if/ifThen (param $0 i32) (result i32)
local.get $0
Expand Down
4 changes: 1 addition & 3 deletions tests/compiler/resolve-function-expression.optimized.wat
Original file line number Diff line number Diff line change
Expand Up @@ -348,10 +348,8 @@
br_if $__inlined_func$~lib/string/String.__eq
drop
block $folding-inner0
i32.const 0
i32.const 1
local.get $1
select
i32.eqz
br_if $folding-inner0
local.get $1
call $~lib/string/String#get:length
Expand Down
6 changes: 0 additions & 6 deletions tests/compiler/std/typedarray.optimized.wat
Original file line number Diff line number Diff line change
Expand Up @@ -9475,8 +9475,6 @@
(local $2 i32)
(local $3 i32)
(local $4 i32)
i32.const 1
i32.const 0
local.get $0
i32.reinterpret_f32
local.tee $1
Expand All @@ -9487,7 +9485,6 @@
local.tee $2
i32.const 255
i32.eq
select
if
local.get $0
f32.const 2
Expand Down Expand Up @@ -9702,8 +9699,6 @@
(local $2 i64)
(local $3 i64)
(local $4 i64)
i32.const 1
i32.const 0
local.get $0
i64.reinterpret_f64
local.tee $1
Expand All @@ -9714,7 +9709,6 @@
local.tee $2
i64.const 2047
i64.eq
select
if
local.get $0
f64.const 2
Expand Down