#if !defined(GC_AMIGA_DEF) && !defined(GC_AMIGA_SB) && !defined(GC_AMIGA_DS) && !defined(GC_AMIGA_AM) # include "private/gc_priv.h" # include <stdio.h> # include <signal.h> # define GC_AMIGA_DEF # define GC_AMIGA_SB # define GC_AMIGA_DS # define GC_AMIGA_AM #endif
#ifdef GC_AMIGA_DEF
# ifndef __GNUC__ # include <exec/exec.h> # endif # include <proto/exec.h> # include <proto/dos.h> # include <dos/dosextens.h> # include <workbench/startup.h>
#endif
#ifdef GC_AMIGA_SB
/****************************************************************** Find the base of the stack.
******************************************************************/
ptr_t GC_get_main_stack_base(void)
{ struct Process *proc = (struct Process*)SysBase->ThisTask;
/* Reference: Amiga Guru Book Pages: 42,567,574 */ if (proc->pr_Task.tc_Node.ln_Type==NT_PROCESS
&& proc->pr_CLI != NULL) { /* first ULONG is StackSize */ /*longPtr = proc->pr_ReturnAddr;
size = longPtr[0];*/
/****************************************************************** Amiga-specific routines to obtain memory, and force GC to give back fast-mem whenever possible. These hacks makes gc-programs go many times faster when the Amiga is low on memory, and are therefore strictly necessary.
-Kjetil S. Matheussen, 2000.
******************************************************************/
/* Type of memory. Once in the execution of a program, this might change to MEMF_ANY|MEMF_CLEAR */
ULONG GC_AMIGA_MEMF = MEMF_FAST | MEMF_CLEAR;
/* Prevents GC_amiga_get_mem from allocating memory if this one is TRUE. */ #ifndef GC_AMIGA_ONLYFAST BOOL GC_amiga_dontalloc=FALSE; #endif
#ifdef GC_AMIGA_PRINTSTATS int succ=0,succ2=0; int nsucc=0,nsucc2=0; int nullretries=0; int numcollects=0; int chipa=0; int allochip=0; int allocfast=0; int cur0=0; int cur1=0; int cur10=0; int cur50=0; int cur150=0; int cur151=0; int ncur0=0; int ncur1=0; int ncur10=0; int ncur50=0; int ncur150=0; int ncur151=0; #endif
#ifdef GC_AMIGA_PRINTSTATS
printf("\n\n" "%d bytes of chip-mem, and %d bytes of fast-mem where allocated from the OS.\n",
allochip,allocfast
);
printf( "%d bytes of chip-mem were returned from the GC_AMIGA_FASTALLOC supported allocating functions.\n",
chipa
);
printf("\n");
printf("GC_gcollect was called %d times to avoid returning NULL or start allocating with the MEMF_ANY flag.\n",numcollects);
printf("%d of them was a success. (the others had to use allocation from the OS.)\n",nullretries);
printf("\n");
printf("Succeeded forcing %d gc-allocations (%d bytes) of chip-mem to be fast-mem.\n",succ,succ2);
printf("Failed forcing %d gc-allocations (%d bytes) of chip-mem to be fast-mem.\n",nsucc,nsucc2);
printf("\n");
printf( "Number of retries before succeeding a chip->fast force:\n" "0: %d, 1: %d, 2-9: %d, 10-49: %d, 50-149: %d, >150: %d\n",
cur0,cur1,cur10,cur50,cur150,cur151
);
printf( "Number of retries before giving up a chip->fast force:\n" "0: %d, 1: %d, 2-9: %d, 10-49: %d, 50-149: %d, >150: %d\n",
ncur0,ncur1,ncur10,ncur50,ncur150,ncur151
); #endif
/* All memory with address lower than this one is chip-mem. */
char *chipmax;
/* * Always set to the last size of memory tried to be allocated. * Needed to ensure allocation when the size is bigger than 100000. *
*/
size_t latestsize;
#endif
#ifdef GC_AMIGA_FASTALLOC
/* * The actual function that is called with the GET_MEM macro. *
*/
/* We really don't want to use chip-mem, but if we must, then as little as possible. */ if(GC_AMIGA_MEMF==(MEMF_ANY|MEMF_CLEAR) && size>100000 && latestsize<50000) return NULL; #endif
/* Tries very hard to force GC to find fast-mem to return. Done recursively * to hold the rejected memory-pointers reachable from the collector in an * easy way. *
*/ #ifdef GC_AMIGA_RETRY void *GC_amiga_rec_alloc(size_t size,void *(*AllocFunction)(size_t size2),constint rec){ void *ret;
void *GC_amiga_allocwrapper_firsttime(size_t size,void *(*AllocFunction)(size_t size2)){
atexit(&GC_amiga_free_all_mem);
chipmax=(char *)SysBase->MaxLocMem; /* For people still having SysBase in chip-mem, this might speed up a bit. */
GC_amiga_allocwrapper_do=GC_amiga_allocwrapper_fast; return GC_amiga_allocwrapper_fast(size,AllocFunction);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.