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/CodeGen/cpscompile/memAliasing.sml
ViewVC logotype

Diff of /sml/trunk/compiler/CodeGen/cpscompile/memAliasing.sml

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

revision 585, Wed Mar 29 23:55:35 2000 UTC revision 773, Mon Jan 8 16:18:37 2001 UTC
# Line 73  Line 73 
73    
74     exception NotFound     exception NotFound
75    
76       val top = CPSRegions.memory
77    
78     (*     (*
79      * Analyze a set of CPS functions      * Analyze a set of CPS functions
80      *)      *)
# Line 97  Line 99 
99           | sizeOf(C.PURE(p,vs,x,cty,k),hp) = sizeOf(k,hp)           | sizeOf(C.PURE(p,vs,x,cty,k),hp) = sizeOf(k,hp)
100           | sizeOf(C.ARITH(a,vs,x,cty,k),hp) = sizeOf(k,hp)           | sizeOf(C.ARITH(a,vs,x,cty,k),hp) = sizeOf(k,hp)
101           | sizeOf(C.LOOKER(lk,vs,x,cty,k),hp) = sizeOf(k,hp)           | sizeOf(C.LOOKER(lk,vs,x,cty,k),hp) = sizeOf(k,hp)
102             | sizeOf(C.RCC(_,_,_,_,k),hp) = sizeOf(k,hp)
103    
104         and sizeOfs([],hp)    = hp         and sizeOfs([],hp)    = hp
105           | sizeOfs(k::ks,hp) = Int.max(sizeOf(k,hp),sizeOfs(ks,hp))           | sizeOfs(k::ks,hp) = Int.max(sizeOf(k,hp),sizeOfs(ks,hp))
106    
107         val locMap = Intmap.new(37,NotFound) (* lvar -> loc *)         val locMap = IntHashTable.mkTable(37,NotFound) (* lvar -> loc *)
108         val look   = Intmap.map locMap         val look   = IntHashTable.lookup locMap
109         val bind   = Intmap.add locMap         val bind   = IntHashTable.insert locMap
110    
111         val newMem = Cells.newCell Cells.MEM         val newMem = Cells.newCell Cells.MEM
112    
# Line 175  Line 178 
178               | mkRecord(C.RK_VECTOR,x,vs,hp) = mkVector(x,vs,hp)               | mkRecord(C.RK_VECTOR,x,vs,hp) = mkVector(x,vs,hp)
179               | mkRecord(_,x,vs,hp) = mkNormalRecord(x,vs,hp)               | mkRecord(_,x,vs,hp) = mkNormalRecord(x,vs,hp)
180    
181               fun makeTop(m) = (PT.unify(m, top); top)
182    
183             (* CPS Pure Primitives *)             (* CPS Pure Primitives *)
184             fun arrayptr v = PT.strongSubscript(value v, 0)             fun arrayptr v = PT.pi(value v, 0)
185    
186             fun mkspecial(x,v,hp) = mkNormalRecord(x,[(v,off0)],hp)             fun mkspecial(x,v,hp) = mkNormalRecord(x,[(v,off0)],hp)
187             fun fwrap(x,v,hp) = mkFRecord(x,[(v,off0)],hp)             fun fwrap(x,v,hp) = mkFRecord(x,[(v,off0)],hp)
# Line 185  Line 190 
190             fun newarray0(x,hp) =             fun newarray0(x,hp) =
191                 bind(x,PT.mkRecord(NONE,[PT.mkRecord(NONE,[])]))                 bind(x,PT.mkRecord(NONE,[PT.mkRecord(NONE,[])]))
192    
193             fun objlength(x,v) = bind(x, PT.strongSubscript(value v, ~1))             fun objlength(x,v) = bind(x, PT.pi(value v, ~1))
194             fun length(x,v) = bind(x, PT.strongSubscript(value v, 1))             fun length(x,v) = bind(x, PT.pi(value v, 1))
195             fun arraysub(x,a,i) = bind(x,PT.weakSubscript(arrayptr a))             fun arraysub(x,a,i) = makeTop(PT.weakSubscript(arrayptr a))
196             fun subscriptv(x,a,i) = arraysub(x,a,i)             fun subscriptv(x,a,i) = arraysub(x,a,i)
197             fun subscript(x,a,i) = arraysub(x,a,i)             fun subscript(x,a,i) = arraysub(x,a,i)
198             fun pure_numsubscript(x,a,i) = arraysub(x,a,i)             fun pure_numsubscript(x,a,i) = arraysub(x,a,i)
199             fun gettag(x,v) = bind(x,PT.strongSubscript(value v, ~1))             fun gettag(x,v) = bind(x,PT.pi(value v, ~1))
200             fun numsubscript8(x,a,i) = arraysub(x,a,i)             fun numsubscript8(x,a,i) = arraysub(x,a,i)
201             fun numsubscriptf64(x,a,i) = arraysub(x,a,i)             fun numsubscriptf64(x,a,i) = arraysub(x,a,i)
202             fun getcon(x,v) = bind(x, PT.strongSubscript(value v,0))             fun getcon(x,v) = bind(x, PT.pi(value v,0))
203             fun getexn(x,v) = bind(x, PT.strongSubscript(value v,0))             fun getexn(x,v) = bind(x, PT.pi(value v,0))
204             fun recsubscript(x,a,i) = arraysub(x,a,i)             fun recsubscript(x,a,i) = arraysub(x,a,i)
205             fun raw64subscript(x,a,i) = arraysub(x,a,i)             fun raw64subscript(x,a,i) = arraysub(x,a,i)
206    
207             (* CPS Looker Primitives *)             (* CPS Looker Primitives *)
208             fun deref(x,v) = bind(x, PT.strongSubscript(value v, 0))             fun deref(x,v) = makeTop(PT.strongSubscript(value v, 0))
209             fun gethdlr x = bind(x, PT.strongSubscript(exnptr, 0))             fun gethdlr x = bind(x, PT.strongSubscript(exnptr, 0))
210             fun getvar x = bind(x, PT.strongSubscript(varptr, 0))             fun getvar x = bind(x, PT.strongSubscript(varptr, 0))
211    
212             (* CPS Setter Primitives *)             (* CPS Setter Primitives *)
213             fun supdate(a,x) = PT.strongUpdate(value a, 0, value x)             fun supdate(a,x) = PT.strongUpdate(value a, 0, makeTop(value x))
214             fun wupdate(a,x) = PT.weakUpdate(value a, value x)             fun wupdate(a,x) = PT.weakUpdate(value a, makeTop(value x))
215    
216               fun arrayupdate(a,i,x) = PT.weakUpdate(arrayptr a,value x)
217    
218             fun assign(a,x) = supdate(a,x)             fun assign(a,x) = supdate(a,x)
219             fun unboxedassign(a,x) = supdate(a,x)             fun unboxedassign(a,x) = supdate(a,x)
220             fun update(a,i,x) = wupdate(a,x)             fun update(a,i,x) = arrayupdate(a,i,x)
221             fun boxedupdate(a,i,x) = wupdate(a,x)             fun boxedupdate(a,i,x) = arrayupdate(a,i,x)
222             fun numupdate(a,i,x) = wupdate(a,x)             fun unboxedupdate(a,i,x) = arrayupdate(a,i,x)
223             fun numupdateF64(a,i,x) = wupdate(a,x)             fun numupdate(a,i,x) = arrayupdate(a,i,x)
224               fun numupdateF64(a,i,x) = arrayupdate(a,i,x)
225             fun sethdlr x = PT.strongUpdate(exnptr, 0, value x)             fun sethdlr x = PT.strongUpdate(exnptr, 0, value x)
226             fun setvar  x = PT.strongUpdate(varptr, 0, value x)             fun setvar  x = PT.strongUpdate(varptr, 0, value x)
227    
228               (* I don't know whether the following makes any sense...
229                * Basically, I want to ignore this aliasing analysis
230                * as far as raw access is concerned.  (The invariant is
231                * that raw access NEVER occurs to any memory location
232                * that ML "knows" about.  -- Blume (2000/1/1) *)
233               fun rawstore (a, x) = ()
234               fun rawload (a, x) = top
235    
236             fun infer(C.RECORD(rk,vs,x,k),hp) =             fun infer(C.RECORD(rk,vs,x,k),hp) =
237                   (mkRecord(rk,x,vs,hp); infer(k,allocRecord(rk,vs,hp)))                   (mkRecord(rk,x,vs,hp); infer(k,allocRecord(rk,vs,hp)))
238               | infer(C.SELECT(i,v,x,cty,k),hp) = (select(i,v,x); infer(k,hp))               | infer(C.SELECT(i,v,x,cty,k),hp) = (select(i,v,x); infer(k,hp))
# Line 274  Line 290 
290               | infer(C.LOOKER(P.getvar,[],x,_,k),hp) = (getvar x; infer(k,hp))               | infer(C.LOOKER(P.getvar,[],x,_,k),hp) = (getvar x; infer(k,hp))
291    
292               | infer(C.LOOKER(P.deflvar,[],x,cty,k),hp) = infer(k,hp) (* nop! *)               | infer(C.LOOKER(P.deflvar,[],x,cty,k),hp) = infer(k,hp) (* nop! *)
293                 | infer (C.LOOKER (P.rawload _, [a], x, _, k), hp) =
294                     (rawload (x, a); infer(k,hp))
295    
296                 (* Setters *)                 (* Setters *)
297               | infer(C.SETTER(P.assign, [a,v], k),hp) =               | infer(C.SETTER(P.assign, [a,v], k),hp) =
# Line 284  Line 302 
302                   (update(a,i,v); infer(k,hp+storeListSize))                   (update(a,i,v); infer(k,hp+storeListSize))
303               | infer(C.SETTER(P.boxedupdate, [a,i,v], k),hp) =               | infer(C.SETTER(P.boxedupdate, [a,i,v], k),hp) =
304                   (boxedupdate(a,i,v); infer(k,hp+storeListSize))                   (boxedupdate(a,i,v); infer(k,hp+storeListSize))
305                 | infer(C.SETTER(P.unboxedupdate, [a,i,v], k), hp) =
306                     (unboxedupdate(a,i,v); infer(k,hp))
307               | infer(C.SETTER(P.numupdate{kind=P.INT _}, [a,i,v], k),hp) =               | infer(C.SETTER(P.numupdate{kind=P.INT _}, [a,i,v], k),hp) =
308                   (numupdate(a,i,v); infer(k,hp))                   (numupdate(a,i,v); infer(k,hp))
309               | infer(C.SETTER(P.numupdate{kind=P.FLOAT 64}, [a,i,v], k),hp) =               | infer(C.SETTER(P.numupdate{kind=P.FLOAT 64}, [a,i,v], k),hp) =
# Line 291  Line 311 
311    
312               | infer(C.SETTER(P.sethdlr, [x], k), hp) = (sethdlr x; infer(k,hp))               | infer(C.SETTER(P.sethdlr, [x], k), hp) = (sethdlr x; infer(k,hp))
313               | infer(C.SETTER(P.setvar, [x], k), hp) = (setvar x; infer(k,hp))               | infer(C.SETTER(P.setvar, [x], k), hp) = (setvar x; infer(k,hp))
314                 | infer (C.SETTER (P.rawstore _, [a, x], k), hp) =
315                     (rawstore (a, x); infer (k, hp))
316    
317                  (* Apparently these are nops (see MLRiscGen.sml) *)                  (* Apparently these are nops (see MLRiscGen.sml) *)
318               | infer(C.SETTER(P.uselvar, [x], k), hp) = infer(k, hp)               | infer(C.SETTER(P.uselvar, [x], k), hp) = infer(k, hp)
# Line 308  Line 330 
330         in infer(cexp, 0)         in infer(cexp, 0)
331         end         end
332    
        val top = CPSRegions.memory  
333     in  if !Control.CG.memDisambiguate then     in  if !Control.CG.memDisambiguate then
334         (CPSRegions.reset();         (CPSRegions.reset();
335          app defineFunction cpsFunctions;          app defineFunction cpsFunctions;

Legend:
Removed from v.585  
changed lines
  Added in v.773

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