Skip to content

Commit 5ee9ce9

Browse files
committed
handle shared everything feat for setFeature
1 parent 0f86186 commit 5ee9ce9

5 files changed

Lines changed: 17 additions & 2 deletions

File tree

src/common.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ export namespace CommonNames {
191191
export const ASC_FEATURE_RELAXED_SIMD = "ASC_FEATURE_RELAXED_SIMD";
192192
export const ASC_FEATURE_EXTENDED_CONST = "ASC_FEATURE_EXTENDED_CONST";
193193
export const ASC_FEATURE_STRINGREF = "ASC_FEATURE_STRINGREF";
194+
export const ASC_FEATURE_SHARED_EVERYTHING = "ASC_FEATURE_SHARED_EVERYTHING";
194195
export const ASC_VERSION_MAJOR = "ASC_VERSION_MAJOR";
195196
export const ASC_VERSION_MINOR = "ASC_VERSION_MINOR";
196197
export const ASC_VERSION_PATCH = "ASC_VERSION_PATCH";

src/compiler.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,8 @@ export class Options {
325325
/** Sets whether a feature is enabled. */
326326
setFeature(feature: Feature, on: bool = true): void {
327327
if (on) {
328+
// Enabling Shared Everything also enables Threads and GC
329+
if (feature & Feature.SharedEverything) feature |= Feature.Threads | Feature.GC;
328330
// Enabling Stringref also enables GC
329331
if (feature & Feature.Strings) feature |= Feature.GC;
330332
// Enabling GC also enables Reference Types
@@ -339,6 +341,8 @@ export class Options {
339341
if (feature & Feature.GC) feature |= Feature.Strings;
340342
// Disabling SIMD also disables Relaxed SIMD
341343
if (feature & Feature.Simd) feature |= Feature.RelaxedSimd;
344+
// Disabling Threads or GC also disables Shared Everything
345+
if (feature & (Feature.Threads | Feature.GC)) feature |= Feature.SharedEverything;
342346
this.features &= ~feature;
343347
}
344348
}
@@ -516,6 +520,7 @@ export class Compiler extends DiagnosticEmitter {
516520
if (options.hasFeature(Feature.RelaxedSimd)) featureFlags |= FeatureFlags.RelaxedSIMD;
517521
if (options.hasFeature(Feature.ExtendedConst)) featureFlags |= FeatureFlags.ExtendedConst;
518522
if (options.hasFeature(Feature.Strings)) featureFlags |= FeatureFlags.Strings;
523+
if (options.hasFeature(Feature.SharedEverything)) featureFlags |= FeatureFlags.SharedEverything;
519524
module.setFeatures(featureFlags);
520525

521526
// set up the main start function

src/index-wasm.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,8 @@ export const FEATURE_RELAXED_SIMD = Feature.RelaxedSimd;
202202
export const FEATURE_EXTENDED_CONST = Feature.ExtendedConst;
203203
/** String references. */
204204
export const FEATURE_STRINGREF = Feature.Strings;
205+
/** Shared-everything threads. */
206+
export const FEATURE_SHARED_EVERYTHING = Feature.SharedEverything;
205207
/** All features. */
206208
export const FEATURES_ALL = Feature.All;
207209
/** Default features. */

src/program.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1086,6 +1086,8 @@ export class Program extends DiagnosticEmitter {
10861086
i64_new(options.hasFeature(Feature.ExtendedConst) ? 1 : 0, 0));
10871087
this.registerConstantInteger(CommonNames.ASC_FEATURE_STRINGREF, Type.bool,
10881088
i64_new(options.hasFeature(Feature.Strings) ? 1 : 0, 0));
1089+
this.registerConstantInteger(CommonNames.ASC_FEATURE_SHARED_EVERYTHING, Type.bool,
1090+
i64_new(options.hasFeature(Feature.Strings) ? 1 : 0, 0));
10891091

10901092
// remember deferred elements
10911093
let queuedImports = new Array<QueuedImport>();
@@ -1289,7 +1291,9 @@ export class Program extends DiagnosticEmitter {
12891291
this.registerWrapperClass(Type.bool, CommonNames.Bool);
12901292
this.registerWrapperClass(Type.f32, CommonNames.F32);
12911293
this.registerWrapperClass(Type.f64, CommonNames.F64);
1292-
if (options.hasFeature(Feature.Simd)) this.registerWrapperClass(Type.v128, CommonNames.V128);
1294+
if (options.hasFeature(Feature.Simd)) {
1295+
this.registerWrapperClass(Type.v128, CommonNames.V128);
1296+
}
12931297
if (options.hasFeature(Feature.ReferenceTypes)) {
12941298
this.registerWrapperClass(Type.func, CommonNames.RefFunc);
12951299
this.registerWrapperClass(Type.extern, CommonNames.RefExtern);

std/assembly/shared/feature.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,10 @@ export const enum Feature {
3434
ExtendedConst = 1 << 13, // see: https://github.com/WebAssembly/extended-const
3535
/** Reference typed strings. */
3636
Strings = 1 << 14, // see: https://github.com/WebAssembly/stringref
37+
/** Shared-everything threads. */
38+
SharedEverything = 1 << 15, // see: https://github.com/WebAssembly/shared-everything-threads
3739
/** All features. */
38-
All = (1 << 15) - 1
40+
All = (1 << 16) - 1
3941
}
4042

4143
/** Gets the name of the specified feature one would specify on the command line. */
@@ -56,6 +58,7 @@ export function featureToString(feature: Feature): string {
5658
case Feature.RelaxedSimd: return "relaxed-simd";
5759
case Feature.ExtendedConst: return "extended-const";
5860
case Feature.Strings: return "stringref";
61+
case Feature.SharedEverything: return "shared-everything";
5962
}
6063
assert(false);
6164
return "";

0 commit comments

Comments
 (0)