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

Annotation of /sml/trunk/src/MLRISC/gc-safety/gc-gen.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 545 - (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 : monnier 475 structure GCMap : GC_MAP
12 : george 545 structure GCCallBack : GC_CALLBACK
13 : monnier 427 structure InsnProps : INSN_PROPERTIES
14 : george 545 sharing GCCallBack.T = MLTreeComp.T
15 :     sharing GCCallBack.GC = GCMap.GC
16 :     sharing GCCallBack.C = IR.I.C
17 : monnier 427 sharing MLTreeComp.T.Constant = IR.I.Constant
18 :     sharing MLTreeComp.T.PseudoOp = IR.CFG.P
19 :     sharing IR.I = InsnProps.I = MLTreeComp.I
20 : george 545 ) : MLRISC_IR_OPTIMIZATION =
21 : monnier 427 struct
22 :    
23 :     structure C = IR.I.C
24 :     structure T = MLTreeComp.T
25 :     structure IR = IR
26 :     structure CFG = IR.CFG
27 : monnier 475 structure GC = GCMap.GC
28 : monnier 427 structure G = Graph
29 :     structure A = Array
30 : george 545 structure Liveness =
31 : monnier 427 GCLiveness(structure IR = IR
32 : monnier 475 structure GCMap = GCMap
33 : monnier 427 structure InsnProps = InsnProps)
34 :    
35 : monnier 498 structure Gen = CFGGen
36 :     (structure CFG = CFG
37 :     structure MLTree = T
38 :     structure InsnProps = InsnProps
39 : monnier 427 )
40 :    
41 : george 545 type flowgraph = IR.IR
42 : monnier 427
43 : george 545 fun error msg = MLRiscErrorMsg.error("GCGen",msg)
44 :    
45 :     val name = "Generate GC code"
46 :    
47 :     fun run (IR as G.GRAPH cfg) =
48 : monnier 427 let (*
49 :     * Run gc-typed liveness analysis
50 :     *)
51 :     val table = Liveness.liveness IR
52 : monnier 498 val instrStream = Gen.newStream{compile=fn _ => (), flowgraph=SOME IR}
53 : george 545 fun dummy _ = error "no extension"
54 :     val extender = T.EXTENDER{compileStm=dummy,
55 :     compileRexp=dummy,
56 :     compileFexp=dummy,
57 :     compileCCexp=dummy}
58 : monnier 498 val stream as T.Stream.STREAM{beginCluster, endCluster, ...} =
59 : george 545 MLTreeComp.selectInstructions extender instrStream
60 : monnier 498
61 : monnier 427 (*
62 :     * For each gc-point, invoke the callback to generate GC code.
63 :     *)
64 :     fun process(b,b' as CFG.BLOCK{annotations,insns,...}) =
65 : george 545 case #get MLRiscAnnotations.GCSAFEPOINT (!annotations) of
66 : monnier 498 NONE => ()
67 : george 545 | SOME msg =>
68 : monnier 498 let val {liveIn,liveOut} = A.sub(table,b)
69 : monnier 475 val roots = liveIn
70 : monnier 498 val return = #node_info cfg (hd(#succ cfg b))
71 :     in CFG.changed IR;
72 : george 545 GCCallBack.callgcCallback
73 :     { id = b,
74 :     msg = msg,
75 :     gcLabel = CFG.defineLabel b',
76 :     returnLabel = CFG.defineLabel return,
77 :     roots = liveIn,
78 :     stream = stream
79 :     }
80 : monnier 475 end
81 : monnier 427
82 : monnier 498 in beginCluster 0;
83 :     #forall_nodes cfg process;
84 :     endCluster [];
85 :     IR
86 : monnier 427 end
87 :    
88 :     end

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