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/branches/SMLNJ/src/runtime/kernel/boot.c
ViewVC logotype

Diff of /sml/branches/SMLNJ/src/runtime/kernel/boot.c

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

revision 138, Mon Sep 7 21:11:35 1998 UTC revision 139, Mon Sep 7 21:11:35 1998 UTC
# Line 57  Line 57 
57  void BootML (const char *binDir, heap_params_t *heapParams)  void BootML (const char *binDir, heap_params_t *heapParams)
58  {  {
59      ml_state_t  *msp;      ml_state_t  *msp;
60      char        *fname;      char        fname[512];
61    
62      msp = AllocMLState (TRUE, heapParams);      msp = AllocMLState (TRUE, heapParams);
63    
# Line 77  Line 77 
77    
78    /* boot the system */    /* boot the system */
79      while (BinFileList != LIST_nil) {      while (BinFileList != LIST_nil) {
80          fname = PTR_MLtoC(char, LIST_hd(BinFileList));          strcpy(fname, PTR_MLtoC(char, LIST_hd(BinFileList)));
81          Say ("[Loading %s]\n", fname);          Say ("[Loading %s]\n", fname);
82          BinFileList = LIST_tl(BinFileList);          BinFileList = LIST_tl(BinFileList);
83          LoadBinFile (msp, binDir, fname);          LoadBinFile (msp, binDir, fname);
# Line 316  Line 316 
316  PVT void LoadBinFile (ml_state_t *msp, const char *binDir, const char *fname)  PVT void LoadBinFile (ml_state_t *msp, const char *binDir, const char *fname)
317  {  {
318      FILE            *file;      FILE            *file;
319      int             i, exportSzB, remainingCode;      int             i, exportSzB, remainingCode, importRecLen;
320      bool_t          isDataSeg;      bool_t          isDataSeg;
321      ml_val_t        codeObj, importRec, closure, exportVal, val;      ml_val_t        codeObj, importRec, closure, val;
322      binfile_hdr_t   hdr;      binfile_hdr_t   hdr;
323      pers_id_t       exportPerID;      pers_id_t       exportPerID;
324      Int32_t         thisSzB;      Int32_t         thisSzB;
# Line 346  Line 346 
346      {      {
347          int     importVecPos;          int     importVecPos;
348    
349          if (NeedGC (msp, REC_SZB(hdr.importCnt + 1)))          importRecLen = hdr.importCnt + 1;
             InvokeGCWithRoots (msp, 0, &BinFileList, &exportVal, NIL(ml_val_t *));  
350    
351          ML_AllocWrite (msp, 0, MAKE_DESC(hdr.importCnt + 1, DTAG_record));          if (NeedGC (msp, REC_SZB(importRecLen)))
352          for (importVecPos = 1; importVecPos <= hdr.importCnt; ) {              InvokeGCWithRoots (msp, 0, &BinFileList, NIL(ml_val_t *));
353    
354            ML_AllocWrite (msp, 0, MAKE_DESC(importRecLen, DTAG_record));
355            for (importVecPos = 1; importVecPos < importRecLen; ) {
356              pers_id_t   importPid;              pers_id_t   importPid;
357              ReadBinFile (file, &importPid, sizeof(pers_id_t), binDir, fname);              ReadBinFile (file, &importPid, sizeof(pers_id_t), binDir, fname);
358              ImportSelection (              ImportSelection (
359                  msp, file, binDir, fname, &importVecPos,                  msp, file, binDir, fname, &importVecPos,
360                  LookupPerID(&importPid));                  LookupPerID(&importPid));
361          }          }
362          ML_AllocWrite(msp, hdr.importCnt + 1, ML_nil);          ML_AllocWrite(msp, importRecLen, ML_nil);
363          importRec = ML_Alloc(msp, hdr.importCnt + 1);          importRec = ML_Alloc(msp, importRecLen);
364      }      }
365    
366    /* read the export PerID */    /* read the export PerID */
# Line 434  Line 436 
436              SaveCState (msp, &BinFileList, &importRec, NIL(ml_val_t *));              SaveCState (msp, &BinFileList, &importRec, NIL(ml_val_t *));
437              val = ApplyMLFn (msp, closure, val, TRUE);              val = ApplyMLFn (msp, closure, val, TRUE);
438              RestoreCState (msp, &BinFileList, &importRec, NIL(ml_val_t *));              RestoreCState (msp, &BinFileList, &importRec, NIL(ml_val_t *));
439              REC_SEL(importRec,hdr.importCnt) = val;            /* do a functional update of the last element of the importRec. */
440              val = importRec;              for (i = 0;  i < importRecLen;  i++)
441                    ML_AllocWrite(msp, i, PTR_MLtoC(ml_val_t, importRec)[i-1]);
442                ML_AllocWrite(msp, importRecLen, val);
443                val = ML_Alloc(msp, importRecLen);
444              isDataSeg = FALSE;              isDataSeg = FALSE;
445          }          }
446          else {          else {
# Line 449  Line 454 
454              InvokeGCWithRoots (msp, 0, &BinFileList, &val, NIL(ml_val_t *));              InvokeGCWithRoots (msp, 0, &BinFileList, &val, NIL(ml_val_t *));
455      }      }
456    
   /* we are done: val -> exportVal */  
     exportVal = val;  
   
457    /* record the resulting exported PerID */    /* record the resulting exported PerID */
458      if (exportSzB != 0)      if (exportSzB != 0)
459        EnterPerID (msp, &exportPerID, exportVal);          EnterPerID (msp, &exportPerID, val);
460    
461      fclose (file);      fclose (file);
462    
# Line 513  Line 515 
515      *cp++ = '\0';      *cp++ = '\0';
516    
517  } /* end of ShowPerID */  } /* end of ShowPerID */
   

Legend:
Removed from v.138  
changed lines
  Added in v.139

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