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 775 - (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 : george 545 structure GCCallBack : GC_CALLBACK
12 : monnier 427 structure InsnProps : INSN_PROPERTIES
13 : george 545 sharing GCCallBack.T = MLTreeComp.T
14 :     sharing GCCallBack.C = IR.I.C
15 : monnier 427 sharing MLTreeComp.T.Constant = IR.I.Constant
16 :     sharing MLTreeComp.T.PseudoOp = IR.CFG.P
17 :     sharing IR.I = InsnProps.I = MLTreeComp.I
18 : george 545 ) : MLRISC_IR_OPTIMIZATION =
19 : monnier 427 struct
20 :    
21 :     structure C = IR.I.C
22 :     structure T = MLTreeComp.T
23 :     structure IR = IR
24 :     structure CFG = IR.CFG
25 : leunga 775 structure GC = GCCallBack.GC
26 : monnier 427 structure G = Graph
27 :     structure A = Array
28 : george 545 structure Liveness =
29 : monnier 427 GCLiveness(structure IR = IR
30 : leunga 775 structure GC = GC
31 : monnier 427 structure InsnProps = InsnProps)
32 :    
33 : monnier 498 structure Gen = CFGGen
34 :     (structure CFG = CFG
35 :     structure MLTree = T
36 :     structure InsnProps = InsnProps
37 : monnier 427 )
38 :    
39 : george 545 type flowgraph = IR.IR
40 : monnier 427
41 : george 545 fun error msg = MLRiscErrorMsg.error("GCGen",msg)
42 :    
43 : leunga 657 val gc_bug = MLRiscControl.getCounter "gc-bug"
44 :    
45 : george 545 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 : leunga 695 val cfgAnnotations = CFG.annotations IR
57 : monnier 498
58 : monnier 427 (*
59 :     * For each gc-point, invoke the callback to generate GC code.
60 :     *)
61 :     fun process(b,b' as CFG.BLOCK{annotations,insns,...}) =
62 : george 545 case #get MLRiscAnnotations.GCSAFEPOINT (!annotations) of
63 : monnier 498 NONE => ()
64 : george 545 | SOME msg =>
65 : monnier 498 let val {liveIn,liveOut} = A.sub(table,b)
66 : monnier 475 val roots = liveIn
67 : monnier 498 val return = #node_info cfg (hd(#succ cfg b))
68 :     in CFG.changed IR;
69 : george 545 GCCallBack.callgcCallback
70 :     { id = b,
71 :     msg = msg,
72 :     gcLabel = CFG.defineLabel b',
73 :     returnLabel = CFG.defineLabel return,
74 :     roots = liveIn,
75 :     stream = stream
76 : leunga 657 } handle _ => gc_bug := !gc_bug + 1 (* continue on error *)
77 : monnier 475 end
78 : monnier 427
79 : monnier 498 in beginCluster 0;
80 :     #forall_nodes cfg process;
81 :     endCluster [];
82 :     IR
83 : monnier 427 end
84 :    
85 :     end

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