Skip to content

Commit 946f328

Browse files
natebiggsCommit Queue
authored andcommitted
[dart2wasm] Clean up some dead or unnecessary code.
Change-Id: I01001194f67a908d710622c9b13678d94ce75b0b Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/400922 Reviewed-by: Martin Kustermann <[email protected]> Commit-Queue: Nate Biggs <[email protected]>
1 parent 231b463 commit 946f328

File tree

6 files changed

+11
-16
lines changed

6 files changed

+11
-16
lines changed

pkg/dart2wasm/lib/async.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ mixin AsyncCodeGeneratorMixin on StateMachineEntryAstCodeGenerator {
3030
b.addLocal(w.RefType(asyncSuspendStateInfo.struct, nullable: false));
3131

3232
// AsyncResumeFun _resume
33-
translator.globals
34-
.readGlobal(b, translator.makeFunctionRef(b.module, resumeFun));
33+
translator.globals.readGlobal(b, translator.makeFunctionRef(resumeFun));
3534

3635
// WasmStructRef? _context
3736
if (context != null) {

pkg/dart2wasm/lib/constants.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class ConstantInfo {
2828
bool get isLazy => function != null;
2929

3030
void _readGlobal(Translator translator, w.InstructionsBuilder b) {
31-
translator.globals.readGlobal(b, global, importNameSuffix: 'constant');
31+
translator.globals.readGlobal(b, global);
3232
}
3333

3434
w.ValueType readConstant(Translator translator, w.InstructionsBuilder b) {

pkg/dart2wasm/lib/globals.dart

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,10 @@ class Globals {
2121
final Map<w.Global, w.BaseFunction> _globalGetters = {};
2222

2323
final Map<Field, w.Global> _globalInitializedFlag = {};
24+
final WasmGlobalImporter _globalsModuleMap;
2425

25-
late final WasmGlobalImporter _globalsModuleMap =
26-
WasmGlobalImporter(translator, 'global');
27-
28-
Globals(this.translator);
26+
Globals(this.translator)
27+
: _globalsModuleMap = WasmGlobalImporter(translator, 'global');
2928

3029
Constant? _getConstantInitializer(Field variable) {
3130
Expression? init = variable.initializer;
@@ -43,8 +42,7 @@ class Globals {
4342
/// Takes into account the calling module and the module the global belongs
4443
/// to. If they are not the same then accesses the global indirectly, either
4544
/// through an import or a getter call.
46-
w.ValueType readGlobal(w.InstructionsBuilder b, w.Global global,
47-
{String importNameSuffix = ''}) {
45+
w.ValueType readGlobal(w.InstructionsBuilder b, w.Global global) {
4846
final owningModule = global.enclosingModule;
4947
final callingModule = b.module;
5048
if (owningModule == callingModule) {

pkg/dart2wasm/lib/intrinsics.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1157,7 +1157,7 @@ class Intrinsifier {
11571157
w.BaseFunction wasmFunction =
11581158
translator.functions.getFunction(func.targetReference);
11591159
return translator.globals
1160-
.readGlobal(b, translator.makeFunctionRef(b.module, wasmFunction));
1160+
.readGlobal(b, translator.makeFunctionRef(wasmFunction));
11611161
}
11621162

11631163
// Wasm(AnyRef|FuncRef|EqRef|StructRef|I32|I64|F32|F64) constructors

pkg/dart2wasm/lib/sync_star.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ mixin SyncStarCodeGeneratorMixin on StateMachineEntryAstCodeGenerator {
3636
} else {
3737
b.ref_null(w.HeapType.struct);
3838
}
39-
translator.globals
40-
.readGlobal(b, translator.makeFunctionRef(b.module, resumeFun));
39+
translator.globals.readGlobal(b, translator.makeFunctionRef(resumeFun));
4140
b.struct_new(syncStarIterableInfo.struct);
4241
b.return_();
4342
b.end();

pkg/dart2wasm/lib/translator.dart

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -737,11 +737,10 @@ class Translator with KernelNodes {
737737
return translateExternalType(type) as w.RefType;
738738
}
739739

740-
/// Creates a global reference to [f] in [module]. [f] must also be located
741-
/// in [module].
742-
w.Global makeFunctionRef(w.ModuleBuilder module, w.BaseFunction f) {
740+
/// Creates a global reference to [f] in its [w.BaseFunction.enclosingModule].
741+
w.Global makeFunctionRef(w.BaseFunction f) {
743742
return functionRefCache.putIfAbsent(f, () {
744-
final global = module.globals.define(
743+
final global = f.enclosingModule.globals.define(
745744
w.GlobalType(w.RefType.def(f.type, nullable: false), mutable: false));
746745
global.initializer.ref_func(f);
747746
global.initializer.end();

0 commit comments

Comments
 (0)