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

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

Issue 2301293002: kernel -> ssa: implement if-statements (Closed)
Patch Set: 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'; 5 import '../elements/elements.dart';
6 import '../types/types.dart'; 6 import '../types/types.dart';
7
8 import 'locals_handler.dart';
7 import 'nodes.dart'; 9 import 'nodes.dart';
8 10
9 /// Base class for objects that build up an SSA graph. 11 /// Base class for objects that build up an SSA graph.
10 /// 12 ///
11 /// This contains helpers for building the graph and tracking information about 13 /// This contains helpers for building the graph and tracking information about
12 /// the current state of the graph being built. 14 /// the current state of the graph being built.
13 abstract class GraphBuilder { 15 abstract class GraphBuilder {
14 /// Holds the resulting SSA graph. 16 /// Holds the resulting SSA graph.
15 final HGraph graph = new HGraph(); 17 final HGraph graph = new HGraph();
16 18
19 /// Used to track the locals while building the graph.
20 LocalsHandler localsHandler;
21
17 /// A stack of instructions. 22 /// A stack of instructions.
18 /// 23 ///
19 /// We build the SSA graph by simulating a stack machine. 24 /// We build the SSA graph by simulating a stack machine.
20 List<HInstruction> stack = <HInstruction>[]; 25 List<HInstruction> stack = <HInstruction>[];
21 26
22 27
23 void push(HInstruction instruction) { 28 void push(HInstruction instruction) {
24 add(instruction); 29 add(instruction);
25 stack.add(instruction); 30 stack.add(instruction);
26 } 31 }
27 32
28 HInstruction pop() { 33 HInstruction pop() {
29 return stack.removeLast(); 34 return stack.removeLast();
30 } 35 }
31 36
37 /// Pops the most recent instruction from the stack and 'boolifies' it.
38 ///
39 /// Boolification is checking if the value is '=== true'.
40 HBoolify popBoolified();
41
42 /// Pushes a boolean checking [expression] against null.
43 pushCheckNull(HInstruction expression);
44
32 void dup() { 45 void dup() {
33 stack.add(stack.last); 46 stack.add(stack.last);
34 } 47 }
35 48
36 HBasicBlock _current; 49 HBasicBlock _current;
37 50
38 /// The current block to add instructions to. Might be null, if we are 51 /// The current block to add instructions to. Might be null, if we are
39 /// visiting dead code, but see [isReachable]. 52 /// visiting dead code, but see [isReachable].
40 HBasicBlock get current => _current; 53 HBasicBlock get current => _current;
41 54
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 HParameterValue result = new HParameterValue(parameter, type); 128 HParameterValue result = new HParameterValue(parameter, type);
116 if (lastAddedParameter == null) { 129 if (lastAddedParameter == null) {
117 graph.entry.addBefore(graph.entry.first, result); 130 graph.entry.addBefore(graph.entry.first, result);
118 } else { 131 } else {
119 graph.entry.addAfter(lastAddedParameter, result); 132 graph.entry.addAfter(lastAddedParameter, result);
120 } 133 }
121 lastAddedParameter = result; 134 lastAddedParameter = result;
122 return result; 135 return result;
123 } 136 }
124 } 137 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698