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

SCM Repository

[diderot] Diff of /branches/vis15/src/compiler/simplify/simple-contract.sml
ViewVC logotype

Diff of /branches/vis15/src/compiler/simplify/simple-contract.sml

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

revision 3509, Fri Dec 18 15:01:54 2015 UTC revision 3510, Fri Dec 18 16:37:24 2015 UTC
# Line 37  Line 37 
37    
38      fun sumChanges () = ST.sum {from=firstCounter, to=lastCounter}      fun sumChanges () = ST.sum {from=firstCounter, to=lastCounter}
39    
40    (* for constant, global, and strand-state variables, we count uses *)    (* for constant, global, strand-state variables, and local variables we count uses *)
41      local      local
42        val {clrFn, getFn, peekFn, ...} = SV.newProp (fn _ => ref 0)        val {clrFn, getFn, peekFn, ...} = SV.newProp (fn _ => ref 0)
43      in      in
# Line 51  Line 51 
51                | SV.LocalVar => use x                | SV.LocalVar => use x
52                | _ => ()                | _ => ()
53              (* end case *))              (* end case *))
54        fun isUsed x = (case peekFn x of SOME(ref n) => (n > 0) | _ => false)        fun useCnt x = (case peekFn x of SOME(ref n) => n | _ => 0)
55          fun isUsed x = (case SV.kindOf x
56                 of SV.InputVar => true (* inputs are always in use *)
57                  | SV.StrandOutputVar => true (* outputs are always in use *)
58                  | _ => (case peekFn x of SOME(ref n) => (n > 0) | _ => false)
59                (* end case *))
60        fun clrUsedMark x = clrFn x        fun clrUsedMark x = clrFn x
61      end (* local *)      end (* local *)
62    
# Line 186  Line 191 
191            val update = Option.map contractBlock update            val update = Option.map contractBlock update
192            val n = sumChanges()            val n = sumChanges()
193            in            in
             List.app clrUsedMark consts;  
             List.app clrUsedMark globals;  
194              if n = nChanges              if n = nChanges
195                then (n, prog)                then (n, prog)
196                else (n, S.Program{                else (n, S.Program{
# Line 222  Line 225 
225            fun removeUnused cntr x = if isUsed x            fun removeUnused cntr x = if isUsed x
226                  then true                  then true
227                  else (ST.tick cntr; false)                  else (ST.tick cntr; false)
228            in            val prog = S.Program{
             S.Program{  
229                  props = props,                  props = props,
230                  consts = List.filter (removeUnused cntUnusedConst) consts,                  consts = List.filter (removeUnused cntUnusedConst) consts,
231                  inputs = inputs,                  inputs = inputs,
# Line 235  Line 237 
237                  create = create,                  create = create,
238                  update = update                  update = update
239                }                }
240              in
241                List.app clrUsedMark consts;
242                List.app clrUsedMark globals;
243                prog
244            end            end
245    
246      fun transform prog = let      fun transform prog = let

Legend:
Removed from v.3509  
changed lines
  Added in v.3510

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