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

Side by Side Diff: frog/leg/ssa/types.dart

Issue 9873021: Move frog/leg to lib/compiler/implementation. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 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 | Annotate | Revision Log
« no previous file with comments | « frog/leg/ssa/tracer.dart ('k') | frog/leg/ssa/validate.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
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.
4
5 class SsaTypePropagator extends HGraphVisitor implements OptimizationPhase {
6
7 final Map<int, HInstruction> workmap;
8 final List<int> worklist;
9 final Compiler compiler;
10 final String name = 'type propagator';
11
12 SsaTypePropagator(Compiler this.compiler)
13 : workmap = new Map<int, HInstruction>(),
14 worklist = new List<int>();
15
16 void visitGraph(HGraph graph) {
17 visitDominatorTree(graph);
18 processWorklist();
19 }
20
21 visitBasicBlock(HBasicBlock block) {
22 if (block.isLoopHeader()) {
23 block.forEachPhi((HPhi phi) {
24 phi.setInitialTypeForLoopPhi();
25 addToWorkList(phi);
26 });
27 } else {
28 block.forEachPhi((HPhi phi) {
29 if (phi.updateType()) addUsersAndInputsToWorklist(phi);
30 });
31 }
32
33 HInstruction instruction = block.first;
34 while (instruction !== null) {
35 if (instruction.updateType()) addUsersAndInputsToWorklist(instruction);
36 instruction = instruction.next;
37 }
38 }
39
40 void processWorklist() {
41 while (!worklist.isEmpty()) {
42 int id = worklist.removeLast();
43 HInstruction instruction = workmap[id];
44 assert(instruction !== null);
45 workmap.remove(id);
46 if (instruction.updateType()) addUsersAndInputsToWorklist(instruction);
47 }
48 }
49
50 void addUsersAndInputsToWorklist(HInstruction instruction) {
51 for (int i = 0, length = instruction.usedBy.length; i < length; i++) {
52 addToWorkList(instruction.usedBy[i]);
53 }
54 for (int i = 0, length = instruction.inputs.length; i < length; i++) {
55 addToWorkList(instruction.inputs[i]);
56 }
57 }
58
59 void addToWorkList(HInstruction instruction) {
60 final int id = instruction.id;
61 if (!workmap.containsKey(id)) {
62 worklist.add(id);
63 workmap[id] = instruction;
64 }
65 }
66 }
OLDNEW
« no previous file with comments | « frog/leg/ssa/tracer.dart ('k') | frog/leg/ssa/validate.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698