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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 986 - (view) (download)

1 : blume 402 (*
2 :     * Compilation traversals.
3 :     *
4 :     * (C) 1999 Lucent Technologies, Bell Laboratories
5 :     *
6 :     * Author: Matthias Blume (blume@kurims.kyoto-u.ac.jp)
7 :     *)
8 : blume 398 local
9 :     structure GP = GeneralParams
10 :     structure DG = DependencyGraph
11 :     structure GG = GroupGraph
12 : blume 879 structure SE = StaticEnv
13 :     structure Pid = PersStamps
14 : blume 398 structure PP = PrettyPrint
15 : blume 879 structure EM = ErrorMsg
16 :     structure SF = SmlFile
17 : blume 398
18 :     type pid = Pid.persstamp
19 : blume 905 type statenv = StaticEnv.staticEnv
20 :     type symenv = SymbolicEnv.env
21 : blume 398 type result = { stat: statenv, sym: symenv }
22 : blume 460 type ed = IInfo.info
23 : blume 398 in
24 :     signature COMPILE = sig
25 : blume 402
26 : blume 400 type bfc
27 : blume 771 type stats
28 : blume 400
29 : blume 398 (* reset internal persistent state *)
30 :     val reset : unit -> unit
31 : blume 399
32 :     (* notify linkage module about recompilation *)
33 : blume 400 type notifier = GP.info -> SmlInfo.info -> unit
34 : blume 399
35 : blume 403 (* type of a function to store away the binfile contents *)
36 : blume 771 type bfcReceiver =
37 : blume 879 SmlInfo.info * { contents: bfc, stats: stats } -> unit
38 : blume 403
39 : blume 398 val getII : SmlInfo.info -> IInfo.info
40 : blume 399
41 : blume 537 val evictStale : unit -> unit
42 : blume 402 val evictAll : unit -> unit
43 : blume 399
44 : blume 771 val newSbnodeTraversal : unit -> DG.sbnode -> GP.info -> ed option
45 : blume 400
46 : blume 403 val newTraversal : notifier * bfcReceiver * GG.group ->
47 : blume 399 { group: GP.info -> result option,
48 : blume 801 allgroups: GP.info -> bool,
49 : blume 399 exports: (GP.info -> result option) SymbolMap.map }
50 : blume 398 end
51 :    
52 : blume 879 functor CompileFn (structure Backend : BACKEND
53 : blume 588 structure StabModmap : STAB_MODMAP
54 : blume 677 val useStream : TextIO.instream -> unit
55 : blume 666 val compile_there : SrcPath.file -> bool) :>
56 : blume 879 COMPILE where type bfc = Binfile.bfContents
57 :     where type stats = Binfile.stats =
58 : blume 400 struct
59 : blume 398
60 : blume 879 val arch = Backend.architecture
61 : blume 902 val version = #version_id CompilerVersion.version
62 : blume 879
63 : blume 400 type notifier = GP.info -> SmlInfo.info -> unit
64 : blume 399
65 : blume 879 structure BF = Binfile
66 :     structure C = Backend.Compile
67 : blume 398
68 : blume 879 type bfc = BF.bfContents
69 : blume 771 type stats = BF.stats
70 : blume 398
71 : blume 771 type bfcReceiver =
72 : blume 879 SmlInfo.info * { contents: bfc, stats: stats } -> unit
73 : blume 403
74 : blume 447 structure FilterMap = MapFn
75 : blume 398 (struct
76 :     type ord_key = pid * SymbolSet.set
77 :     fun compare ((u, f), (u', f')) =
78 :     case Pid.compare (u, u') of
79 :     EQUAL => SymbolSet.compare (f, f')
80 :     | unequal => unequal
81 :     end)
82 :    
83 : blume 403 type bfinfo =
84 :     { cmdata: PidSet.set,
85 :     statenv: unit -> statenv,
86 :     symenv: unit -> symenv,
87 :     statpid: pid,
88 :     sympid: pid }
89 :    
90 : blume 399 type env = { envs: unit -> result, pids: PidSet.set }
91 : blume 460 type envdelta = IInfo.info
92 : blume 398
93 : blume 460 type memo = { ii: IInfo.info, ts: TStamp.t, cmdata: PidSet.set }
94 : blume 398
95 :     (* persistent state! *)
96 :     val filtermap = ref (FilterMap.empty: pid FilterMap.map)
97 :    
98 :     (* more persistent state! *)
99 : blume 402 val globalstate = ref (SmlInfoMap.empty: memo SmlInfoMap.map)
100 : blume 398
101 :     fun reset () =
102 :     (filtermap := FilterMap.empty;
103 : blume 402 globalstate := SmlInfoMap.empty)
104 : blume 398
105 :     fun isValidMemo (memo: memo, provided, smlinfo) =
106 :     not (TStamp.needsUpdate { source = SmlInfo.lastseen smlinfo,
107 :     target = #ts memo })
108 : blume 403 andalso PidSet.equal (provided, #cmdata memo)
109 : blume 398
110 : blume 587 fun memo2ii (memo: memo) = #ii memo
111 : blume 398
112 : blume 460 fun memo2ed memo = memo2ii memo
113 : blume 398
114 : blume 879 fun bfc2memo (bfc, ts, context_senv) = let
115 :     fun statenv () =
116 :     let val mm0 = StabModmap.get ()
117 :     val m = GenModIdMap.mkMap' (context_senv, mm0)
118 :     fun context _ = m
119 :     val { pid, pickle } = BF.senvPickleOf bfc
120 :     in UnpickMod.unpickleEnv context (pid, pickle)
121 :     end
122 :     fun symenv () =
123 :     let val { pickle, ... } = BF.lambdaPickleOf bfc
124 :     val l = if Word8Vector.length pickle = 0 then NONE
125 :     else UnpickMod.unpickleFLINT pickle
126 :     in SymbolicEnv.mk (BF.exportPidOf bfc, l)
127 :     end
128 :     val ii = { statenv = Memoize.memoize statenv,
129 :     symenv = Memoize.memoize symenv,
130 : blume 403 statpid = BF.staticPidOf bfc,
131 :     sympid = BF.lambdaPidOf bfc }
132 :     val cmdata = PidSet.addList (PidSet.empty, BF.cmDataOf bfc)
133 :     in
134 : blume 460 { ii = ii, ts = ts, cmdata = cmdata }
135 : blume 403 end
136 :    
137 : blume 398 fun pidset (p1, p2) = PidSet.add (PidSet.singleton p1, p2)
138 :    
139 :     fun nofilter (ed: envdelta) = let
140 : blume 460 val { statenv, symenv, statpid, sympid } = ed
141 : blume 587 val statenv' = Memoize.memoize statenv
142 : blume 398 in
143 : blume 587 { envs = fn () => { stat = statenv' (), sym = symenv () },
144 : blume 398 pids = pidset (statpid, sympid) }
145 :     end
146 :    
147 : blume 735 fun requiredFiltering set se = let
148 : blume 905 val dom = SymbolSet.addList (SymbolSet.empty,
149 :     BrowseStatEnv.catalog se)
150 : blume 735 val filt = SymbolSet.intersection (set, dom)
151 :     in
152 :     if SymbolSet.equal (dom, filt) then NONE
153 :     else SOME filt
154 :     end
155 : blume 398
156 : blume 460 fun filter (ii, s) = let
157 : blume 398 val { statenv, symenv, statpid, sympid } = ii
158 : blume 587 val ste = statenv ()
159 : blume 398 in
160 : blume 735 case requiredFiltering s ste of
161 :     NONE => { envs = fn () => { stat = ste, sym = symenv () },
162 :     pids = pidset (statpid, sympid) }
163 :     | SOME s => let
164 : blume 905 val ste' = SE.filter (ste, SymbolSet.listItems s)
165 : blume 587 val key = (statpid, s)
166 :     val statpid' =
167 :     case FilterMap.find (!filtermap, key) of
168 :     SOME statpid' => statpid'
169 :     | NONE => let
170 : blume 879 val statpid' = Rehash.rehash
171 : blume 587 { env = ste', orig_hash = statpid }
172 :     in
173 :     filtermap :=
174 :     FilterMap.insert (!filtermap, key, statpid');
175 :     statpid'
176 :     end
177 :     in
178 :     { envs = fn () => { stat = ste', sym = symenv () },
179 :     pids = pidset (statpid', sympid) }
180 :     end
181 : blume 398 end
182 :    
183 : blume 905 fun rlayer ({ stat, sym }, { stat = stat', sym = sym' }) =
184 :     { stat = SE.consolidateLazy (SE.atop (stat, stat')),
185 :     (* let's not bother with stale pids here... *)
186 :     sym = SymbolicEnv.atop (sym, sym') }
187 : blume 399
188 : blume 905 val emptyEnv =
189 :     { envs = fn () => { stat = SE.empty, sym = SymbolicEnv.empty },
190 :     pids = PidSet.empty }
191 : blume 398
192 :     fun layer ({ envs = e, pids = p }, { envs = e', pids = p' }) =
193 :     { envs = fn () => rlayer (e (), e' ()),
194 :     pids = PidSet.union (p, p') }
195 :    
196 : blume 462 (* I would rather not use an exception here, but short of a better
197 :     * implementation of concurrency I see no choice.
198 :     * The problem is that at each node we sequentiallay wait for the
199 :     * children nodes. But the scheduler might (and probably will)
200 :     * let a child run that we are not currently waiting for, so an
201 :     * error there will not result in "wait" to immediately return
202 :     * as it should for clean error recovery.
203 :     * Using the exception avoids having to implement a
204 :     * "wait for any child -- whichever finishes first" kind of call. *)
205 :     exception Abort
206 : blume 399
207 : blume 462 fun layer'wait u (p, NONE) =
208 :     (ignore (Concur.waitU u p); NONE)
209 :     | layer'wait u (p, SOME e) =
210 :     (case Concur.waitU u p of
211 :     SOME e' => SOME (layer (e', e))
212 :     | NONE => NONE)
213 :    
214 : blume 454 fun mkTraversal (notify, storeBFC, getUrgency) = let
215 : blume 402 val localstate = ref SmlInfoMap.empty
216 : blume 398
217 : blume 537 fun sbnode gp (DG.SB_SNODE n) = snode gp n
218 :     (* The beauty of this scheme is that we don't have
219 :     * to do anything at all for SB_BNODEs: Everything
220 :     * is prepared ready to be used when the library
221 :     * is unpickled: *)
222 : blume 737 | sbnode gp (DG.SB_BNODE (_, ii, _)) = SOME ii
223 : blume 398
224 :     and fsbnode gp (f, n) =
225 :     case (sbnode gp n, f) of
226 :     (NONE, _) => NONE
227 :     | (SOME d, NONE) => SOME (nofilter d)
228 :     | (SOME d, SOME s) => SOME (filter (d, s))
229 :    
230 :     and snode gp (DG.SNODE n) = let
231 : blume 692 val youngest = #youngest gp
232 : blume 398 val { smlinfo = i, localimports = li, globalimports = gi } = n
233 :     val binname = SmlInfo.binname i
234 : blume 771 val descr = SmlInfo.descr i
235 : blume 398
236 : blume 771 fun pstats (s: BF.stats) = let
237 :     fun info ((sel, lab), (l, t)) =
238 :     case sel s of
239 :     0 => (l, t)
240 :     | n => (lab :: ": " :: Int.toString n ::
241 :     t :: " " :: l,
242 :     ",")
243 :     in
244 :     Say.vsay ("[" :: #1 (foldr info
245 :     (["bytes]\n"], "")
246 :     [(#code, "code"),
247 :     (#data, "data"),
248 :     (#env, "env"),
249 :     (#inlinfo, "inlinable")]))
250 :     end
251 :    
252 : blume 801 fun loaded _ = Say.vsay ["[loading ", descr, "]\n"]
253 :     fun received s =
254 :     (Say.vsay ["[receiving ", descr, "]\n"];
255 :     pstats s)
256 : blume 771
257 : blume 462 fun fail () =
258 :     if #keep_going (#param gp) then NONE else raise Abort
259 :    
260 : blume 537 fun compile_here (stat, sym, pids, split) = let
261 : blume 677 fun perform_setup _ NONE = ()
262 :     | perform_setup what (SOME code) =
263 :     (Say.vsay ["[setup (", what, "): ", code, "]\n"];
264 :     SafeIO.perform
265 :     { openIt = fn () => TextIO.openString code,
266 :     closeIt = TextIO.closeIn,
267 :     work = useStream,
268 :     cleanup = fn _ => () })
269 : blume 398 fun save bfc = let
270 : blume 757 fun writer s = let
271 : blume 902 val s = BF.write { arch = arch, version = version,
272 :     nopickle = false,
273 : blume 879 stream = s, contents = bfc }
274 : blume 771 in pstats s; s
275 : blume 757 end
276 : blume 459 fun cleanup _ =
277 : blume 398 OS.FileSys.remove binname handle _ => ()
278 :     in
279 : blume 400 notify gp i;
280 : blume 771 (SafeIO.perform { openIt =
281 : blume 398 fn () => AutoDir.openBinOut binname,
282 : blume 771 closeIt = BinIO.closeOut,
283 :     work = writer,
284 :     cleanup = cleanup }
285 :     before TStamp.setTime (binname, SmlInfo.lastseen i))
286 : blume 398 handle exn => let
287 :     fun ppb pps =
288 :     (PP.add_newline pps;
289 :     PP.add_string pps (General.exnMessage exn))
290 :     in
291 :     SmlInfo.error gp i EM.WARN
292 : blume 771 ("failed to write " ^ binname) ppb;
293 :     { code = 0, env = 0, inlinfo = 0, data = 0 }
294 :     end
295 : blume 398 end (* save *)
296 :     in
297 :     case SmlInfo.parsetree gp i of
298 : blume 462 NONE => fail ()
299 : blume 398 | SOME (ast, source) => let
300 : blume 592 val ast =
301 :     case #explicit_core_sym (SmlInfo.attribs i) of
302 :     NONE => ast
303 :     | SOME sy => CoreHack.rewrite (ast, sy)
304 : blume 398 val cmData = PidSet.listItems pids
305 : blume 677 val (pre, post) = SmlInfo.setup i
306 : blume 905 val topLevel = EnvRef.loc ()
307 :     val toplenv = #get topLevel ()
308 : blume 677 before perform_setup "pre" pre
309 : blume 398 (* clear error flag (could still be set from
310 :     * earlier run) *)
311 :     val _ = #anyErrors source := false
312 : blume 879 (* we actually run the compiler here;
313 :     * Binfile is not doing it anymore *)
314 :     val err = EM.errors source
315 :     fun check phase =
316 :     if EM.anyErrors err then
317 :     raise CompileExn.Compile
318 :     (phase ^ " failed")
319 :     else ()
320 :     val cinfo = C.mkCompInfo { source = source,
321 :     transform = fn x => x }
322 :     val splitting = Control.LambdaSplitting.get' split
323 :     val { csegments, newstatenv, exportPid,
324 :     staticPid, imports, pickle = senvP,
325 :     inlineExp, ... } =
326 :     C.compile { source = source, ast = ast,
327 :     statenv = stat, symenv = sym,
328 :     compInfo = cinfo, checkErr = check,
329 :     splitting = splitting }
330 :     val { hash = lambdaPid, pickle = lambdaP } =
331 :     PickMod.pickleFLINT inlineExp
332 :     val lambdaP = case inlineExp of
333 :     NONE => Byte.stringToBytes ""
334 :     | SOME _ => lambdaP
335 : blume 537 val bfc = BF.create
336 : blume 879 { imports = imports,
337 :     exportPid = exportPid,
338 :     cmData = cmData,
339 :     senv = { pickle = senvP,
340 :     pid = staticPid },
341 :     lambda = { pickle = lambdaP,
342 :     pid = lambdaPid },
343 :     csegments = csegments }
344 :     val memo =
345 :     bfc2memo (bfc, SmlInfo.lastseen i, stat)
346 : blume 398 in
347 : blume 677 perform_setup "post" post;
348 : blume 905 #set topLevel toplenv;
349 : blume 879 storeBFC (i, { contents = bfc, stats = save bfc });
350 : blume 402 SOME memo
351 : blume 879 end handle (EM.Error | CompileExn.Compile _)
352 : blume 757 (* At this point we handle only
353 :     * explicit compiler bugs and ordinary
354 :     * compilation errors because for those
355 :     * there will already have been
356 :     * explanatory messages. Everything
357 :     * else "falls through" and will be
358 :     * treated at top level. *)
359 :     => fail ()
360 : blume 448 end (* compile_here *)
361 : blume 398 fun notlocal () = let
362 : blume 692 val _ = youngest := TStamp.max (!youngest,
363 :     SmlInfo.lastseen i)
364 : blume 454 val urgency = getUrgency i
365 : blume 402 (* Ok, it is not in the local state, so we first have
366 : blume 398 * to traverse all children before we can proceed... *)
367 :     fun loc li_n = Option.map nofilter (snode gp li_n)
368 :     fun glob gi_n = fsbnode gp gi_n
369 : blume 448 val gi_cl =
370 :     map (fn gi_n => Concur.fork (fn () => glob gi_n)) gi
371 :     val li_cl =
372 :     map (fn li_n => Concur.fork (fn () => loc li_n)) li
373 : blume 398 val e =
374 : blume 462 foldl (layer'wait urgency)
375 :     (foldl (layer'wait urgency)
376 : blume 537 (SOME emptyEnv)
377 : blume 462 gi_cl)
378 :     li_cl
379 : blume 398 in
380 :     case e of
381 :     NONE => NONE
382 :     | SOME { envs, pids } => let
383 :     (* We have successfully traversed all
384 :     * children. Now it is time to check the
385 :     * global map... *)
386 :     fun fromfile () = let
387 :     val { stat, sym } = envs ()
388 : blume 537 val { split, extra_compenv, ... } =
389 :     SmlInfo.attribs i
390 :     val stat =
391 :     case extra_compenv of
392 :     NONE => stat
393 : blume 905 | SOME s => SE.atop (stat, s)
394 : blume 398 fun load () = let
395 :     val ts = TStamp.fmodTime binname
396 :     fun openIt () = BinIO.openIn binname
397 : blume 588 fun reader s = let
398 :     val mm0 = StabModmap.get ()
399 :     val m = GenModIdMap.mkMap' (stat, mm0)
400 : blume 879 val { contents, stats } =
401 :     BF.read { arch = arch,
402 : blume 902 version = version,
403 : blume 986 stream = s }
404 : blume 588 in
405 : blume 879 (contents, ts, stats)
406 : blume 588 end
407 : blume 398 in
408 :     SOME (SafeIO.perform
409 :     { openIt = openIt,
410 :     closeIt = BinIO.closeIn,
411 :     work = reader,
412 : blume 459 cleanup = fn _ => () })
413 : blume 398 handle _ => NONE
414 :     end (* load *)
415 : blume 801 fun tryload (sync, report, otherwise) =
416 :     case (sync (); load ()) of
417 : blume 448 NONE => otherwise ()
418 : blume 771 | SOME (bfc, ts, stats) => let
419 : blume 879 val memo = bfc2memo (bfc, ts, stat)
420 :     val contst = { contents = bfc,
421 : blume 771 stats = stats }
422 : blume 448 in
423 :     if isValidMemo (memo, pids, i) then
424 : blume 771 (report stats;
425 :     storeBFC (i, contst);
426 : blume 448 SOME memo)
427 :     else otherwise ()
428 :     end
429 : blume 801 fun sy0 () = ()
430 : blume 632 fun bottleneck () =
431 :     (* Are we the only runable task? *)
432 :     Servers.allIdle () andalso
433 :     Concur.noTasks ()
434 : blume 448 fun compile_again () =
435 : blume 771 (Say.vsay ["[compiling ", descr, "]\n"];
436 : blume 537 compile_here (stat, sym, pids, split))
437 : blume 632 fun compile_there' p =
438 :     not (bottleneck ()) andalso
439 :     compile_there p
440 : blume 448 fun compile () = let
441 :     val sp = SmlInfo.sourcepath i
442 : blume 801 fun sy () = let
443 :     fun ready () =
444 :     OS.FileSys.fileSize binname > 0
445 :     handle _ => false
446 :     in
447 :     (***** busy wait for file to appear;
448 :     * this is obviously very bad! *)
449 :     while not (ready ()) do ()
450 :     end
451 : blume 448 in
452 : blume 801 OS.FileSys.remove binname handle _ => ();
453 : blume 692 youngest := TStamp.NOTSTAMP;
454 : blume 632 if compile_there' sp then
455 : blume 801 tryload (sy, received, compile_again)
456 : blume 448 else compile_again ()
457 :     end
458 : blume 398 in
459 : blume 448 (* If anything goes wrong loading the first
460 :     * time, we go and compile. Compiling
461 :     * may mean compiling externally, and if so,
462 :     * we must load the result of that.
463 :     * If the second load also goes wrong, we
464 :     * compile locally to gather error messages
465 :     * and make everything look "normal". *)
466 : blume 801 tryload (sy0, loaded, compile)
467 : blume 398 end (* fromfile *)
468 : blume 402 fun notglobal () =
469 :     case fromfile () of
470 :     NONE => NONE
471 :     | SOME memo =>
472 :     (globalstate :=
473 :     SmlInfoMap.insert (!globalstate, i,
474 :     memo);
475 :     SOME memo)
476 : blume 398 in
477 : blume 402 case SmlInfoMap.find (!globalstate, i) of
478 :     NONE => notglobal ()
479 : blume 398 | SOME memo =>
480 :     if isValidMemo (memo, pids, i) then
481 : blume 402 SOME memo
482 :     else notglobal ()
483 : blume 398 end
484 :     end (* notlocal *)
485 :     in
486 : blume 462 (* Here we just wait (no "waitU") so we don't get
487 :     * priority over threads that may have to clean up after
488 :     * errors. *)
489 : blume 402 case SmlInfoMap.find (!localstate, i) of
490 : blume 448 SOME mopt_c => Option.map memo2ed (Concur.wait mopt_c)
491 : blume 398 | NONE => let
492 : blume 448 val mopt_c = Concur.fork
493 :     (fn () => notlocal () before
494 :     (* "Not local" means that we have not processed
495 :     * this file before. Therefore, we should now
496 :     * remove its parse tree... *)
497 :     SmlInfo.forgetParsetree i)
498 : blume 398 in
499 : blume 402 localstate :=
500 : blume 632 SmlInfoMap.insert (!localstate, i, mopt_c);
501 : blume 448 Option.map memo2ed (Concur.wait mopt_c)
502 : blume 398 end
503 :     end (* snode *)
504 :    
505 : blume 652 fun impexp gp (nth, _, _) = fsbnode gp (nth ())
506 : blume 399 in
507 :     { sbnode = sbnode, impexp = impexp }
508 :     end
509 : blume 398
510 : blume 587 fun newTraversal (_, _, GG.ERRORGROUP) =
511 : blume 801 { group = fn _ => NONE,
512 :     allgroups = fn _ => false,
513 :     exports = SymbolMap.empty }
514 : blume 587 | newTraversal (notify, storeBFC, g as GG.GROUP grec) = let
515 :     val { exports, ... } = grec
516 : blume 652 val um = Memoize.memoize (fn () => Indegree.indegrees g)
517 :     fun getUrgency i = getOpt (SmlInfoMap.find (um (), i), 0)
518 :     (* generate the traversal -- lazily *)
519 :     val impexpth =
520 :     Memoize.memoize
521 :     (fn () =>
522 :     #impexp
523 :     (mkTraversal (notify, storeBFC, getUrgency)))
524 : blume 801
525 :     fun many (gp, iel) = let
526 : blume 587 val eo_cl =
527 : blume 652 map (fn x => Concur.fork (fn () => impexpth () gp x))
528 : blume 801 iel
529 : blume 587 val eo = foldl (layer'wait 0) (SOME emptyEnv) eo_cl
530 :     in
531 :     case eo of
532 :     NONE => (Servers.reset false; NONE)
533 :     | SOME e => SOME (#envs e ())
534 :     end handle Abort => (Servers.reset false; NONE)
535 : blume 801
536 :     fun group gp = many (gp, SymbolMap.listItems exports)
537 :    
538 :     fun allgroups gp = let
539 :     fun addgroup ((_, th, _), gl) = th () :: gl
540 :     fun collect ([], _, l) = l
541 :     | collect (GG.ERRORGROUP :: gl, done, l) =
542 :     collect (gl, done, l)
543 :     | collect (GG.GROUP g :: gl, done, l) =
544 :     if SrcPathSet.member (done, #grouppath g) then
545 :     collect (gl, done, l)
546 :     else
547 :     collect (foldl addgroup gl (#sublibs g),
548 :     SrcPathSet.add (done, #grouppath g),
549 :     SymbolMap.foldl (op ::) l (#exports g))
550 :     val l = collect ([g], SrcPathSet.empty, [])
551 :     in
552 :     isSome (many (gp, l))
553 :     end
554 :    
555 : blume 587 fun mkExport ie gp =
556 : blume 652 case impexpth () gp ie handle Abort => NONE of
557 : blume 587 NONE => (Servers.reset false; NONE)
558 :     | SOME e => SOME (#envs e ())
559 : blume 399 in
560 : blume 587 { group = group,
561 : blume 801 allgroups = allgroups,
562 : blume 587 exports = SymbolMap.map mkExport exports }
563 :     end
564 : blume 398
565 : blume 400 fun newSbnodeTraversal () = let
566 : blume 537 val { sbnode, ... } =
567 :     mkTraversal (fn _ => fn _ => (), fn _ => (), fn _ => 0)
568 : blume 771 fun sbn_trav n gp = let
569 :     val r = sbnode gp n handle Abort => NONE
570 : blume 461 in
571 :     if isSome r then () else Servers.reset false;
572 :     r
573 :     end
574 : blume 398 in
575 : blume 461 sbn_trav
576 : blume 398 end
577 :    
578 : blume 537 fun evictStale () =
579 :     globalstate :=
580 :     SmlInfoMap.filteri (SmlInfo.isKnown o #1) (!globalstate)
581 : blume 400
582 : blume 403 fun evictAll () = globalstate := SmlInfoMap.empty
583 : blume 402
584 : blume 403 fun getII i = memo2ii (valOf (SmlInfoMap.find (!globalstate, i)))
585 : blume 398 end
586 :     end

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