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

Side by Side Diff: pkg/compiler/lib/src/cps_ir/eagerly_load_statics.dart

Issue 1859343004: dartfmt pkg/compiler (Closed) Base URL: git@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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library dart2js.cps_ir.eagerly_load_statics; 5 library dart2js.cps_ir.eagerly_load_statics;
6 6
7 import 'cps_ir_nodes.dart'; 7 import 'cps_ir_nodes.dart';
8 import 'optimizers.dart' show Pass; 8 import 'optimizers.dart' show Pass;
9 import '../elements/elements.dart'; 9 import '../elements/elements.dart';
10 import 'cps_fragment.dart'; 10 import 'cps_fragment.dart';
11 11
12 /// Replaces [GetLazyStatic] with [GetStatic] when the static field is known 12 /// Replaces [GetLazyStatic] with [GetStatic] when the static field is known
13 /// to have been initialized. 13 /// to have been initialized.
14 /// 14 ///
15 /// Apart from [GetStatic] generating better code, this improves the side-effect 15 /// Apart from [GetStatic] generating better code, this improves the side-effect
16 /// analysis in the [GVN] pass, since [GetStatic] has no effects. 16 /// analysis in the [GVN] pass, since [GetStatic] has no effects.
17 class EagerlyLoadStatics extends TrampolineRecursiveVisitor implements Pass { 17 class EagerlyLoadStatics extends TrampolineRecursiveVisitor implements Pass {
18 String get passName => 'Eagerly load statics'; 18 String get passName => 'Eagerly load statics';
19 19
20 Map<FieldElement, Primitive> initializerFor = <FieldElement, Primitive>{}; 20 Map<FieldElement, Primitive> initializerFor = <FieldElement, Primitive>{};
21 21
22 final Map<Continuation, Map<FieldElement, Primitive>> initializersAt = 22 final Map<Continuation, Map<FieldElement, Primitive>> initializersAt =
23 <Continuation, Map<FieldElement, Primitive>>{}; 23 <Continuation, Map<FieldElement, Primitive>>{};
24 24
25 static Map<FieldElement, Primitive> cloneFieldMap( 25 static Map<FieldElement, Primitive> cloneFieldMap(
26 Map<FieldElement, Primitive> map) { 26 Map<FieldElement, Primitive> map) {
27 return new Map<FieldElement, Primitive>.from(map); 27 return new Map<FieldElement, Primitive>.from(map);
28 } 28 }
29 29
30 void rewrite(FunctionDefinition node) { 30 void rewrite(FunctionDefinition node) {
31 visit(node.body); 31 visit(node.body);
32 } 32 }
33 33
34 Expression traverseLetPrim(LetPrim node) { 34 Expression traverseLetPrim(LetPrim node) {
35 Expression next = node.body; 35 Expression next = node.body;
36 visit(node.primitive); 36 visit(node.primitive);
(...skipping 18 matching lines...) Expand all
55 initializerFor = initializersAt[cont]; 55 initializerFor = initializersAt[cont];
56 return cont.body; 56 return cont.body;
57 } 57 }
58 58
59 void visitGetLazyStatic(GetLazyStatic node) { 59 void visitGetLazyStatic(GetLazyStatic node) {
60 Primitive initializer = initializerFor[node.element]; 60 Primitive initializer = initializerFor[node.element];
61 if (initializer is GetLazyStatic && initializer.isFinal) { 61 if (initializer is GetLazyStatic && initializer.isFinal) {
62 // No reason to create a GetStatic when the field is final. 62 // No reason to create a GetStatic when the field is final.
63 node.replaceWithFragment(new CpsFragment(), initializer); 63 node.replaceWithFragment(new CpsFragment(), initializer);
64 } else if (initializer != null) { 64 } else if (initializer != null) {
65 GetStatic newNode = new GetStatic.witnessed(node.element, 65 GetStatic newNode = new GetStatic.witnessed(node.element, initializer,
66 initializer, sourceInformation: node.sourceInformation) 66 sourceInformation: node.sourceInformation)..type = node.type;
67 ..type = node.type;
68 node.replaceWith(newNode); 67 node.replaceWith(newNode);
69 } else { 68 } else {
70 initializerFor[node.element] = node; 69 initializerFor[node.element] = node;
71 } 70 }
72 } 71 }
73 72
74 void visitSetStatic(SetStatic node) { 73 void visitSetStatic(SetStatic node) {
75 initializerFor.putIfAbsent(node.element, () => node); 74 initializerFor.putIfAbsent(node.element, () => node);
76 } 75 }
77 } 76 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/cps_ir/cps_ir_tracer.dart ('k') | pkg/compiler/lib/src/cps_ir/effects.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698