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/branches/blume-private-devel/src/cm/compile/compile.sml
ViewVC logotype

Annotation of /sml/branches/blume-private-devel/src/cm/compile/compile.sml

Parent Directory Parent Directory | Revision Log Revision Log


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

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