[dart2wasm] Don't generate duplicate selectors for dynamic calls

Change-Id: I8c41e8289400c4673d1268826bfe1cbc161a4d90
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/332402
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
This commit is contained in:
Ömer Sinan Ağacan 2023-10-27 12:31:23 +00:00 committed by Commit Queue
parent c349f992a6
commit 3a8d3cdf2f

View file

@ -237,13 +237,13 @@ class DispatchTable {
final Map<int, SelectorInfo> _selectorInfo = {};
/// Maps member names to getter selectors with the same member name.
final Map<String, List<SelectorInfo>> _dynamicGetters = {};
final Map<String, Set<SelectorInfo>> _dynamicGetters = {};
/// Maps member names to setter selectors with the same member name.
final Map<String, List<SelectorInfo>> _dynamicSetters = {};
final Map<String, Set<SelectorInfo>> _dynamicSetters = {};
/// Maps member names to method selectors with the same member name.
final Map<String, List<SelectorInfo>> _dynamicMethods = {};
final Map<String, Set<SelectorInfo>> _dynamicMethods = {};
/// Contents of [wasmTable]. For a selector with ID S and a target class of
/// the selector with ID C, `table[S + C]` gives the reference to the class
@ -305,11 +305,11 @@ class DispatchTable {
selector.paramInfo.merge(paramInfo);
if (calledDynamically) {
if (isGetter) {
(_dynamicGetters[member.name.text] ??= []).add(selector);
(_dynamicGetters[member.name.text] ??= {}).add(selector);
} else if (isSetter) {
(_dynamicSetters[member.name.text] ??= []).add(selector);
(_dynamicSetters[member.name.text] ??= {}).add(selector);
} else {
(_dynamicMethods[member.name.text] ??= []).add(selector);
(_dynamicMethods[member.name.text] ??= {}).add(selector);
}
}
return selector;