Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] Diff of /sml/trunk/src/compiler/Execution/binfile/binfile.sml
ViewVC logotype

Diff of /sml/trunk/src/compiler/Execution/binfile/binfile.sml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1136, Tue Mar 12 19:44:02 2002 UTC revision 1137, Tue Mar 12 22:28:55 2002 UTC
# Line 25  Line 25 
25   *           24  4  size of import tree area in bytes (importSzB)   *           24  4  size of import tree area in bytes (importSzB)
26   *           28  4  size of CM-specific info in bytes (cmInfoSzB)   *           28  4  size of CM-specific info in bytes (cmInfoSzB)
27   *           32  4  size of pickled lambda-expression in bytes (lambdaSzB)   *           32  4  size of pickled lambda-expression in bytes (lambdaSzB)
28   *           36  4  size of "pepper" area in bytes (pepper)   *           36  4  size of GUID area in bytes (g)
29   *           40  4  size of padding in bytes (pad)   *           40  4  size of padding in bytes (pad)
30   *           44  4  size of code area in bytes (codeSzB)   *           44  4  size of code area in bytes (codeSzB)
31   *           48  4  size of pickled environment in bytes (envSzB)   *           48  4  size of pickled environment in bytes (envSzB)
# Line 38  Line 38 
38   * ----END OF HEADER----   * ----END OF HEADER----
39   *            0  h  HEADER (h = 52+cm+ex+i)   *            0  h  HEADER (h = 52+cm+ex+i)
40   *            h  l  pickle of exported lambda-expr. (l = lambdaSzB)   *            h  l  pickle of exported lambda-expr. (l = lambdaSzB)
41   *          l+h  pp pepper area (pp = pepper)   *          l+h  g  GUID area (g = guid)
42   *        r+l+h  p  padding (p = pad)   *        r+l+h  p  padding (p = pad)
43   *      p+r+l+h  c  code area (c = codeSzB) [Structured into several   *      p+r+l+h  c  code area (c = codeSzB) [Structured into several
44   *                    segments -- see below.]   *                    segments -- see below.]
# Line 141  Line 141 
141                  cmData: pid list,                  cmData: pid list,
142                  senv: pickle,                  senv: pickle,
143                  lambda: pickle,                  lambda: pickle,
144                  fingerprint: pid,                  guid: string,
                 pepper: string,  
145                  csegments: csegments,                  csegments: csegments,
146                  executable: executable option ref }                  executable: executable option ref }
147      fun unBF (BF x) = x      fun unBF (BF x) = x
# Line 157  Line 156 
156      val lambdaPickleOf = #lambda o unBF      val lambdaPickleOf = #lambda o unBF
157      val lambdaPidOf = #pid o lambdaPickleOf      val lambdaPidOf = #pid o lambdaPickleOf
158    
159      val fingerprintOf = #fingerprint o unBF      val guidOf = #guid o unBF
     val pepperOf = #pepper o unBF  
160    
161      fun error msg =      fun error msg =
162          (Control_Print.say (concat ["binfile format error: ", msg, "\n"]);          (Control_Print.say (concat ["binfile format error: ", msg, "\n"]);
# Line 311  Line 309 
309       * call to "write". *)       * call to "write". *)
310      fun size { contents, nopickle } = let      fun size { contents, nopickle } = let
311          val { imports, exportPid, senv, cmData, lambda,  csegments,          val { imports, exportPid, senv, cmData, lambda,  csegments,
312                pepper, ... } =                guid, ... } =
313              unBF contents              unBF contents
314          val (_, picki) = pickleImports imports          val (_, picki) = pickleImports imports
315          val hasExports = isSome exportPid          val hasExports = isSome exportPid
# Line 322  Line 320 
320          9 * 4 +          9 * 4 +
321          Word8Vector.length picki +          Word8Vector.length picki +
322          (if hasExports then bytesPerPid else 0) +          (if hasExports then bytesPerPid else 0) +
323          bytesPerPid * (length cmData + 3) + (* 3 extra: stat/sym/fprint *)          bytesPerPid * (length cmData + 2) + (* 2 extra: stat/sym *)
324          String.size pepper +          String.size guid +
325          pickleSize lambda +          pickleSize lambda +
326          codeSize csegments +          codeSize csegments +
327          pickleSize senv          pickleSize senv
328      end      end
329    
330      fun create { imports, exportPid, cmData, senv, lambda,      fun create { imports, exportPid, cmData, senv, lambda, csegments, guid } =
                  fingerprint, pepper, csegments } =  
331          BF { imports = imports,          BF { imports = imports,
332               exportPid = exportPid,               exportPid = exportPid,
333               cmData = cmData,               cmData = cmData,
334               senv = senv,               senv = senv,
335               lambda = lambda,               lambda = lambda,
336               fingerprint = fingerprint,               guid = guid,
              pepper = pepper,  
337               csegments = csegments,               csegments = csegments,
338               executable = ref NONE }               executable = ref NONE }
339    
# Line 364  Line 360 
360            | [] => error "missing code objects"            | [] => error "missing code objects"
361      end      end
362    
363      fun readFingerprintInfo s = let      fun readGUid s = let
364          val _ = bytesIn (s, magicBytes)          val _ = bytesIn (s, magicBytes)
365          val _ = readInt32 s          val _ = readInt32 s
366          val ne = readInt32 s          val ne = readInt32 s
# Line 372  Line 368 
368          val cmInfoSzB = readInt32 s          val cmInfoSzB = readInt32 s
369          val nei = cmInfoSzB div bytesPerPid          val nei = cmInfoSzB div bytesPerPid
370          val lambdaSz = readInt32 s          val lambdaSz = readInt32 s
371          val pp = readInt32 s          val g = readInt32 s
372          val _ = bytesIn (s, importSzB + 3 * 4)          val _ = bytesIn (s, importSzB + 3 * 4)
373          val _ = bytesIn (s, ne * bytesPerPid)          val _ = bytesIn (s, ne * bytesPerPid)
374          val envPids = readPidList (s, nei)          val _ = readPidList (s, nei)
         val (staticPid, lambdaPid, fingerprint, cmData) =  
             case envPids of  
                 st :: lm :: fp :: cmData => (st, lm, fp, cmData)  
               | _ => error "env PID list"  
375          val _ = bytesIn (s, lambdaSz)          val _ = bytesIn (s, lambdaSz)
         val pepper = Byte.bytesToString (bytesIn (s, pp))  
376      in      in
377          { staticPid = staticPid, fingerprint = fingerprint, pepper = pepper }          Byte.bytesToString (bytesIn (s, g))
378      end      end
379    
380      fun read { arch, version, stream = s } = let      fun read { arch, version, stream = s } = let
# Line 396  Line 387 
387          val cmInfoSzB = readInt32 s          val cmInfoSzB = readInt32 s
388          val nei = cmInfoSzB div bytesPerPid          val nei = cmInfoSzB div bytesPerPid
389          val lambdaSz = readInt32 s          val lambdaSz = readInt32 s
390          val pp = readInt32 s          val g = readInt32 s
391          val pad = readInt32 s          val pad = readInt32 s
392          val cs = readInt32 s          val cs = readInt32 s
393          val es = readInt32 s          val es = readInt32 s
# Line 407  Line 398 
398                 | 1 => SOME(readPid s)                 | 1 => SOME(readPid s)
399                 | _ => error "too many export PIDs")                 | _ => error "too many export PIDs")
400          val envPids = readPidList (s, nei)          val envPids = readPidList (s, nei)
401          val (staticPid, lambdaPid, fingerprint, cmData) =          val (staticPid, lambdaPid, cmData) =
402              case envPids of              case envPids of
403                  st :: lm :: fp :: cmData => (st, lm, fp, cmData)                  st :: lm :: cmData => (st, lm, cmData)
404                | _ => error "env PID list"                | _ => error "env PID list"
405          val plambda = bytesIn (s, lambdaSz)          val plambda = bytesIn (s, lambdaSz)
406          val pepper = Byte.bytesToString (bytesIn (s, pp))          val guid = Byte.bytesToString (bytesIn (s, g))
407          (* skip padding *)          (* skip padding *)
408          val _ = if pad <> 0 then ignore (bytesIn (s, pad)) else ()          val _ = if pad <> 0 then ignore (bytesIn (s, pad)) else ()
409          (* now get the code *)          (* now get the code *)
# Line 424  Line 415 
415                                cmData = cmData,                                cmData = cmData,
416                                senv = { pid = staticPid, pickle = penv },                                senv = { pid = staticPid, pickle = penv },
417                                lambda = { pid = lambdaPid, pickle = plambda },                                lambda = { pid = lambdaPid, pickle = plambda },
418                                fingerprint = fingerprint,                                guid = guid,
                               pepper = pepper,  
419                                csegments = code },                                csegments = code },
420            stats = { env = es, inlinfo = lambdaSz, code = cs,            stats = { env = es, inlinfo = lambdaSz, code = cs,
421                      data = Word8Vector.length (#data code) } }                      data = Word8Vector.length (#data code) } }
# Line 434  Line 424 
424      fun write { arch, version, stream = s, contents, nopickle } = let      fun write { arch, version, stream = s, contents, nopickle } = let
425          (* Keep this in sync with "size" (see above). *)          (* Keep this in sync with "size" (see above). *)
426          val { imports, exportPid, cmData, senv, lambda,          val { imports, exportPid, cmData, senv, lambda,
427                csegments, fingerprint, pepper, ... } =                csegments, guid, ... } =
428              unBF contents              unBF contents
429          val { pickle = senvP, pid = staticPid } = senv          val { pickle = senvP, pid = staticPid } = senv
430          val { pickle = lambdaP, pid = lambdaPid } = lambda          val { pickle = lambdaP, pid = lambdaPid } = lambda
431          val envPids = staticPid :: lambdaPid :: fingerprint :: cmData          val envPids = staticPid :: lambdaPid :: cmData
432          val (leni, picki) = pickleImports imports          val (leni, picki) = pickleImports imports
433          val importSzB = Word8Vector.length picki          val importSzB = Word8Vector.length picki
434          val (ne, epl) =          val (ne, epl) =
# Line 450  Line 440 
440          fun pickleSize { pid, pickle } =          fun pickleSize { pid, pickle } =
441              if nopickle then 0 else Word8Vector.length pickle              if nopickle then 0 else Word8Vector.length pickle
442          val lambdaSz = pickleSize lambda          val lambdaSz = pickleSize lambda
443          val pp = String.size pepper          val g = String.size guid
444          val pad = 0                     (* currently no padding *)          val pad = 0                     (* currently no padding *)
445          val cs = codeSize csegments          val cs = codeSize csegments
446          fun codeOut c = (writeInt32 s (CodeObj.size c);          fun codeOut c = (writeInt32 s (CodeObj.size c);
# Line 464  Line 454 
454      in      in
455          BinIO.output (s, MAGIC);          BinIO.output (s, MAGIC);
456          app (writeInt32 s) [leni, ne, importSzB, cmInfoSzB,          app (writeInt32 s) [leni, ne, importSzB, cmInfoSzB,
457                              lambdaSz, pp, pad, cs, es];                              lambdaSz, g, pad, cs, es];
458          BinIO.output (s, picki);          BinIO.output (s, picki);
459          writePidList (s, epl);          writePidList (s, epl);
460          (* arena1 *)          (* arena1 *)
461          writePidList (s, envPids);          writePidList (s, envPids);
462          (* arena2 -- pickled flint stuff *)          (* arena2 -- pickled flint stuff *)
463          if lambdaSz = 0 then () else BinIO.output (s, lambdaP);          if lambdaSz = 0 then () else BinIO.output (s, lambdaP);
464          (* pepper area *)          (* GUID area *)
465          BinIO.output (s, Byte.stringToBytes pepper);          BinIO.output (s, Byte.stringToBytes guid);
466          (* padding area is currently empty *)          (* padding area is currently empty *)
467          (* code objects *)          (* code objects *)
468          writeInt32 s datasz;          writeInt32 s datasz;

Legend:
Removed from v.1136  
changed lines
  Added in v.1137

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