Home My Page Projects Code Snippets Project Openings diderot
Summary Activity Tracker Tasks SCM

SCM Repository

[diderot] Diff of /branches/pure-cfg/src/compiler/IL/census-fn.sml
ViewVC logotype

Diff of /branches/pure-cfg/src/compiler/IL/census-fn.sml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1156, Sun May 8 21:20:52 2011 UTC revision 1157, Mon May 9 15:47:35 2011 UTC
# Line 52  Line 52 
52                  end                  end
53          (* increment the use counts of a list of variables *)          (* increment the use counts of a list of variables *)
54            val incList = List.app inc            val incList = List.app inc
55          (* increment the counts of the variables used in a node *)          (* increment the counts of the variables used in a node.  The exitCount function
56            fun incNode (IL.ND{kind, ...}) = (case kind           * is used to count the live variables at exits, since the context affects the
57             * treatment of these.
58             *)
59              fun incNode exitCount (IL.ND{kind, ...}) = (case kind
60                   of IL.JOIN{phis, ...} => let                   of IL.JOIN{phis, ...} => let
61                        fun f (y, xs) = (                        fun f (y, xs) = (
62                              setBinding (y, IL.VB_PHI xs);                              setBinding (y, IL.VB_PHI xs);
# Line 72  Line 75 
75                          | (IL.CONS(_, args)) => incList args                          | (IL.CONS(_, args)) => incList args
76                        (* end case *))                        (* end case *))
77                    | IL.NEW{args, ...} => incList args                    | IL.NEW{args, ...} => incList args
78                    | IL.EXIT{kind, live, ...} => (case kind                    | IL.EXIT{live, ...} => exitCount live
                        of ExitKind.RETURN => () (* don't count the live variables as uses *)  
                         | ExitKind.DIE => ()  
                         | _ => incList live  
                       (* end case *))  
79                    | _ => ()                    | _ => ()
80                  (* end case *))                  (* end case *))
81          (* increment the counts of variables used in the initially code *)          (* increment the counts of variables used in the initially code *)
# Line 85  Line 84 
84                        setBinding (param, IL.VB_PARAM);  (* QUESTION: should there be a special kind for this? *)                        setBinding (param, IL.VB_PARAM);  (* QUESTION: should there be a special kind for this? *)
85                        inc lo; inc hi)                        inc lo; inc hi)
86                  in                  in
87                    IL.CFG.apply incNode rangeInit;                    IL.CFG.apply (incNode (fn live => incList live)) rangeInit;
88                    List.app incIter iters;                    List.app incIter iters;
89                    IL.CFG.apply incNode (#1 create);                    IL.CFG.apply (incNode (fn _ => ())) (#1 create);
90                    List.app inc (#3 create)                    List.app inc (#3 create)
91                  end                  end
92          (* increment the counts of the variables used in a strand *)          (* increment the counts of the variables used in a strand *)
# Line 96  Line 95 
95                        ListPair.app                        ListPair.app
96                          (fn (x, (_, x')) => IL.Var.setBinding(x, IL.VB_RHS(IL.VAR x')))                          (fn (x, (_, x')) => IL.Var.setBinding(x, IL.VB_RHS(IL.VAR x')))
97                            (stateIn, state);                            (stateIn, state);
98                        IL.CFG.apply incNode body)                        IL.CFG.apply (incNode (fn live => incList live)) body)
99                  in                  in
100                    List.app (fn x => setBinding(x, IL.VB_PARAM)) params;                    List.app (fn x => setBinding(x, IL.VB_PARAM)) params;
101                    List.app (inc o #2) state;  (* state variables are implicitly used *)                    IL.CFG.apply (incNode (fn live => incList live)) stateInit;
                   IL.CFG.apply incNode stateInit;  
102                    List.app incMethod methods                    List.app incMethod methods
103                  end                  end
104            in            in
# Line 109  Line 107 
107              clearInitially initially;              clearInitially initially;
108              List.app clearStrand strands;              List.app clearStrand strands;
109            (* then count uses *)            (* then count uses *)
110              IL.CFG.apply incNode globalInit;              IL.CFG.apply (incNode (fn _ => ())) globalInit;
111              incInitially initially;              incInitially initially;
112              List.app incStrand strands              List.app incStrand strands
113            end            end

Legend:
Removed from v.1156  
changed lines
  Added in v.1157

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0