Skip to content

Commit 26da655

Browse files
mkustermannCommit Queue
authored andcommitted
[dart2wasm] Remove duplicate code to call references
Change-Id: I304729f6ed19a75de16ddced15b3f47f894e9c49 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/430740 Reviewed-by: Ömer Ağacan <[email protected]> Commit-Queue: Martin Kustermann <[email protected]>
1 parent 3deffab commit 26da655

File tree

2 files changed

+10
-17
lines changed

2 files changed

+10
-17
lines changed

pkg/dart2wasm/lib/code_generator.dart

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -689,17 +689,7 @@ abstract class AstCodeGenerator
689689
}
690690

691691
List<w.ValueType> call(Reference target) {
692-
final targetModule = translator.moduleForReference(target);
693-
final isLocalModuleCall = targetModule == b.module;
694-
final name = translator.functions.getFunctionName(target);
695-
696-
if (isLocalModuleCall) {
697-
b.comment('Direct call to $name');
698-
return b.invoke(translator.directCallTarget(target));
699-
} else {
700-
b.comment('Direct call to $name (across modules)');
701-
return translator.callReference(target, b);
702-
}
692+
return translator.callReference(target, b);
703693
}
704694

705695
@override

pkg/dart2wasm/lib/translator.dart

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -553,16 +553,19 @@ class Translator with KernelNodes {
553553
}
554554
}
555555

556-
/// Gets the function associated with [reference] and calls its using
557-
/// [callFunction].
556+
/// Calls the function referred to in [reference] either directly or via a
557+
/// cross-module call.
558+
///
559+
/// When performing a direct call it may inline the target if allowed and
560+
/// beneficial.
558561
List<w.ValueType> callReference(
559562
Reference reference, w.InstructionsBuilder b) {
560-
final function = functions.getFunction(reference);
561-
final targetModule = function.enclosingModule;
562-
if (targetModule == b.module) {
563+
final targetModule = moduleForReference(reference);
564+
final isLocalModuleCall = targetModule == b.module;
565+
if (isLocalModuleCall) {
563566
return b.invoke(directCallTarget(reference));
564567
}
565-
return callFunction(function, b);
568+
return callFunction(functions.getFunction(reference), b);
566569
}
567570

568571
late final WasmFunctionImporter _importedFunctions =

0 commit comments

Comments
 (0)