Skip to content

Commit d90cd08

Browse files
committed
Update Binaryen
1 parent 6949cf9 commit d90cd08

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+2849
-9222
lines changed

dist/asc.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.

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: 145 additions & 225 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
},
1313
"dependencies": {
1414
"@protobufjs/utf8": "^1.1.0",
15-
"binaryen": "49.0.0-nightly.20180731",
15+
"binaryen": "^51.0.0",
1616
"glob": "^7.1.3",
1717
"long": "^4.0.0"
1818
},
@@ -26,7 +26,7 @@
2626
"typedoc": "^0.11.1",
2727
"typedoc-plugin-external-module-name": "^1.1.3",
2828
"typescript": "^3.0.3",
29-
"webpack": "^4.17.2",
29+
"webpack": "^4.18.1",
3030
"webpack-cli": "^3.1.0"
3131
},
3232
"main": "index.js",

src/builtins.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3078,7 +3078,7 @@ export function ensureGCHook(
30783078
// remember the function index so we don't recurse infinitely
30793079
var functionTable = compiler.functionTable;
30803080
var gcHookIndex = functionTable.length;
3081-
functionTable.push(0);
3081+
functionTable.push("<placeholder>");
30823082
classInstance.gcHookIndex = gcHookIndex;
30833083

30843084
// if the class extends a base class, call its hook first (calls mark)
@@ -3133,11 +3133,13 @@ export function ensureGCHook(
31333133
}
31343134

31353135
// add the function to the module and return its table index
3136-
functionTable[gcHookIndex] = module.addFunction(
3137-
classInstance.internalName + "~gc",
3136+
var funcName = classInstance.internalName + "~gc";
3137+
module.addFunction(
3138+
funcName,
31383139
compiler.ensureFunctionType(null, Type.void, options.usizeType),
31393140
null,
31403141
module.createBlock(null, body)
31413142
);
3143+
functionTable[gcHookIndex] = funcName;
31423144
return gcHookIndex;
31433145
}

src/compiler.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ export class Compiler extends DiagnosticEmitter {
286286
/** Map of already compiled static string segments. */
287287
stringSegments: Map<string,MemorySegment> = new Map();
288288
/** Function table being compiled. */
289-
functionTable: FunctionRef[] = [];
289+
functionTable: string[] = [];
290290
/** Argument count helper global. */
291291
argcVar: GlobalRef = 0;
292292
/** Argument count helper setter. */
@@ -1474,7 +1474,7 @@ export class Compiler extends DiagnosticEmitter {
14741474
// insert the trampoline if the function has optional parameters
14751475
func = this.ensureTrampoline(func);
14761476
}
1477-
functionTable.push(func.ref);
1477+
functionTable.push(func.internalName);
14781478
func.functionTableIndex = index;
14791479
return index;
14801480
}

src/glue/binaryen.d.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,10 +199,8 @@ declare function _BinaryenGeFloat64(): BinaryenOp;
199199

200200
declare type BinaryenHostOp = BinaryenOp;
201201

202-
declare function _BinaryenPageSize(): BinaryenHostOp;
203202
declare function _BinaryenCurrentMemory(): BinaryenHostOp;
204203
declare function _BinaryenGrowMemory(): BinaryenHostOp;
205-
declare function _BinaryenHasFeature(): BinaryenHostOp;
206204

207205
declare type BinaryenAtomicRMWOp = BinaryenOp;
208206

src/module.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -204,10 +204,8 @@ export enum BinaryOp {
204204
}
205205

206206
export enum HostOp {
207-
PageSize = _BinaryenPageSize(),
208207
CurrentMemory = _BinaryenCurrentMemory(),
209208
GrowMemory = _BinaryenGrowMemory(),
210-
HasFeature = _BinaryenHasFeature(),
211209

212210
// see: https://github.com/WebAssembly/bulk-memory-operations
213211
// MoveMemory
@@ -875,12 +873,18 @@ export class Module {
875873
}
876874
}
877875

878-
setFunctionTable(funcs: FunctionRef[]): void {
879-
var cArr = allocPtrArray(funcs);
876+
setFunctionTable(funcs: string[]): void {
877+
var numNames = funcs.length;
878+
var names = new Array<usize>(numNames);
879+
for (let i = 0; i < numNames; ++i) {
880+
names[i] = allocString(funcs[i]);
881+
}
882+
var cArr = allocI32Array(names);
880883
try {
881-
_BinaryenSetFunctionTable(this.ref, cArr, funcs.length);
884+
_BinaryenSetFunctionTable(this.ref, cArr, numNames);
882885
} finally {
883886
memory.free(cArr);
887+
for (let i = numNames; i >= 0; --i) memory.free(names[i]);
884888
}
885889
}
886890

0 commit comments

Comments
 (0)