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

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

Issue 1521553003: dart2js cps: Replace GetLazyStatic with GetStatic. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Remove obsolete comment 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 | « pkg/compiler/lib/src/cps_ir/finalize.dart ('k') | pkg/compiler/lib/src/cps_ir/optimizers.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 5a005af20f51bbcc6e053e2913a37c82c3dd0c4f..cb84402047a36598d7056060de882e52f2a52aab 100644
--- a/pkg/compiler/lib/src/cps_ir/gvn.dart
+++ b/pkg/compiler/lib/src/cps_ir/gvn.dart
@@ -104,8 +104,6 @@ class GVN extends TrampolineRecursiveVisitor implements Pass {
// 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 ||
@@ -127,13 +125,22 @@ class GVN extends TrampolineRecursiveVisitor implements Pass {
return next;
}
+ // Update effect numbers due to side effects from a static initializer.
+ // GetLazyStatic is GVN'ed like a GetStatic, but the effects of the static
+ // initializer occur before reading the field.
+ if (prim is GetLazyStatic) {
+ visit(prim);
+ }
+
// Compute the GVN vector for this computation.
List vector = gvnVectorBuilder.make(prim, effectNumbers);
// Update effect numbers due to side effects.
// Do this after computing the GVN vector so the primitive's GVN is not
- // influenced by its own side effects.
- visit(prim);
+ // influenced by its own side effects, except in the case of GetLazyStatic.
+ if (prim is! GetLazyStatic) {
+ visit(prim);
+ }
if (vector == null) {
// The primitive is not GVN'able. Move on.
@@ -675,12 +682,13 @@ class GvnVectorBuilder extends DeepRecursiveVisitor {
vector = [GvnCode.GET_INDEX, effectNumbers.indexableContent];
}
- processGetStatic(GetStatic node) {
+ visitGetStatic(GetStatic node) {
if (isImmutable(node.element)) {
vector = [GvnCode.GET_STATIC, node.element];
} else {
vector = [GvnCode.GET_STATIC, node.element, effectNumbers.staticField];
}
+ // Suppress visit to witness argument.
}
processGetLazyStatic(GetLazyStatic node) {
« no previous file with comments | « pkg/compiler/lib/src/cps_ir/finalize.dart ('k') | pkg/compiler/lib/src/cps_ir/optimizers.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698