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

SCM Repository

[smlnj] Annotation of /MLRISC/releases/release-110.64/gc-safety/gc-cells.sml
ViewVC logotype

Annotation of /MLRISC/releases/release-110.64/gc-safety/gc-cells.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 651 - (view) (download)
Original Path: sml/trunk/src/MLRISC/gc-safety/gc-cells.sml

1 : monnier 427 (*
2 :     * This makes a new cell module that automatically propagate gc type info.
3 :     *)
4 : george 545 functor GCCells(structure C : CELLS
5 : monnier 475 structure GCMap : GC_MAP) : GC_CELLS =
6 : monnier 427 struct
7 :    
8 :     structure C = C
9 : monnier 475 structure GC = GCMap.GC
10 :     structure GCMap = GCMap
11 : leunga 586
12 :     fun error msg = MLRiscErrorMsg.error("GCCells",msg)
13 : monnier 427
14 : monnier 475 val gcmap = ref NONE : GCMap.gcmap option ref
15 : monnier 427
16 :     fun setGCMap map = gcmap := SOME map
17 :    
18 : leunga 586 fun getGCMap() =
19 :     case !gcmap of
20 :     NONE => error "no gc map"
21 :     | SOME gcmap => gcmap
22 :    
23 :     fun clearGCMap() = gcmap := NONE
24 :    
25 : monnier 427 (*
26 :     * Generate a new virtual register and update the gc map at the same time.
27 :     *)
28 :     fun newCell k =
29 :     let val new = C.newCell k
30 :     val gcmap = getGCMap()
31 :     val add = Intmap.add gcmap
32 :     fun genVar gc =
33 :     let val r = new()
34 :     in add(r,gc); r end
35 :     in genVar
36 :     end
37 :    
38 :     (*
39 :     * Create a new GC map
40 :     *)
41 :     fun newGCMap() =
42 : monnier 475 let val gcmap = Intmap.new(129,GCMap.GCMap)
43 : monnier 427 in case C.zeroReg C.GP of
44 :     SOME r => Intmap.add gcmap (r,GC.CONST 0)
45 :     | _ => ();
46 :     gcmap
47 :     end
48 :    
49 :     end

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