Skip to content

Commit b723ff3

Browse files
committed
Update Binaryen to latest
1 parent 21675ec commit b723ff3

File tree

8 files changed

+36
-25
lines changed

8 files changed

+36
-25
lines changed

dist/assemblyscript.js

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

dist/assemblyscript.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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
@@ -12,7 +12,7 @@
1212
},
1313
"dependencies": {
1414
"@protobufjs/utf8": "^1.1.0",
15-
"binaryen": "52.0.0-nightly.20181108",
15+
"binaryen": "55.0.0-nightly.20181122",
1616
"glob": "^7.1.3",
1717
"long": "^4.0.0"
1818
},

src/glue/binaryen.d.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -414,15 +414,15 @@ declare function _BinaryenModuleInterpret(module: BinaryenModuleRef): void;
414414
declare function _BinaryenModuleAddDebugInfoFileName(module: BinaryenModuleRef, filename: usize): BinaryenIndex;
415415
declare function _BinaryenModuleGetDebugInfoFileName(module: BinaryenModuleRef, index: BinaryenIndex): usize;
416416

417-
declare type RelooperRef = usize;
418-
declare type RelooperBlockRef = usize;
419-
420-
declare function _RelooperCreate(): RelooperRef;
421-
declare function _RelooperAddBlock(relooper: RelooperRef, code: BinaryenExpressionRef): RelooperBlockRef;
422-
declare function _RelooperAddBranch(from: RelooperBlockRef, to: RelooperBlockRef, condition: BinaryenExpressionRef, code: BinaryenExpressionRef): void;
423-
declare function _RelooperAddBlockWithSwitch(relooper: RelooperRef, code: BinaryenExpressionRef, condition: BinaryenExpressionRef): RelooperBlockRef;
424-
declare function _RelooperAddBranchForSwitch(from: RelooperBlockRef, to: RelooperBlockRef, indexes: usize, numIndexes: BinaryenIndex, code: BinaryenExpressionRef): void;
425-
declare function _RelooperRenderAndDispose(relooper: RelooperRef, entry: RelooperBlockRef, labelHelper: BinaryenIndex, module: BinaryenModuleRef): BinaryenExpressionRef;
417+
declare type BinaryenRelooperRef = usize;
418+
declare type BinaryenRelooperBlockRef = usize;
419+
420+
declare function _RelooperCreate(module: BinaryenModuleRef): BinaryenRelooperRef;
421+
declare function _RelooperAddBlock(relooper: BinaryenRelooperRef, code: BinaryenExpressionRef): BinaryenRelooperBlockRef;
422+
declare function _RelooperAddBranch(from: BinaryenRelooperBlockRef, to: BinaryenRelooperBlockRef, condition: BinaryenExpressionRef, code: BinaryenExpressionRef): void;
423+
declare function _RelooperAddBlockWithSwitch(relooper: BinaryenRelooperRef, code: BinaryenExpressionRef, condition: BinaryenExpressionRef): BinaryenRelooperBlockRef;
424+
declare function _RelooperAddBranchForSwitch(from: BinaryenRelooperBlockRef, to: BinaryenRelooperBlockRef, indexes: usize, numIndexes: BinaryenIndex, code: BinaryenExpressionRef): void;
425+
declare function _RelooperRenderAndDispose(relooper: BinaryenRelooperRef, entry: BinaryenRelooperBlockRef, labelHelper: BinaryenIndex): BinaryenExpressionRef;
426426

427427
declare function _BinaryenGetOptimizeLevel(): i32;
428428
declare function _BinaryenSetOptimizeLevel(level: i32): void;

src/glue/js/binaryen.d.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@
44

55
declare namespace binaryen {
66
class Module {
7-
constructor(ref: number);
8-
runPasses(passes: string[]): void;
9-
emitText(): string;
7+
constructor();
108
emitStackIR(optimize?: boolean): string;
119
emitAsmjs(): string;
1210
}
11+
function wrapModule(ptr: number): Module;
1312
}

src/glue/js/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ import "./i64";
1414
import { Module } from "../../module";
1515

1616
Module.prototype.toText = function(this: Module) {
17-
return new binaryen.Module(this.ref).emitStackIR();
17+
return binaryen.wrapModule(this.ref).emitStackIR();
1818
};
1919

2020
Module.prototype.toAsmjs = function(this: Module) {
21-
return new binaryen.Module(this.ref).emitAsmjs();
21+
return binaryen.wrapModule(this.ref).emitAsmjs();
2222
};

src/module.ts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ export type ExpressionRef = usize;
1414
export type GlobalRef = usize;
1515
export type ImportRef = usize;
1616
export type ExportRef = usize;
17+
export type RelooperRef = usize;
18+
export type RelooperBlockRef = usize;
1719
export type Index = u32;
1820

1921
export const enum NativeType {
@@ -1329,7 +1331,7 @@ export class Relooper {
13291331
static create(module: Module): Relooper {
13301332
var relooper = new Relooper();
13311333
relooper.module = module;
1332-
relooper.ref = _RelooperCreate();
1334+
relooper.ref = _RelooperCreate(module.ref);
13331335
return relooper;
13341336
}
13351337

@@ -1339,15 +1341,25 @@ export class Relooper {
13391341
return _RelooperAddBlock(this.ref, code);
13401342
}
13411343

1342-
addBranch(from: RelooperBlockRef, to: RelooperBlockRef, condition: ExpressionRef = 0, code: ExpressionRef = 0): void {
1344+
addBranch(
1345+
from: RelooperBlockRef,
1346+
to: RelooperBlockRef,
1347+
condition: ExpressionRef = 0,
1348+
code: ExpressionRef = 0
1349+
): void {
13431350
_RelooperAddBranch(from, to, condition, code);
13441351
}
13451352

13461353
addBlockWithSwitch(code: ExpressionRef, condition: ExpressionRef): RelooperBlockRef {
13471354
return _RelooperAddBlockWithSwitch(this.ref, code, condition);
13481355
}
13491356

1350-
addBranchForSwitch(from: RelooperBlockRef, to: RelooperBlockRef, indexes: i32[], code: ExpressionRef = 0): void {
1357+
addBranchForSwitch(
1358+
from: RelooperBlockRef,
1359+
to: RelooperBlockRef,
1360+
indexes: i32[],
1361+
code: ExpressionRef = 0
1362+
): void {
13511363
var cArr = allocI32Array(indexes);
13521364
try {
13531365
_RelooperAddBranchForSwitch(from, to, cArr, indexes.length, code);
@@ -1357,7 +1369,7 @@ export class Relooper {
13571369
}
13581370

13591371
renderAndDispose(entry: RelooperBlockRef, labelHelper: Index): ExpressionRef {
1360-
return _RelooperRenderAndDispose(this.ref, entry, labelHelper, this.module.ref);
1372+
return _RelooperRenderAndDispose(this.ref, entry, labelHelper);
13611373
}
13621374
}
13631375

0 commit comments

Comments
 (0)