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/compiler/FLINT/clos/closure.sml
ViewVC logotype

Diff of /sml/trunk/compiler/FLINT/clos/closure.sml

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

sml/branches/SMLNJ/src/compiler/FLINT/clos/closure.sml revision 418, Fri Sep 3 23:51:27 1999 UTC sml/trunk/compiler/FLINT/clos/closure.sml revision 2162, Thu Nov 2 21:20:47 2006 UTC
# Line 286  Line 286 
286  abstype env = Env of lvar list *                  (* values *)  abstype env = Env of lvar list *                  (* values *)
287                       (lvar * closureRep) list *   (* closures *)                       (lvar * closureRep) list *   (* closures *)
288                       lvar list *                  (* disposable cells *)                       lvar list *                  (* disposable cells *)
289                       object Intmap.intmap         (* what map *)                       object IntHashTable.hash_table (* what map *)
290  with  with
291    
292  (****************************************************************************  (****************************************************************************
# Line 294  Line 294 
294   ****************************************************************************)   ****************************************************************************)
295    
296  exception NotBound  exception NotBound
297  fun emptyEnv() = Env([],[],[],Intmap.new(32,NotBound))  fun emptyEnv() = Env([],[],[],IntHashTable.mkTable(32,NotBound))
298    
299  (* add a new object to an environment *)  (* add a new object to an environment *)
300  fun augment(m as (v,obj),e as Env(valueL,closureL,dispL,whatMap)) =  fun augment(m as (v,obj),e as Env(valueL,closureL,dispL,whatMap)) =
301    (Intmap.add whatMap m;    (IntHashTable.insert whatMap m;
302     case obj     case obj
303      of Value _ => Env(v::valueL,closureL,dispL,whatMap)      of Value _ => Env(v::valueL,closureL,dispL,whatMap)
304       | Closure cr => Env(valueL,(v,cr)::closureL,dispL,whatMap)       | Closure cr => Env(valueL,(v,cr)::closureL,dispL,whatMap)
# Line 393  Line 393 
393    in  pr "Values:"; ilist valueL;    in  pr "Values:"; ilist valueL;
394        pr "Closures:\n"; p(fn () => (),closureL,nil);        pr "Closures:\n"; p(fn () => (),closureL,nil);
395        pr "Disposable records:\n"; ilist dispL;        pr "Disposable records:\n"; ilist dispL;
396        pr "Known function mapping:\n"; Intmap.app fp whatMap;        pr "Known function mapping:\n"; IntHashTable.appi fp whatMap;
397        pr "Callee-save continuation mapping:\n";        pr "Callee-save continuation mapping:\n";
398        Intmap.app cp whatMap        IntHashTable.appi cp whatMap
399    end    end
400    
401  (****************************************************************************  (****************************************************************************
# Line 404  Line 404 
404    
405  exception Lookup of lvar * env  exception Lookup of lvar * env
406  fun whatIs(env as Env(_,_,_,whatMap),v) =  fun whatIs(env as Env(_,_,_,whatMap),v) =
407    Intmap.map whatMap v handle NotBound => raise Lookup(v,env)    IntHashTable.lookup whatMap v handle NotBound => raise Lookup(v,env)
408    
409  (* Add v to the access environment, v must be in whatMap already *)  (* Add v to the access environment, v must be in whatMap already *)
410  fun augvar(v,e as Env(valueL,closureL,dispL,whatMap)) =  fun augvar(v,e as Env(valueL,closureL,dispL,whatMap)) =
# Line 1021  Line 1021 
1021               | SOME v => (enter(v,t),b))               | SOME v => (enter(v,t),b))
1022    
1023        (* process the rest groups in free *)        (* process the rest groups in free *)
1024        fun h([],i,r,t,b) = m(r,t,b)        fun h([],i:int,r,t,b) = m(r,t,b)
1025          | h((v,_,j)::z,i,r,t,b) =          | h((v,_,j)::z,i,r,t,b) =
1026              if j = i then h(z,i,enter(v,r),t,b)              if j = i then h(z,i,enter(v,r),t,b)
1027              else let val (nt,nb) = m(r,t,b)              else let val (nt,nb) = m(r,t,b)
# Line 1464  Line 1464 
1464    
1465          (* for recursive functions, always spill deeper level free variables *)          (* for recursive functions, always spill deeper level free variables *)
1466          val ((gpspill,gpfree),(fpspill,fpfree),nflag) = case lpv          val ((gpspill,gpfree),(fpspill,fpfree),nflag) = case lpv
1467            of SOME _ => (partition deep1 gpfree,partition deep1 fpfree,true)            of SOME _ =>
1468                   let fun h((v,_,_),l) =
1469                         case whatIs(initEnv,v)
1470                          of (Closure (CR(_,{free,...}))) => merge(rmv(v,free),l)
1471                           | _ => l
1472                       val gpfree = removeV(foldr h [] gpfree, gpfree)
1473                       val gpfreePart =
1474                             if length(gpfree) < numCSgpregs
1475                             then ([],gpfree)
1476                             else partition deep1 gpfree
1477                    in (gpfreePart, partition deep1 fpfree,true)
1478                   end
1479             | NONE => if ekfuns v then ((gpfree,[]),(fpfree,[]),flag)             | NONE => if ekfuns v then ((gpfree,[]),(fpfree,[]),flag)
1480                       else (partition deep2 gpfree,partition deep2 fpfree,flag)                       else (partition deep2 gpfree,partition deep2 fpfree,flag)
1481    
# Line 2022  Line 2033 
2033             val ne = close(e,augValue(w,t,env),sn,csg,csf,ret)             val ne = close(e,augValue(w,t,env),sn,csg,csf,ret)
2034          in header(PURE(i,args,w,t,ne))          in header(PURE(i,args,w,t,ne))
2035         end         end
2036        | RCC(k,l,p,args,wtl,e) =>
2037           let val (env,header) = fixAccess(args,env)
2038               val ne = close(e,foldl (fn((w, t), env) =>
2039                                         augValue(w,t,env)) env wtl,
2040                              sn,csg,csf,ret)
2041            in header(RCC(k,l,p,args,wtl,ne))
2042           end
2043    
2044  (***************************************************************************  (***************************************************************************
2045   * Calling the "close" on the CPS expression with proper initializations   *   * Calling the "close" on the CPS expression with proper initializations   *

Legend:
Removed from v.418  
changed lines
  Added in v.2162

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