Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(104)

Unified Diff: pkg/compiler/lib/src/cps_ir/update_refinements.dart

Issue 1668913002: dart2js cps: More aggressive operator specialization. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: pkg/compiler/lib/src/cps_ir/update_refinements.dart
diff --git a/pkg/compiler/lib/src/cps_ir/update_refinements.dart b/pkg/compiler/lib/src/cps_ir/update_refinements.dart
index 48e3242457e27fb3b8c8826e67e1357462ead8ab..3500521ac01464102c55211ee7276f96059846b2 100644
--- a/pkg/compiler/lib/src/cps_ir/update_refinements.dart
+++ b/pkg/compiler/lib/src/cps_ir/update_refinements.dart
@@ -3,6 +3,7 @@ library dart2js.cps_ir.update_refinements;
import 'cps_ir_nodes.dart';
import 'optimizers.dart' show Pass;
import 'type_mask_system.dart';
+import '../world.dart';
/// Updates all references to use the most refined version in scope.
///
@@ -19,6 +20,7 @@ class UpdateRefinements extends TrampolineRecursiveVisitor implements Pass {
String get passName => 'Update refinements';
final TypeMaskSystem typeSystem;
+ World get classWorld => typeSystem.classWorld;
Map<Primitive, Primitive> refinementFor = <Primitive, Primitive>{};
@@ -34,20 +36,21 @@ class UpdateRefinements extends TrampolineRecursiveVisitor implements Pass {
return next;
}
- visitNullCheck(NullCheck node) {
+ visitReceiverCheck(ReceiverCheck node) {
if (refine(node.value)) {
+ // Update the type if the input has changed.
Primitive value = node.value.definition;
- if (value.type.isNullable) {
- // Update the type if the input has changed.
- node.type = value.type.nonNullable();
+ if (value.type.needsNoSuchMethodHandling(node.selector, classWorld)) {
+ node.type = typeSystem.receiverTypeFor(node.selector, value.type);
} else {
+ // Check is no longer needed.
node..replaceUsesWith(value)..destroy();
LetPrim letPrim = node.parent;
letPrim.remove();
return;
}
}
- // Use the NullCheck as a refinement.
+ // Use the ReceiverCheck as a refinement.
Primitive value = node.effectiveDefinition;
Primitive old = refinementFor[value];
refinementFor[value] = node;

Powered by Google App Engine
This is Rietveld 408576698