Skip to content

Commit

Permalink
build: update binaryen to version_116
Browse files Browse the repository at this point in the history
  • Loading branch information
HerrCai0907 committed Nov 1, 2023
1 parent 145cbc6 commit aa00984
Show file tree
Hide file tree
Showing 319 changed files with 92,578 additions and 95,539 deletions.
38 changes: 19 additions & 19 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 @@ -25,7 +25,7 @@
},
"engineStrict": true,
"dependencies": {
"binaryen": "112.0.0-nightly.20230411",
"binaryen": "116.0.0",
"long": "^5.2.1"
},
"devDependencies": {
Expand Down
15 changes: 5 additions & 10 deletions src/glue/binaryen.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ export type ExpressionRunnerRef = Ref;
export type BinaryenModuleAllocateAndWriteResultRef = Ref;
export type TypeBuilderRef = Ref;
export type TypeBuilderErrorReason = u32;
export type TypeSystem = u32;

export declare function _BinaryenTypeCreate(types: ArrayRef<TypeRef>, numTypes: u32): TypeRef;
export declare function _BinaryenTypeArity(type: TypeRef): u32;
Expand Down Expand Up @@ -546,9 +545,9 @@ export declare function _BinaryenTupleExtractSetIndex(expr: ExpressionRef, index

export declare function _BinaryenPop(module: ModuleRef, type: TypeRef): ExpressionRef;

export declare function _BinaryenI31New(module: ModuleRef, value: ExpressionRef): ExpressionRef;
export declare function _BinaryenI31NewGetValue(expr: ExpressionRef): ExpressionRef;
export declare function _BinaryenI31NewSetValue(expr: ExpressionRef, valueExpr: ExpressionRef): void;
export declare function _BinaryenRefI31(module: ModuleRef, value: ExpressionRef): ExpressionRef;
export declare function _BinaryenRefI31GetValue(expr: ExpressionRef): ExpressionRef;
export declare function _BinaryenRefI31SetValue(expr: ExpressionRef, valueExpr: ExpressionRef): void;

export declare function _BinaryenI31Get(module: ModuleRef, i31Expr: ExpressionRef, signed: bool): ExpressionRef;
export declare function _BinaryenI31GetGetI31(expr: ExpressionRef): ExpressionRef;
Expand Down Expand Up @@ -661,7 +660,7 @@ export declare function _BinaryenArrayCopyGetLength(expr: ExpressionRef): Expres
export declare function _BinaryenArrayCopySetLength(expr: ExpressionRef, lengthExpr: ExpressionRef): void;

// TODO: BinaryenArrayFill
// TODO: BinaryenArrayInit
// TODO: BinaryenArrayNewFixed

export declare function _BinaryenStringNew(module: ModuleRef, op: Op, ptr: ExpressionRef, length: ExpressionRef, start: ExpressionRef, end: ExpressionRef, isTry: bool): ExpressionRef;
export declare function _BinaryenStringNewGetOp(expr: ExpressionRef): Op;
Expand Down Expand Up @@ -884,16 +883,14 @@ export declare function _ExpressionRunnerRunAndDispose(runner: ExpressionRunnerR
export declare function _TypeBuilderCreate(size: Index): TypeBuilderRef;
export declare function _TypeBuilderGrow(builder: TypeBuilderRef, count: Index): void;
export declare function _TypeBuilderGetSize(builder: TypeBuilderRef): Index;
export declare function _TypeBuilderSetBasicHeapType(builder: TypeBuilderRef, index: Index, basicHeapType: HeapTypeRef): void;
export declare function _TypeBuilderSetSignatureType(builder: TypeBuilderRef, index: Index, paramTypes: TypeRef, resultTypes: TypeRef): void;
export declare function _TypeBuilderSetStructType(builder: TypeBuilderRef, index: Index, fieldTypes: ArrayRef<TypeRef>, fieldPackedTypes: ArrayRef<PackedType>, fieldMutables: ArrayRef<bool>, numFields: i32): void;
export declare function _TypeBuilderSetArrayType(builder: TypeBuilderRef, index: Index, elementType: TypeRef, elementPackedTyype: PackedType, elementMutable: bool): void;
export declare function _TypeBuilderIsBasic(builder: TypeBuilderRef, index: Index): bool;
export declare function _TypeBuilderGetBasic(builder: TypeBuilderRef, index: Index): HeapTypeRef;
export declare function _TypeBuilderGetTempHeapType(builder: TypeBuilderRef, index: Index): HeapTypeRef;
export declare function _TypeBuilderGetTempTupleType(builder: TypeBuilderRef, types: ArrayRef<TypeRef>, numTypes: Index): TypeRef;
export declare function _TypeBuilderGetTempRefType(builder: TypeBuilderRef, heapType: HeapTypeRef, nullable: bool): TypeRef;
export declare function _TypeBuilderSetSubType(builder: TypeBuilderRef, index: Index, superType: HeapTypeRef): void;
export declare function _TypeBuilderSetOpen(builder: TypeBuilderRef, index: Index): void;
export declare function _TypeBuilderCreateRecGroup(builder: TypeBuilderRef, index: Index, length: Index): void;
export declare function _TypeBuilderBuildAndDispose(builder: TypeBuilderRef, heapTypes: ArrayRef<HeapTypeRef>, errorIndex: Pointer<Index>, errorReason: Pointer<TypeBuilderErrorReason>): bool;
export declare function _BinaryenModuleSetTypeName(module: ModuleRef, heapType: HeapTypeRef, name: StringRef): void;
Expand Down Expand Up @@ -922,8 +919,6 @@ export declare function _BinaryenGetOneCallerInlineMaxSize(): Index;
export declare function _BinaryenSetOneCallerInlineMaxSize(size: Index): void;
export declare function _BinaryenGetAllowInliningFunctionsWithLoops(): bool;
export declare function _BinaryenSetAllowInliningFunctionsWithLoops(enabled: bool): void;
export declare function _BinaryenGetTypeSystem(): TypeSystem;
export declare function _BinaryenSetTypeSystem(typeSystem: TypeSystem): void;

// Helpers

Expand Down
12 changes: 4 additions & 8 deletions src/glue/binaryen.js
Original file line number Diff line number Diff line change
Expand Up @@ -504,9 +504,9 @@ export const {

_BinaryenPop,

_BinaryenI31New,
_BinaryenI31NewGetValue,
_BinaryenI31NewSetValue,
_BinaryenRefI31,
_BinaryenRefI31GetValue,
_BinaryenRefI31SetValue,

_BinaryenI31Get,
_BinaryenI31GetGetI31,
Expand Down Expand Up @@ -837,16 +837,14 @@ export const {
_TypeBuilderCreate,
_TypeBuilderGrow,
_TypeBuilderGetSize,
_TypeBuilderSetBasicHeapType,
_TypeBuilderSetSignatureType,
_TypeBuilderSetStructType,
_TypeBuilderSetArrayType,
_TypeBuilderIsBasic,
_TypeBuilderGetBasic,
_TypeBuilderGetTempHeapType,
_TypeBuilderGetTempTupleType,
_TypeBuilderGetTempRefType,
_TypeBuilderSetSubType,
_TypeBuilderSetOpen,
_TypeBuilderCreateRecGroup,
_TypeBuilderBuildAndDispose,
_BinaryenModuleSetTypeName,
Expand Down Expand Up @@ -875,8 +873,6 @@ export const {
_BinaryenSetOneCallerInlineMaxSize,
_BinaryenGetAllowInliningFunctionsWithLoops,
_BinaryenSetAllowInliningFunctionsWithLoops,
_BinaryenGetTypeSystem,
_BinaryenSetTypeSystem,

// Helpers

Expand Down
57 changes: 23 additions & 34 deletions src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,13 +202,6 @@ export namespace TypeBuilderErrorReason {
}
}

/** Type system constants. */
export type TypeSystem = binaryen.TypeSystem;
export namespace TypeSystem {
export const Isorecursive: TypeSystem = 0 /* _BinaryenTypeSystemIsorecursive */;
export const Nominal: TypeSystem = 1 /* _BinaryenTypeSystemNominal */;
}

/** Binaryen feature constants. */
export const enum FeatureFlags {
MVP = 0 /* _BinaryenFeatureMVP */,
Expand Down Expand Up @@ -287,7 +280,7 @@ export const enum ExpressionId {
Rethrow = 51 /* _BinaryenRethrowId */,
TupleMake = 52 /* _BinaryenTupleMakeId */,
TupleExtract = 53 /* _BinaryenTupleExtractId */,
I31New = 54 /* _BinaryenI31NewId */,
RefI31 = 54 /* _BinaryenRefI31Id */,
I31Get = 55 /* _BinaryenI31GetId */,
CallRef = 56 /* _BinaryenCallRefId */,
RefTest = 57 /* _BinaryenRefTestId */,
Expand All @@ -297,28 +290,26 @@ export const enum ExpressionId {
StructGet = 61 /* _BinaryenStructGetId */,
StructSet = 62 /* _BinaryenStructSetId */,
ArrayNew = 63 /* _BinaryenArrayNewId */,
ArrayNewSeg = 64 /* TODO_BinaryenArraySegId */,
ArrayNewFixed = 65 /* _BinaryenArrayNewFixedId */,
ArrayGet = 66 /* _BinaryenArrayGetId */,
ArraySet = 67 /* _BinaryenArraySetId */,
ArrayLen = 68 /* _BinaryenArrayLenId */,
ArrayCopy = 69 /* _BinaryenArrayCopyId */,
ArrayFill = 70 /* _BinaryenArrayFillId */,
ArrayInit = 71 /* _BinaryenArrayInitId */,
RefAs = 72 /* _BinaryenRefAsId */,
StringNew = 73 /* _BinaryenStringNewId */,
StringConst = 74 /* _BinaryenStringConstId */,
StringMeasure = 75 /* _BinaryenStringMeasureId */,
StringEncode = 76 /* _BinaryenStringEncodeId */,
StringConcat = 77 /* _BinaryenStringConcatId */,
StringEq = 78 /* _BinaryenStringEqId */,
StringAs = 79 /* _BinaryenStringAsId */,
StringWTF8Advance = 80 /* _BinaryenStringWTF8AdvanceId */,
StringWTF16Get = 81 /* _BinaryenStringWTF16GetId */,
StringIterNext = 82 /* _BinaryenStringIterNextId */,
StringIterMove = 83 /* _BinaryenStringIterMoveId */,
StringSliceWTF = 84 /* _BinaryenStringSliceWTFId */,
StringSliceIter = 85 /* _BinaryenStringSliceIterId */
ArrayNewFixed = 66 /* _BinaryenArrayNewFixedId */,
ArrayGet = 67 /* _BinaryenArrayGetId */,
ArraySet = 68 /* _BinaryenArraySetId */,
ArrayLen = 69 /* _BinaryenArrayLenId */,
ArrayCopy = 70 /* _BinaryenArrayCopyId */,
ArrayFill = 71 /* _BinaryenArrayFillId */,
RefAs = 74 /* _BinaryenRefAsId */,
StringNew = 75 /* _BinaryenStringNewId */,
StringConst = 76 /* _BinaryenStringConstId */,
StringMeasure = 77 /* _BinaryenStringMeasureId */,
StringEncode = 78 /* _BinaryenStringEncodeId */,
StringConcat = 79 /* _BinaryenStringConcatId */,
StringEq = 80 /* _BinaryenStringEqId */,
StringAs = 81 /* _BinaryenStringAsId */,
StringWTF8Advance = 82 /* _BinaryenStringWTF8AdvanceId */,
StringWTF16Get = 83 /* _BinaryenStringWTF16GetId */,
StringIterNext = 84 /* _BinaryenStringIterNextId */,
StringIterMove = 85 /* _BinaryenStringIterMoveId */,
StringSliceWTF = 86 /* _BinaryenStringSliceWTFId */,
StringSliceIter = 87 /* _BinaryenStringSliceIterId */
}

/** Binaryen external kind constants. */
Expand Down Expand Up @@ -1378,7 +1369,6 @@ export class Module {
) {
assert(sizeType == TypeRef.I32 || sizeType == TypeRef.I64);
this.lit = binaryen._malloc(binaryen._BinaryenSizeofLiteral());
binaryen._BinaryenSetTypeSystem(TypeSystem.Nominal);
}

private lit: usize;
Expand Down Expand Up @@ -2126,7 +2116,7 @@ export class Module {
i31_new(
value: ExpressionRef
): ExpressionRef {
return binaryen._BinaryenI31New(this.ref, value);
return binaryen._BinaryenRefI31(this.ref, value);
}

i31_get(
Expand Down Expand Up @@ -2959,7 +2949,7 @@ export class Module {
case ExpressionId.Const:
case ExpressionId.RefNull:
case ExpressionId.RefFunc:
case ExpressionId.I31New: return true;
case ExpressionId.RefI31: return true;
case ExpressionId.Binary: {
if (this.getFeatures() & FeatureFlags.ExtendedConst) {
switch (getBinaryOp(expr)) {
Expand Down Expand Up @@ -3713,7 +3703,6 @@ export function ensureType(type: Type): TypeRef {
// @ts-ignore: Wasm only
assert(sizeof<usize>() == 4); // ABI code below assumes 32-bit pointers
}
assert(binaryen._BinaryenGetTypeSystem() == TypeSystem.Nominal);
let builder = binaryen._TypeBuilderCreate(0);
let seen = new Map<Type,HeapTypeRef>();
prepareType(builder, seen, type); // drop temp return
Expand Down
18 changes: 9 additions & 9 deletions src/passes/pass.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,9 @@ import {
_BinaryenRefEqSetLeft,
_BinaryenRefEqSetRight,
_BinaryenFunctionSetBody,
_BinaryenI31NewGetValue,
_BinaryenRefI31GetValue,
_BinaryenI31GetGetI31,
_BinaryenI31NewSetValue,
_BinaryenRefI31SetValue,
_BinaryenI31GetSetI31,
_BinaryenCallRefGetNumOperands,
_BinaryenCallRefGetOperandAt,
Expand Down Expand Up @@ -512,7 +512,7 @@ export abstract class Visitor {
// unimp
}

visitI31New(expr: ExpressionRef): void {
visitRefI31(expr: ExpressionRef): void {
// unimp
}

Expand Down Expand Up @@ -1040,11 +1040,11 @@ export abstract class Visitor {
this.visitTupleExtract(expr);
break;
}
case ExpressionId.I31New: {
case ExpressionId.RefI31: {
this.stack.push(expr);
this.visit(_BinaryenI31NewGetValue(expr));
this.visit(_BinaryenRefI31GetValue(expr));
assert(this.stack.pop() == expr);
this.visitI31New(expr);
this.visitRefI31(expr);
break;
}
case ExpressionId.I31Get: {
Expand Down Expand Up @@ -1884,10 +1884,10 @@ export function replaceChild(
}
break;
}
case ExpressionId.I31New: {
let value = _BinaryenI31NewGetValue(parent);
case ExpressionId.RefI31: {
let value = _BinaryenRefI31GetValue(parent);
if (value == search) {
_BinaryenI31NewSetValue(parent, replacement);
_BinaryenRefI31SetValue(parent, replacement);
return value;
}
break;
Expand Down
Loading

0 comments on commit aa00984

Please sign in to comment.