CVS: sml-dist/src/runtime/gc heap-in-util.c,1.2,1.3 import-heap.c,1.9,1.10

Matthias Blume <[email protected]>
Newsgroups gmane.comp.lang.sml.smlnj.commits
Message-ID <[email protected]>
Update of /cvsroot/smlnj/sml-dist/src/runtime/gc
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11855/src/runtime/gc

Modified Files:
	heap-in-util.c import-heap.c 
Log Message:
new experimental heap2exec facility

Index: heap-in-util.c
===================================================================
RCS file: /cvsroot/smlnj/sml-dist/src/runtime/gc/heap-in-util.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** heap-in-util.c	1 Jun 2000 18:33:50 -0000	1.2
--- heap-in-util.c	14 Jan 2005 23:53:19 -0000	1.3
***************
*** 13,16 ****
--- 13,21 ----
  #include "heap-input.h"
  
+ #ifndef SEEK_SET
+ #  define SEEK_SET	0
+ #  define SEEK_END	2
+ #endif
+ 
  /* local routines */
  PVT status_t ReadBlock (FILE *file, void *blk, long len);
***************
*** 67,71 ****
      }
      else {
! 	Die ("HeapIO_Seek");
      }
  
--- 72,78 ----
      }
      else {
!       if (fseek (bp->file, offset, SEEK_SET) != 0)
! 	Die ("unable to seek on heap image\n");
!       bp->nbytes = 0;		/* just in case? */
      }
  

Index: import-heap.c
===================================================================
RCS file: /cvsroot/smlnj/sml-dist/src/runtime/gc/import-heap.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** import-heap.c	21 Nov 2001 21:03:16 -0000	1.9
--- import-heap.c	14 Jan 2005 23:53:19 -0000	1.10
***************
*** 24,30 ****
  #include "heap-io.h"
  
! #ifndef SEEK_SET
! #  define SEEK_SET	0
! #  define SEEK_END	2
  #endif
  
--- 24,29 ----
  #include "heap-io.h"
  
! #ifdef DLOPEN
! #include <dlfcn.h>
  #endif
  
***************
*** 69,76 ****
  #define READ(bp,obj)	HeapIO_ReadBlock(bp, &(obj), sizeof(obj))
  
- #ifdef HACKED_STANDALONE
- PVT long	heapStart = -1;
- #endif
- 
  
  /* ImportHeapImage:
--- 68,71 ----
***************
*** 85,124 ****
      inbuf_t		inBuf;
  
!   /* Resolve the name of the image.  If the file exists use it, otherwise try the
!    * pathname with the machine ID as an extension.
!    */
!     if ((inBuf.file = fopen(fname, "rb")) != NULL) {
  	if (! SilentLoad)
! 	    Say("loading %s ", fname);
!     }
!     else {
  	char	buf[1024];
  
  	if (QualifyImageName(strcpy(buf, fname))
! 	&& ((inBuf.file = fopen(buf, "rb")) != NULL)) {
! 	    if (! SilentLoad)
! 		Say("loading %s ", buf);
  	}
  	else
! 	    Die ("unable to open heap image \"%s\"\n", fname);
!     }
! 
  
!     inBuf.needsSwap = FALSE;
!     inBuf.buf	    = NIL(Byte_t *);
!     inBuf.nbytes    = 0;
  
! #ifdef HACKED_STANDALONE
!   /* note that the seek may (will) succeed even if there's nothing there */
!   /* for now, we'll be content to just fail on the reads below */
!     if (StandAlone) {
! 	if ((fseek (inBuf.file, -sizeof(long), SEEK_END) != 0)
! 	||  (fread(&heapStart, sizeof(long), 1, inBuf.file) != 1)
! 	||  (fseek (inBuf.file, heapStart, SEEK_SET) != 0)) {
! 	    Die ("unable to seek to internal image in stand-alone at %x\n",
! 		heapStart);
! 	}
!     }
  #endif
  
      READ(&inBuf, imHdr);
--- 80,125 ----
      inbuf_t		inBuf;
  
!     if (fname != NULL) {
!       /* Resolve the name of the image.  If the file exists use it, otherwise try the
!        * pathname with the machine ID as an extension.
!        */
!       if ((inBuf.file = fopen(fname, "rb")) != NULL) {
  	if (! SilentLoad)
! 	  Say("loading %s ", fname);
!       }
!       else {
  	char	buf[1024];
  
  	if (QualifyImageName(strcpy(buf, fname))
! 	    && ((inBuf.file = fopen(buf, "rb")) != NULL)) {
! 	  if (! SilentLoad)
! 	    Say("loading %s ", buf);
  	}
  	else
! 	  Die ("unable to open heap image \"%s\"\n", fname);
!       }
  
!       inBuf.needsSwap = FALSE;
!       inBuf.buf	    = NIL(Byte_t *);
!       inBuf.nbytes    = 0;
!     } else {
!       /* fname == NULL, so try to find an in-core heap image */
! #ifdef DLOPEN
!       void *lib = dlopen (NULL, RTLD_LAZY);
!       void *vimg, *vimglenptr;
!       if ((vimg = dlsym(lib,HEAP_IMAGE_SYMBOL)) == NULL)
! 	Die("no in-core heap image found\n");
!       if ((vimglenptr = dlsym(lib,HEAP_IMAGE_LEN_SYMBOL)) == NULL)
! 	Die("unable to find length of in-core heap image\n");
  
!       inBuf.file = NULL;
!       inBuf.needsSwap = FALSE;
!       inBuf.base = vimg;
!       inBuf.buf = inBuf.base;
!       inBuf.nbytes = *(long*)vimglenptr;
! #else
!       Die("in-core heap images not implemented\n");
  #endif
+     }
  
      READ(&inBuf, imHdr);
***************
*** 194,198 ****
  
      FREE (externs);
!     fclose (inBuf.file);
  
      if (! SilentLoad)
--- 195,200 ----
  
      FREE (externs);
!     if (inBuf.file != NULL)
!       fclose (inBuf.file);
  
      if (! SilentLoad)
***************
*** 292,311 ****
  	for (j = 0;  j < NUM_ARENAS;  j++) {
  	    arena_t		*ap = gen->arena[j];
- 	    long		offset;
  
  	    if (p->info.o.sizeB > 0) {
  		addrOffset[i][j] = (Addr_t)(ap->tospBase) - (Addr_t)(p->info.o.baseAddr);
! #ifdef HACKED_STANDALONE
! 	      /* 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");
  		HeapIO_ReadBlock(bp, (ap->tospBase), p->info.o.sizeB);
  		ap->nextw	= (ml_val_t *)((Addr_t)(ap->tospBase) + p->info.o.sizeB);
--- 294,301 ----
  	for (j = 0;  j < NUM_ARENAS;  j++) {
  	    arena_t		*ap = gen->arena[j];
  
  	    if (p->info.o.sizeB > 0) {
  		addrOffset[i][j] = (Addr_t)(ap->tospBase) - (Addr_t)(p->info.o.baseAddr);
! 		HeapIO_Seek (bp, (long)(p->offset));
  		HeapIO_ReadBlock(bp, (ap->tospBase), p->info.o.sizeB);
  		ap->nextw	= (ml_val_t *)((Addr_t)(ap->tospBase) + p->info.o.sizeB);



-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues
Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek.
It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.