diff --git a/pkg/wasm_builder/lib/src/builder/global.dart b/pkg/wasm_builder/lib/src/builder/global.dart index 9cbc0bf61db..b7b8749bb73 100644 --- a/pkg/wasm_builder/lib/src/builder/global.dart +++ b/pkg/wasm_builder/lib/src/builder/global.dart @@ -10,8 +10,7 @@ class GlobalBuilder extends ir.Global with IndexableBuilder { GlobalBuilder(ModuleBuilder module, super.index, super.type, [super.globalName]) - : initializer = - InstructionsBuilder(module, [type.type], isGlobalInitializer: true); + : initializer = InstructionsBuilder(module, [type.type]); @override ir.DefinedGlobal forceBuild() => diff --git a/pkg/wasm_builder/lib/src/builder/instructions.dart b/pkg/wasm_builder/lib/src/builder/instructions.dart index 694f9872bc0..fe60c1e7928 100644 --- a/pkg/wasm_builder/lib/src/builder/instructions.dart +++ b/pkg/wasm_builder/lib/src/builder/instructions.dart @@ -104,9 +104,6 @@ class InstructionsBuilder with Builder { /// Locals declared in this body, including parameters. final List locals = []; - /// Is this the initializer of a global variable? - final bool isGlobalInitializer; - /// Whether a textual trace of the instruction stream should be recorded when /// emitting instructions (provided asserts are enabled). /// @@ -143,8 +140,7 @@ class InstructionsBuilder with Builder { final Map? _stackTraces; /// Create a new instruction sequence. - InstructionsBuilder(this.module, List outputs, - {this.isGlobalInitializer = false}) + InstructionsBuilder(this.module, List outputs) : _stackTraces = module.watchPoints.isNotEmpty ? {} : null { _labelStack.add(Expression(const [], outputs)); } @@ -1076,7 +1072,6 @@ class InstructionsBuilder with Builder { [ir.RefType.def(arrayType, nullable: false)], trace: ['array.new_data', arrayType, data.index])); _add(ir.ArrayNewData(arrayType, data)); - if (isGlobalInitializer) module.dataReferencedFromGlobalInitializer = true; } /// Emit an `array.copy` instruction. diff --git a/pkg/wasm_builder/lib/src/builder/module.dart b/pkg/wasm_builder/lib/src/builder/module.dart index 0cd86665c2b..47ec9f5c4ce 100644 --- a/pkg/wasm_builder/lib/src/builder/module.dart +++ b/pkg/wasm_builder/lib/src/builder/module.dart @@ -17,7 +17,6 @@ class ModuleBuilder with Builder { final dataSegments = DataSegmentsBuilder(); late final globals = GlobalsBuilder(this); final exports = ExportsBuilder(); - bool dataReferencedFromGlobalInitializer = false; /// Create a new, initially empty, module. /// @@ -47,7 +46,6 @@ class ModuleBuilder with Builder { .followedBy(finalMemories.imported) .followedBy(finalGlobals.imported) .toList(), - watchPoints, - dataReferencedFromGlobalInitializer); + watchPoints); } } diff --git a/pkg/wasm_builder/lib/src/ir/module.dart b/pkg/wasm_builder/lib/src/ir/module.dart index 04b8de70a98..a188358c0cf 100644 --- a/pkg/wasm_builder/lib/src/ir/module.dart +++ b/pkg/wasm_builder/lib/src/ir/module.dart @@ -17,7 +17,6 @@ class Module implements Serializable { final DataSegments dataSegments; final List imports; final List watchPoints; - final bool dataReferencedFromGlobalInitializer; Module( this.functions, @@ -29,8 +28,7 @@ class Module implements Serializable { this.types, this.dataSegments, this.imports, - this.watchPoints, - this.dataReferencedFromGlobalInitializer); + this.watchPoints); /// Serialize a module to its binary representation. @override @@ -46,16 +44,11 @@ class Module implements Serializable { TableSection(tables.defined, watchPoints).serialize(s); MemorySection(memories.defined, watchPoints).serialize(s); TagSection(tags.defined, watchPoints).serialize(s); - if (dataReferencedFromGlobalInitializer) { - DataCountSection(dataSegments.defined, watchPoints).serialize(s); - } GlobalSection(globals.defined, watchPoints).serialize(s); ExportSection(exports.exported, watchPoints).serialize(s); StartSection(functions.start, watchPoints).serialize(s); ElementSection(tables.defined, watchPoints).serialize(s); - if (!dataReferencedFromGlobalInitializer) { - DataCountSection(dataSegments.defined, watchPoints).serialize(s); - } + DataCountSection(dataSegments.defined, watchPoints).serialize(s); CodeSection(functions.defined, watchPoints).serialize(s); DataSection(dataSegments.defined, watchPoints).serialize(s); if (functions.namedCount > 0 || types.namedCount > 0) {