Skip to content

Commit 2641ecc

Browse files
authored
Update Binaryen and other dependencies (AssemblyScript#1266)
1 parent 5f1fc27 commit 2641ecc

File tree

7 files changed

+176
-29
lines changed

7 files changed

+176
-29
lines changed

package-lock.json

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

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,22 @@
2121
"url": "https://github.com/AssemblyScript/assemblyscript/issues"
2222
},
2323
"dependencies": {
24-
"binaryen": "92.0.0-nightly.20200426",
24+
"binaryen": "93.0.0-nightly.20200514",
2525
"long": "^4.0.0",
2626
"source-map-support": "^0.5.19",
2727
"ts-node": "^6.2.0"
2828
},
2929
"devDependencies": {
30-
"@types/node": "^13.13.2",
30+
"@types/node": "^14.0.1",
3131
"browser-process-hrtime": "^1.0.0",
3232
"diff": "^4.0.2",
3333
"glob": "^7.1.6",
3434
"physical-cpu-count": "^2.0.0",
3535
"source-map-support": "^0.5.19",
36-
"ts-loader": "^6.2.2",
36+
"ts-loader": "^7.0.4",
3737
"ts-node": "^6.2.0",
3838
"tslint": "^5.20.1",
39-
"typescript": "^3.8.3",
39+
"typescript": "^3.9.2",
4040
"webpack": "^4.43.0",
4141
"webpack-cli": "^3.3.11"
4242
},

src/builtins.ts

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,8 @@ export namespace BuiltinNames {
352352
export const v128_bitmask = "~lib/builtins/v128.bitmask";
353353
export const v128_min = "~lib/builtins/v128.min";
354354
export const v128_max = "~lib/builtins/v128.max";
355+
export const v128_pmin = "~lib/builtins/v128.pmin";
356+
export const v128_pmax = "~lib/builtins/v128.pmax";
355357
export const v128_dot = "~lib/builtins/v128.dot";
356358
export const v128_avgr = "~lib/builtins/v128.avgr";
357359
export const v128_abs = "~lib/builtins/v128.abs";
@@ -521,6 +523,8 @@ export namespace BuiltinNames {
521523
export const f32x4_neg = "~lib/builtins/f32x4.neg";
522524
export const f32x4_min = "~lib/builtins/f32x4.min";
523525
export const f32x4_max = "~lib/builtins/f32x4.max";
526+
export const f32x4_pmin = "~lib/builtins/f32x4.pmin";
527+
export const f32x4_pmax = "~lib/builtins/f32x4.pmax";
524528
export const f32x4_abs = "~lib/builtins/f32x4.abs";
525529
export const f32x4_sqrt = "~lib/builtins/f32x4.sqrt";
526530
export const f32x4_eq = "~lib/builtins/f32x4.eq";
@@ -544,6 +548,8 @@ export namespace BuiltinNames {
544548
export const f64x2_neg = "~lib/builtins/f64x2.neg";
545549
export const f64x2_min = "~lib/builtins/f64x2.min";
546550
export const f64x2_max = "~lib/builtins/f64x2.max";
551+
export const f64x2_pmin = "~lib/builtins/f64x2.pmin";
552+
export const f64x2_pmax = "~lib/builtins/f64x2.pmax";
547553
export const f64x2_abs = "~lib/builtins/f64x2.abs";
548554
export const f64x2_sqrt = "~lib/builtins/f64x2.sqrt";
549555
export const f64x2_eq = "~lib/builtins/f64x2.eq";
@@ -3969,6 +3975,68 @@ function builtin_v128_max(ctx: BuiltinContext): ExpressionRef {
39693975
}
39703976
builtins.set(BuiltinNames.v128_max, builtin_v128_max);
39713977

3978+
// v128.pmin<T!>(a: v128, b: v128) -> v128
3979+
function builtin_v128_pmin(ctx: BuiltinContext): ExpressionRef {
3980+
var compiler = ctx.compiler;
3981+
var module = compiler.module;
3982+
if (
3983+
checkFeatureEnabled(ctx, Feature.SIMD) |
3984+
checkTypeRequired(ctx) |
3985+
checkArgsRequired(ctx, 2)
3986+
) {
3987+
compiler.currentType = Type.v128;
3988+
return module.unreachable();
3989+
}
3990+
var operands = ctx.operands;
3991+
var typeArguments = ctx.typeArguments!;
3992+
var type = typeArguments[0];
3993+
var arg0 = compiler.compileExpression(operands[0], Type.v128, Constraints.CONV_IMPLICIT);
3994+
var arg1 = compiler.compileExpression(operands[1], Type.v128, Constraints.CONV_IMPLICIT);
3995+
if (!type.is(TypeFlags.REFERENCE)) {
3996+
switch (type.kind) {
3997+
case TypeKind.F32: return module.binary(BinaryOp.PminF32x4, arg0, arg1);
3998+
case TypeKind.F64: return module.binary(BinaryOp.PminF64x2, arg0, arg1);
3999+
}
4000+
}
4001+
compiler.error(
4002+
DiagnosticCode.Operation_0_cannot_be_applied_to_type_1,
4003+
ctx.reportNode.typeArgumentsRange, "v128.pmin", type.toString()
4004+
);
4005+
return module.unreachable();
4006+
}
4007+
builtins.set(BuiltinNames.v128_pmin, builtin_v128_pmin);
4008+
4009+
// v128.pmax<T!>(a: v128, b: v128) -> v128
4010+
function builtin_v128_pmax(ctx: BuiltinContext): ExpressionRef {
4011+
var compiler = ctx.compiler;
4012+
var module = compiler.module;
4013+
if (
4014+
checkFeatureEnabled(ctx, Feature.SIMD) |
4015+
checkTypeRequired(ctx) |
4016+
checkArgsRequired(ctx, 2)
4017+
) {
4018+
compiler.currentType = Type.v128;
4019+
return module.unreachable();
4020+
}
4021+
var operands = ctx.operands;
4022+
var typeArguments = ctx.typeArguments!;
4023+
var type = typeArguments[0];
4024+
var arg0 = compiler.compileExpression(operands[0], Type.v128, Constraints.CONV_IMPLICIT);
4025+
var arg1 = compiler.compileExpression(operands[1], Type.v128, Constraints.CONV_IMPLICIT);
4026+
if (!type.is(TypeFlags.REFERENCE)) {
4027+
switch (type.kind) {
4028+
case TypeKind.F32: return module.binary(BinaryOp.PmaxF32x4, arg0, arg1);
4029+
case TypeKind.F64: return module.binary(BinaryOp.PmaxF64x2, arg0, arg1);
4030+
}
4031+
}
4032+
compiler.error(
4033+
DiagnosticCode.Operation_0_cannot_be_applied_to_type_1,
4034+
ctx.reportNode.typeArgumentsRange, "v128.pmax", type.toString()
4035+
);
4036+
return module.unreachable();
4037+
}
4038+
builtins.set(BuiltinNames.v128_pmax, builtin_v128_pmax);
4039+
39724040
// v128.dot<T!>(a: v128, b: v128) -> v128
39734041
function builtin_v128_dot(ctx: BuiltinContext): ExpressionRef {
39744042
var compiler = ctx.compiler;
@@ -7444,6 +7512,24 @@ function builtin_f32x4_max(ctx: BuiltinContext): ExpressionRef {
74447512
}
74457513
builtins.set(BuiltinNames.f32x4_max, builtin_f32x4_max);
74467514

7515+
// f32x4.pmin -> v128.pmin<f32>
7516+
function builtin_f32x4_pmin(ctx: BuiltinContext): ExpressionRef {
7517+
checkTypeAbsent(ctx);
7518+
ctx.typeArguments = [ Type.f32 ];
7519+
ctx.contextualType = Type.v128;
7520+
return builtin_v128_pmin(ctx);
7521+
}
7522+
builtins.set(BuiltinNames.f32x4_pmin, builtin_f32x4_pmin);
7523+
7524+
// f32x4.pmax -> v128.pmax<f32>
7525+
function builtin_f32x4_pmax(ctx: BuiltinContext): ExpressionRef {
7526+
checkTypeAbsent(ctx);
7527+
ctx.typeArguments = [ Type.f32 ];
7528+
ctx.contextualType = Type.v128;
7529+
return builtin_v128_pmax(ctx);
7530+
}
7531+
builtins.set(BuiltinNames.f32x4_pmax, builtin_f32x4_pmax);
7532+
74477533
// f32x4.abs -> v128.abs<f32>
74487534
function builtin_f32x4_abs(ctx: BuiltinContext): ExpressionRef {
74497535
checkTypeAbsent(ctx);
@@ -7642,6 +7728,24 @@ function builtin_f64x2_max(ctx: BuiltinContext): ExpressionRef {
76427728
}
76437729
builtins.set(BuiltinNames.f64x2_max, builtin_f64x2_max);
76447730

7731+
// f64x2.pmin -> v128.pmin<f64>
7732+
function builtin_f64x2_pmin(ctx: BuiltinContext): ExpressionRef {
7733+
checkTypeAbsent(ctx);
7734+
ctx.typeArguments = [ Type.f64 ];
7735+
ctx.contextualType = Type.v128;
7736+
return builtin_v128_pmin(ctx);
7737+
}
7738+
builtins.set(BuiltinNames.f64x2_pmin, builtin_f64x2_pmin);
7739+
7740+
// f64x2.pmax -> v128.pmax<f64>
7741+
function builtin_f64x2_pmax(ctx: BuiltinContext): ExpressionRef {
7742+
checkTypeAbsent(ctx);
7743+
ctx.typeArguments = [ Type.f64 ];
7744+
ctx.contextualType = Type.v128;
7745+
return builtin_v128_pmax(ctx);
7746+
}
7747+
builtins.set(BuiltinNames.f64x2_pmax, builtin_f64x2_pmax);
7748+
76457749
// f64x2.abs -> v128.abs<f64>
76467750
function builtin_f64x2_abs(ctx: BuiltinContext): ExpressionRef {
76477751
checkTypeAbsent(ctx);

src/glue/binaryen.d.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,7 @@ export declare function _BinaryenPop(module: BinaryenModuleRef, type: BinaryenTy
532532
export declare function _BinaryenExpressionGetId(expr: BinaryenExpressionRef): BinaryenExpressionId;
533533
export declare function _BinaryenExpressionGetType(expr: BinaryenExpressionRef): BinaryenType;
534534
export declare function _BinaryenExpressionPrint(expr: BinaryenExpressionRef): void;
535+
export declare function _BinaryenExpressionCopy(expr: BinaryenExpressionRef, module: BinaryenModuleRef): BinaryenExpressionRef;
535536

536537
export declare function _BinaryenBlockGetName(expr: BinaryenExpressionRef): usize;
537538
export declare function _BinaryenBlockGetNumChildren(expr: BinaryenExpressionRef): BinaryenIndex;
@@ -837,5 +838,3 @@ export declare function _BinaryenGetFlexibleInlineMaxSize(): BinaryenIndex;
837838
export declare function _BinaryenSetFlexibleInlineMaxSize(size: BinaryenIndex): void;
838839
export declare function _BinaryenGetOneCallerInlineMaxSize(): BinaryenIndex;
839840
export declare function _BinaryenSetOneCallerInlineMaxSize(size: BinaryenIndex): void;
840-
841-
export declare function _BinaryenSetAPITracing(on: bool): void;

src/module.ts

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -392,17 +392,21 @@ export enum BinaryOp {
392392
DivF32x4 = 159 /* _BinaryenDivVecF32x4 */,
393393
MinF32x4 = 160 /* _BinaryenMinVecF32x4 */,
394394
MaxF32x4 = 161 /* _BinaryenMaxVecF32x4 */,
395-
AddF64x2 = 162 /* _BinaryenAddVecF64x2 */,
396-
SubF64x2 = 163 /* _BinaryenSubVecF64x2 */,
397-
MulF64x2 = 164 /* _BinaryenMulVecF64x2 */,
398-
DivF64x2 = 165 /* _BinaryenDivVecF64x2 */,
399-
MinF64x2 = 166 /* _BinaryenMinVecF64x2 */,
400-
MaxF64x2 = 167 /* _BinaryenMaxVecF64x2 */,
401-
NarrowI16x8ToI8x16 = 168 /* _BinaryenNarrowSVecI16x8ToVecI8x16 */,
402-
NarrowU16x8ToU8x16 = 169 /* _BinaryenNarrowUVecI16x8ToVecI8x16 */,
403-
NarrowI32x4ToI16x8 = 170 /* _BinaryenNarrowSVecI32x4ToVecI16x8 */,
404-
NarrowU32x4ToU16x8 = 171 /* _BinaryenNarrowUVecI32x4ToVecI16x8 */,
405-
SwizzleV8x16 = 172 /* _BinaryenSwizzleVec8x16 */
395+
PminF32x4 = 162 /* _BinaryenPMinVecF32x4 */,
396+
PmaxF32x4 = 163 /* _BinaryenPMaxVecF32x4 */,
397+
AddF64x2 = 164 /* _BinaryenAddVecF64x2 */,
398+
SubF64x2 = 165 /* _BinaryenSubVecF64x2 */,
399+
MulF64x2 = 166 /* _BinaryenMulVecF64x2 */,
400+
DivF64x2 = 167 /* _BinaryenDivVecF64x2 */,
401+
MinF64x2 = 168 /* _BinaryenMinVecF64x2 */,
402+
MaxF64x2 = 169 /* _BinaryenMaxVecF64x2 */,
403+
PminF64x2 = 170 /* _BinaryenPMinVecF64x2 */,
404+
PmaxF64x2 = 171 /* _BinaryenPMaxVecF64x2 */,
405+
NarrowI16x8ToI8x16 = 172 /* _BinaryenNarrowSVecI16x8ToVecI8x16 */,
406+
NarrowU16x8ToU8x16 = 173 /* _BinaryenNarrowUVecI16x8ToVecI8x16 */,
407+
NarrowI32x4ToI16x8 = 174 /* _BinaryenNarrowSVecI32x4ToVecI16x8 */,
408+
NarrowU32x4ToU16x8 = 175 /* _BinaryenNarrowUVecI32x4ToVecI16x8 */,
409+
SwizzleV8x16 = 176 /* _BinaryenSwizzleVec8x16 */
406410
}
407411

408412
export enum HostOp {
@@ -1778,6 +1782,10 @@ export class Module {
17781782
return 0;
17791783
}
17801784

1785+
copyExpression(expr: ExpressionRef): ExpressionRef {
1786+
return binaryen._BinaryenExpressionCopy(expr, this.ref);
1787+
}
1788+
17811789
runExpression(expr: ExpressionRef, flags: ExpressionRunnerFlags, maxDepth: i32 = 50, maxLoopIterations: i32 = 1): ExpressionRef {
17821790
var runner = binaryen._ExpressionRunnerCreate(this.ref, flags, maxDepth, maxLoopIterations);
17831791
var precomp = binaryen._ExpressionRunnerRunAndDispose(runner, expr);

std/assembly/builtins.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1093,6 +1093,14 @@ export namespace v128 {
10931093
@builtin
10941094
export declare function max<T>(a: v128, b: v128): v128;
10951095

1096+
// @ts-ignore: decorator
1097+
@builtin
1098+
export declare function pmin<T>(a: v128, b: v128): v128;
1099+
1100+
// @ts-ignore: decorator
1101+
@builtin
1102+
export declare function pmax<T>(a: v128, b: v128): v128;
1103+
10961104
// @ts-ignore: decorator
10971105
@builtin
10981106
export declare function dot<T>(a: v128, b: v128): v128; // i16 only
@@ -1763,6 +1771,14 @@ export namespace f32x4 {
17631771
@builtin
17641772
export declare function max(a: v128, b: v128): v128;
17651773

1774+
// @ts-ignore: decorator
1775+
@builtin
1776+
export declare function pmin(a: v128, b: v128): v128;
1777+
1778+
// @ts-ignore: decorator
1779+
@builtin
1780+
export declare function pmax(a: v128, b: v128): v128;
1781+
17661782
// @ts-ignore: decorator
17671783
@builtin
17681784
export declare function abs(a: v128): v128;
@@ -1858,6 +1874,14 @@ export namespace f64x2 {
18581874
@builtin
18591875
export declare function max(a: v128, b: v128): v128;
18601876

1877+
// @ts-ignore: decorator
1878+
@builtin
1879+
export declare function pmin(a: v128, b: v128): v128;
1880+
1881+
// @ts-ignore: decorator
1882+
@builtin
1883+
export declare function pmax(a: v128, b: v128): v128;
1884+
18611885
// @ts-ignore: decorator
18621886
@builtin
18631887
export declare function abs(a: v128): v128;

std/assembly/index.d.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -597,6 +597,10 @@ declare namespace v128 {
597597
export function min<T>(a: v128, b: v128): v128;
598598
/** Computes the maximum of each lane. */
599599
export function max<T>(a: v128, b: v128): v128;
600+
/** Computes the pseudo-minimum of each lane. */
601+
export function pmin<T>(a: v128, b: v128): v128;
602+
/** Computes the pseudo-maximum of each lane. */
603+
export function pmax<T>(a: v128, b: v128): v128;
600604
/** Computes the dot product of two lanes each, yielding lanes one size wider than the input. */
601605
export function dot<T = i16>(a: v128, b: v128): v128;
602606
/** Computes the average of each lane. */
@@ -933,6 +937,10 @@ declare namespace f32x4 {
933937
export function min(a: v128, b: v128): v128;
934938
/** Computes the maximum of each 32-bit float lane. */
935939
export function max(a: v128, b: v128): v128;
940+
/** Computes the pseudo-minimum of each 32-bit float lane. */
941+
export function pmin(a: v128, b: v128): v128;
942+
/** Computes the pseudo-maximum of each 32-bit float lane. */
943+
export function pmax(a: v128, b: v128): v128;
936944
/** Computes the absolute value of each 32-bit float lane. */
937945
export function abs(a: v128): v128;
938946
/** Computes the square root of each 32-bit float lane. */
@@ -981,6 +989,10 @@ declare namespace f64x2 {
981989
export function min(a: v128, b: v128): v128;
982990
/** Computes the maximum of each 64-bit float lane. */
983991
export function max(a: v128, b: v128): v128;
992+
/** Computes the pseudo-minimum of each 64-bit float lane. */
993+
export function pmin(a: v128, b: v128): v128;
994+
/** Computes the pseudo-maximum of each 64-bit float lane. */
995+
export function pmax(a: v128, b: v128): v128;
984996
/** Computes the absolute value of each 64-bit float lane. */
985997
export function abs(a: v128): v128;
986998
/** Computes the square root of each 64-bit float lane. */

0 commit comments

Comments
 (0)