Skip to content

Update to latest Binaryen #911

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 2 commits into from
Oct 16, 2019
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 @@ -12,7 +12,7 @@
},
"dependencies": {
"@protobufjs/utf8": "^1.1.0",
"binaryen": "89.0.0-nightly.20190918",
"binaryen": "89.0.0-nightly.20191012",
"glob": "^7.1.4",
"long": "^4.0.0",
"opencollective-postinstall": "^2.0.0",
Expand Down
211 changes: 195 additions & 16 deletions src/builtins.ts

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ export class Compiler extends DiagnosticEmitter {

// set up function table
var functionTable = this.functionTable;
module.setFunctionTable(functionTable.length, 0xffffffff, functionTable);
module.setFunctionTable(functionTable.length, 0xffffffff, functionTable, module.i32(0));
module.addFunction("null", this.ensureFunctionType(null, Type.void), null, module.block(null, []));

// import table if requested (default table is named '0' by Binaryen)
Expand Down
382 changes: 198 additions & 184 deletions src/glue/binaryen.d.ts

Large diffs are not rendered by default.

51 changes: 45 additions & 6 deletions src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
*//***/

import { Target } from "./common";
import { Type } from "./types";

export type ModuleRef = usize;
export type FunctionTypeRef = usize;
Expand Down Expand Up @@ -79,6 +78,7 @@ export enum ExpressionId {
SIMDShuffle = _BinaryenSIMDShuffleId(),
SIMDTernary = _BinaryenSIMDTernaryId(),
SIMDShift = _BinaryenSIMDShiftId(),
SIMDLoad = _BinaryenSIMDLoadId(),
MemoryInit = _BinaryenMemoryInitId(),
DataDrop = _BinaryenDataDropId(),
MemoryCopy = _BinaryenMemoryCopyId(),
Expand Down Expand Up @@ -325,6 +325,7 @@ export enum BinaryOp {
AndV128 = _BinaryenAndVec128(),
OrV128 = _BinaryenOrVec128(),
XorV128 = _BinaryenXorVec128(),
AndNotV128 = _BinaryenAndNotVec128(),
AddI8x16 = _BinaryenAddVecI8x16(),
AddSatI8x16 = _BinaryenAddSatSVecI8x16(),
AddSatU8x16 = _BinaryenAddSatUVecI8x16(),
Expand Down Expand Up @@ -359,7 +360,8 @@ export enum BinaryOp {
NarrowI16x8ToI8x16 = _BinaryenNarrowSVecI16x8ToVecI8x16(),
NarrowU16x8ToU8x16 = _BinaryenNarrowUVecI16x8ToVecI8x16(),
NarrowI32x4ToI16x8 = _BinaryenNarrowSVecI32x4ToVecI16x8(),
NarrowU32x4ToU16x8 = _BinaryenNarrowUVecI32x4ToVecI16x8()
NarrowU32x4ToU16x8 = _BinaryenNarrowUVecI32x4ToVecI16x8(),
SwizzleV8x16 = _BinaryenSwizzleVec8x16()
}

export enum HostOp {
Expand Down Expand Up @@ -419,6 +421,19 @@ export enum SIMDTernaryOp {
QFMSF64x2 = _BinaryenQFMSVecF64x2()
}

export enum SIMDLoadOp {
LoadSplatV8x16 = _BinaryenLoadSplatVec8x16(),
LoadSplatV16x8 = _BinaryenLoadSplatVec16x8(),
LoadSplatV32x4 = _BinaryenLoadSplatVec32x4(),
LoadSplatV64x2 = _BinaryenLoadSplatVec64x2(),
LoadI8ToI16x8 = _BinaryenLoadExtSVec8x8ToVecI16x8(),
LoadU8ToU16x8 = _BinaryenLoadExtUVec8x8ToVecI16x8(),
LoadI16ToI32x4 = _BinaryenLoadExtSVec16x4ToVecI32x4(),
LoadU16ToU32x4 = _BinaryenLoadExtUVec16x4ToVecI32x4(),
LoadI32ToI64x2 = _BinaryenLoadExtSVec32x2ToVecI64x2(),
LoadU32ToU64x2 = _BinaryenLoadExtUVec32x2ToVecI64x2()
}

export class MemorySegment {

buffer: Uint8Array;
Expand Down Expand Up @@ -921,7 +936,7 @@ export class Module {
}

simd_ternary(
op: BinaryenSIMDOp,
op: SIMDTernaryOp,
a: ExpressionRef,
b: ExpressionRef,
c: ExpressionRef
Expand All @@ -937,6 +952,15 @@ export class Module {
return _BinaryenSIMDShift(this.ref, op, vec, shift);
}

simd_load(
op: SIMDLoadOp,
ptr: ExpressionRef,
offset: u32,
align: u32
): ExpressionRef {
return _BinaryenSIMDLoad(this.ref, op, offset, align, ptr);
}

// meta

addGlobal(
Expand All @@ -946,7 +970,7 @@ export class Module {
initializer: ExpressionRef
): GlobalRef {
var cStr = this.allocStringCached(name);
return _BinaryenAddGlobal(this.ref, cStr, type, mutable ? 1 : 0, initializer);
return _BinaryenAddGlobal(this.ref, cStr, type, mutable, initializer);
}

removeGlobal(
Expand Down Expand Up @@ -1169,7 +1193,8 @@ export class Module {
setFunctionTable(
initial: Index,
maximum: Index,
funcs: string[]
funcs: string[],
offset: ExpressionRef
): void {
var numNames = funcs.length;
var names = new Array<usize>(numNames);
Expand All @@ -1178,7 +1203,7 @@ export class Module {
}
var cArr = allocI32Array(names);
try {
_BinaryenSetFunctionTable(this.ref, initial, maximum, cArr, numNames);
_BinaryenSetFunctionTable(this.ref, initial, maximum, cArr, numNames, offset);
} finally {
memory.free(cArr);
}
Expand All @@ -1188,6 +1213,16 @@ export class Module {
_BinaryenSetStart(this.ref, func);
}

addCustomSection(name: string, contents: Uint8Array): void {
var cStr = this.allocStringCached(name);
var cArr = allocU8Array(contents);
try {
_BinaryenAddCustomSection(this.ref, cStr, cArr, contents.length);
} finally {
memory.free(cArr);
}
}

getOptimizeLevel(): i32 {
return _BinaryenGetOptimizeLevel();
}
Expand Down Expand Up @@ -2063,6 +2098,10 @@ export function traverse<T>(expr: ExpressionRef, data: T, visit: (expr: Expressi
visit(_BinaryenSIMDShiftGetShift(expr), data);
break;
}
case ExpressionId.SIMDLoad: {
visit(_BinaryenSIMDLoadGetPtr(expr), data);
break;
}
case ExpressionId.MemoryInit: {
visit(_BinaryenMemoryInitGetDest(expr), data);
visit(_BinaryenMemoryInitGetOffset(expr), data);
Expand Down
Loading