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

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

Issue 1914623002: Fix for issue 26243 - illegal motion of assignments in instruction merging (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 8 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
« no previous file with comments | « pkg/compiler/lib/src/ssa/optimize.dart ('k') | tests/compiler/dart2js_extra/26243_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/ssa/types_propagation.dart
diff --git a/pkg/compiler/lib/src/ssa/types_propagation.dart b/pkg/compiler/lib/src/ssa/types_propagation.dart
index 64e4c30167d96e72b3da950ac20f90d0c8d2a9fd..50409033b78b11abef15bd1c476a00464310d40e 100644
--- a/pkg/compiler/lib/src/ssa/types_propagation.dart
+++ b/pkg/compiler/lib/src/ssa/types_propagation.dart
@@ -200,11 +200,23 @@ class SsaTypePropagator extends HBaseVisitor implements OptimizationPhase {
}
}
if (inputType != outputType) {
- input.replaceAllUsersDominatedBy(instruction.next, instruction);
+ // Replace dominated uses of input with uses of this HTypeConversion so
+ // the uses benefit from the stronger type.
+ //
+ // The dependency on the checked value also improves the generated
+ // JavaScript. Many checks are compiled to a function call expression that
+ // returns the checked result, so the check can be generated as a
+ // subexpression rather than a separate statement.
+ //
+ // Do not replace local accesses, since the local must be a HLocalValue,
+ // not a HTypeConversion.
+ if (!(input is HParameterValue && input.usedAsVariable())) {
+ input.replaceAllUsersDominatedBy(instruction.next, instruction);
+ }
}
return outputType;
}
-
+
TypeMask visitTypeKnown(HTypeKnown instruction) {
HInstruction input = instruction.checkedInput;
TypeMask inputType = input.instructionType;
« no previous file with comments | « pkg/compiler/lib/src/ssa/optimize.dart ('k') | tests/compiler/dart2js_extra/26243_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698