Skip to content

Sync with latest Binaryen #2493

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 21 commits into from
Sep 24, 2022
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
2 changes: 1 addition & 1 deletion cli/options.json
Original file line number Diff line number Diff line change
Expand Up @@ -204,14 +204,14 @@
" simd SIMD types and operations.",
" reference-types Reference types and operations.",
" gc Garbage collection (WIP).",
" stringref String reference types.",
""
],
"TODO_doesNothingYet": [
" exception-handling Exception handling.",
" tail-calls Tail call operations.",
" multi-value Multi value types.",
" memory64 Memory64 operations.",
" function-references Function reference types.",
" relaxed-simd Relaxed SIMD operations.",
" extended-const Extended const expressions."
],
Expand Down
15 changes: 7 additions & 8 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": "109.0.0-nightly.20220831",
"binaryen": "110.0.0-nightly.20220924",
"long": "^5.2.0"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion scripts/update-constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ var src = fs.readFileSync(srcfile, "utf8")
if (val.startsWith("binaryen.")) {
return $0;
}
var match = val.match(/\b(_(?:Binaryen|Relooper|ExpressionRunner)\w+)\b/);
var match = val.match(/\b(_(?:Binaryen|Relooper|ExpressionRunner|TypeBuilder)\w+)\b/);
if (match) {
let fn = match[1];
if (typeof binaryen[fn] !== "function") throw Error("API mismatch on '" + fn + "': Is Binaryen up to date?");
Expand Down
12 changes: 10 additions & 2 deletions src/builtins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3492,7 +3492,11 @@ function builtin_assert(ctx: BuiltinContext): ExpressionRef {
case TypeKind.ANYREF:
case TypeKind.EQREF:
case TypeKind.DATAREF:
case TypeKind.I31REF: return module.if(module.ref_is(RefIsOp.Null, arg0), abort);
case TypeKind.I31REF:
case TypeKind.STRINGREF:
case TypeKind.STRINGVIEW_WTF8:
case TypeKind.STRINGVIEW_WTF16:
case TypeKind.STRINGVIEW_ITER: return module.if(module.ref_is(RefIsOp.Null, arg0), abort);

}
} else {
Expand Down Expand Up @@ -3574,7 +3578,11 @@ function builtin_assert(ctx: BuiltinContext): ExpressionRef {
case TypeKind.ANYREF:
case TypeKind.EQREF:
case TypeKind.DATAREF:
case TypeKind.I31REF: {
case TypeKind.I31REF:
case TypeKind.STRINGREF:
case TypeKind.STRINGVIEW_WTF8:
case TypeKind.STRINGVIEW_WTF16:
case TypeKind.STRINGVIEW_ITER: {
let temp = flow.getTempLocal(type);
let ret = module.if(
module.ref_is(RefIsOp.Null,
Expand Down
6 changes: 5 additions & 1 deletion src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,10 @@ export namespace CommonNames {
export const eqref = "eqref";
export const i31ref = "i31ref";
export const dataref = "dataref";
export const stringref = "stringref";
export const stringview_wtf8 = "stringview_wtf8";
export const stringview_wtf16 = "stringview_wtf16";
export const stringview_iter = "stringview_iter";
export const i8x16 = "i8x16";
export const u8x16 = "u8x16";
export const i16x8 = "i16x8";
Expand Down Expand Up @@ -181,9 +185,9 @@ export namespace CommonNames {
export const ASC_FEATURE_MULTI_VALUE = "ASC_FEATURE_MULTI_VALUE";
export const ASC_FEATURE_GC = "ASC_FEATURE_GC";
export const ASC_FEATURE_MEMORY64 = "ASC_FEATURE_MEMORY64";
export const ASC_FEATURE_FUNCTION_REFERENCES = "ASC_FEATURE_FUNCTION_REFERENCES";
export const ASC_FEATURE_RELAXED_SIMD = "ASC_FEATURE_RELAXED_SIMD";
export const ASC_FEATURE_EXTENDED_CONST = "ASC_FEATURE_EXTENDED_CONST";
export const ASC_FEATURE_STRINGREF = "ASC_FEATURE_STRINGREF";
export const ASC_VERSION_MAJOR = "ASC_VERSION_MAJOR";
export const ASC_VERSION_MINOR = "ASC_VERSION_MINOR";
export const ASC_VERSION_PATCH = "ASC_VERSION_PATCH";
Expand Down
33 changes: 30 additions & 3 deletions src/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -472,9 +472,9 @@ export class Compiler extends DiagnosticEmitter {
if (options.hasFeature(Feature.MULTI_VALUE)) featureFlags |= FeatureFlags.MultiValue;
if (options.hasFeature(Feature.GC)) featureFlags |= FeatureFlags.GC;
if (options.hasFeature(Feature.MEMORY64)) featureFlags |= FeatureFlags.Memory64;
if (options.hasFeature(Feature.FUNCTION_REFERENCES)) featureFlags |= FeatureFlags.FunctionReferences;
if (options.hasFeature(Feature.RELAXED_SIMD)) featureFlags |= FeatureFlags.RelaxedSIMD;
if (options.hasFeature(Feature.EXTENDED_CONST)) featureFlags |= FeatureFlags.ExtendedConst;
if (options.hasFeature(Feature.STRINGREF)) featureFlags |= FeatureFlags.Stringref;
module.setFeatures(featureFlags);

// set up the main start function
Expand Down Expand Up @@ -4870,6 +4870,10 @@ export class Compiler extends DiagnosticEmitter {
case TypeKind.EQREF:
case TypeKind.I31REF:
case TypeKind.DATAREF: return module.ref_eq(leftExpr, rightExpr);
case TypeKind.STRINGREF: return module.string_eq(leftExpr, rightExpr);
case TypeKind.STRINGVIEW_WTF8:
case TypeKind.STRINGVIEW_WTF16:
case TypeKind.STRINGVIEW_ITER:
case TypeKind.FUNCREF:
case TypeKind.EXTERNREF:
case TypeKind.ANYREF: {
Expand Down Expand Up @@ -4919,6 +4923,14 @@ export class Compiler extends DiagnosticEmitter {
module.ref_eq(leftExpr, rightExpr)
);
}
case TypeKind.STRINGREF: {
return module.unary(UnaryOp.EqzI32,
module.string_eq(leftExpr, rightExpr)
);
}
case TypeKind.STRINGVIEW_WTF8:
case TypeKind.STRINGVIEW_WTF16:
case TypeKind.STRINGVIEW_ITER:
case TypeKind.FUNCREF:
case TypeKind.EXTERNREF:
case TypeKind.ANYREF: {
Expand Down Expand Up @@ -9836,6 +9848,13 @@ export class Compiler extends DiagnosticEmitter {
return this.checkFeatureEnabled(Feature.REFERENCE_TYPES, reportNode)
&& this.checkFeatureEnabled(Feature.GC, reportNode);
}
case TypeKind.STRINGREF:
case TypeKind.STRINGVIEW_WTF8:
case TypeKind.STRINGVIEW_WTF16:
case TypeKind.STRINGVIEW_ITER: {
return this.checkFeatureEnabled(Feature.REFERENCE_TYPES, reportNode)
&& this.checkFeatureEnabled(Feature.STRINGREF, reportNode);
}
}
let classReference = type.getClass();
if (classReference) {
Expand Down Expand Up @@ -9941,7 +9960,11 @@ export class Compiler extends DiagnosticEmitter {
case TypeKind.EXTERNREF:
case TypeKind.ANYREF:
case TypeKind.EQREF:
case TypeKind.DATAREF: return module.ref_null(type.toRef());
case TypeKind.DATAREF:
case TypeKind.STRINGREF:
case TypeKind.STRINGVIEW_WTF8:
case TypeKind.STRINGVIEW_WTF16:
case TypeKind.STRINGVIEW_ITER: return module.ref_null(type.toRef());
case TypeKind.I31REF: return module.i31_new(module.i32(0));
}
}
Expand Down Expand Up @@ -10090,7 +10113,11 @@ export class Compiler extends DiagnosticEmitter {
case TypeKind.ANYREF:
case TypeKind.EQREF:
case TypeKind.I31REF:
case TypeKind.DATAREF: {
case TypeKind.DATAREF:
case TypeKind.STRINGREF:
case TypeKind.STRINGVIEW_WTF8:
case TypeKind.STRINGVIEW_WTF16:
case TypeKind.STRINGVIEW_ITER: {
// Needs to be true (i.e. not zero) when the ref is _not_ null,
// which means `ref.is_null` returns false (i.e. zero).
return module.unary(UnaryOp.EqzI32, module.ref_is_null(expr));
Expand Down
Loading