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

Side by Side Diff: pkg/compiler/lib/src/ssa/graph_builder.dart

Issue 2283443002: Make LocalsHandler depend on GraphBuilder instead of SsaBuilder. (Closed)
Patch Set: fix tests Created 4 years, 3 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) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 import '../elements/elements.dart';
6 import '../types/types.dart';
5 import 'nodes.dart'; 7 import 'nodes.dart';
6 8
7 /// Base class for objects that build up an SSA graph. 9 /// Base class for objects that build up an SSA graph.
8 /// 10 ///
9 /// This contains helpers for building the graph and tracking information about 11 /// This contains helpers for building the graph and tracking information about
10 /// the current state of the graph being built. 12 /// the current state of the graph being built.
11 abstract class GraphBuilder { 13 abstract class GraphBuilder {
12 /// Holds the resulting SSA graph. 14 /// Holds the resulting SSA graph.
13 final HGraph graph = new HGraph(); 15 final HGraph graph = new HGraph();
14 16
(...skipping 13 matching lines...) Expand all
28 /// current block is closed. 30 /// current block is closed.
29 HBasicBlock lastOpenedBlock; 31 HBasicBlock lastOpenedBlock;
30 32
31 /// Indicates whether the current block is dead (because it has a throw or a 33 /// Indicates whether the current block is dead (because it has a throw or a
32 /// return further up). If this is false, then [current] may be null. If the 34 /// return further up). If this is false, then [current] may be null. If the
33 /// block is dead then it may also be aborted, but for simplicity we only 35 /// block is dead then it may also be aborted, but for simplicity we only
34 /// abort on statement boundaries, not in the middle of expressions. See 36 /// abort on statement boundaries, not in the middle of expressions. See
35 /// [isAborted]. 37 /// [isAborted].
36 bool isReachable = true; 38 bool isReachable = true;
37 39
40 HParameterValue lastAddedParameter;
41
42 Map<ParameterElement, HInstruction> parameters =
43 <ParameterElement, HInstruction>{};
44
38 HBasicBlock addNewBlock() { 45 HBasicBlock addNewBlock() {
39 HBasicBlock block = graph.addNewBlock(); 46 HBasicBlock block = graph.addNewBlock();
40 // If adding a new block during building of an expression, it is due to 47 // If adding a new block during building of an expression, it is due to
41 // conditional expressions or short-circuit logical operators. 48 // conditional expressions or short-circuit logical operators.
42 return block; 49 return block;
43 } 50 }
44 51
45 void open(HBasicBlock block) { 52 void open(HBasicBlock block) {
46 block.open(); 53 block.open();
47 current = block; 54 current = block;
(...skipping 29 matching lines...) Expand all
77 HBasicBlock openNewBlock() { 84 HBasicBlock openNewBlock() {
78 HBasicBlock newBlock = addNewBlock(); 85 HBasicBlock newBlock = addNewBlock();
79 if (!isAborted()) goto(current, newBlock); 86 if (!isAborted()) goto(current, newBlock);
80 open(newBlock); 87 open(newBlock);
81 return newBlock; 88 return newBlock;
82 } 89 }
83 90
84 void add(HInstruction instruction) { 91 void add(HInstruction instruction) {
85 current.add(instruction); 92 current.add(instruction);
86 } 93 }
94
95 HParameterValue addParameter(Entity parameter, TypeMask type) {
96 HParameterValue result = new HParameterValue(parameter, type);
97 if (lastAddedParameter == null) {
98 graph.entry.addBefore(graph.entry.first, result);
99 } else {
100 graph.entry.addAfter(lastAddedParameter, result);
101 }
102 lastAddedParameter = result;
103 return result;
104 }
87 } 105 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/ssa/builder_kernel.dart ('k') | pkg/compiler/lib/src/ssa/locals_handler.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698