Skip to content

Commit 7698535

Browse files
natebiggsCommit Queue
authored andcommitted
[dart2wasm] Fix static tear-off vtable instantiation.
When dynamic modules are enabled vtables should only include the dynamic call entry point. Change-Id: Ifdf935a00039fe478c290d4bef585659cfdb9661 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/427860 Reviewed-by: Martin Kustermann <[email protected]> Commit-Queue: Nate Biggs <[email protected]>
1 parent 6cea179 commit 7698535

File tree

4 files changed

+36
-0
lines changed

4 files changed

+36
-0
lines changed

pkg/dart2wasm/lib/constants.dart

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1129,6 +1129,13 @@ class ConstantCreator extends ConstantVisitor<ConstantInfo?>
11291129
void makeVtable() {
11301130
declareAndAddRefFunc(dynamicCallEntry);
11311131
assert(!instantiationOfTearOffRepresentation.isGeneric);
1132+
1133+
if (translator.dynamicModuleSupportEnabled) {
1134+
// Dynamic modules only use the dynamic call entry.
1135+
b.struct_new(instantiationOfTearOffRepresentation.vtableStruct);
1136+
return;
1137+
}
1138+
11321139
for (int posArgCount = 0;
11331140
posArgCount <= positionalCount;
11341141
posArgCount++) {
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file
2+
# for details. All rights reserved. Use of this source code is governed by a
3+
# BSD-style license that can be found in the LICENSE file.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
import '../../common/testing.dart' as helper;
6+
import 'package:expect/expect.dart';
7+
8+
void main() async {
9+
final f = await helper.load('entry1.dart') as int Function(int);
10+
Expect.equals(3, f(3));
11+
helper.done();
12+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
T tearImpl<T>(T value) {
6+
return value;
7+
}
8+
9+
int Function(int) tear = tearImpl<int>;
10+
11+
@pragma('dyn-module:entry-point')
12+
dynamic dynamicModuleEntrypoint() {
13+
return tear;
14+
}

0 commit comments

Comments
 (0)