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

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

Issue 1519513002: dart2js cps: Retain refinement nodes and update refinements after GVN. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Undo removed passes Created 5 years 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/gvn.dart
diff --git a/pkg/compiler/lib/src/cps_ir/gvn.dart b/pkg/compiler/lib/src/cps_ir/gvn.dart
index 02379d85c1a5e3493d6acda9c84e6beb317f30f5..d6a670303a5ef21104ab357e6bb16e96a0ad2247 100644
--- a/pkg/compiler/lib/src/cps_ir/gvn.dart
+++ b/pkg/compiler/lib/src/cps_ir/gvn.dart
@@ -95,6 +95,22 @@ class GVN extends TrampolineRecursiveVisitor implements Pass {
// ------------------ GLOBAL VALUE NUMBERING ---------------------
+ /// True if [prim] can be eliminated if its value is already in scope.
+ bool canReplaceWithExistingValue(Primitive prim) {
+ // Primitives that have no side effects other than potentially throwing are
+ // known not the throw if the value is already in scope. Handling those
+ // specially is equivalent to updating refinements during GVN.
+ // GetLazyStatic cannot have side effects because the field has already
+ // been initialized.
+ // TODO(asgerf): Replace GetLazyStatic in an earlier pass so it does not
+ // confuse the LoopSideEffects pre-analysis.
+ return prim.isSafeForElimination ||
+ prim is GetField ||
+ prim is GetLength ||
+ prim is GetIndex ||
+ prim is GetLazyStatic;
+ }
+
@override
Expression traverseLetPrim(LetPrim node) {
Expression next = node.body;
@@ -129,7 +145,7 @@ class GVN extends TrampolineRecursiveVisitor implements Pass {
// Try to reuse a previously computed value with the same GVN.
Primitive existing = environment[gvn];
if (existing != null &&
- (prim.isSafeForElimination || prim is GetLazyStatic) &&
+ canReplaceWithExistingValue(prim) &&
!isTrivialPrimitive(prim)) {
if (prim is Interceptor) {
Interceptor interceptor = existing;

Powered by Google App Engine
This is Rietveld 408576698