Skip to content

Commit eafb6b7

Browse files
natebiggsCommit Queue
authored andcommitted
[dart2wasm] Fix dispatch table class ID loop bounds.
The loop iterates over the class IDs up to (but not including) maxConcreteClassId. But maxConcreteClassId is the actual ID of the last concrete class so the loop is ending 1 early. From some testing, WasmTable seems to always be the last class. This class doesn't have any subclasses so all the calls to it are likely devirtualized anyway skipping the dispatch table. In fact the way the class IDs are assigned, the last class should always be a leaf concrete class. I believe that's why this hasn't caused a detectable bug. Change-Id: I7003dfd015c2ad13a4a042ae86af5e4f54242452 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/391862 Commit-Queue: Nate Biggs <[email protected]> Reviewed-by: Ömer Ağacan <[email protected]>
1 parent d4fdb84 commit eafb6b7

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

pkg/dart2wasm/lib/dispatch_table.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ class DispatchTable {
392392

393393
final selectorTargets = <SelectorInfo, Map<int, Reference>>{};
394394
final maxConcreteClassId = translator.classIdNumbering.maxConcreteClassId;
395-
for (int classId = 0; classId < maxConcreteClassId; ++classId) {
395+
for (int classId = 0; classId <= maxConcreteClassId; ++classId) {
396396
final cls = translator.classes[classId].cls;
397397
if (cls != null) {
398398
selectorsInClass[cls]!.forEach((selectorInfo, target) {

0 commit comments

Comments
 (0)