Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] Diff of /sml/trunk/src/compiler/FLINT/opt/fcontract.sml
ViewVC logotype

Diff of /sml/trunk/src/compiler/FLINT/opt/fcontract.sml

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

revision 212, Fri Jan 15 16:19:21 1999 UTC revision 213, Fri Jan 15 21:18:35 1999 UTC
# Line 5  Line 5 
5  sig  sig
6    
7      (* needs Collect to be setup properly *)      (* needs Collect to be setup properly *)
8      val contract : FLINT.prog * Stats.counter -> FLINT.prog      val contract : FLINT.prog -> FLINT.prog
9    
10  end  end
11    
# Line 276  Line 276 
276    
277  fun inScope m lv = (M.lookup m lv; true) handle M.IntmapF => false  fun inScope m lv = (M.lookup m lv; true) handle M.IntmapF => false
278    
279  fun click s c = (if !CTRL.misc = 1 then say s else (); Stats.addCounter c 1)  fun click s c = (if !CTRL.misc = 1 then say s else ();
280                     c := !c + 1 (* Stats.addCounter c 1 *) )
281    
282  (*  val c_inline         = Stats.newCounter[] *)  fun contract (fdec as (_,f,_,_)) = let
 (*  val c_deadval        = Stats.newCounter[] *)  
 (*  val c_deadlexp       = Stats.newCounter[] *)  
 (*  val c_select         = Stats.newCounter[] *)  
 (*  val c_record         = Stats.newCounter[] *)  
 (*  val c_lacktype       = Stats.newCounter[] *)  
 (*  val c_con    = Stats.newCounter[] *)  
 (*  val c_switch         = Stats.newCounter[] *)  
 (*  val c_eta    = Stats.newCounter[] *)  
 (*  val c_etasplit       = Stats.newCounter[] *)  
 (*  val c_branch         = Stats.newCounter[] *)  
 (*  val c_dropargs       = Stats.newCounter[] *)  
     val c_cstarg = Stats.newCounter[]  
     val c_outofscope = Stats.newCounter[]  
 (* (*      val _ = Stats.registerStat(Stats.newStat("FC-cstarg", [c_cstarg])) *) *)  
 (* (*      val _ = Stats.registerStat(Stats.newStat("FC-outofscope", [c_outofscope])) *) *)  
283    
284  fun contract (fdec as (_,f,_,_), counter) = let      val c_dummy = ref 0 (* Stats.newCounter[] *)
285        val c_miss = ref 0 (* Stats.newCounter[] *)
286    
287      val c_dummy = Stats.newCounter[]      val counter = c_dummy
     val c_miss = Stats.newCounter[]  
288    
289      fun click_deadval  () = (click "d" counter)      fun click_deadval  () = (click "d" counter)
290      fun click_deadlexp () = (click "D" counter)      fun click_deadlexp () = (click "D" counter)
# Line 315  Line 301 
301    
302      (* this counters is actually *used* by fcontract.      (* this counters is actually *used* by fcontract.
303       * It's  not used just for statistics. *)       * It's  not used just for statistics. *)
304      val c_inline         = Stats.newCounter[counter]      val c_inline         = ref 0 (* Stats.newCounter[counter] *)
 (*      val c_inline1    = Stats.newCounter[c_inline] *)  
 (*      val c_inline2    = Stats.newCounter[c_inline] *)  
 (*      val c_unroll     = Stats.newCounter[c_inline] *)  
305      fun click_simpleinline () = (click "i" c_inline)      fun click_simpleinline () = (click "i" c_inline)
306      fun click_copyinline   () = (click "I" c_inline)      fun click_copyinline   () = (click "I" c_inline)
307      fun click_unroll       () = (click "u" c_inline)      fun click_unroll       () = (click "u" c_inline)
308      fun inline_count () = Stats.getCounter c_inline      fun inline_count () = (* Stats.getCounter *) !c_inline
309    
310      fun used lv = (C.usenb(C.get lv) > 0)      fun used lv = (C.usenb(C.get lv) > 0)
311                        (* handle x =>                        (* handle x =>
# Line 534  Line 517 
517                      * recursively *)                      * recursively *)
518                     (C.use NONE fi; undertake m f; (m,fs))                     (C.use NONE fi; undertake m f; (m,fs))
519                 else                 else
520                     let (* val _ = say ("Entering "^(C.LVarString f)^"\n") *)                     let (*  val _ = say ("\nEntering "^(C.LVarString f)) *)
521                         val saved_ic = inline_count()                         val saved_ic = inline_count()
522                         (* make up the bindings for args inside the body *)                         (* make up the bindings for args inside the body *)
523                         val actuals = if isSome isrec orelse                         val actuals = if isSome isrec orelse
# Line 561  Line 544 
544                          * the old uncontracted code *)                          * the old uncontracted code *)
545                         val nm = addbind(m, f, Fun(f, nbody, args, nfk, ref []))                         val nm = addbind(m, f, Fun(f, nbody, args, nfk, ref []))
546                     in (nm, (nfk, f, args, nbody)::fs)                     in (nm, (nfk, f, args, nbody)::fs)
547                       (* before say ("Exiting "^(C.LVarString f)^"\n") *)                     (*  before say ("\nExiting "^(C.LVarString f)) *)
548                     end                     end
549              end              end
550    
# Line 712  Line 695 
695                      * This inlining strategy looks inoffensive enough,                      * This inlining strategy looks inoffensive enough,
696                      * but still requires some care: see comments at the                      * but still requires some care: see comments at the
697                      * begining of this file and in cfun *)                      * begining of this file and in cfun *)
698                     ((* say("SimpleInline of "^(C.LVarString g)^"\n"); *)                     (click_simpleinline();
                     click_simpleinline();  
699                      ignore(C.unuse true gi);                      ignore(C.unuse true gi);
700                      loop m (F.LET(map #1 args, F.RET vs, body)) cont)                      loop m (F.LET(map #1 args, F.RET vs, body)) cont)
701                 fun copyinline () =                 fun copyinline () =
# Line 733  Line 715 
715                     let val nle = (F.LET(map #1 args, F.RET vs, body))                     let val nle = (F.LET(map #1 args, F.RET vs, body))
716                         val nle = C.copylexp M.empty nle                         val nle = C.copylexp M.empty nle
717                     in                     in
                        (* say("CopyInline of "^(C.LVarString g)^"\n"); *)  
718                         click_copyinline();                         click_copyinline();
719                         (app (unuseval m) vs);                         (app (unuseval m) vs);
720                         unusecall m g;                         unusecall m g;

Legend:
Removed from v.212  
changed lines
  Added in v.213

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