Skip to content

Commit 6d918dd

Browse files
committed
update pass pipeline. Rename Stringref -> Strings feature internally
1 parent 28e32f9 commit 6d918dd

5 files changed

Lines changed: 25 additions & 13 deletions

File tree

src/compiler.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ export class Options {
326326
setFeature(feature: Feature, on: bool = true): void {
327327
if (on) {
328328
// Enabling Stringref also enables GC
329-
if (feature & Feature.Stringref) feature |= Feature.GC;
329+
if (feature & Feature.Strings) feature |= Feature.GC;
330330
// Enabling GC also enables Reference Types
331331
if (feature & Feature.GC) feature |= Feature.ReferenceTypes;
332332
// Enabling Relaxed SIMD also enables SIMD
@@ -336,7 +336,7 @@ export class Options {
336336
// Disabling Reference Types also disables GC
337337
if (feature & Feature.ReferenceTypes) feature |= Feature.GC;
338338
// Disabling GC also disables Stringref
339-
if (feature & Feature.GC) feature |= Feature.Stringref;
339+
if (feature & Feature.GC) feature |= Feature.Strings;
340340
// Disabling SIMD also disables Relaxed SIMD
341341
if (feature & Feature.Simd) feature |= Feature.RelaxedSimd;
342342
this.features &= ~feature;
@@ -515,7 +515,7 @@ export class Compiler extends DiagnosticEmitter {
515515
if (options.hasFeature(Feature.Memory64)) featureFlags |= FeatureFlags.Memory64;
516516
if (options.hasFeature(Feature.RelaxedSimd)) featureFlags |= FeatureFlags.RelaxedSIMD;
517517
if (options.hasFeature(Feature.ExtendedConst)) featureFlags |= FeatureFlags.ExtendedConst;
518-
if (options.hasFeature(Feature.Stringref)) featureFlags |= FeatureFlags.Stringref;
518+
if (options.hasFeature(Feature.Strings)) featureFlags |= FeatureFlags.Strings;
519519
module.setFeatures(featureFlags);
520520

521521
// set up the main start function

src/index-wasm.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ export const FEATURE_RELAXED_SIMD = Feature.RelaxedSimd;
201201
/** Extended const expressions. */
202202
export const FEATURE_EXTENDED_CONST = Feature.ExtendedConst;
203203
/** String references. */
204-
export const FEATURE_STRINGREF = Feature.Stringref;
204+
export const FEATURE_STRINGREF = Feature.Strings;
205205
/** All features. */
206206
export const FEATURES_ALL = Feature.All;
207207
/** Default features. */

src/module.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ export const enum FeatureFlags {
210210
Memory64 = 2048 /* _BinaryenFeatureMemory64 */,
211211
RelaxedSIMD = 4096 /* _BinaryenFeatureRelaxedSIMD */,
212212
ExtendedConst = 8192 /* _BinaryenFeatureExtendedConst */,
213-
Stringref = 16384 /* _BinaryenFeatureStrings */,
213+
Strings = 16384 /* _BinaryenFeatureStrings */,
214214
MultiMemory = 32768 /* _BinaryenFeatureMultiMemory */,
215215
StackSwitching = 65536 /* _BinaryenFeatureStackSwitching */,
216216
SharedEverything = 131072 /* _BinaryenFeatureSharedEverything */,
@@ -2689,6 +2689,12 @@ export class Module {
26892689
passes.push("gufa-optimizing");
26902690
passes.push("dae-optimizing");
26912691
}
2692+
if (this.getFeatures() & FeatureFlags.MultiValue) {
2693+
// Optimize tuples before local opts (as splitting tuples can help local
2694+
// opts), but also not too early, as we want to be after
2695+
// optimize-instructions at least (which can remove tuple-related things).
2696+
passes.push("tuple-optimization");
2697+
}
26922698
if (optimizeLevel >= 3) {
26932699
passes.push("simplify-locals-nostructure");
26942700
passes.push("flatten");
@@ -2822,6 +2828,12 @@ export class Module {
28222828
passes.push("merge-blocks");
28232829
passes.push("vacuum");
28242830

2831+
if (this.getFeatures() & FeatureFlags.Strings) {
2832+
// Gather strings to globals right before reorder-globals, which will then
2833+
// sort them properly.
2834+
passes.push("string-gathering");
2835+
}
2836+
28252837
passes.push("simplify-globals-optimizing");
28262838
passes.push("reorder-globals");
28272839
passes.push("remove-unused-brs");

src/program.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -390,9 +390,9 @@ export namespace OperatorKind {
390390
case Token.GreaterThan_GreaterThan_Equals: return OperatorKind.BitwiseShr;
391391
case Token.GreaterThan_GreaterThan_GreaterThan:
392392
case Token.GreaterThan_GreaterThan_GreaterThan_Equals: return OperatorKind.BitwiseShrU;
393-
case Token.Equals_Equals:
393+
case Token.Equals_Equals:
394394
case Token.Equals_Equals_Equals: return OperatorKind.Eq;
395-
case Token.Exclamation_Equals:
395+
case Token.Exclamation_Equals:
396396
case Token.Exclamation_Equals_Equals: return OperatorKind.Ne;
397397
case Token.GreaterThan: return OperatorKind.Gt;
398398
case Token.GreaterThan_Equals: return OperatorKind.Ge;
@@ -436,7 +436,7 @@ export class Program extends DiagnosticEmitter {
436436
diagnostics: DiagnosticMessage[] | null = null
437437
) {
438438
super(diagnostics);
439-
this.module = Module.create(options.stackSize > 0, options.sizeTypeRef);
439+
this.module = Module.create(options.stackSize > 0, options.sizeTypeRef);
440440
this.parser = new Parser(this.diagnostics, this.sources);
441441
this.resolver = new Resolver(this);
442442
let nativeFile = new File(this, Source.native);
@@ -1085,7 +1085,7 @@ export class Program extends DiagnosticEmitter {
10851085
this.registerConstantInteger(CommonNames.ASC_FEATURE_EXTENDED_CONST, Type.bool,
10861086
i64_new(options.hasFeature(Feature.ExtendedConst) ? 1 : 0, 0));
10871087
this.registerConstantInteger(CommonNames.ASC_FEATURE_STRINGREF, Type.bool,
1088-
i64_new(options.hasFeature(Feature.Stringref) ? 1 : 0, 0));
1088+
i64_new(options.hasFeature(Feature.Strings) ? 1 : 0, 0));
10891089

10901090
// remember deferred elements
10911091
let queuedImports = new Array<QueuedImport>();
@@ -1300,7 +1300,7 @@ export class Program extends DiagnosticEmitter {
13001300
this.registerWrapperClass(Type.array, CommonNames.RefArray);
13011301
this.registerWrapperClass(Type.i31, CommonNames.RefI31);
13021302
}
1303-
if (options.hasFeature(Feature.Stringref)) {
1303+
if (options.hasFeature(Feature.Strings)) {
13041304
this.registerWrapperClass(Type.string, CommonNames.RefString);
13051305
}
13061306
}
@@ -1974,7 +1974,7 @@ export class Program extends DiagnosticEmitter {
19741974
case TypeKind.StringviewWTF16:
19751975
case TypeKind.StringviewIter: {
19761976
return this.checkFeatureEnabled(Feature.ReferenceTypes, reportNode)
1977-
&& this.checkFeatureEnabled(Feature.Stringref, reportNode);
1977+
&& this.checkFeatureEnabled(Feature.Strings, reportNode);
19781978
}
19791979
}
19801980
let classReference = type.getClass();

std/assembly/shared/feature.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export const enum Feature {
3333
/** Extended const expressions. */
3434
ExtendedConst = 1 << 13, // see: https://github.com/WebAssembly/extended-const
3535
/** Reference typed strings. */
36-
Stringref = 1 << 14, // see: https://github.com/WebAssembly/stringref
36+
Strings = 1 << 14, // see: https://github.com/WebAssembly/stringref
3737
/** All features. */
3838
All = (1 << 15) - 1
3939
}
@@ -55,7 +55,7 @@ export function featureToString(feature: Feature): string {
5555
case Feature.Memory64: return "memory64";
5656
case Feature.RelaxedSimd: return "relaxed-simd";
5757
case Feature.ExtendedConst: return "extended-const";
58-
case Feature.Stringref: return "stringref";
58+
case Feature.Strings: return "stringref";
5959
}
6060
assert(false);
6161
return "";

0 commit comments

Comments
 (0)