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 /sml/branches/SMLNJ/src/MLRISC/gc-safety/gc-gen.sml
ViewVC logotype

Annotation of /sml/branches/SMLNJ/src/MLRISC/gc-safety/gc-gen.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 469 - (view) (download)

1 : monnier 427 (*
2 :     * This module is reponsible for generating garbage collection
3 :     * code for all gc-points in the program. That is, we delay the generation
4 :     * of garbage collection code until all optimizations have been performed.
5 :     * The gc code to be generated is determined by a callback to the client.
6 :     *)
7 :    
8 :     functor GCGen
9 :     (structure MLTreeComp : MLTREECOMP
10 :     structure IR : MLRISC_IR
11 :     structure GC : GC_TYPE
12 :     structure InsnProps : INSN_PROPERTIES
13 :     sharing MLTreeComp.T.Constant = IR.I.Constant
14 :     sharing MLTreeComp.T.PseudoOp = IR.CFG.P
15 :     sharing IR.I = InsnProps.I = MLTreeComp.I
16 :     ) : GC_GEN =
17 :     struct
18 :    
19 :     structure C = IR.I.C
20 :     structure T = MLTreeComp.T
21 :     structure IR = IR
22 :     structure CFG = IR.CFG
23 :     structure GC = GC
24 :     structure G = Graph
25 :     structure A = Array
26 :     structure Liveness =
27 :     GCLiveness(structure IR = IR
28 :     structure GC = GC
29 :     structure InsnProps = InsnProps)
30 :    
31 :     structure Gen = InstrGen
32 :     (structure MLTree = T
33 :     structure I = IR.I
34 :     )
35 :    
36 :     type callgcCallback =
37 :     { id : int,
38 :     label : Label.label,
39 :     roots : (C.cell * GC.gctype) list,
40 :     stream : (T.stm,C.regmap) T.stream
41 :     } -> unit
42 :    
43 :     val debug = MLRiscControl.getFlag "debug-gc-gen"
44 :    
45 :     fun gcGen {callgc} (IR as G.GRAPH cfg) =
46 :     let (*
47 :     * Run gc-typed liveness analysis
48 :     *)
49 :     val table = Liveness.liveness IR
50 :    
51 :     (*
52 :     * Check if
53 :     *)
54 : monnier 469 fun isGCPoint an = #contains BasicAnnotations.CALLGC an
55 : monnier 427
56 :     (*
57 :     * For each gc-point, invoke the callback to generate GC code.
58 :     *)
59 :     fun process(b,b' as CFG.BLOCK{annotations,insns,...}) =
60 :     if isGCPoint(!annotations) then
61 :     let val stream = MLTreeComp.selectInstructions
62 :     (Gen.newStream insns)
63 :     val {liveIn,liveOut} = A.sub(table,b)
64 :     val roots = liveIn
65 :     in if !debug then
66 :     print("id="^Int.toString b^
67 :     " roots="^Liveness.GCTypeMap.toString roots^"\n")
68 :     else ();
69 :     callgc{id = b,
70 :     label = CFG.defineLabel b',
71 :     roots = liveIn,
72 :     stream = stream}
73 :     end
74 :     else ()
75 :    
76 :     val _ = #forall_nodes cfg process
77 :     in IR
78 :     end
79 :    
80 :     end

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