-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
area-dart2wasmIssues for the dart2wasm compiler.Issues for the dart2wasm compiler.
Description
While working on #55231 and having trouble with functions getting defined multiple times and getting defined accidentally (when calling unrelated functions) and not being compiled, I noticed that we actually compile many things multiple times. When I add debug prints to print when a function with the same name is defined again, I see thousands of duplicate definitions in the test suite. Some examples:
Initializers:
toStringVisiting initializerGrowableList._emptyData initializerBoxedDouble._cache initializerBoxedDouble._cacheEvictIndex initializer
Type test functions:
<obj> as _PendingEvents<T0><obj> is num<obj> as double
Closures:
generator1 closure at ...foo closure at ...createErrorStream closure at ...
Closure wrappers:
closure wrapper at file://... trampolineclosure wrapper at file://... trampolineclosure wrapper at file://... trampolineclosure wrapper at file://... trampoline
This is not an exhaustive list, there may be other kind of things that we compile multiple times.
The diff that I used to generate this output:
diff --git a/pkg/wasm_builder/lib/src/builder/functions.dart b/pkg/wasm_builder/lib/src/builder/functions.dart
index 2969a5f815f..5aa987e26f0 100644
--- a/pkg/wasm_builder/lib/src/builder/functions.dart
+++ b/pkg/wasm_builder/lib/src/builder/functions.dart
@@ -46,6 +46,15 @@ class FunctionsBuilder with Builder<ir.Functions> {
FunctionBuilder define(ir.FunctionType type, [String? name]) {
final function =
FunctionBuilder(_module, ir.FinalizableIndex(), type, name);
+
+ if (name != null) {
+ for (final builder in _functionBuilders) {
+ if (builder.functionName == name) {
+ print("Generating duplicate name: $name");
+ }
+ }
+ }
+
_functionBuilders.add(function);
_addName(name, function);
return function;
Metadata
Metadata
Assignees
Labels
area-dart2wasmIssues for the dart2wasm compiler.Issues for the dart2wasm compiler.