[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 <kustermann@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
diff --git a/pkg/dart2wasm/lib/async.dart b/pkg/dart2wasm/lib/async.dart
index 4c66dbd..e9487d5 100644
--- a/pkg/dart2wasm/lib/async.dart
+++ b/pkg/dart2wasm/lib/async.dart
@@ -30,8 +30,7 @@
b.addLocal(w.RefType(asyncSuspendStateInfo.struct, nullable: false));
// AsyncResumeFun _resume
- translator.globals
- .readGlobal(b, translator.makeFunctionRef(b.module, resumeFun));
+ translator.globals.readGlobal(b, translator.makeFunctionRef(resumeFun));
// WasmStructRef? _context
if (context != null) {
diff --git a/pkg/dart2wasm/lib/constants.dart b/pkg/dart2wasm/lib/constants.dart
index 7114318..81ed8c6 100644
--- a/pkg/dart2wasm/lib/constants.dart
+++ b/pkg/dart2wasm/lib/constants.dart
@@ -28,7 +28,7 @@
bool get isLazy => function != null;
void _readGlobal(Translator translator, w.InstructionsBuilder b) {
- translator.globals.readGlobal(b, global, importNameSuffix: 'constant');
+ translator.globals.readGlobal(b, global);
}
w.ValueType readConstant(Translator translator, w.InstructionsBuilder b) {
diff --git a/pkg/dart2wasm/lib/globals.dart b/pkg/dart2wasm/lib/globals.dart
index 8e7cd2e..eb2a067 100644
--- a/pkg/dart2wasm/lib/globals.dart
+++ b/pkg/dart2wasm/lib/globals.dart
@@ -21,11 +21,10 @@
final Map<w.Global, w.BaseFunction> _globalGetters = {};
final Map<Field, w.Global> _globalInitializedFlag = {};
+ final WasmGlobalImporter _globalsModuleMap;
- late final WasmGlobalImporter _globalsModuleMap =
- WasmGlobalImporter(translator, 'global');
-
- Globals(this.translator);
+ Globals(this.translator)
+ : _globalsModuleMap = WasmGlobalImporter(translator, 'global');
Constant? _getConstantInitializer(Field variable) {
Expression? init = variable.initializer;
@@ -43,8 +42,7 @@
/// Takes into account the calling module and the module the global belongs
/// to. If they are not the same then accesses the global indirectly, either
/// through an import or a getter call.
- w.ValueType readGlobal(w.InstructionsBuilder b, w.Global global,
- {String importNameSuffix = ''}) {
+ w.ValueType readGlobal(w.InstructionsBuilder b, w.Global global) {
final owningModule = global.enclosingModule;
final callingModule = b.module;
if (owningModule == callingModule) {
diff --git a/pkg/dart2wasm/lib/intrinsics.dart b/pkg/dart2wasm/lib/intrinsics.dart
index c7dc54a..34e0b5f 100644
--- a/pkg/dart2wasm/lib/intrinsics.dart
+++ b/pkg/dart2wasm/lib/intrinsics.dart
@@ -1157,7 +1157,7 @@
w.BaseFunction wasmFunction =
translator.functions.getFunction(func.targetReference);
return translator.globals
- .readGlobal(b, translator.makeFunctionRef(b.module, wasmFunction));
+ .readGlobal(b, translator.makeFunctionRef(wasmFunction));
}
// Wasm(AnyRef|FuncRef|EqRef|StructRef|I32|I64|F32|F64) constructors
diff --git a/pkg/dart2wasm/lib/sync_star.dart b/pkg/dart2wasm/lib/sync_star.dart
index 3c60a30..4fcc2b2 100644
--- a/pkg/dart2wasm/lib/sync_star.dart
+++ b/pkg/dart2wasm/lib/sync_star.dart
@@ -36,8 +36,7 @@
} else {
b.ref_null(w.HeapType.struct);
}
- translator.globals
- .readGlobal(b, translator.makeFunctionRef(b.module, resumeFun));
+ translator.globals.readGlobal(b, translator.makeFunctionRef(resumeFun));
b.struct_new(syncStarIterableInfo.struct);
b.return_();
b.end();
diff --git a/pkg/dart2wasm/lib/translator.dart b/pkg/dart2wasm/lib/translator.dart
index 37cca50..3f0dea3 100644
--- a/pkg/dart2wasm/lib/translator.dart
+++ b/pkg/dart2wasm/lib/translator.dart
@@ -737,11 +737,10 @@
return translateExternalType(type) as w.RefType;
}
- /// Creates a global reference to [f] in [module]. [f] must also be located
- /// in [module].
- w.Global makeFunctionRef(w.ModuleBuilder module, w.BaseFunction f) {
+ /// Creates a global reference to [f] in its [w.BaseFunction.enclosingModule].
+ w.Global makeFunctionRef(w.BaseFunction f) {
return functionRefCache.putIfAbsent(f, () {
- final global = module.globals.define(
+ final global = f.enclosingModule.globals.define(
w.GlobalType(w.RefType.def(f.type, nullable: false), mutable: false));
global.initializer.ref_func(f);
global.initializer.end();