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/releases/release-110.37/src/cm/compile/bfc.sml
ViewVC logotype

Annotation of /sml/releases/release-110.37/src/cm/compile/bfc.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 994 - (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 : blume 879 val new : unit -> { store: SmlInfo.info * { contents: bfc, stats: stats }
19 : blume 771 -> unit,
20 : blume 879 get: SmlInfo.info -> { contents: bfc, stats: stats } }
21 : blume 537 val getStable : { stable: string, offset: int, descr: string } -> bfc
22 : blume 403 end
23 :    
24 : blume 879 functor BfcFn (val arch: string) :> BFC
25 :     where type bfc = Binfile.bfContents =
26 : blume 403 struct
27 :    
28 : blume 879 structure BF = Binfile
29 :     type bfc = BF.bfContents
30 : blume 771 type stats = { env: int, inlinfo: int, data: int, code: int }
31 : blume 403
32 : blume 902 val version = #version_id CompilerVersion.version
33 :    
34 : blume 403 fun new () = let
35 :     val m = ref SmlInfoMap.empty
36 :    
37 : blume 771 fun store (i, x) = m := SmlInfoMap.insert (!m, i, x)
38 : blume 403
39 :     fun get i =
40 :     case SmlInfoMap.find (!m, i) of
41 : blume 771 SOME x => x
42 : blume 403 | NONE => let
43 :     val binname = SmlInfo.binname i
44 :     fun reader s = let
45 : blume 902 val x = BF.read { arch = arch, version = version,
46 : blume 986 stream = s }
47 : blume 403 in
48 : blume 771 store (i, x);
49 :     x
50 : blume 403 end
51 :     in
52 :     SafeIO.perform { openIt = fn () => BinIO.openIn binname,
53 :     closeIt = BinIO.closeIn,
54 :     work = reader,
55 : blume 459 cleanup = fn _ => () }
56 : blume 403 end
57 :     in
58 :     { store = store, get = get }
59 :     end
60 : blume 537
61 :     fun getStable { stable, offset, descr } = let
62 :     fun work s =
63 :     (Seek.seek (s, offset);
64 :     (* We can use an empty static env because no
65 :     * unpickling will be done. *)
66 : blume 902 #contents (BF.read { arch = arch, version = version,
67 : blume 986 stream = s }))
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