Skip to content

Commit 36fb02d

Browse files
mkustermannCommit Queue
authored and
Commit Queue
committed
[dart2wasm] Use vm's modular transformers as-optimization lowering
Currently `-O4` drops explicit as-checks. Before changing this, we have to do more optimizations on type checks. As a start, we call out to the VM's lowering of as-checks in the modular transformer. Issue #55516 Change-Id: I71f35a95ab41cc7a30f7dea088d9d41ac5243f59 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/365141 Commit-Queue: Martin Kustermann <[email protected]> Reviewed-by: Slava Egorov <[email protected]>
1 parent 24370b4 commit 36fb02d

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

pkg/dart2wasm/lib/transformers.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import 'package:kernel/core_types.dart';
88
import 'package:kernel/target/targets.dart';
99
import 'package:kernel/type_algebra.dart';
1010
import 'package:kernel/type_environment.dart';
11+
import 'package:vm/modular/transformations/type_casts_optimizer.dart'
12+
as typeCastsOptimizer show transformAsExpression;
1113

1214
import 'list_factory_specializer.dart';
1315

@@ -704,6 +706,12 @@ class _WasmTransformer extends Transformer {
704706
node.transformChildren(this);
705707
return node.receiver;
706708
}
709+
710+
@override
711+
TreeNode visitAsExpression(AsExpression node) {
712+
node.transformChildren(this);
713+
return typeCastsOptimizer.transformAsExpression(node, typeContext);
714+
}
707715
}
708716

709717
class _AsyncStarFrame {

pkg/front_end/testcases/dart2wasm/inference_update_2/issue52452.dart.strong.transformed.expect

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,13 @@ static method testConflictWithNoSuchMethodForwarderIfImplementedInMixin(self::C
128128
}
129129
static method testNoConflictWithNoSuchMethodForwarderIfImplementedInMixin1(self::C c) → void {
130130
if(!(c.{self::C::_f3}{core::int?} == null)) {
131-
core::int x = c.{self::C::_f3}{core::int?} as{Unchecked} core::int;
131+
core::int x = let core::int? #t3 = c.{self::C::_f3}{core::int?} in #t3 == null ?{core::int} #t3 as{Unchecked} core::int : #t3{core::int};
132132
self::acceptsInt(x);
133133
}
134134
}
135135
static method testNoConflictWithNoSuchMethodForwarderIfImplementedInMixin2(self::C c) → void {
136136
if(!(c.{self::C::_f4}{core::int?} == null)) {
137-
core::int x = c.{self::C::_f4}{core::int?} as{Unchecked} core::int;
137+
core::int x = let core::int? #t4 = c.{self::C::_f4}{core::int?} in #t4 == null ?{core::int} #t4 as{Unchecked} core::int : #t4{core::int};
138138
self::acceptsInt(x);
139139
}
140140
}

0 commit comments

Comments
 (0)