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/runtime/gc/import-heap.c
ViewVC logotype

Diff of /sml/trunk/src/runtime/gc/import-heap.c

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

revision 1746, Fri Jan 7 17:44:23 2005 UTC revision 1747, Fri Jan 14 23:53:21 2005 UTC
# Line 23  Line 23 
23  #include "heap-input.h"  #include "heap-input.h"
24  #include "heap-io.h"  #include "heap-io.h"
25    
26  #ifndef SEEK_SET  #ifdef DLOPEN
27  #  define SEEK_SET      0  #include <dlfcn.h>
 #  define SEEK_END      2  
28  #endif  #endif
29    
30  #ifdef DEBUG  #ifdef DEBUG
# Line 68  Line 67 
67    
68  #define READ(bp,obj)    HeapIO_ReadBlock(bp, &(obj), sizeof(obj))  #define READ(bp,obj)    HeapIO_ReadBlock(bp, &(obj), sizeof(obj))
69    
 #ifdef HACKED_STANDALONE  
 PVT long        heapStart = -1;  
 #endif  
   
70    
71  /* ImportHeapImage:  /* ImportHeapImage:
72   */   */
# Line 84  Line 79 
79      ml_vproc_image_t    image;      ml_vproc_image_t    image;
80      inbuf_t             inBuf;      inbuf_t             inBuf;
81    
82        if (fname != NULL) {
83    /* Resolve the name of the image.  If the file exists use it, otherwise try the    /* Resolve the name of the image.  If the file exists use it, otherwise try the
84     * pathname with the machine ID as an extension.     * pathname with the machine ID as an extension.
85     */     */
# Line 103  Line 99 
99              Die ("unable to open heap image \"%s\"\n", fname);              Die ("unable to open heap image \"%s\"\n", fname);
100      }      }
101    
   
102      inBuf.needsSwap = FALSE;      inBuf.needsSwap = FALSE;
103      inBuf.buf       = NIL(Byte_t *);      inBuf.buf       = NIL(Byte_t *);
104      inBuf.nbytes    = 0;      inBuf.nbytes    = 0;
105        } else {
106          /* fname == NULL, so try to find an in-core heap image */
107    #ifdef DLOPEN
108          void *lib = dlopen (NULL, RTLD_LAZY);
109          void *vimg, *vimglenptr;
110          if ((vimg = dlsym(lib,HEAP_IMAGE_SYMBOL)) == NULL)
111            Die("no in-core heap image found\n");
112          if ((vimglenptr = dlsym(lib,HEAP_IMAGE_LEN_SYMBOL)) == NULL)
113            Die("unable to find length of in-core heap image\n");
114    
115  #ifdef HACKED_STANDALONE        inBuf.file = NULL;
116    /* note that the seek may (will) succeed even if there's nothing there */        inBuf.needsSwap = FALSE;
117    /* for now, we'll be content to just fail on the reads below */        inBuf.base = vimg;
118      if (StandAlone) {        inBuf.buf = inBuf.base;
119          if ((fseek (inBuf.file, -sizeof(long), SEEK_END) != 0)        inBuf.nbytes = *(long*)vimglenptr;
120          ||  (fread(&heapStart, sizeof(long), 1, inBuf.file) != 1)  #else
121          ||  (fseek (inBuf.file, heapStart, SEEK_SET) != 0)) {        Die("in-core heap images not implemented\n");
             Die ("unable to seek to internal image in stand-alone at %x\n",  
                 heapStart);  
         }  
     }  
122  #endif  #endif
123        }
124    
125      READ(&inBuf, imHdr);      READ(&inBuf, imHdr);
126      if (imHdr.byteOrder != ORDER)      if (imHdr.byteOrder != ORDER)
# Line 193  Line 194 
194      }      }
195    
196      FREE (externs);      FREE (externs);
197        if (inBuf.file != NULL)
198      fclose (inBuf.file);      fclose (inBuf.file);
199    
200      if (! SilentLoad)      if (! SilentLoad)
# Line 291  Line 293 
293         */         */
294          for (j = 0;  j < NUM_ARENAS;  j++) {          for (j = 0;  j < NUM_ARENAS;  j++) {
295              arena_t             *ap = gen->arena[j];              arena_t             *ap = gen->arena[j];
             long                offset;  
296    
297              if (p->info.o.sizeB > 0) {              if (p->info.o.sizeB > 0) {
298                  addrOffset[i][j] = (Addr_t)(ap->tospBase) - (Addr_t)(p->info.o.baseAddr);                  addrOffset[i][j] = (Addr_t)(ap->tospBase) - (Addr_t)(p->info.o.baseAddr);
299  #ifdef HACKED_STANDALONE                  HeapIO_Seek (bp, (long)(p->offset));
               /* assuming here that ReadHeap is only called from ImportHeapImage  
                * and that ImportHeapImage is only called from LoadML on startup.  
                * Otherwise, StandAlone needs to be set to FALSE after the intial  
                * load; or need extra offset param here, etc.  
                */  
                 offset = (long)(p->offset) + (StandAlone ? heapStart : 0);  
 #else  
                 offset = (long)(p->offset);  
 #endif  
                 if (fseek (bp->file, offset, SEEK_SET) != 0)  
                     Die("unable to seek on heap image\n");  
300                  HeapIO_ReadBlock(bp, (ap->tospBase), p->info.o.sizeB);                  HeapIO_ReadBlock(bp, (ap->tospBase), p->info.o.sizeB);
301                  ap->nextw       = (ml_val_t *)((Addr_t)(ap->tospBase) + p->info.o.sizeB);                  ap->nextw       = (ml_val_t *)((Addr_t)(ap->tospBase) + p->info.o.sizeB);
302                  ap->oldTop      = ap->tospBase;                  ap->oldTop      = ap->tospBase;

Legend:
Removed from v.1746  
changed lines
  Added in v.1747

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