Skip to content

Commit d32ef08

Browse files
authored
Sync with latest Binaryen (#2493)
1 parent 4801750 commit d32ef08

File tree

115 files changed

+2413
-1497
lines changed

Some content is hidden

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

115 files changed

+2413
-1497
lines changed

cli/options.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,14 +204,14 @@
204204
" simd SIMD types and operations.",
205205
" reference-types Reference types and operations.",
206206
" gc Garbage collection (WIP).",
207+
" stringref String reference types.",
207208
""
208209
],
209210
"TODO_doesNothingYet": [
210211
" exception-handling Exception handling.",
211212
" tail-calls Tail call operations.",
212213
" multi-value Multi value types.",
213214
" memory64 Memory64 operations.",
214-
" function-references Function reference types.",
215215
" relaxed-simd Relaxed SIMD operations.",
216216
" extended-const Extended const expressions."
217217
],

package-lock.json

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

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
},
2626
"engineStrict": true,
2727
"dependencies": {
28-
"binaryen": "109.0.0-nightly.20220831",
28+
"binaryen": "110.0.0-nightly.20220924",
2929
"long": "^5.2.0"
3030
},
3131
"devDependencies": {

scripts/update-constants.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ var src = fs.readFileSync(srcfile, "utf8")
1515
if (val.startsWith("binaryen.")) {
1616
return $0;
1717
}
18-
var match = val.match(/\b(_(?:Binaryen|Relooper|ExpressionRunner)\w+)\b/);
18+
var match = val.match(/\b(_(?:Binaryen|Relooper|ExpressionRunner|TypeBuilder)\w+)\b/);
1919
if (match) {
2020
let fn = match[1];
2121
if (typeof binaryen[fn] !== "function") throw Error("API mismatch on '" + fn + "': Is Binaryen up to date?");

src/builtins.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3492,7 +3492,11 @@ function builtin_assert(ctx: BuiltinContext): ExpressionRef {
34923492
case TypeKind.ANYREF:
34933493
case TypeKind.EQREF:
34943494
case TypeKind.DATAREF:
3495-
case TypeKind.I31REF: return module.if(module.ref_is(RefIsOp.Null, arg0), abort);
3495+
case TypeKind.I31REF:
3496+
case TypeKind.STRINGREF:
3497+
case TypeKind.STRINGVIEW_WTF8:
3498+
case TypeKind.STRINGVIEW_WTF16:
3499+
case TypeKind.STRINGVIEW_ITER: return module.if(module.ref_is(RefIsOp.Null, arg0), abort);
34963500

34973501
}
34983502
} else {
@@ -3574,7 +3578,11 @@ function builtin_assert(ctx: BuiltinContext): ExpressionRef {
35743578
case TypeKind.ANYREF:
35753579
case TypeKind.EQREF:
35763580
case TypeKind.DATAREF:
3577-
case TypeKind.I31REF: {
3581+
case TypeKind.I31REF:
3582+
case TypeKind.STRINGREF:
3583+
case TypeKind.STRINGVIEW_WTF8:
3584+
case TypeKind.STRINGVIEW_WTF16:
3585+
case TypeKind.STRINGVIEW_ITER: {
35783586
let temp = flow.getTempLocal(type);
35793587
let ret = module.if(
35803588
module.ref_is(RefIsOp.Null,

src/common.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,10 @@ export namespace CommonNames {
132132
export const eqref = "eqref";
133133
export const i31ref = "i31ref";
134134
export const dataref = "dataref";
135+
export const stringref = "stringref";
136+
export const stringview_wtf8 = "stringview_wtf8";
137+
export const stringview_wtf16 = "stringview_wtf16";
138+
export const stringview_iter = "stringview_iter";
135139
export const i8x16 = "i8x16";
136140
export const u8x16 = "u8x16";
137141
export const i16x8 = "i16x8";
@@ -181,9 +185,9 @@ export namespace CommonNames {
181185
export const ASC_FEATURE_MULTI_VALUE = "ASC_FEATURE_MULTI_VALUE";
182186
export const ASC_FEATURE_GC = "ASC_FEATURE_GC";
183187
export const ASC_FEATURE_MEMORY64 = "ASC_FEATURE_MEMORY64";
184-
export const ASC_FEATURE_FUNCTION_REFERENCES = "ASC_FEATURE_FUNCTION_REFERENCES";
185188
export const ASC_FEATURE_RELAXED_SIMD = "ASC_FEATURE_RELAXED_SIMD";
186189
export const ASC_FEATURE_EXTENDED_CONST = "ASC_FEATURE_EXTENDED_CONST";
190+
export const ASC_FEATURE_STRINGREF = "ASC_FEATURE_STRINGREF";
187191
export const ASC_VERSION_MAJOR = "ASC_VERSION_MAJOR";
188192
export const ASC_VERSION_MINOR = "ASC_VERSION_MINOR";
189193
export const ASC_VERSION_PATCH = "ASC_VERSION_PATCH";

src/compiler.ts

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -472,9 +472,9 @@ export class Compiler extends DiagnosticEmitter {
472472
if (options.hasFeature(Feature.MULTI_VALUE)) featureFlags |= FeatureFlags.MultiValue;
473473
if (options.hasFeature(Feature.GC)) featureFlags |= FeatureFlags.GC;
474474
if (options.hasFeature(Feature.MEMORY64)) featureFlags |= FeatureFlags.Memory64;
475-
if (options.hasFeature(Feature.FUNCTION_REFERENCES)) featureFlags |= FeatureFlags.FunctionReferences;
476475
if (options.hasFeature(Feature.RELAXED_SIMD)) featureFlags |= FeatureFlags.RelaxedSIMD;
477476
if (options.hasFeature(Feature.EXTENDED_CONST)) featureFlags |= FeatureFlags.ExtendedConst;
477+
if (options.hasFeature(Feature.STRINGREF)) featureFlags |= FeatureFlags.Stringref;
478478
module.setFeatures(featureFlags);
479479

480480
// set up the main start function
@@ -4870,6 +4870,10 @@ export class Compiler extends DiagnosticEmitter {
48704870
case TypeKind.EQREF:
48714871
case TypeKind.I31REF:
48724872
case TypeKind.DATAREF: return module.ref_eq(leftExpr, rightExpr);
4873+
case TypeKind.STRINGREF: return module.string_eq(leftExpr, rightExpr);
4874+
case TypeKind.STRINGVIEW_WTF8:
4875+
case TypeKind.STRINGVIEW_WTF16:
4876+
case TypeKind.STRINGVIEW_ITER:
48734877
case TypeKind.FUNCREF:
48744878
case TypeKind.EXTERNREF:
48754879
case TypeKind.ANYREF: {
@@ -4919,6 +4923,14 @@ export class Compiler extends DiagnosticEmitter {
49194923
module.ref_eq(leftExpr, rightExpr)
49204924
);
49214925
}
4926+
case TypeKind.STRINGREF: {
4927+
return module.unary(UnaryOp.EqzI32,
4928+
module.string_eq(leftExpr, rightExpr)
4929+
);
4930+
}
4931+
case TypeKind.STRINGVIEW_WTF8:
4932+
case TypeKind.STRINGVIEW_WTF16:
4933+
case TypeKind.STRINGVIEW_ITER:
49224934
case TypeKind.FUNCREF:
49234935
case TypeKind.EXTERNREF:
49244936
case TypeKind.ANYREF: {
@@ -9836,6 +9848,13 @@ export class Compiler extends DiagnosticEmitter {
98369848
return this.checkFeatureEnabled(Feature.REFERENCE_TYPES, reportNode)
98379849
&& this.checkFeatureEnabled(Feature.GC, reportNode);
98389850
}
9851+
case TypeKind.STRINGREF:
9852+
case TypeKind.STRINGVIEW_WTF8:
9853+
case TypeKind.STRINGVIEW_WTF16:
9854+
case TypeKind.STRINGVIEW_ITER: {
9855+
return this.checkFeatureEnabled(Feature.REFERENCE_TYPES, reportNode)
9856+
&& this.checkFeatureEnabled(Feature.STRINGREF, reportNode);
9857+
}
98399858
}
98409859
let classReference = type.getClass();
98419860
if (classReference) {
@@ -9941,7 +9960,11 @@ export class Compiler extends DiagnosticEmitter {
99419960
case TypeKind.EXTERNREF:
99429961
case TypeKind.ANYREF:
99439962
case TypeKind.EQREF:
9944-
case TypeKind.DATAREF: return module.ref_null(type.toRef());
9963+
case TypeKind.DATAREF:
9964+
case TypeKind.STRINGREF:
9965+
case TypeKind.STRINGVIEW_WTF8:
9966+
case TypeKind.STRINGVIEW_WTF16:
9967+
case TypeKind.STRINGVIEW_ITER: return module.ref_null(type.toRef());
99459968
case TypeKind.I31REF: return module.i31_new(module.i32(0));
99469969
}
99479970
}
@@ -10090,7 +10113,11 @@ export class Compiler extends DiagnosticEmitter {
1009010113
case TypeKind.ANYREF:
1009110114
case TypeKind.EQREF:
1009210115
case TypeKind.I31REF:
10093-
case TypeKind.DATAREF: {
10116+
case TypeKind.DATAREF:
10117+
case TypeKind.STRINGREF:
10118+
case TypeKind.STRINGVIEW_WTF8:
10119+
case TypeKind.STRINGVIEW_WTF16:
10120+
case TypeKind.STRINGVIEW_ITER: {
1009410121
// Needs to be true (i.e. not zero) when the ref is _not_ null,
1009510122
// which means `ref.is_null` returns false (i.e. zero).
1009610123
return module.unary(UnaryOp.EqzI32, module.ref_is_null(expr));

0 commit comments

Comments
 (0)