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/cm/compile/recomp-persstate-fn.sml
ViewVC logotype

Annotation of /sml/trunk/src/cm/compile/recomp-persstate-fn.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 297 - (view) (download)

1 : blume 295 (*
2 :     * Build a new "recompilation-related" persistent state.
3 :     *
4 :     * (C) 1999 Lucent Technologies, Bell Laboratories
5 :     *
6 :     * Author: Matthias Blume (blume@kurims.kyoto-u.ac.jp)
7 :     *)
8 :     functor RecompPersstateFn (structure MachDepVC : MACHDEP_VC
9 :     val discard_code : bool) :> RECOMP_PERSSTATE =
10 :     struct
11 :     structure MachDepVC = MachDepVC
12 :     structure BF = MachDepVC.Binfile
13 :     structure E = GenericVC.Environment
14 :    
15 :     type recomp_memo = { bfc: BF.bfContent, ctxt: E.staticEnv }
16 :    
17 :     val smlmap = ref (AbsPathMap.empty: recomp_memo AbsPathMap.map)
18 :     val stablemap = ref (StableMap.empty: recomp_memo StableMap.map)
19 :    
20 : blume 297 fun recomp_look_sml (i, provided, gp) = let
21 : blume 295 fun isValid { bfc, ctxt } = let
22 :     val demanded = PidSet.addList (PidSet.empty, BF.cmDataOf bfc)
23 :     in
24 :     PidSet.equal (provided, demanded)
25 :     end
26 :     val p = SmlInfo.sourcepath i
27 :     in
28 :     case AbsPathMap.find (!smlmap, p) of
29 :     NONE => NONE
30 :     | SOME memo =>
31 :     if isValid memo then SOME memo
32 :     else (smlmap := #1 (AbsPathMap.remove (!smlmap, p));
33 :     NONE)
34 :     end
35 :    
36 :     fun recomp_memo_sml0 (i, memo) =
37 :     smlmap := AbsPathMap.insert (!smlmap, SmlInfo.sourcepath i, memo)
38 :    
39 :     fun discard (arg as (_, { bfc, ctxt })) = (BF.discardCode bfc; arg)
40 :    
41 :     val recomp_memo_sml =
42 :     if discard_code then recomp_memo_sml0 o discard
43 :     else recomp_memo_sml0
44 :    
45 :     fun recomp_look_stable i = StableMap.find (!stablemap, i)
46 :     fun recomp_memo_stable0 (i, memo) =
47 :     stablemap := StableMap.insert (!stablemap, i, memo)
48 :    
49 :     val recomp_memo_stable =
50 :     if discard_code then recomp_memo_stable0 o discard
51 :     else recomp_memo_stable0
52 :    
53 :     fun bfc_fetch_sml i =
54 :     #bfc (valOf (AbsPathMap.find (!smlmap, SmlInfo.sourcepath i)))
55 :     fun bfc_fetch_stable i =
56 :     #bfc (valOf (StableMap.find (!stablemap, i)))
57 :     end

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