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 651 - (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 : monnier 498 val stream as T.Stream.STREAM{beginCluster, endCluster, ...} =
55 : george 555 MLTreeComp.selectInstructions instrStream
56 : monnier 498
57 : monnier 427 (*
58 :     * For each gc-point, invoke the callback to generate GC code.
59 :     *)
60 :     fun process(b,b' as CFG.BLOCK{annotations,insns,...}) =
61 : george 545 case #get MLRiscAnnotations.GCSAFEPOINT (!annotations) of
62 : monnier 498 NONE => ()
63 : george 545 | SOME msg =>
64 : monnier 498 let val {liveIn,liveOut} = A.sub(table,b)
65 : monnier 475 val roots = liveIn
66 : monnier 498 val return = #node_info cfg (hd(#succ cfg b))
67 :     in CFG.changed IR;
68 : george 545 GCCallBack.callgcCallback
69 :     { id = b,
70 :     msg = msg,
71 :     gcLabel = CFG.defineLabel b',
72 :     returnLabel = CFG.defineLabel return,
73 :     roots = liveIn,
74 :     stream = stream
75 : leunga 641 } handle _ => () (* continue on error *)
76 : monnier 475 end
77 : monnier 427
78 : monnier 498 in beginCluster 0;
79 :     #forall_nodes cfg process;
80 :     endCluster [];
81 :     IR
82 : monnier 427 end
83 :    
84 :     end

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