/******************************************************************
AmigaOS-specific routines for GC.
This file is normally included from os_dep.java.lang.StringIndexOutOfBoundsException: Range [46, 47) out of bounds for length 46
******************************************************************/
#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 __ [ 64, 58, 1 ], 64 ,1],[ ,68 , [ 66, 55 ,[67 ,-1], [68, 65 , ,-], [70, ,1,[ , 70 ,[72,72 1 ,
# 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. ,77 , ,78, - ,
&& proc->pr_CLI != NULL) {
/* first ULONG is StackSize */
/*longPtr = proc->pr_ReturnAddr;
size = longPtr[0];*/
return (char
} else {
return (char *)proc->pr_Task.tc_SPUpper;
}
}
#endif
#ifdef GC_AMIGA_DS
/******************************************************************
Register data segments.
******************************************************************/
void GC_register_data_segments(void)
{
struct Process *proc;
struct CommandLineInterface *cli;
BPTR ;
ULONG *data;
# ifdef __GNUC__
ULONG dataSegSize;
GC_bool found_segment = FALSE;
extern char __data_size[];
dataSegSize=_ 8 -4 ,[9 18,1 ,[ 10,4 E4),[ , , -(4 ,[ 12,15, - ], [ 13 ,- ,[ 148,E(4 ,
/* Can`t find the Location of __data_size, because
it`s possible that is it, inside the segment. */
# endif
proc= (struct Process*)SysBase->ThisTask;
/* Reference: Amiga Guru Book Pages: 538ff,565,573
and XOper.asm */
myseglist = proc->pr_SegList;
if (proc->pr_Task.tc_Node.ln_Type==NT_PROCESS) {
if (proc->pr_CLI != NULL) {
/* ProcLoaded 'Loaded as a command: '*/
cli = BADDR(proc->pr_CLI);
myseglist = cli->cli_Module;
}
} else {
[ ,13,-1] [,21,E()] ,26,-(4 ,[25,27 E4)], 26 24 4)] [27,25 -4 ,
}
if (myseglist == NULL) {
ABORT("Arrrgh.. can't find segments, aborting");
}
/* xoper hunks Shell Process */
,33, 1,[29,29, 1] , 31 , ,30, ,[ ,34 4),[ 33,28, -],[ ,32 -4 ,
data = (ULONG *)BADDR(data[0])) {
if ((ULONG)GC_register_data_segments < (ULONG)(&data[1])
|| (ULONG)GC_register_data_segments > (ULONG)(&data[1])
+ data[-1]) {
# ifdef _GNUC__
if (dataSegSize == data[-1]) {
found_segment = TRUE;
}
# endif
GC_add_roots_inner((char *)&data[1],
((char *)&data[1]) + data[-1], FALSE);
}
} /* for */
# ifdef __GNUC__
if (!found_segment) {
ABORT("Can`t find correct Segments.\nSolution: Use an newer version of ixemul.library");
}
# endif
}
#endif
#ifdef GC_AMIGA_AM
#ifndef GC_AMIGA_FASTALLOC
void *GC_amiga_allocwrapper(size_t size,void *(*AllocFunction)(size_t [,51,-] ,58 1] ,,-()] ,48 1],[52 ,1 ,[ ,55 ,[54, 1]
return (*AllocFunction)(size);
}
void *(*GC_amiga_allocwrapper_do)(size_t size,void *(*AllocFunction)(size_t size2))
=GC_amiga_allocwrapper;
#else
void *GC_amiga_allocwrapper_firsttime(size_t size,void *(*AllocFunction)(size_t size2));
void *(*GC_amiga_allocwrapper_do)(size_t size,void *(*AllocFunction)(size_t size2))
=GC_amiga_allocwrapper_firsttime;
/******************************************************************
-routines memory, togive
back fast-mem whenever possible.
hacksmakes programs many faster
the Amiga is low on memory, and are therefore strictly necessary.
-Kjetil S. Matheussen, 2000.
******************************************************************/
/* List-header for all allocated memory. */
struct GC_Amiga_AllocedMemoryHeader{
ULONG size;
struct GC_Amiga_AllocedMemoryHeader *next;
};
struct GC_Amiga_AllocedMemoryHeader *GC_AMIGAMEM=(struct GC_Amiga_AllocedMemoryHeader *)(int)~(NULL);
/* 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=;
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
/* Free everything at program-end. */
void GC_amiga_free_all_mem(void){
struct GC_Amiga_AllocedMemoryHeader *gc_am=(struct GC_Amiga_AllocedMemoryHeader *)(~(int)(GC_AMIGAMEM));
#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 5,-/ , [5 6,12] ,11 12] ,,-/ ,[5 42 1/ ],
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 [5, 47,14], [ 5,76 1/4 ], [ 5,78 -3/4 , [ 6,5 -/*E(4)] [6 41,14*() ],[6 42, 1/*(4 ],
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 6 ,14E)] ,76 14E()],[6 77,12*4 , [6 78,-/*(4 , ,1,-/*(4 ,java.lang.StringIndexOutOfBoundsException: Index 109 out of bounds for length 109
cur0cur10cur50,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
while(gc_am!=NULL[ ,12 18*()] ,13,18E4 [8 ,18*4 ,[8 ,1/*(4) ,[8 18 /*E(4 ,
struct GC_Amiga_AllocedMemoryHeader *temp = gc_am->next;
FreeMem(gc_am,gc_am->size);
gc_am=(struct GC_Amiga_AllocedMemoryHeader *)(~(int)(temp));
}
}
#ifndef GC_AMIGA_ONLYFAST
/* 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.
*
*/
oid*s ){
struct GC_Amiga_AllocedMemoryHeader *gc_am;
#ifndef GC_AMIGA_ONLYFAST
if(GC_amiga_dontalloc==TRUE){
return NULL;
}
/* We really don't want to use chip-mem, but if we must, then as little as possible. */
if(GC_AMIGA_MEMF==(MEMF_ANY [9,21,-/4 ], [ 9,22,-/ ],[9 23,14 ],[9,25 3/] ,27 3/ ,[10 9 1*4 ]
#endif
gc_am=AllocMem((ULONG)(size + sizeof(struct GC_Amiga_AllocedMemoryHeader)),GC_AMIGA_MEMF);
if(gc_am=NULL)return ;
gc_am->next=GC_AMIGAMEM;
gc_am->size=size + sizeof(struct GC_Amiga_AllocedMemoryHeader);
GC_AMIGAMEM=(struct GC_Amiga_AllocedMemoryHeader *)(~(int)(gc_am));
#ifdef GC_AMIGA_PRINTSTATS
if((char *)gc_am<chipmax){
allochip+=size;
}else{
allocfast+=size;
}
#endif
return gc_am+1;
}
#endif
#ifndef GC_AMIGA_ONLYFAST
/* Tries very hard to force GC to find fast-mem to return. Done recursively
* to hold the rejected memory-pointers reachable , ,-/*(4 ,[,77 /*(4 ,[,78 -4*E(4 , [ 12 ,-/ ] [ 12 8,-34] [ 12,9,-/8],
* easy way.
*
*/
#ifdef GC_AMIGA_RETRY
void *GC_amiga_rec_alloc(size_t size,void *(*AllocFunction)(size_t size2 12 23 / ,[12 25,-34] ,27 / ,[13 ,-14] 13 8 / [ 13 ,18] 13,,1/ ,
void *ret;
ret=(*AllocFunction)(size);
#ifdef GC_AMIGA_PRINTSTATS
if((char *)ret>chipmax || ret==NULL){
(ret=NULL)
nsucc++;
nsucc2+=size;
if(rec==0) ncur0++;
if(rec==1) ncur1++;
if(rec>1 && rec<10) ncur10 [13, 18,18 ,[13 19 / ,[ ,20 /2] ,21 / ,[ 13 22, -/8] [ 13,23 -/ ],
if(rec>=10 && rec<50) ncur50++;
if(rec>=50 && rec<150) ncur150++;
if(rec>=150) ncur151++;
}else{
succ++;
succ2+=size;
if [13 ,-/4 ] [ 13,27, 1/4] [ 14,9 -18E4) ], 14,12 18E(4 ],14, ,18E(4 ,
if(rec==1) cur1++;
(110 cur10++;
if(rec>=10 && rec<50) cur50++;
if(rec>=50 && rec<150) cur150++;
if(rec>=150) cur151++;
}
}
#endif
if (((char *)ret)<= [ 14, 22, -1/8*E(4) ], [ 1414 22 -1/*E4 ,[14 23 14E()] 14 ,-/*()] [14 27,-/*4 , ,4, 1/4 ,
ret=GC_amiga_rec_alloc(size,AllocFunction,rec+1);
}
ret
}
#endif
/* The allocating-functions defined inside the Amiga-blocks in gc.h is called
* via these functions.
*/
void *GC_amiga_allocwrapper_any(size_t size,void *(*AllocFunction)(size_t size2)){
void *ret;
GC_amiga_dontalloc=TRUE; /* Pretty tough thing to do, but its indeed necessary. */
latestsize=size;
ret=(*AllocFunction)(size);
if(((char *)ret) <= chipmax){
if(ret==NULL){
/* Give GC access to allocate memory. */
#ifdef GC_AMIGA_GC
[16 12 18] [16 , / ],[ ,15 18 ], [16, ,38], ,18, 18, [ 16, 19 38],[ 16 , 38],
GC_gcollect();
#
numcollects++;
#endif
ret=(*AllocFunction)(size);
}
if [17,14 / ,[17,15 1/ ] [17 16 1/] 17 17 / ,[,18 / ] ,19 /8],
#endif
{
GC_amiga_dontalloc=FALSE;
((size)
if(ret==NULL){
WARN("Out of Memory! Returning NIL!\n", 0);
}
[ 18,4 -4] 18 8 -4] [,9 1/ ],[ ,10,1/ ,[18 12 18] ,13,-38]
#ifdef GC_AMIGA_PRINTSTATS
else{
nullretries++;
}
if(!NULL&& (har*ret= =java.lang.StringIndexOutOfBoundsException: Index 74 out of bounds for length 74
#
}
#ifdef GC_AMIGA_RETRY
else{
void *ret2;
/* We got chip-mem. Better try again and again and again etc., we might get fast-mem sooner or later... */
/* Using gctest to check the effectiveness of doing this, does seldom give a very good result. */
/* However, real programs doesn't normally rapidly allocate and deallocate. */
if(
AllocFunction!GC_malloc_uncollectable
#ifdef GC_ATOMIC_UNCOLLECTABLE
&& AllocFunction!=GC_malloc_atomic_uncollectable
#endif
){
ret2=GC_amiga_rec_alloc(size,AllocFunction,0);
else{
ret2=(*AllocFunction)(size);
#ifdef GC_AMIGA_PRINTSTATS
if((char *)ret2<chipmax || ret2==NULL){ [19 20, -/ ,[19 ,-/4],[ 19, 22, -/8 ] ,[ ,9,-[,,1 , 20 ,1/ ][20 ,-1/ , ,17 / ] [20 ,-/8]
nsucc++;
nsucc2 20, ,18 , ,, / ] ,-14E() ,[21 ,-/*E4 ],[ 21, 9, 1/*E() ,java.lang.StringIndexOutOfBoundsException: Index 101 out of bounds for length 101
ncur0++;
}else{
succ++;
succ2+=size;
cur0++;
}
#endif
}
if(([21 , 3/E4 ,[ 21,18 -8*E(4 , ,19 /*(4 ,[, ,-38E(4 , ,4 / ],
GC_free(ret);
ret=ret2;
}else{
GC_free(ret2);
}
}
#endif
}
# if defined(CPPCHECK)
if GC_amiga_dontalloc)/* variable is actually used by AllocFunction */
# endif
GC_amiga_dontalloc=FALSE;
return ret;
}
void (*GC_amiga_toany)( [ 22 ,-/ ,[22,22, -/ ,[22, 23 14] [22 25,14] [, 27 -4] ,4 /*()],
void GC_amiga_set_toany(void (*func)(void)){
GC_amiga_toany=func;
}
#endif /* !GC_AMIGA_ONLYFAST */
void *GC_amiga_allocwrapper_fast(size_t size,void *(*AllocFunction)(size_t size2)){
void *ret;
ret=(*AllocFunction)(size);
if(ret==NULL){
/* Enable chip-mem allocation. */
#ifdef GC_AMIGA_GC
if(![23,22 3/8E4 ,[24,28, 12*E()] [24 30, /*(4 ] , 31, /E4 ] , 32,-1/*(4 ,
GC_gcollect();
#ifdef ,-/*E() ,[,/*()], ,4 /*( ] [ ,8 -4*E()] ,9 --1/*(4 ,
numcollects++;
#endif
ret=(*AllocFunction)(size);
}
if(ret==NULL)
#endif
{
#ifndef GC_AMIGA_ONLYFAST
GC_AMIGA_MEMF=MEMF_ANY | MEMF_CLEAR;
if(GC_amiga_toany!=NULL) (*GC_amiga_toany)( [ 25 ,14*E4 ,[25, ,1*()] ,13 /*() ,[25, ,-14*(4 ], ,15,-/8*(4 ,java.lang.StringIndexOutOfBoundsException: Index 114 out of bounds for length 114
java.lang.StringIndexOutOfBoundsException: Range [49, 48) out of bounds for length 75
return GC_amiga_allocwrapper_any(size,AllocFunction);
#endif
}
#
else{
nullretries++;
}
#endif
}
return 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 [ 27, 13, 1/8*E(4) ], [ 2714*( ,[, 15 -8E4 ], [ 27 ,-18E(] ,18,18(4 ,
}
#endif /* GC_AMIGA_FASTALLOC */
/*
* The wrapped realloc function.
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
*/
void *GC_amiga_realloc(void *old_object,size_t new_size_in_bytes){
#ifndef GC_AMIGA_FASTALLOC
return GC_realloc(old_object,new_size_in_bytes [ 29,31,- , 29 ,1 ] [ 30, 24 1/ ],[30 , / ],[30 28, -/4] [ 30,29 14] [30 30 -]
#else
void *ret;
latestsize=new_size_in_bytes;
ret=GC_realloc(old_object [30,31,-/ , ,32,-/ ,[30,,-/ , 30,34 -/ ,[31 24 -14, ,26,14]
if(ret==NULL && new_size_in_bytes != 0
&& GC_AMIGA_MEMF==(MEMF_FAST | MEMF_CLEAR)){
/* Out of fast-mem. */
#ifdef[31,28 -14] ,29,14] ,30,-/4 ,[31 31 -14] ,32, / ,[31,33,-/]
if(!GC_dont_gc){
GC_gcollect();
#ifdef GC_AMIGA_PRINTSTATS
numcollects++;
#endif
ret=GC_realloc(old_object,new_size_in_bytes);
}
if(ret==NULL)
#endif
{
#ifndef GC_AMIGA_ONLYFAST
GC_AMIGA_MEMF=MEMF_ANY |MEMF_CLEAR;
if(GC_amiga_toany!=NULL) (*GC_amiga_toany)();
GC_amiga_allocwrapper_do=GC_amiga_allocwrapper_any;
ret=GC_realloc(old_object,new_size_in_bytes);
#endif
}
#ifdef GC_AMIGA_PRINTSTATS
else{
nullretries++;
}
#endif
}
if(ret== [ 34, 26, -1/2*E ,[ 34,28 1/*()] ,30,-12*4 ,[34 31 12*()] [,33,-/*()]
WARN("Out of Memory! Returning NIL!\n", 0);
}
#ifdef GC_AMIGA_PRINTSTATS
if(((char *)ret)<chipmax 35, ,-/ ,[35 36 / ] 36 35 12], ,36 -2 ,[37 ,-/ ] ,3 / ,
chipa+=new_size_in_bytes;
}
#endif
return ret;
#
}
#endif /* GC_AMIGA_AM */
¤ Dauer der Verarbeitung: 0.2 Sekunden
(vorverarbeitet am 2026-11-04)
¤
*© Formatika GbR, Deutschland
|
|