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/bfc.sml
ViewVC logotype

Annotation of /sml/trunk/src/cm/compile/bfc.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 771 - (view) (download)

1 : blume 403 (*
2 :     * Keeping binfiles for short periods of time.
3 :     * This is used in "stabilize" and in "make" where first there is a
4 :     * "compile" traversal that produces certain binfile contents, and
5 :     * then there is a "consumer" traversal that uses the binfile contents.
6 :     * No error checking is done -- the "get" operation assumes that the
7 :     * stuff is either in its cache or in the file system.
8 : blume 404 * Moreover, the static environment cannot be used (BF.senvOf will fail
9 :     * if the binfile had to be reloaded from disk).
10 : blume 403 *
11 :     * (C) 1999 Lucent Technologies, Bell Laboratories
12 :     *
13 :     * Author: Matthias Blume (blume@kurims.kyoto-u.ac.jp)
14 :     *)
15 :     signature BFC = sig
16 :     type bfc
17 : blume 771 type stats = { env: int, inlinfo: int, data: int, code: int }
18 :     val new : unit -> { store: SmlInfo.info * { content: bfc, stats: stats }
19 :     -> unit,
20 :     get: SmlInfo.info -> { content: bfc, stats: stats } }
21 : blume 537 val getStable : { stable: string, offset: int, descr: string } -> bfc
22 : blume 403 end
23 :    
24 :     functor BfcFn (structure MachDepVC : MACHDEP_VC) :> BFC
25 :     where type bfc = MachDepVC.Binfile.bfContent =
26 :     struct
27 :    
28 :     structure BF = MachDepVC.Binfile
29 :     structure E = GenericVC.Environment
30 :     type bfc = BF.bfContent
31 : blume 771 type stats = { env: int, inlinfo: int, data: int, code: int }
32 : blume 403
33 : blume 588 val emap = GenericVC.ModuleId.emptyTmap
34 : blume 403
35 :     fun new () = let
36 :     val m = ref SmlInfoMap.empty
37 :    
38 : blume 771 fun store (i, x) = m := SmlInfoMap.insert (!m, i, x)
39 : blume 403
40 :     fun get i =
41 :     case SmlInfoMap.find (!m, i) of
42 : blume 771 SOME x => x
43 : blume 403 | NONE => let
44 :     val binname = SmlInfo.binname i
45 :     fun reader s = let
46 : blume 771 val x = BF.read { stream = s, name = binname,
47 :     modmap = emap }
48 : blume 403 in
49 : blume 771 store (i, x);
50 :     x
51 : blume 403 end
52 :     in
53 :     SafeIO.perform { openIt = fn () => BinIO.openIn binname,
54 :     closeIt = BinIO.closeIn,
55 :     work = reader,
56 : blume 459 cleanup = fn _ => () }
57 : blume 403 end
58 :     in
59 :     { store = store, get = get }
60 :     end
61 : blume 537
62 :     fun getStable { stable, offset, descr } = let
63 :     fun work s =
64 :     (Seek.seek (s, offset);
65 :     (* We can use an empty static env because no
66 :     * unpickling will be done. *)
67 : blume 771 #content (BF.read { stream = s, name = descr, modmap = emap }))
68 : blume 537 in
69 :     SafeIO.perform { openIt = fn () => BinIO.openIn stable,
70 :     closeIt = BinIO.closeIn,
71 :     work = work,
72 :     cleanup = fn _ => () }
73 :     end
74 : blume 403 end

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