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

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: Merge 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
« no previous file with comments | « no previous file | pkg/compiler/lib/src/cps_ir/optimize_interceptors.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 a6a6ec0f66f145d16632f84061149dcfc727adf4..5a005af20f51bbcc6e053e2913a37c82c3dd0c4f 100644
--- a/pkg/compiler/lib/src/cps_ir/gvn.dart
+++ b/pkg/compiler/lib/src/cps_ir/gvn.dart
@@ -97,6 +97,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;
@@ -131,7 +147,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;
« no previous file with comments | « no previous file | pkg/compiler/lib/src/cps_ir/optimize_interceptors.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698