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 1016, Fri Apr 29 21:59:23 2011 UTC revision 1017, Sun May 1 03:06:05 2011 UTC
# Line 21  Line 21 
21      fun inc (IL.V{useCnt, ...}) = (useCnt := !useCnt + 1)      fun inc (IL.V{useCnt, ...}) = (useCnt := !useCnt + 1)
22      fun setBinding (IL.V{bind, ...}, vb) = bind := vb      fun setBinding (IL.V{bind, ...}, vb) = bind := vb
23    
24      fun init (IL.Program{globals, globalInit, initially, strands}) = let      fun init (IL.Program{globalInit, initially, strands}) = let
25            fun clearVar (IL.V{useCnt, ...}) = useCnt := 0            fun clearVar (IL.V{useCnt, ...}) = useCnt := 0
26          (* clear the counts of the variables defined in a node *)          (* clear the counts of the variables defined in a node *)
27            fun clearNode (IL.ND{kind, ...}) = (case kind            fun clearNode (IL.ND{kind, ...}) = (case kind
# Line 70  Line 70 
70                          | (IL.CONS(_, args)) => incList args                          | (IL.CONS(_, args)) => incList args
71                        (* end case *))                        (* end case *))
72                    | IL.NEW{args, ...} => incList args                    | IL.NEW{args, ...} => incList args
73                    | IL.EXIT{live, ...} => incList live                    | IL.EXIT{kind, live, ...} => (case kind
74                           of ExitKind.RETURN => () (* don't count the live variables as uses *)
75                            | ExitKind.DIE => ()
76                            | _ => incList live
77                          (* end case *))
78                    | _ => ()                    | _ => ()
79                  (* end case *))                  (* end case *))
80          (* increment the counts of variables used in the initially code *)          (* increment the counts of variables used in the initially code *)
# Line 86  Line 90 
90                  end                  end
91          (* increment the counts of the variables used in a strand *)          (* increment the counts of the variables used in a strand *)
92            fun incStrand (IL.Strand{params, state, stateInit, methods, ...}) = let            fun incStrand (IL.Strand{params, state, stateInit, methods, ...}) = let
93                  fun incMethod (IL.Method{stateIn, stateOut, body, ...}) = (                  fun incMethod (IL.Method{stateIn, body, ...}) = (
94                        ListPair.app                        ListPair.app
95                          (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')))
96                            (stateIn, state);                            (stateIn, state);
 (* now that we are counting the live variables at EXIT nodes, I think that we don't  
  * need to count the stateOut occurances. [JHR 2011-03-08]  
                       incList stateOut;  
  *)  
97                        IL.CFG.apply incNode body)                        IL.CFG.apply incNode body)
98                  in                  in
99                    List.app (fn x => setBinding(x, IL.VB_PARAM)) params;                    List.app (fn x => setBinding(x, IL.VB_PARAM)) params;
# Line 103  Line 103 
103                  end                  end
104            in            in
105            (* first clear the counts of all variables *)            (* first clear the counts of all variables *)
             List.app clearVar globals;  
106              IL.CFG.apply clearNode globalInit;              IL.CFG.apply clearNode globalInit;
107              clearInitially initially;              clearInitially initially;
108              List.app clearStrand strands;              List.app clearStrand strands;

Legend:
Removed from v.1016  
changed lines
  Added in v.1017

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