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

Unified Diff: pkg/compiler/lib/src/ssa/optimize.dart

Issue 2497313003: Fix HTypeConversion.checkedInput (Closed)
Patch Set: Add some comments Created 4 years, 1 month 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
« no previous file with comments | « pkg/compiler/lib/src/ssa/nodes.dart ('k') | pkg/compiler/lib/src/ssa/types_propagation.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/ssa/optimize.dart
diff --git a/pkg/compiler/lib/src/ssa/optimize.dart b/pkg/compiler/lib/src/ssa/optimize.dart
index 507c4590c2ea4db808d3913039b0494c3b513f15..5f11f1d342f6996d19969776821e52e2b872475d 100644
--- a/pkg/compiler/lib/src/ssa/optimize.dart
+++ b/pkg/compiler/lib/src/ssa/optimize.dart
@@ -800,11 +800,25 @@ class SsaInstructionSimplifier extends HBaseVisitor
// throw a type error at runtime.
return node;
}
- if (!type.treatAsRaw || type.isTypeVariable) {
+ if (type.isTypeVariable) {
+ return node;
+ }
+ if (!type.treatAsRaw) {
+ HInstruction input = node.checkedInput;
+ // `null` always passes type conversion.
+ if (input.isNull()) return input;
+ // TODO(sra): We can statically check [input] if it is a constructor.
+ // TODO(sra): We can statically check [input] if it is load from a field
+ // of the same ground type, or load from a field of a parameterized type
+ // with the same receiver.
return node;
}
if (type.isFunctionType) {
+ HInstruction input = node.checkedInput;
+ // `null` always passes type conversion.
+ if (input.isNull()) return input;
// TODO(johnniwinther): Optimize function type conversions.
+ // TODO(sra): We can statically check [input] if it is a closure getter.
return node;
}
}
@@ -944,15 +958,18 @@ class SsaInstructionSimplifier extends HBaseVisitor
FieldElement field =
findConcreteFieldForDynamicAccess(receiver, node.selector);
if (field == null || !field.isAssignable) return node;
- // Use [:node.inputs.last:] in case the call follows the
- // interceptor calling convention, but is not a call on an
- // interceptor.
+ // Use `node.inputs.last` in case the call follows the interceptor calling
+ // convention, but is not a call on an interceptor.
HInstruction value = node.inputs.last;
if (compiler.options.enableTypeAssertions) {
DartType type = field.type;
- if (!type.treatAsRaw || type.isTypeVariable) {
+ if (!type.treatAsRaw ||
+ type.isTypeVariable ||
+ type.unaliased.isFunctionType) {
// We cannot generate the correct type representation here, so don't
// inline this access.
+ // TODO(sra): If the input is such that we don't need a type check, we
+ // can skip the test an generate the HFieldSet.
return node;
}
HInstruction other =
« no previous file with comments | « pkg/compiler/lib/src/ssa/nodes.dart ('k') | pkg/compiler/lib/src/ssa/types_propagation.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698