Beispiel #1
0
PVT ml_val_t ptrlist_to_MLlist(ml_state_t *msp)
{
    ml_val_t lp = LIST_nil;
    ml_val_t v;
    ptrlist_t *p;

#ifdef DEBUG_C_CALLS
    int i = 0;
    SayDebug("converting ptrlist (|ptrlist|=%d) to ML list ",ptrlist_len());
#endif
    p = ptrlist;
    while (p != NULL) {
#ifdef DEBUG_C_CALLS
	i++;
#endif
	ptrlist = p->next;
	v = MK_CADDR(msp,p->ptr);
	LIST_cons(msp, lp, v, lp);
	FREE(p);
	p = ptrlist;
    }
#ifdef DEBUG_C_CALLS
    SayDebug("of length %d\n", i);
#endif
    return lp;
}
Beispiel #2
0
/* set_up_fault_handlers:
 */
void set_up_fault_handlers (lib7_state_t *lib7_state)
{
  /* some basic win32 initialization is done here */

  /* determine if we're NT or 95 */
  win32_isNT = !(GetVersion() & 0x80000000);

  /* get the redirected handle; this is "stdin"  */
  win32_stdin_handle = GetStdHandle(STD_INPUT_HANDLE);
  /* get the actual handle of the console */
  win32_console_handle = CreateFile("CONIN$",
				    GENERIC_READ|GENERIC_WRITE,
				    FILE_SHARE_READ|FILE_SHARE_WRITE,
				    NULL,
				    OPEN_EXISTING,
				    0,0);
#ifdef WIN32_DEBUG
  if (win32_console_handle == INVALID_HANDLE_VALUE) {
    SayDebug("win32: failed to get actual console handle");
  }
#endif

  win32_stdout_handle = GetStdHandle(STD_OUTPUT_HANDLE);
  win32_stderr_handle = GetStdHandle(STD_ERROR_HANDLE);

#ifdef WIN32_DEBUG
  SayDebug("console input handle, %x\n", (unsigned int) win32_stdin_handle);
  SayDebug("console output handle, %x\n", (unsigned int) win32_stdout_handle);
  SayDebug("console error handle, %x\n", (unsigned int) win32_stderr_handle);
#endif

  /* create a thread id for the main thread */
  {
    HANDLE cp_h = GetCurrentProcess();

    if (!DuplicateHandle(cp_h,               /* process with handle to dup */
			 GetCurrentThread(), /* pseudohandle, hence the dup */
			 cp_h,               /* handle goes to current proc */
			 &win32_LIB7_thread_handle, /* recipient */
			 THREAD_ALL_ACCESS,
			 FALSE,
			 0                   /* no options */
			 )) {
      Die ("win32:set_up_fault_handlers: cannot duplicate thread handle");
    }
  }
  
  /* install the ctrl-C handler */
  if (!SetConsoleCtrlHandler((PHANDLER_ROUTINE)cntrl_c_handler,TRUE)) {
    Die("win32:set_up_fault_handlers: can't install cntrl_c_handler\n");
  }

  /* initialize the floating-point unit */
  SIG_InitFPE ();
}
Beispiel #3
0
/* GetSignalMask:
 *
 * Return the current signal mask (only those signals supported by Lib7); like
 * SetSignalMask, the result has the following semantics:
 *	NULL	-- the empty mask
 *	THE[]	-- mask all signals
 *	THE l	-- the signals in l are the mask
 */
lib7_val_t GetSignalMask (lib7_state_t *lib7_state)
{
#ifdef WIN32_DEBUG
    SayDebug("win32:GetSignalMask: returning mask as NULL\n");
#endif
    return OPTION_NONE;
}
Beispiel #4
0
/* _ml_RunT_debug : string -> unit
 *
 */
ml_val_t _ml_RunT_debug (ml_state_t *msp, ml_val_t arg)
{
    SayDebug (STR_MLtoC(arg));

    return ML_unit;

} /* end of _ml_RunT_debug */
Beispiel #5
0
/* GetSignalState:
 */
int GetSignalState (vproc_state_t *vsp, int sigNum)
{
#ifdef WIN32_DEBUG
    SayDebug("win32:GetSignalState: returning state for signal %d as LIB7_SIG_DEFAULT\n",sigNum);
#endif
    return LIB7_SIG_DEFAULT;
}  
Beispiel #6
0
/* LoadResumeState:
 *
 * Load the Lib7 state with the state preserved
 * in resumption fate made by MakeResumeCont.
 */
void LoadResumeState (lib7_state_t *lib7_state)
{
    lib7_val_t	    *contClosure;

    #ifdef SIGNAL_DEBUG
    SayDebug ("LoadResumeState:\n");
    #endif

    contClosure = PTR_LIB7toC(lib7_val_t, lib7_state->lib7_closure);

    lib7_state->lib7_argument		= contClosure[1];
    lib7_state->lib7_fate		= contClosure[2];
    lib7_state->lib7_closure		= contClosure[3];
    lib7_state->lib7_link_register	= contClosure[4];
    lib7_state->lib7_program_counter	= contClosure[5];
    lib7_state->lib7_exception_fate	= contClosure[6];

    /* John (Reppy) says current_thread
    should not be included here...
    lib7_state->lib7_current_thread	= contClosure[7];
    */

    lib7_state->lib7_calleeSave[0]	= contClosure[7];
    lib7_state->lib7_calleeSave[1]	= contClosure[8];
    lib7_state->lib7_calleeSave[2]	= contClosure[9];
}
Beispiel #7
0
/* ListSignals:
 */
lib7_val_t ListSignals (lib7_state_t *lib7_state)
{
#ifdef WIN32_DEBUG
    SayDebug("win32:ListSignals: returning dummy signal list\n");
#endif
    return LIB7_SysConstList (lib7_state, &SigTable);
} 
Beispiel #8
0
PVT void restore_ptrlist(ptrlist_t *save)
{
    ptrlist = save;
#ifdef DEBUG_C_CALLS
    SayDebug("restoring ptrlist, |ptrlist|=%d\n", ptrlist_len());
#endif
}
Beispiel #9
0
static SigReturn_t FaultHandler (int signal, siginfo_t *si, void *c)
{
    ucontext_t	    *scp = (ucontext_t *)c;
    lib7_state_t	    *lib7_state = SELF_VPROC->vp_state;
    extern Word_t   request_fault[]; 
    int		    code = SIG_GetCode(si, scp);

#ifdef SIGNAL_DEBUG
    SayDebug ("Fault handler: sig = %d, inLib7 = %d\n",
	signal, SELF_VPROC->vp_inLib7Flag);
#endif

    if (! SELF_VPROC->vp_inLib7Flag) 
	Die ("bogus fault not in Lib7: sig = %d, code = %#x, pc = %#x)\n",
	    signal, SIG_GetCode(si, scp), SIG_GetPC(scp));

    /* Map the signal to the appropriate Lib7 exception. */
    if (INT_OVFLW(signal, code)) {
	lib7_state->lib7_fault_exception = OverflowId;
	lib7_state->lib7_faulting_program_counter = (Word_t)SIG_GetPC(scp);
    }
    else if (INT_DIVZERO(signal, code)) {
	lib7_state->lib7_fault_exception = DivId;
	lib7_state->lib7_faulting_program_counter = (Word_t)SIG_GetPC(scp);
    }
    else
	Die ("unexpected fault, signal = %d, code = %#x", signal, code);

    SIG_SetPC (scp, request_fault);

    SIG_ResetFPE (scp);

} /* end of FaultHandler */
Beispiel #10
0
/* PartitionAllocArena:
 *
 * Divide this allocation arena into smaller disjoint arenas for
 * use by the parallel processors.
 */
void PartitionAllocArena (vproc_state_t *vsps[])
{
    int		indivSz;
    ml_val_t	*aBase;
    int		i;
    int pollFreq = INT_MLtoC(DEREF(PollFreq));
    ml_state_t  *msp, *msp0;

    msp0 = vsps[0]->vp_state;
    indivSz = msp0->ml_heap->allocSzB / MAX_NUM_PROCS;
    aBase = msp0->ml_heap->allocBase;
    for (i = 0; i < MAX_NUM_PROCS; i++) {
	msp = vsps[i]->vp_state;
#ifdef MP_DEBUG
SayDebug ("vsps[%d]->vp_state-> (ml_allocPtr %x/ml_limitPtr %x) changed to ",
i, msp->ml_allocPtr, msp->ml_limitPtr);
#endif
	msp->ml_heap = msp0->ml_heap;
	msp->ml_allocPtr = aBase;
	msp->ml_realLimit = HEAP_LIMIT_SIZE(aBase, indivSz);

#ifdef MP_GCPOLL
	if (pollFreq > 0) {
#ifdef MP_DEBUG
SayDebug ("(with PollFreq=%d) ", pollFreq);
#endif
	    msp->ml_limitPtr = aBase + pollFreq*POLL_GRAIN_CPSI;
	    msp->ml_limitPtr =
		(msp->ml_limitPtr > msp->ml_realLimit)
		    ? msp->ml_realLimit
		    : msp->ml_limitPtr;

	}
	else {
	    msp->ml_limitPtr = msp->ml_realLimit;
	}
#else
	msp->ml_limitPtr = HEAP_LIMIT_SIZE(aBase,indivSz);
#endif

#ifdef MP_DEBUG
SayDebug ("%x/%x\n",msp->ml_allocPtr, msp->ml_limitPtr);
#endif
	aBase = (ml_val_t *) (((Addr_t) aBase) + indivSz);
    }

} /* end of PartitionAllocArena */
Beispiel #11
0
PVT void save_ptrlist(ptrlist_t **save)
{
#ifdef DEBUG_C_CALLS
    SayDebug("saving ptrlist, |ptrlist|=%d\n", ptrlist_len());
#endif
    *save = ptrlist;
    ptrlist = NULL;
}
Beispiel #12
0
PVT void spaceCheck(ml_state_t *msp, int bytes, ml_val_t *one_root)
{
    /* assume the ONE_K buffer will absorb descriptors, '\0' terminators */
    if (NeedGC(msp,bytes + ONE_K)) {
#ifdef DEBUG_C_CALLS
SayDebug("spaceCheck: invoking GC\n");
#endif
	InvokeGCWithRoots(msp,0,one_root,NIL(ml_val_t *));
	if (NeedGC(msp,bytes + ONE_K))
	    Error("spaceCheck: cannot alloc ML space for ML-C conversion\n");
    }
Beispiel #13
0
static void print_region_map (bo_region_reloc_t *r)
{
    bo_reloc_t		*dp, *dq;
    int			i;

    SayDebug ("region @%#x: |", r->firstPage);
    for (i = 0, dq = r->chunkMap[0];  i < r->nPages;  i++) {
	dp = r->chunkMap[i];
	if (dp != dq) {
	    SayDebug ("|");
	    dq = dp;
	}
	if (dp == NULL)
	    SayDebug ("_");
	else
	    SayDebug ("X");
    }
    SayDebug ("|\n");

}
Beispiel #14
0
/* MP_StartCollect:
 *
 * Waits for all procs to check in and chooses one to do the 
 * collect (MPCollectorProc).  MPCollectorProc returns to the invoking
 * collection function and does the collect while the other procs
 * wait at a barrier. MPCollectorProc will eventually check into this
 * barrier releasing the waiting procs.
 */
int MP_StartCollect (ml_state_t *msp)
{
    int		nProcs;
    vproc_state_t *vsp = msp->ml_vproc;

    MP_SetLock(MP_GCLock);
    if (MP_RdyForGC++ == 0) {
        mpExtraRoots[0] = NIL(ml_val_t *);
        mpExtraRootsPtr = mpExtraRoots;
#ifdef MP_GCPOLL
	ASSIGN(PollEvent, ML_true);
#ifdef MP_DEBUG
	SayDebug ("%d: set poll event\n", msp->ml_mpSelf);
#endif
#endif
      /* we're the first one in, we'll do the collect */
	MPCollectorProc = vsp->vp_mpSelf;
#ifdef MP_DEBUG
	SayDebug ("MPCollectorProc is %d\n",MPCollectorProc);
#endif
    }
Beispiel #15
0
PVT void keep_ptr(Word_t *p)
{
    ptrlist_t *q = (ptrlist_t *) checked_alloc(sizeof(ptrlist_t));

#ifdef DEBUG_C_CALLS
    SayDebug("keeping ptr %x, |ptrlist|=%d\n", p, ptrlist_len());
#endif

    q->ptr = p;
    q->next = ptrlist;
    ptrlist = q;
}
Beispiel #16
0
PVT ml_val_t double_CtoML(ml_state_t *msp,double g)
{
    ml_val_t res;

#ifdef DEBUG_C_CALLS
SayDebug("double_CtoML: building an ML double %l.15f\n", g);
#endif
    /* Force REALD_SZB alignment */
    msp->ml_allocPtr = (ml_val_t *)((Addr_t)(msp->ml_allocPtr) | WORD_SZB);
    ML_AllocWrite(msp,0,DESC_reald);
    res = ML_Alloc(msp,(sizeof(double)>>2));
    memcpy (res, &g, sizeof(double));
    return res;
}
Beispiel #17
0
PVT void free_ptrlist()
{
    ptrlist_t *p;

#ifdef DEBUG_C_CALLS
    SayDebug("freeing ptr list, |ptrlist|=%d\n",ptrlist_len());
#endif
    p = ptrlist;
    while (p != NULL) {
	ptrlist = ptrlist->next;
	FREE(p->ptr);               /* the block */
	FREE(p);                    /* the block's descriptor */
	p = ptrlist;
    }
}
Beispiel #18
0
/* return the number of bytes the ptrlist will occupy in the ML heap */
PVT int ptrlist_space()
{
    int n = 0;
    ptrlist_t *p;

    p = ptrlist;
    while (p != NULL) {
	p = p->next;
	n += CONS_SZB + CADDR_SZB;
    }
#ifdef DEBUG_C_CALLS
    SayDebug("space for ptrlist is %d, |ptrlist|=%d\n",n,ptrlist_len());
#endif
    return n;
}
Beispiel #19
0
/* MakeHandlerArg:
 *
 * Build the argument record for the Lib7 signal handler.
 * It has the type
 *
 *   sigHandler : (Int, Int, Fate(Void)) -> X
 *
 * where
 *     The first  argument is  the signal code,
 *     the second argument is  the signal count and
 *     the third  argument is  the resumption fate.
 *
 * The Lib7 signal handler should never return.
 * NOTE: maybe this should be combined with ChooseSignal???	XXX BUGGO FIXME
 */
lib7_val_t MakeHandlerArg (lib7_state_t *lib7_state, lib7_val_t resume[])
{
    lib7_val_t	resumeCont, arg;
    vproc_state_t *vsp = lib7_state->lib7_vproc;

    resumeCont = MakeResumeCont(lib7_state, resume);

    /* Allocate the Lib7 signal handler's argument record:
    */
    REC_ALLOC3(lib7_state, arg,
	INT_CtoLib7(vsp->vp_sigCode), INT_CtoLib7(vsp->vp_sigCount),
	resumeCont);

    #ifdef SIGNAL_DEBUG
    SayDebug ("MakeHandlerArg: resumeC = %#x, arg = %#x\n", resumeCont, arg);
    #endif

    return arg;
}
Beispiel #20
0
/* ChooseSignal:
 *
 * Caller guarantees that at least one Unix signal has been
 * seen at the C level but not yet handled at the Mythryl
 * level.  Our job is to find and return the number of
 * that signal plus the number of times it has fired at
 * the C level since last being handled at the Mythry level.
 *
 * Choose which signal to pass to the Mythryl-level handler
 * and set up the Mythryl state vector accordingly.
 *
 * This function gets called (only) from
 *
 *     src/runtime/main/run-runtime.c
 *
 * WARNING: This should be called with signals masked
 * to avoid race conditions.
 */
void ChooseSignal (vproc_state_t *vsp)
{
    int		i, j, delta;

    /* Scan the signal counts looking for
     * a signal that needs to be handled.
     *
     * The 'nReceived' field for a signal gets
     * incremented once for each incoming signal
     * in   CSigHandler()   in
     *
     *     src/runtime/machine-dependent/unix-signal.c
     *
     * Here we increment the matching 'nHandled' field
     * each time we invoke appropriate handling for that
     * signal;  thus, the difference between the two
     * gives the number of pending instances of that signal
     * currently needing to be handled.
     *
     * For fairness we scan for signals round-robin style, using
     *
     *     vsp->vp_nextPendingSig
     *
     * to remember where we left off scanning, so we can pick
     * up from there next time:	
     *
     */
    i = vsp->vp_nextPendingSig;
    j = 0;
    do {
	ASSERT (j++ < NUM_SIGS);

	i++;

	/* Wrap circularly around the signal vector:
	 */
	if (i == SIGMAP_SZ)
            i = MIN_SYSTEM_SIG;

	/* Does this signal have pending work? (Nonzero == "yes"):
	 */
	delta = vsp->vp_sigCounts[i].nReceived - vsp->vp_sigCounts[i].nHandled;

    } while (delta == 0);

    vsp->vp_nextPendingSig = i;		/* Next signal to scan on next call to this fn. */

    /* Record the signal to process
     * and how many times it has fired
     * since last being handled at the
     * Mythryl level:
     */
    vsp->vp_sigCode  = i;
    vsp->vp_sigCount = delta;

    /* Mark this signal as 'done':
     */
    vsp->vp_sigCounts[i].nHandled  += delta;
    vsp->vp_totalSigCount.nHandled += delta;

    #ifdef SIGNAL_DEBUG
    SayDebug ("ChooseSignal: sig = %d, count = %d\n",
    vsp->vp_sigCode, vsp->vp_sigCount);
    #endif
}
Beispiel #21
0
/* SetSignalState:
 */
void SetSignalState (vproc_state_t *vsp, int sigNum, int sigState)
{
#ifdef WIN32_DEBUG
    SayDebug("win32:SetSignalState: not setting state for signal %d\n",sigNum);
#endif
}
Beispiel #22
0
/* SetSignalMask:
 *
 * Set the signal mask to the given list of signals.  The sigList has the
 * type: "sysconst list option", with the following semantics (see
 * signals.pkg):
 *	NULL	-- the empty mask
 *	THE[]	-- mask all signals
 *	THE l	-- the signals in l are the mask
 */
void SetSignalMask (lib7_val_t sigList)
{
#ifdef WIN32_DEBUG
    SayDebug("win32:SetSigMask: not setting mask\n");
#endif
}
Beispiel #23
0
static void   read_heap   (   inbuf_t*            bp,
                             lib7_heap_hdr_t*   header,
                             lib7_state_t*      lib7_state,
                             lib7_val_t*        externs
                         )
{
    heap_t*		heap = lib7_state->lib7_heap;
    heap_arena_hdr_t	*arenaHdrs, *p, *q;
    int			arenaHdrsSize;
    int			i, j, k;
    long		prevSzB[NUM_ARENAS], size;
    bibop_t		oldBIBOP;
    Addr_t		addrOffset[MAX_NUM_GENS][NUM_ARENAS];
    bo_region_reloc_t	*boRelocInfo;
    addr_table_t		*boRegionTable;

    /* Allocate a BIBOP for the imported
     * heap image's address space:
     */
#ifdef TWO_LEVEL_MAP
#  error two level map not supported
#else
    oldBIBOP = NEW_VEC (aid_t, BIBOP_SZ);
#endif

    /* Read in the big-chunk region descriptors
     * for the old address space:
     */
    {
	int		  size;
	bo_region_info_t* boRgnHdr;

	boRegionTable = MakeAddrTable(BIBOP_SHIFT+1, header->numBORegions);
	size = header->numBORegions * sizeof(bo_region_info_t);
	boRgnHdr = (bo_region_info_t *) MALLOC (size);
	HeapIO_ReadBlock (bp, boRgnHdr, size);

	boRelocInfo = NEW_VEC(bo_region_reloc_t, header->numBORegions);

	for (i = 0;  i < header->numBORegions;  i++) {
	    MarkRegion(oldBIBOP,
		(lib7_val_t *)(boRgnHdr[i].baseAddr),
		RND_HEAP_CHUNK_SZB(boRgnHdr[i].sizeB),
		AID_BIGCHUNK(1)
            );
	    oldBIBOP[BIBOP_ADDR_TO_INDEX(boRgnHdr[i].baseAddr)] = AID_BIGCHUNK_HDR(MAX_NUM_GENS);
	    boRelocInfo[i].firstPage = boRgnHdr[i].firstPage;

	    boRelocInfo[i].nPages
                =
                (boRgnHdr[i].sizeB - (boRgnHdr[i].firstPage - boRgnHdr[i].baseAddr))
                >>
                BIGCHUNK_PAGE_SHIFT;

	    boRelocInfo[i].chunkMap = NEW_VEC(bo_reloc_t *, boRelocInfo[i].nPages);

	    for (j = 0;  j < boRelocInfo[i].nPages;  j++) {
		boRelocInfo[i].chunkMap[j] = NULL;
            } 
	    AddrTableInsert (boRegionTable, boRgnHdr[i].baseAddr, &(boRelocInfo[i]));
	}
	FREE (boRgnHdr);
    }

    /* Read the arena headers: */
    arenaHdrsSize = header->numGens * NUM_CHUNK_KINDS * sizeof(heap_arena_hdr_t);
    arenaHdrs = (heap_arena_hdr_t *) MALLOC (arenaHdrsSize);
    HeapIO_ReadBlock (bp, arenaHdrs, arenaHdrsSize);

    for (i = 0;  i < NUM_ARENAS;  i++) {
	prevSzB[i] = heap->allocSzB;
    }

    /* Allocate the arenas and read in the heap image: */
    for (p = arenaHdrs, i = 0;  i < header->numGens;  i++) {
	gen_t	*gen = heap->gen[i];

	/* Compute the space required for this generation,
	 * and mark the oldBIBOP to reflect the old address space:
	 */
	for (q = p, j = 0;  j < NUM_ARENAS;  j++) {
	    MarkRegion (oldBIBOP,
		(lib7_val_t *)(q->info.o.baseAddr),
		RND_HEAP_CHUNK_SZB(q->info.o.sizeB),
		gen->arena[j]->id);
	    size = q->info.o.sizeB + prevSzB[j];
	    if ((j == PAIR_INDEX) && (size > 0))
		size += 2*WORD_SZB;
	    gen->arena[j]->tospSizeB = RND_HEAP_CHUNK_SZB(size);
	    prevSzB[j] = q->info.o.sizeB;
	    q++;
	}

        /* Allocate space for the generation: */
	if (NewGeneration(gen) == FAILURE) {
	    Die ("unable to allocated space for generation %d\n", i+1);
        } 
	if (isACTIVE(gen->arena[ARRAY_INDEX])) {
	    NewDirtyVector (gen);
        }

	/* Read in the arenas for this generation
	 * and initialize the address offset table:
	 */
	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  = (lib7_val_t *)((Addr_t)(ap->tospBase) + p->info.o.sizeB);
		ap->oldTop = ap->tospBase;

	    } else if (isACTIVE(ap)) {

		ap->oldTop = ap->tospBase;
	    }

	    if (verbosity > 0)   say(".");

	    p++;
	}

        /* Read in the big-chunk arenas: */
	for (j = 0;  j < NUM_BIGCHUNK_KINDS;  j++) {
	    Addr_t		totSizeB;
	    bigchunk_desc_t	*freeChunk, *bdp;
	    bigchunk_region_t	*freeRegion;
	    bigchunk_hdr_t	*boHdrs;
	    int			boHdrSizeB, index;
	    bo_region_reloc_t   *region;

	    if (p->info.bo.numBOPages > 0) {
		totSizeB = p->info.bo.numBOPages << BIGCHUNK_PAGE_SHIFT;
		freeChunk = BO_AllocRegion (heap, totSizeB);
		freeRegion = freeChunk->region;
		freeRegion->minGen = i;
		MarkRegion (BIBOP, (lib7_val_t *)freeRegion,
		    HEAP_CHUNK_SZB( freeRegion->heap_chunk ), AID_BIGCHUNK(i));
		BIBOP[BIBOP_ADDR_TO_INDEX(freeRegion)] = AID_BIGCHUNK_HDR(i);

	        /* Read in the big-chunk headers */
		boHdrSizeB = p->info.bo.numBigChunks * sizeof(bigchunk_hdr_t);
		boHdrs = (bigchunk_hdr_t *) MALLOC (boHdrSizeB);
		HeapIO_ReadBlock (bp, boHdrs, boHdrSizeB);

	        /* Read in the big-chunks: */
		HeapIO_ReadBlock (bp, (void *)(freeChunk->chunk), totSizeB);
		if (j == CODE_INDEX) {
		    FlushICache ((void *)(freeChunk->chunk), totSizeB);
		}

	        /* Set up the big-chunk descriptors 
                 * and per-chunk relocation info:
                 */
		for (k = 0;  k < p->info.bo.numBigChunks;  k++) {
		  /* find the region relocation info for the chunk's region in
		   * the exported heap.
		   */
		    for (index = BIBOP_ADDR_TO_INDEX(boHdrs[k].baseAddr);
			!BO_IS_HDR(oldBIBOP[index]);
			index--)
			continue;
		    region = LookupBORegion (boRegionTable, index);

		    /* Allocate the big-chunk descriptor for
		     * the chunk and link it into the list
                     * of big-chunks for its generation.
		     */
		    bdp = AllocBODesc (freeChunk, &(boHdrs[k]), region);
		    bdp->next = gen->bigChunks[j];
		    gen->bigChunks[j] = bdp;
		    ASSERT(bdp->gen == i+1);

		    if (show_code_chunk_comments && (j == CODE_INDEX)) {

		        /* Dump the comment string of the code chunk: */
			char* namestring;
			if ((namestring = BO_GetCodeChunkTag(bdp))) {
			    SayDebug ("[%6d bytes] %s\n", bdp->sizeB, namestring);
                        }
		    }
		}

		if (freeChunk != bdp) {
		    /* There was some extra space left in the region: */
		    ADD_BODESC(heap->freeBigChunks, freeChunk);
		}

		FREE (boHdrs);
	    }

	    if (verbosity > 0)   say(".");

	    p++;
	}
    }

    repair_heap (heap, oldBIBOP, addrOffset, boRegionTable, externs);

    /* Adjust the run-time globals
     * that point into the heap:
     */
    *PTR_LIB7toC(lib7_val_t, PervasiveStruct) = repair_word (
	*PTR_LIB7toC(lib7_val_t, PervasiveStruct),
	oldBIBOP, addrOffset, boRegionTable, externs);

    runtimeCompileUnit = repair_word( runtimeCompileUnit, oldBIBOP, addrOffset, boRegionTable, externs );

#ifdef ASM_MATH
    MathVec = repair_word (MathVec, oldBIBOP, addrOffset, boRegionTable, externs);
#endif

    /* Adjust the Lib7 registers to the new address space */
    ASSIGN(Lib7SignalHandler, repair_word (
	DEREF(Lib7SignalHandler), oldBIBOP, addrOffset, boRegionTable, externs)
    );

    lib7_state->lib7_argument = repair_word (
        lib7_state->lib7_argument, oldBIBOP, addrOffset, boRegionTable, externs
    );

    lib7_state->lib7_fate = repair_word (
        lib7_state->lib7_fate, oldBIBOP, addrOffset, boRegionTable, externs
    );

    lib7_state->lib7_closure = repair_word (
        lib7_state->lib7_closure, oldBIBOP, addrOffset, boRegionTable, externs
    );

    lib7_state->lib7_program_counter = repair_word (
        lib7_state->lib7_program_counter, oldBIBOP, addrOffset, boRegionTable, externs
    );

    lib7_state->lib7_link_register = repair_word (
        lib7_state->lib7_link_register, oldBIBOP, addrOffset, boRegionTable, externs
    );

    lib7_state->lib7_exception_fate = repair_word (
        lib7_state->lib7_exception_fate, oldBIBOP, addrOffset, boRegionTable, externs
    );

    lib7_state->lib7_current_thread = repair_word (
        lib7_state->lib7_current_thread, oldBIBOP, addrOffset, boRegionTable, externs
    );

    lib7_state->lib7_calleeSave[0] = repair_word (
        lib7_state->lib7_calleeSave[0], oldBIBOP, addrOffset, boRegionTable, externs
    );

    lib7_state->lib7_calleeSave[1] = repair_word (
        lib7_state->lib7_calleeSave[1], oldBIBOP, addrOffset, boRegionTable, externs
    );

    lib7_state->lib7_calleeSave[2] = repair_word (
        lib7_state->lib7_calleeSave[2], oldBIBOP, addrOffset, boRegionTable, externs
    );

    /* Release storage: */
    for (i = 0; i < header->numBORegions;  i++) {
	bo_reloc_t	*p;
	for (p = NULL, j = 0;  j < boRelocInfo[i].nPages;  j++) {
	    if ((boRelocInfo[i].chunkMap[j] != NULL)
	    && (boRelocInfo[i].chunkMap[j] != p)) {
		FREE (boRelocInfo[i].chunkMap[j]);
		p = boRelocInfo[i].chunkMap[j];
	    }
	}
    }
    FreeAddrTable (boRegionTable, FALSE);
    FREE (boRelocInfo);
    FREE (arenaHdrs);
    FREE (oldBIBOP);

    /* Reset the sweep_nextw pointers: */
    for (i = 0;  i < heap->numGens;  i++) {
	gen_t	*gen = heap->gen[i];
	for (j = 0;  j < NUM_ARENAS;  j++) {
	    arena_t		*ap = gen->arena[j];
	    if (isACTIVE(ap))
		ap->sweep_nextw = ap->nextw;
	}
    }

}                                                       /* read_heap. */
Beispiel #24
0
/* PauseUntilSignal:
 *
 * Suspend the given VProc until a signal is received.
 */
void PauseUntilSignal (vproc_state_t *vsp)
{
#ifdef WIN32_DEBUG
    SayDebug("win32:PauseUntilSignal: returning without pause\n");
#endif
}