mirror of
https://github.com/vishapoberon/compiler.git
synced 2026-04-06 18:02:25 +00:00
Completely update addresing vars in heap from LONGINT to SYSTEM.UINTPTR.
This commit is contained in:
parent
db18774de1
commit
4ec2e61ed0
6 changed files with 380 additions and 379 deletions
|
|
@ -51,15 +51,15 @@ typedef
|
|||
Heap_ModuleName name;
|
||||
int32 refcnt;
|
||||
Heap_Cmd cmds;
|
||||
int32 types;
|
||||
uintptr types;
|
||||
Heap_EnumProc enumPtrs;
|
||||
int32 reserved1, reserved2;
|
||||
} Heap_ModuleDesc;
|
||||
|
||||
|
||||
export SYSTEM_PTR Heap_modules;
|
||||
static int32 Heap_freeList[10];
|
||||
static int32 Heap_bigBlocks;
|
||||
static uintptr Heap_freeList[10];
|
||||
static uintptr Heap_bigBlocks;
|
||||
export uintptr Heap_allocated;
|
||||
static BOOLEAN Heap_firstTry;
|
||||
static uintptr Heap_heap, Heap_heapend;
|
||||
|
|
@ -75,18 +75,18 @@ export LONGINT *Heap_FinDesc__typ;
|
|||
export LONGINT *Heap__1__typ;
|
||||
|
||||
static void Heap_CheckFin (void);
|
||||
static void Heap_ExtendHeap (int32 blksz);
|
||||
static void Heap_ExtendHeap (uintptr blksz);
|
||||
export void Heap_FINALL (void);
|
||||
static void Heap_Finalize (void);
|
||||
export void Heap_GC (BOOLEAN markStack);
|
||||
static void Heap_HeapSort (int32 n, int32 *a, LONGINT a__len);
|
||||
static void Heap_HeapSort (uintptr n, uintptr *a, LONGINT a__len);
|
||||
export void Heap_INCREF (Heap_Module m);
|
||||
export void Heap_InitHeap (void);
|
||||
export void Heap_Lock (void);
|
||||
static void Heap_Mark (int32 q);
|
||||
static void Heap_MarkCandidates (int32 n, int32 *cand, LONGINT cand__len);
|
||||
static void Heap_Mark (uintptr q);
|
||||
static void Heap_MarkCandidates (uintptr n, uintptr *cand, LONGINT cand__len);
|
||||
static void Heap_MarkP (SYSTEM_PTR p);
|
||||
static void Heap_MarkStack (int32 n, int32 *cand, LONGINT cand__len);
|
||||
static void Heap_MarkStack (uintptr n, uintptr *cand, LONGINT cand__len);
|
||||
export SYSTEM_PTR Heap_NEWBLK (uintptr size);
|
||||
export SYSTEM_PTR Heap_NEWREC (uintptr tag);
|
||||
static uintptr Heap_NewChunk (uintptr blksz);
|
||||
|
|
@ -95,11 +95,11 @@ export SYSTEM_PTR Heap_REGMOD (Heap_ModuleName name, Heap_EnumProc enumPtrs);
|
|||
export void Heap_REGTYP (Heap_Module m, uintptr typ);
|
||||
export void Heap_RegisterFinalizer (SYSTEM_PTR obj, Heap_Finalizer finalize);
|
||||
static void Heap_Scan (void);
|
||||
static void Heap_Sift (int32 l, int32 r, int32 *a, LONGINT a__len);
|
||||
static void Heap_Sift (uintptr l, uintptr r, uintptr *a, LONGINT a__len);
|
||||
export void Heap_Unlock (void);
|
||||
|
||||
extern void *Heap__init();
|
||||
extern LONGINT Platform_MainStackFrame;
|
||||
extern uintptr Platform_MainStackFrame;
|
||||
extern uintptr Platform_OSAllocate(uintptr size);
|
||||
#define Heap_FetchAddress(pointer) (uintptr)(*((void**)((uintptr)pointer)))
|
||||
#define Heap_HeapModuleInit() Heap__init()
|
||||
|
|
@ -156,7 +156,7 @@ void Heap_REGCMD (Heap_Module m, Heap_CmdName name, Heap_Command cmd)
|
|||
|
||||
void Heap_REGTYP (Heap_Module m, uintptr typ)
|
||||
{
|
||||
__PUT(typ, m->types, int32);
|
||||
__PUT(typ, m->types, uintptr);
|
||||
m->types = typ;
|
||||
}
|
||||
|
||||
|
|
@ -174,8 +174,8 @@ static uintptr Heap_NewChunk (uintptr blksz)
|
|||
__PUT(chnk + 4, chnk + (12 + blksz), uintptr);
|
||||
__PUT(chnk + 12, chnk + 16, uintptr);
|
||||
__PUT(chnk + 16, blksz, uintptr);
|
||||
__PUT(chnk + 20, -4, int32);
|
||||
__PUT(chnk + 24, Heap_bigBlocks, int32);
|
||||
__PUT(chnk + 20, -4, uintptr);
|
||||
__PUT(chnk + 24, Heap_bigBlocks, uintptr);
|
||||
Heap_bigBlocks = chnk + 12;
|
||||
Heap_heapsize += blksz;
|
||||
}
|
||||
|
|
@ -183,9 +183,9 @@ static uintptr Heap_NewChunk (uintptr blksz)
|
|||
return _o_result;
|
||||
}
|
||||
|
||||
static void Heap_ExtendHeap (int32 blksz)
|
||||
static void Heap_ExtendHeap (uintptr blksz)
|
||||
{
|
||||
int32 size, chnk, j, next;
|
||||
uintptr size, chnk, j, next;
|
||||
if (blksz > 160000) {
|
||||
size = blksz;
|
||||
} else {
|
||||
|
|
@ -203,8 +203,8 @@ static void Heap_ExtendHeap (int32 blksz)
|
|||
j = next;
|
||||
next = Heap_FetchAddress(j);
|
||||
}
|
||||
__PUT(chnk, next, int32);
|
||||
__PUT(j, chnk, int32);
|
||||
__PUT(chnk, next, uintptr);
|
||||
__PUT(j, chnk, uintptr);
|
||||
}
|
||||
if (next == 0) {
|
||||
Heap_heapend = Heap_FetchAddress(chnk + 4);
|
||||
|
|
@ -236,10 +236,10 @@ SYSTEM_PTR Heap_NEWREC (uintptr tag)
|
|||
restsize = __ASHL(di, 4);
|
||||
end = adr + restsize;
|
||||
__PUT(end + 4, blksz, uintptr);
|
||||
__PUT(end + 8, -4, int32);
|
||||
__PUT(end, end + 4, int32);
|
||||
__PUT(end + 8, -4, uintptr);
|
||||
__PUT(end, end + 4, uintptr);
|
||||
__PUT(adr + 4, restsize, uintptr);
|
||||
__PUT(adr + 12, Heap_freeList[di], int32);
|
||||
__PUT(adr + 12, Heap_freeList[di], uintptr);
|
||||
Heap_freeList[di] = adr;
|
||||
adr += restsize;
|
||||
}
|
||||
|
|
@ -280,8 +280,8 @@ SYSTEM_PTR Heap_NEWREC (uintptr tag)
|
|||
restsize = t - blksz;
|
||||
end = adr + restsize;
|
||||
__PUT(end + 4, blksz, uintptr);
|
||||
__PUT(end + 8, -4, int32);
|
||||
__PUT(end, end + 4, int32);
|
||||
__PUT(end + 8, -4, uintptr);
|
||||
__PUT(end, end + 4, uintptr);
|
||||
if (restsize > 144) {
|
||||
__PUT(adr + 4, restsize, uintptr);
|
||||
} else {
|
||||
|
|
@ -294,7 +294,7 @@ SYSTEM_PTR Heap_NEWREC (uintptr tag)
|
|||
if (restsize > 0) {
|
||||
di = __ASHR(restsize, 4);
|
||||
__PUT(adr + 4, restsize, uintptr);
|
||||
__PUT(adr + 12, Heap_freeList[di], int32);
|
||||
__PUT(adr + 12, Heap_freeList[di], uintptr);
|
||||
Heap_freeList[di] = adr;
|
||||
}
|
||||
}
|
||||
|
|
@ -303,16 +303,16 @@ SYSTEM_PTR Heap_NEWREC (uintptr tag)
|
|||
i = adr + 16;
|
||||
end = adr + blksz;
|
||||
while (i < end) {
|
||||
__PUT(i, 0, int32);
|
||||
__PUT(i + 4, 0, int32);
|
||||
__PUT(i + 8, 0, int32);
|
||||
__PUT(i + 12, 0, int32);
|
||||
__PUT(i, 0, uintptr);
|
||||
__PUT(i + 4, 0, uintptr);
|
||||
__PUT(i + 8, 0, uintptr);
|
||||
__PUT(i + 12, 0, uintptr);
|
||||
i += 16;
|
||||
}
|
||||
__PUT(adr + 12, 0, int32);
|
||||
__PUT(adr + 12, 0, uintptr);
|
||||
__PUT(adr, tag, uintptr);
|
||||
__PUT(adr + 4, 0, int32);
|
||||
__PUT(adr + 8, 0, int32);
|
||||
__PUT(adr + 4, 0, uintptr);
|
||||
__PUT(adr + 8, 0, uintptr);
|
||||
Heap_allocated += blksz;
|
||||
Heap_Unlock();
|
||||
_o_result = (SYSTEM_PTR)(uintptr)(adr + 4);
|
||||
|
|
@ -327,29 +327,29 @@ SYSTEM_PTR Heap_NEWBLK (uintptr size)
|
|||
Heap_Lock();
|
||||
blksz = __ASHL(__ASHR(size + 31, 4), 4);
|
||||
new = Heap_NEWREC((uintptr)&blksz);
|
||||
tag = (((int32)(uintptr)new) + blksz) - 12;
|
||||
__PUT(tag - 4, 0, int32);
|
||||
tag = ((uintptr)(uintptr)new + blksz) - 12;
|
||||
__PUT(tag - 4, 0, uintptr);
|
||||
__PUT(tag, blksz, uintptr);
|
||||
__PUT(tag + 4, -4, int32);
|
||||
__PUT((int32)(uintptr)new - 4, tag, uintptr);
|
||||
__PUT(tag + 4, -4, uintptr);
|
||||
__PUT((uintptr)(uintptr)new - 4, tag, uintptr);
|
||||
Heap_Unlock();
|
||||
_o_result = new;
|
||||
return _o_result;
|
||||
}
|
||||
|
||||
static void Heap_Mark (int32 q)
|
||||
static void Heap_Mark (uintptr q)
|
||||
{
|
||||
int32 p, tag, fld, n, offset, tagbits;
|
||||
uintptr p, tag, offset, fld, n, tagbits;
|
||||
if (q != 0) {
|
||||
tagbits = Heap_FetchAddress(q - 4);
|
||||
if (!__ODD(tagbits)) {
|
||||
__PUT(q - 4, tagbits + 1, int32);
|
||||
__PUT(q - 4, tagbits + 1, uintptr);
|
||||
p = 0;
|
||||
tag = tagbits + 4;
|
||||
for (;;) {
|
||||
__GET(tag, offset, int32);
|
||||
if (offset < 0) {
|
||||
__PUT(q - 4, (tag + offset) + 1, int32);
|
||||
__GET(tag, offset, uintptr);
|
||||
if (__BIT((uintptr)&offset, 31)) {
|
||||
__PUT(q - 4, (tag + offset) + 1, uintptr);
|
||||
if (p == 0) {
|
||||
break;
|
||||
}
|
||||
|
|
@ -357,7 +357,7 @@ static void Heap_Mark (int32 q)
|
|||
q = p;
|
||||
tag = Heap_FetchAddress(q - 4);
|
||||
tag -= 1;
|
||||
__GET(tag, offset, int32);
|
||||
__GET(tag, offset, uintptr);
|
||||
fld = q + offset;
|
||||
p = Heap_FetchAddress(fld);
|
||||
__PUT(fld, (SYSTEM_PTR)(uintptr)n, SYSTEM_PTR);
|
||||
|
|
@ -367,8 +367,8 @@ static void Heap_Mark (int32 q)
|
|||
if (n != 0) {
|
||||
tagbits = Heap_FetchAddress(n - 4);
|
||||
if (!__ODD(tagbits)) {
|
||||
__PUT(n - 4, tagbits + 1, int32);
|
||||
__PUT(q - 4, tag + 1, int32);
|
||||
__PUT(n - 4, tagbits + 1, uintptr);
|
||||
__PUT(q - 4, tag + 1, uintptr);
|
||||
__PUT(fld, (SYSTEM_PTR)(uintptr)p, SYSTEM_PTR);
|
||||
p = q;
|
||||
q = n;
|
||||
|
|
@ -384,7 +384,7 @@ static void Heap_Mark (int32 q)
|
|||
|
||||
static void Heap_MarkP (SYSTEM_PTR p)
|
||||
{
|
||||
Heap_Mark((int32)(uintptr)p);
|
||||
Heap_Mark((uintptr)(uintptr)p);
|
||||
}
|
||||
|
||||
static void Heap_Scan (void)
|
||||
|
|
@ -409,14 +409,14 @@ static void Heap_Scan (void)
|
|||
start = adr - freesize;
|
||||
__PUT(start, start + 4, uintptr);
|
||||
__PUT(start + 4, freesize, uintptr);
|
||||
__PUT(start + 8, -4, int32);
|
||||
__PUT(start + 8, -4, uintptr);
|
||||
i = __ASHR(freesize, 4);
|
||||
freesize = 0;
|
||||
if (i < 9) {
|
||||
__PUT(start + 12, Heap_freeList[i], int32);
|
||||
__PUT(start + 12, Heap_freeList[i], uintptr);
|
||||
Heap_freeList[i] = start;
|
||||
} else {
|
||||
__PUT(start + 12, Heap_bigBlocks, int32);
|
||||
__PUT(start + 12, Heap_bigBlocks, uintptr);
|
||||
Heap_bigBlocks = start;
|
||||
}
|
||||
}
|
||||
|
|
@ -435,14 +435,14 @@ static void Heap_Scan (void)
|
|||
start = adr - freesize;
|
||||
__PUT(start, start + 4, uintptr);
|
||||
__PUT(start + 4, freesize, uintptr);
|
||||
__PUT(start + 8, -4, int32);
|
||||
__PUT(start + 8, -4, uintptr);
|
||||
i = __ASHR(freesize, 4);
|
||||
freesize = 0;
|
||||
if (i < 9) {
|
||||
__PUT(start + 12, Heap_freeList[i], int32);
|
||||
__PUT(start + 12, Heap_freeList[i], uintptr);
|
||||
Heap_freeList[i] = start;
|
||||
} else {
|
||||
__PUT(start + 12, Heap_bigBlocks, int32);
|
||||
__PUT(start + 12, Heap_bigBlocks, uintptr);
|
||||
Heap_bigBlocks = start;
|
||||
}
|
||||
}
|
||||
|
|
@ -450,9 +450,9 @@ static void Heap_Scan (void)
|
|||
}
|
||||
}
|
||||
|
||||
static void Heap_Sift (int32 l, int32 r, int32 *a, LONGINT a__len)
|
||||
static void Heap_Sift (uintptr l, uintptr r, uintptr *a, LONGINT a__len)
|
||||
{
|
||||
int32 i, j, x;
|
||||
uintptr i, j, x;
|
||||
j = l;
|
||||
x = a[j];
|
||||
for (;;) {
|
||||
|
|
@ -469,9 +469,9 @@ static void Heap_Sift (int32 l, int32 r, int32 *a, LONGINT a__len)
|
|||
a[i] = x;
|
||||
}
|
||||
|
||||
static void Heap_HeapSort (int32 n, int32 *a, LONGINT a__len)
|
||||
static void Heap_HeapSort (uintptr n, uintptr *a, LONGINT a__len)
|
||||
{
|
||||
int32 l, r, x;
|
||||
uintptr l, r, x;
|
||||
l = __ASHR(n, 1);
|
||||
r = n - 1;
|
||||
while (l > 0) {
|
||||
|
|
@ -487,9 +487,9 @@ static void Heap_HeapSort (int32 n, int32 *a, LONGINT a__len)
|
|||
}
|
||||
}
|
||||
|
||||
static void Heap_MarkCandidates (int32 n, int32 *cand, LONGINT cand__len)
|
||||
static void Heap_MarkCandidates (uintptr n, uintptr *cand, LONGINT cand__len)
|
||||
{
|
||||
int32 chnk, adr, tag, next, lim, lim1, i, ptr, size;
|
||||
uintptr chnk, adr, tag, next, lim, lim1, i, ptr, size;
|
||||
chnk = Heap_heap;
|
||||
i = 0;
|
||||
lim = cand[n - 1];
|
||||
|
|
@ -527,7 +527,7 @@ static void Heap_MarkCandidates (int32 n, int32 *cand, LONGINT cand__len)
|
|||
static void Heap_CheckFin (void)
|
||||
{
|
||||
Heap_FinNode n;
|
||||
int32 tag;
|
||||
uintptr tag;
|
||||
n = Heap_fin;
|
||||
while (n != NIL) {
|
||||
tag = Heap_FetchAddress(n->obj - 4);
|
||||
|
|
@ -576,10 +576,10 @@ void Heap_FINALL (void)
|
|||
}
|
||||
}
|
||||
|
||||
static void Heap_MarkStack (int32 n, int32 *cand, LONGINT cand__len)
|
||||
static void Heap_MarkStack (uintptr n, uintptr *cand, LONGINT cand__len)
|
||||
{
|
||||
SYSTEM_PTR frame;
|
||||
int32 inc, nofcand, sp, p, stack0;
|
||||
uintptr inc, nofcand, sp, p, stack0;
|
||||
struct Heap__1 align;
|
||||
if (n > 0) {
|
||||
Heap_MarkStack(n - 1, cand, cand__len);
|
||||
|
|
@ -596,7 +596,7 @@ static void Heap_MarkStack (int32 n, int32 *cand, LONGINT cand__len)
|
|||
inc = -inc;
|
||||
}
|
||||
while (sp != stack0) {
|
||||
__GET(sp, p, int32);
|
||||
__GET(sp, p, uintptr);
|
||||
if ((p > Heap_heap && p < Heap_heapend)) {
|
||||
if (nofcand == cand__len) {
|
||||
Heap_HeapSort(nofcand, (void*)cand, cand__len);
|
||||
|
|
@ -618,8 +618,8 @@ static void Heap_MarkStack (int32 n, int32 *cand, LONGINT cand__len)
|
|||
void Heap_GC (BOOLEAN markStack)
|
||||
{
|
||||
Heap_Module m;
|
||||
int32 i0, i1, i2, i3, i4, i5, i6, i7, i8, i9, i10, i11, i12, i13, i14, i15, i16, i17, i18, i19, i20, i21, i22, i23;
|
||||
int32 cand[10000];
|
||||
uintptr i0, i1, i2, i3, i4, i5, i6, i7, i8, i9, i10, i11, i12, i13, i14, i15, i16, i17, i18, i19, i20, i21, i22, i23;
|
||||
uintptr cand[10000];
|
||||
if (Heap_lockdepth == 0 || (Heap_lockdepth == 1 && !markStack)) {
|
||||
Heap_Lock();
|
||||
m = (Heap_Module)(uintptr)Heap_modules;
|
||||
|
|
@ -699,7 +699,7 @@ void Heap_RegisterFinalizer (SYSTEM_PTR obj, Heap_Finalizer finalize)
|
|||
{
|
||||
Heap_FinNode f;
|
||||
__NEW(f, Heap_FinDesc);
|
||||
f->obj = (int32)(uintptr)obj;
|
||||
f->obj = (uintptr)(uintptr)obj;
|
||||
f->finalize = finalize;
|
||||
f->marked = 1;
|
||||
f->next = Heap_fin;
|
||||
|
|
@ -710,7 +710,7 @@ void Heap_InitHeap (void)
|
|||
{
|
||||
Heap_heap = Heap_NewChunk(128000);
|
||||
Heap_heapend = Heap_FetchAddress(Heap_heap + 4);
|
||||
__PUT(Heap_heap, 0, int32);
|
||||
__PUT(Heap_heap, 0, uintptr);
|
||||
Heap_allocated = 0;
|
||||
Heap_firstTry = 1;
|
||||
Heap_freeList[9] = 1;
|
||||
|
|
|
|||
|
|
@ -51,15 +51,15 @@ typedef
|
|||
Heap_ModuleName name;
|
||||
int32 refcnt;
|
||||
Heap_Cmd cmds;
|
||||
int32 types;
|
||||
uintptr types;
|
||||
Heap_EnumProc enumPtrs;
|
||||
int32 reserved1, reserved2;
|
||||
} Heap_ModuleDesc;
|
||||
|
||||
|
||||
export SYSTEM_PTR Heap_modules;
|
||||
static int32 Heap_freeList[10];
|
||||
static int32 Heap_bigBlocks;
|
||||
static uintptr Heap_freeList[10];
|
||||
static uintptr Heap_bigBlocks;
|
||||
export uintptr Heap_allocated;
|
||||
static BOOLEAN Heap_firstTry;
|
||||
static uintptr Heap_heap, Heap_heapend;
|
||||
|
|
@ -75,18 +75,18 @@ export LONGINT *Heap_FinDesc__typ;
|
|||
export LONGINT *Heap__1__typ;
|
||||
|
||||
static void Heap_CheckFin (void);
|
||||
static void Heap_ExtendHeap (int32 blksz);
|
||||
static void Heap_ExtendHeap (uintptr blksz);
|
||||
export void Heap_FINALL (void);
|
||||
static void Heap_Finalize (void);
|
||||
export void Heap_GC (BOOLEAN markStack);
|
||||
static void Heap_HeapSort (int32 n, int32 *a, LONGINT a__len);
|
||||
static void Heap_HeapSort (uintptr n, uintptr *a, LONGINT a__len);
|
||||
export void Heap_INCREF (Heap_Module m);
|
||||
export void Heap_InitHeap (void);
|
||||
export void Heap_Lock (void);
|
||||
static void Heap_Mark (int32 q);
|
||||
static void Heap_MarkCandidates (int32 n, int32 *cand, LONGINT cand__len);
|
||||
static void Heap_Mark (uintptr q);
|
||||
static void Heap_MarkCandidates (uintptr n, uintptr *cand, LONGINT cand__len);
|
||||
static void Heap_MarkP (SYSTEM_PTR p);
|
||||
static void Heap_MarkStack (int32 n, int32 *cand, LONGINT cand__len);
|
||||
static void Heap_MarkStack (uintptr n, uintptr *cand, LONGINT cand__len);
|
||||
export SYSTEM_PTR Heap_NEWBLK (uintptr size);
|
||||
export SYSTEM_PTR Heap_NEWREC (uintptr tag);
|
||||
static uintptr Heap_NewChunk (uintptr blksz);
|
||||
|
|
@ -95,11 +95,11 @@ export SYSTEM_PTR Heap_REGMOD (Heap_ModuleName name, Heap_EnumProc enumPtrs);
|
|||
export void Heap_REGTYP (Heap_Module m, uintptr typ);
|
||||
export void Heap_RegisterFinalizer (SYSTEM_PTR obj, Heap_Finalizer finalize);
|
||||
static void Heap_Scan (void);
|
||||
static void Heap_Sift (int32 l, int32 r, int32 *a, LONGINT a__len);
|
||||
static void Heap_Sift (uintptr l, uintptr r, uintptr *a, LONGINT a__len);
|
||||
export void Heap_Unlock (void);
|
||||
|
||||
extern void *Heap__init();
|
||||
extern LONGINT Platform_MainStackFrame;
|
||||
extern uintptr Platform_MainStackFrame;
|
||||
extern uintptr Platform_OSAllocate(uintptr size);
|
||||
#define Heap_FetchAddress(pointer) (uintptr)(*((void**)((uintptr)pointer)))
|
||||
#define Heap_HeapModuleInit() Heap__init()
|
||||
|
|
@ -156,7 +156,7 @@ void Heap_REGCMD (Heap_Module m, Heap_CmdName name, Heap_Command cmd)
|
|||
|
||||
void Heap_REGTYP (Heap_Module m, uintptr typ)
|
||||
{
|
||||
__PUT(typ, m->types, int32);
|
||||
__PUT(typ, m->types, uintptr);
|
||||
m->types = typ;
|
||||
}
|
||||
|
||||
|
|
@ -174,8 +174,8 @@ static uintptr Heap_NewChunk (uintptr blksz)
|
|||
__PUT(chnk + 4, chnk + (12 + blksz), uintptr);
|
||||
__PUT(chnk + 12, chnk + 16, uintptr);
|
||||
__PUT(chnk + 16, blksz, uintptr);
|
||||
__PUT(chnk + 20, -4, int32);
|
||||
__PUT(chnk + 24, Heap_bigBlocks, int32);
|
||||
__PUT(chnk + 20, -4, uintptr);
|
||||
__PUT(chnk + 24, Heap_bigBlocks, uintptr);
|
||||
Heap_bigBlocks = chnk + 12;
|
||||
Heap_heapsize += blksz;
|
||||
}
|
||||
|
|
@ -183,9 +183,9 @@ static uintptr Heap_NewChunk (uintptr blksz)
|
|||
return _o_result;
|
||||
}
|
||||
|
||||
static void Heap_ExtendHeap (int32 blksz)
|
||||
static void Heap_ExtendHeap (uintptr blksz)
|
||||
{
|
||||
int32 size, chnk, j, next;
|
||||
uintptr size, chnk, j, next;
|
||||
if (blksz > 160000) {
|
||||
size = blksz;
|
||||
} else {
|
||||
|
|
@ -203,8 +203,8 @@ static void Heap_ExtendHeap (int32 blksz)
|
|||
j = next;
|
||||
next = Heap_FetchAddress(j);
|
||||
}
|
||||
__PUT(chnk, next, int32);
|
||||
__PUT(j, chnk, int32);
|
||||
__PUT(chnk, next, uintptr);
|
||||
__PUT(j, chnk, uintptr);
|
||||
}
|
||||
if (next == 0) {
|
||||
Heap_heapend = Heap_FetchAddress(chnk + 4);
|
||||
|
|
@ -236,10 +236,10 @@ SYSTEM_PTR Heap_NEWREC (uintptr tag)
|
|||
restsize = __ASHL(di, 4);
|
||||
end = adr + restsize;
|
||||
__PUT(end + 4, blksz, uintptr);
|
||||
__PUT(end + 8, -4, int32);
|
||||
__PUT(end, end + 4, int32);
|
||||
__PUT(end + 8, -4, uintptr);
|
||||
__PUT(end, end + 4, uintptr);
|
||||
__PUT(adr + 4, restsize, uintptr);
|
||||
__PUT(adr + 12, Heap_freeList[di], int32);
|
||||
__PUT(adr + 12, Heap_freeList[di], uintptr);
|
||||
Heap_freeList[di] = adr;
|
||||
adr += restsize;
|
||||
}
|
||||
|
|
@ -280,8 +280,8 @@ SYSTEM_PTR Heap_NEWREC (uintptr tag)
|
|||
restsize = t - blksz;
|
||||
end = adr + restsize;
|
||||
__PUT(end + 4, blksz, uintptr);
|
||||
__PUT(end + 8, -4, int32);
|
||||
__PUT(end, end + 4, int32);
|
||||
__PUT(end + 8, -4, uintptr);
|
||||
__PUT(end, end + 4, uintptr);
|
||||
if (restsize > 144) {
|
||||
__PUT(adr + 4, restsize, uintptr);
|
||||
} else {
|
||||
|
|
@ -294,7 +294,7 @@ SYSTEM_PTR Heap_NEWREC (uintptr tag)
|
|||
if (restsize > 0) {
|
||||
di = __ASHR(restsize, 4);
|
||||
__PUT(adr + 4, restsize, uintptr);
|
||||
__PUT(adr + 12, Heap_freeList[di], int32);
|
||||
__PUT(adr + 12, Heap_freeList[di], uintptr);
|
||||
Heap_freeList[di] = adr;
|
||||
}
|
||||
}
|
||||
|
|
@ -303,16 +303,16 @@ SYSTEM_PTR Heap_NEWREC (uintptr tag)
|
|||
i = adr + 16;
|
||||
end = adr + blksz;
|
||||
while (i < end) {
|
||||
__PUT(i, 0, int32);
|
||||
__PUT(i + 4, 0, int32);
|
||||
__PUT(i + 8, 0, int32);
|
||||
__PUT(i + 12, 0, int32);
|
||||
__PUT(i, 0, uintptr);
|
||||
__PUT(i + 4, 0, uintptr);
|
||||
__PUT(i + 8, 0, uintptr);
|
||||
__PUT(i + 12, 0, uintptr);
|
||||
i += 16;
|
||||
}
|
||||
__PUT(adr + 12, 0, int32);
|
||||
__PUT(adr + 12, 0, uintptr);
|
||||
__PUT(adr, tag, uintptr);
|
||||
__PUT(adr + 4, 0, int32);
|
||||
__PUT(adr + 8, 0, int32);
|
||||
__PUT(adr + 4, 0, uintptr);
|
||||
__PUT(adr + 8, 0, uintptr);
|
||||
Heap_allocated += blksz;
|
||||
Heap_Unlock();
|
||||
_o_result = (SYSTEM_PTR)(uintptr)(adr + 4);
|
||||
|
|
@ -327,29 +327,29 @@ SYSTEM_PTR Heap_NEWBLK (uintptr size)
|
|||
Heap_Lock();
|
||||
blksz = __ASHL(__ASHR(size + 31, 4), 4);
|
||||
new = Heap_NEWREC((uintptr)&blksz);
|
||||
tag = (((int32)(uintptr)new) + blksz) - 12;
|
||||
__PUT(tag - 4, 0, int32);
|
||||
tag = ((uintptr)(uintptr)new + blksz) - 12;
|
||||
__PUT(tag - 4, 0, uintptr);
|
||||
__PUT(tag, blksz, uintptr);
|
||||
__PUT(tag + 4, -4, int32);
|
||||
__PUT((int32)(uintptr)new - 4, tag, uintptr);
|
||||
__PUT(tag + 4, -4, uintptr);
|
||||
__PUT((uintptr)(uintptr)new - 4, tag, uintptr);
|
||||
Heap_Unlock();
|
||||
_o_result = new;
|
||||
return _o_result;
|
||||
}
|
||||
|
||||
static void Heap_Mark (int32 q)
|
||||
static void Heap_Mark (uintptr q)
|
||||
{
|
||||
int32 p, tag, fld, n, offset, tagbits;
|
||||
uintptr p, tag, offset, fld, n, tagbits;
|
||||
if (q != 0) {
|
||||
tagbits = Heap_FetchAddress(q - 4);
|
||||
if (!__ODD(tagbits)) {
|
||||
__PUT(q - 4, tagbits + 1, int32);
|
||||
__PUT(q - 4, tagbits + 1, uintptr);
|
||||
p = 0;
|
||||
tag = tagbits + 4;
|
||||
for (;;) {
|
||||
__GET(tag, offset, int32);
|
||||
if (offset < 0) {
|
||||
__PUT(q - 4, (tag + offset) + 1, int32);
|
||||
__GET(tag, offset, uintptr);
|
||||
if (__BIT((uintptr)&offset, 31)) {
|
||||
__PUT(q - 4, (tag + offset) + 1, uintptr);
|
||||
if (p == 0) {
|
||||
break;
|
||||
}
|
||||
|
|
@ -357,7 +357,7 @@ static void Heap_Mark (int32 q)
|
|||
q = p;
|
||||
tag = Heap_FetchAddress(q - 4);
|
||||
tag -= 1;
|
||||
__GET(tag, offset, int32);
|
||||
__GET(tag, offset, uintptr);
|
||||
fld = q + offset;
|
||||
p = Heap_FetchAddress(fld);
|
||||
__PUT(fld, (SYSTEM_PTR)(uintptr)n, SYSTEM_PTR);
|
||||
|
|
@ -367,8 +367,8 @@ static void Heap_Mark (int32 q)
|
|||
if (n != 0) {
|
||||
tagbits = Heap_FetchAddress(n - 4);
|
||||
if (!__ODD(tagbits)) {
|
||||
__PUT(n - 4, tagbits + 1, int32);
|
||||
__PUT(q - 4, tag + 1, int32);
|
||||
__PUT(n - 4, tagbits + 1, uintptr);
|
||||
__PUT(q - 4, tag + 1, uintptr);
|
||||
__PUT(fld, (SYSTEM_PTR)(uintptr)p, SYSTEM_PTR);
|
||||
p = q;
|
||||
q = n;
|
||||
|
|
@ -384,7 +384,7 @@ static void Heap_Mark (int32 q)
|
|||
|
||||
static void Heap_MarkP (SYSTEM_PTR p)
|
||||
{
|
||||
Heap_Mark((int32)(uintptr)p);
|
||||
Heap_Mark((uintptr)(uintptr)p);
|
||||
}
|
||||
|
||||
static void Heap_Scan (void)
|
||||
|
|
@ -409,14 +409,14 @@ static void Heap_Scan (void)
|
|||
start = adr - freesize;
|
||||
__PUT(start, start + 4, uintptr);
|
||||
__PUT(start + 4, freesize, uintptr);
|
||||
__PUT(start + 8, -4, int32);
|
||||
__PUT(start + 8, -4, uintptr);
|
||||
i = __ASHR(freesize, 4);
|
||||
freesize = 0;
|
||||
if (i < 9) {
|
||||
__PUT(start + 12, Heap_freeList[i], int32);
|
||||
__PUT(start + 12, Heap_freeList[i], uintptr);
|
||||
Heap_freeList[i] = start;
|
||||
} else {
|
||||
__PUT(start + 12, Heap_bigBlocks, int32);
|
||||
__PUT(start + 12, Heap_bigBlocks, uintptr);
|
||||
Heap_bigBlocks = start;
|
||||
}
|
||||
}
|
||||
|
|
@ -435,14 +435,14 @@ static void Heap_Scan (void)
|
|||
start = adr - freesize;
|
||||
__PUT(start, start + 4, uintptr);
|
||||
__PUT(start + 4, freesize, uintptr);
|
||||
__PUT(start + 8, -4, int32);
|
||||
__PUT(start + 8, -4, uintptr);
|
||||
i = __ASHR(freesize, 4);
|
||||
freesize = 0;
|
||||
if (i < 9) {
|
||||
__PUT(start + 12, Heap_freeList[i], int32);
|
||||
__PUT(start + 12, Heap_freeList[i], uintptr);
|
||||
Heap_freeList[i] = start;
|
||||
} else {
|
||||
__PUT(start + 12, Heap_bigBlocks, int32);
|
||||
__PUT(start + 12, Heap_bigBlocks, uintptr);
|
||||
Heap_bigBlocks = start;
|
||||
}
|
||||
}
|
||||
|
|
@ -450,9 +450,9 @@ static void Heap_Scan (void)
|
|||
}
|
||||
}
|
||||
|
||||
static void Heap_Sift (int32 l, int32 r, int32 *a, LONGINT a__len)
|
||||
static void Heap_Sift (uintptr l, uintptr r, uintptr *a, LONGINT a__len)
|
||||
{
|
||||
int32 i, j, x;
|
||||
uintptr i, j, x;
|
||||
j = l;
|
||||
x = a[j];
|
||||
for (;;) {
|
||||
|
|
@ -469,9 +469,9 @@ static void Heap_Sift (int32 l, int32 r, int32 *a, LONGINT a__len)
|
|||
a[i] = x;
|
||||
}
|
||||
|
||||
static void Heap_HeapSort (int32 n, int32 *a, LONGINT a__len)
|
||||
static void Heap_HeapSort (uintptr n, uintptr *a, LONGINT a__len)
|
||||
{
|
||||
int32 l, r, x;
|
||||
uintptr l, r, x;
|
||||
l = __ASHR(n, 1);
|
||||
r = n - 1;
|
||||
while (l > 0) {
|
||||
|
|
@ -487,9 +487,9 @@ static void Heap_HeapSort (int32 n, int32 *a, LONGINT a__len)
|
|||
}
|
||||
}
|
||||
|
||||
static void Heap_MarkCandidates (int32 n, int32 *cand, LONGINT cand__len)
|
||||
static void Heap_MarkCandidates (uintptr n, uintptr *cand, LONGINT cand__len)
|
||||
{
|
||||
int32 chnk, adr, tag, next, lim, lim1, i, ptr, size;
|
||||
uintptr chnk, adr, tag, next, lim, lim1, i, ptr, size;
|
||||
chnk = Heap_heap;
|
||||
i = 0;
|
||||
lim = cand[n - 1];
|
||||
|
|
@ -527,7 +527,7 @@ static void Heap_MarkCandidates (int32 n, int32 *cand, LONGINT cand__len)
|
|||
static void Heap_CheckFin (void)
|
||||
{
|
||||
Heap_FinNode n;
|
||||
int32 tag;
|
||||
uintptr tag;
|
||||
n = Heap_fin;
|
||||
while (n != NIL) {
|
||||
tag = Heap_FetchAddress(n->obj - 4);
|
||||
|
|
@ -576,10 +576,10 @@ void Heap_FINALL (void)
|
|||
}
|
||||
}
|
||||
|
||||
static void Heap_MarkStack (int32 n, int32 *cand, LONGINT cand__len)
|
||||
static void Heap_MarkStack (uintptr n, uintptr *cand, LONGINT cand__len)
|
||||
{
|
||||
SYSTEM_PTR frame;
|
||||
int32 inc, nofcand, sp, p, stack0;
|
||||
uintptr inc, nofcand, sp, p, stack0;
|
||||
struct Heap__1 align;
|
||||
if (n > 0) {
|
||||
Heap_MarkStack(n - 1, cand, cand__len);
|
||||
|
|
@ -596,7 +596,7 @@ static void Heap_MarkStack (int32 n, int32 *cand, LONGINT cand__len)
|
|||
inc = -inc;
|
||||
}
|
||||
while (sp != stack0) {
|
||||
__GET(sp, p, int32);
|
||||
__GET(sp, p, uintptr);
|
||||
if ((p > Heap_heap && p < Heap_heapend)) {
|
||||
if (nofcand == cand__len) {
|
||||
Heap_HeapSort(nofcand, (void*)cand, cand__len);
|
||||
|
|
@ -618,8 +618,8 @@ static void Heap_MarkStack (int32 n, int32 *cand, LONGINT cand__len)
|
|||
void Heap_GC (BOOLEAN markStack)
|
||||
{
|
||||
Heap_Module m;
|
||||
int32 i0, i1, i2, i3, i4, i5, i6, i7, i8, i9, i10, i11, i12, i13, i14, i15, i16, i17, i18, i19, i20, i21, i22, i23;
|
||||
int32 cand[10000];
|
||||
uintptr i0, i1, i2, i3, i4, i5, i6, i7, i8, i9, i10, i11, i12, i13, i14, i15, i16, i17, i18, i19, i20, i21, i22, i23;
|
||||
uintptr cand[10000];
|
||||
if (Heap_lockdepth == 0 || (Heap_lockdepth == 1 && !markStack)) {
|
||||
Heap_Lock();
|
||||
m = (Heap_Module)(uintptr)Heap_modules;
|
||||
|
|
@ -699,7 +699,7 @@ void Heap_RegisterFinalizer (SYSTEM_PTR obj, Heap_Finalizer finalize)
|
|||
{
|
||||
Heap_FinNode f;
|
||||
__NEW(f, Heap_FinDesc);
|
||||
f->obj = (int32)(uintptr)obj;
|
||||
f->obj = (uintptr)(uintptr)obj;
|
||||
f->finalize = finalize;
|
||||
f->marked = 1;
|
||||
f->next = Heap_fin;
|
||||
|
|
@ -710,7 +710,7 @@ void Heap_InitHeap (void)
|
|||
{
|
||||
Heap_heap = Heap_NewChunk(128000);
|
||||
Heap_heapend = Heap_FetchAddress(Heap_heap + 4);
|
||||
__PUT(Heap_heap, 0, int32);
|
||||
__PUT(Heap_heap, 0, uintptr);
|
||||
Heap_allocated = 0;
|
||||
Heap_firstTry = 1;
|
||||
Heap_freeList[9] = 1;
|
||||
|
|
|
|||
|
|
@ -52,15 +52,15 @@ typedef
|
|||
Heap_ModuleName name;
|
||||
int64 refcnt;
|
||||
Heap_Cmd cmds;
|
||||
int64 types;
|
||||
uintptr types;
|
||||
Heap_EnumProc enumPtrs;
|
||||
int64 reserved1, reserved2;
|
||||
} Heap_ModuleDesc;
|
||||
|
||||
|
||||
export SYSTEM_PTR Heap_modules;
|
||||
static int64 Heap_freeList[10];
|
||||
static int64 Heap_bigBlocks;
|
||||
static uintptr Heap_freeList[10];
|
||||
static uintptr Heap_bigBlocks;
|
||||
export uintptr Heap_allocated;
|
||||
static BOOLEAN Heap_firstTry;
|
||||
static uintptr Heap_heap, Heap_heapend;
|
||||
|
|
@ -76,18 +76,18 @@ export LONGINT *Heap_FinDesc__typ;
|
|||
export LONGINT *Heap__1__typ;
|
||||
|
||||
static void Heap_CheckFin (void);
|
||||
static void Heap_ExtendHeap (int64 blksz);
|
||||
static void Heap_ExtendHeap (uintptr blksz);
|
||||
export void Heap_FINALL (void);
|
||||
static void Heap_Finalize (void);
|
||||
export void Heap_GC (BOOLEAN markStack);
|
||||
static void Heap_HeapSort (int64 n, int64 *a, LONGINT a__len);
|
||||
static void Heap_HeapSort (uintptr n, uintptr *a, LONGINT a__len);
|
||||
export void Heap_INCREF (Heap_Module m);
|
||||
export void Heap_InitHeap (void);
|
||||
export void Heap_Lock (void);
|
||||
static void Heap_Mark (int64 q);
|
||||
static void Heap_MarkCandidates (int64 n, int64 *cand, LONGINT cand__len);
|
||||
static void Heap_Mark (uintptr q);
|
||||
static void Heap_MarkCandidates (uintptr n, uintptr *cand, LONGINT cand__len);
|
||||
static void Heap_MarkP (SYSTEM_PTR p);
|
||||
static void Heap_MarkStack (int64 n, int64 *cand, LONGINT cand__len);
|
||||
static void Heap_MarkStack (uintptr n, uintptr *cand, LONGINT cand__len);
|
||||
export SYSTEM_PTR Heap_NEWBLK (uintptr size);
|
||||
export SYSTEM_PTR Heap_NEWREC (uintptr tag);
|
||||
static uintptr Heap_NewChunk (uintptr blksz);
|
||||
|
|
@ -96,11 +96,11 @@ export SYSTEM_PTR Heap_REGMOD (Heap_ModuleName name, Heap_EnumProc enumPtrs);
|
|||
export void Heap_REGTYP (Heap_Module m, uintptr typ);
|
||||
export void Heap_RegisterFinalizer (SYSTEM_PTR obj, Heap_Finalizer finalize);
|
||||
static void Heap_Scan (void);
|
||||
static void Heap_Sift (int64 l, int64 r, int64 *a, LONGINT a__len);
|
||||
static void Heap_Sift (uintptr l, uintptr r, uintptr *a, LONGINT a__len);
|
||||
export void Heap_Unlock (void);
|
||||
|
||||
extern void *Heap__init();
|
||||
extern LONGINT Platform_MainStackFrame;
|
||||
extern uintptr Platform_MainStackFrame;
|
||||
extern uintptr Platform_OSAllocate(uintptr size);
|
||||
#define Heap_FetchAddress(pointer) (uintptr)(*((void**)((uintptr)pointer)))
|
||||
#define Heap_HeapModuleInit() Heap__init()
|
||||
|
|
@ -157,7 +157,7 @@ void Heap_REGCMD (Heap_Module m, Heap_CmdName name, Heap_Command cmd)
|
|||
|
||||
void Heap_REGTYP (Heap_Module m, uintptr typ)
|
||||
{
|
||||
__PUT(typ, m->types, int64);
|
||||
__PUT(typ, m->types, uintptr);
|
||||
m->types = typ;
|
||||
}
|
||||
|
||||
|
|
@ -175,8 +175,8 @@ static uintptr Heap_NewChunk (uintptr blksz)
|
|||
__PUT(chnk + 8, chnk + (24 + blksz), uintptr);
|
||||
__PUT(chnk + 24, chnk + 32, uintptr);
|
||||
__PUT(chnk + 32, blksz, uintptr);
|
||||
__PUT(chnk + 40, -8, int64);
|
||||
__PUT(chnk + 48, Heap_bigBlocks, int64);
|
||||
__PUT(chnk + 40, -8, uintptr);
|
||||
__PUT(chnk + 48, Heap_bigBlocks, uintptr);
|
||||
Heap_bigBlocks = chnk + 24;
|
||||
Heap_heapsize += blksz;
|
||||
}
|
||||
|
|
@ -184,9 +184,9 @@ static uintptr Heap_NewChunk (uintptr blksz)
|
|||
return _o_result;
|
||||
}
|
||||
|
||||
static void Heap_ExtendHeap (int64 blksz)
|
||||
static void Heap_ExtendHeap (uintptr blksz)
|
||||
{
|
||||
int64 size, chnk, j, next;
|
||||
uintptr size, chnk, j, next;
|
||||
if (blksz > 320000) {
|
||||
size = blksz;
|
||||
} else {
|
||||
|
|
@ -204,8 +204,8 @@ static void Heap_ExtendHeap (int64 blksz)
|
|||
j = next;
|
||||
next = Heap_FetchAddress(j);
|
||||
}
|
||||
__PUT(chnk, next, int64);
|
||||
__PUT(j, chnk, int64);
|
||||
__PUT(chnk, next, uintptr);
|
||||
__PUT(j, chnk, uintptr);
|
||||
}
|
||||
if (next == 0) {
|
||||
Heap_heapend = Heap_FetchAddress(chnk + 8);
|
||||
|
|
@ -237,10 +237,10 @@ SYSTEM_PTR Heap_NEWREC (uintptr tag)
|
|||
restsize = __ASHL(di, 5);
|
||||
end = adr + restsize;
|
||||
__PUT(end + 8, blksz, uintptr);
|
||||
__PUT(end + 16, -8, int64);
|
||||
__PUT(end, end + 8, int64);
|
||||
__PUT(end + 16, -8, uintptr);
|
||||
__PUT(end, end + 8, uintptr);
|
||||
__PUT(adr + 8, restsize, uintptr);
|
||||
__PUT(adr + 24, Heap_freeList[di], int64);
|
||||
__PUT(adr + 24, Heap_freeList[di], uintptr);
|
||||
Heap_freeList[di] = adr;
|
||||
adr += restsize;
|
||||
}
|
||||
|
|
@ -281,8 +281,8 @@ SYSTEM_PTR Heap_NEWREC (uintptr tag)
|
|||
restsize = t - blksz;
|
||||
end = adr + restsize;
|
||||
__PUT(end + 8, blksz, uintptr);
|
||||
__PUT(end + 16, -8, int64);
|
||||
__PUT(end, end + 8, int64);
|
||||
__PUT(end + 16, -8, uintptr);
|
||||
__PUT(end, end + 8, uintptr);
|
||||
if (restsize > 288) {
|
||||
__PUT(adr + 8, restsize, uintptr);
|
||||
} else {
|
||||
|
|
@ -295,7 +295,7 @@ SYSTEM_PTR Heap_NEWREC (uintptr tag)
|
|||
if (restsize > 0) {
|
||||
di = __ASHR(restsize, 5);
|
||||
__PUT(adr + 8, restsize, uintptr);
|
||||
__PUT(adr + 24, Heap_freeList[di], int64);
|
||||
__PUT(adr + 24, Heap_freeList[di], uintptr);
|
||||
Heap_freeList[di] = adr;
|
||||
}
|
||||
}
|
||||
|
|
@ -304,16 +304,16 @@ SYSTEM_PTR Heap_NEWREC (uintptr tag)
|
|||
i = adr + 32;
|
||||
end = adr + blksz;
|
||||
while (i < end) {
|
||||
__PUT(i, 0, int64);
|
||||
__PUT(i + 8, 0, int64);
|
||||
__PUT(i + 16, 0, int64);
|
||||
__PUT(i + 24, 0, int64);
|
||||
__PUT(i, 0, uintptr);
|
||||
__PUT(i + 8, 0, uintptr);
|
||||
__PUT(i + 16, 0, uintptr);
|
||||
__PUT(i + 24, 0, uintptr);
|
||||
i += 32;
|
||||
}
|
||||
__PUT(adr + 24, 0, int64);
|
||||
__PUT(adr + 24, 0, uintptr);
|
||||
__PUT(adr, tag, uintptr);
|
||||
__PUT(adr + 8, 0, int64);
|
||||
__PUT(adr + 16, 0, int64);
|
||||
__PUT(adr + 8, 0, uintptr);
|
||||
__PUT(adr + 16, 0, uintptr);
|
||||
Heap_allocated += blksz;
|
||||
Heap_Unlock();
|
||||
_o_result = (SYSTEM_PTR)(uintptr)(adr + 8);
|
||||
|
|
@ -328,29 +328,29 @@ SYSTEM_PTR Heap_NEWBLK (uintptr size)
|
|||
Heap_Lock();
|
||||
blksz = __ASHL(__ASHR(size + 63, 5), 5);
|
||||
new = Heap_NEWREC((uintptr)&blksz);
|
||||
tag = (((int64)(uintptr)new) + blksz) - 24;
|
||||
__PUT(tag - 8, 0, int64);
|
||||
tag = ((uintptr)(uintptr)new + blksz) - 24;
|
||||
__PUT(tag - 8, 0, uintptr);
|
||||
__PUT(tag, blksz, uintptr);
|
||||
__PUT(tag + 8, -8, int64);
|
||||
__PUT((int64)(uintptr)new - 8, tag, uintptr);
|
||||
__PUT(tag + 8, -8, uintptr);
|
||||
__PUT((uintptr)(uintptr)new - 8, tag, uintptr);
|
||||
Heap_Unlock();
|
||||
_o_result = new;
|
||||
return _o_result;
|
||||
}
|
||||
|
||||
static void Heap_Mark (int64 q)
|
||||
static void Heap_Mark (uintptr q)
|
||||
{
|
||||
int64 p, tag, fld, n, offset, tagbits;
|
||||
uintptr p, tag, offset, fld, n, tagbits;
|
||||
if (q != 0) {
|
||||
tagbits = Heap_FetchAddress(q - 8);
|
||||
if (!__ODD(tagbits)) {
|
||||
__PUT(q - 8, tagbits + 1, int64);
|
||||
__PUT(q - 8, tagbits + 1, uintptr);
|
||||
p = 0;
|
||||
tag = tagbits + 8;
|
||||
for (;;) {
|
||||
__GET(tag, offset, int64);
|
||||
if (offset < 0) {
|
||||
__PUT(q - 8, (tag + offset) + 1, int64);
|
||||
__GET(tag, offset, uintptr);
|
||||
if (__BIT((uintptr)&offset, 63)) {
|
||||
__PUT(q - 8, (tag + offset) + 1, uintptr);
|
||||
if (p == 0) {
|
||||
break;
|
||||
}
|
||||
|
|
@ -358,7 +358,7 @@ static void Heap_Mark (int64 q)
|
|||
q = p;
|
||||
tag = Heap_FetchAddress(q - 8);
|
||||
tag -= 1;
|
||||
__GET(tag, offset, int64);
|
||||
__GET(tag, offset, uintptr);
|
||||
fld = q + offset;
|
||||
p = Heap_FetchAddress(fld);
|
||||
__PUT(fld, (SYSTEM_PTR)(uintptr)n, SYSTEM_PTR);
|
||||
|
|
@ -368,8 +368,8 @@ static void Heap_Mark (int64 q)
|
|||
if (n != 0) {
|
||||
tagbits = Heap_FetchAddress(n - 8);
|
||||
if (!__ODD(tagbits)) {
|
||||
__PUT(n - 8, tagbits + 1, int64);
|
||||
__PUT(q - 8, tag + 1, int64);
|
||||
__PUT(n - 8, tagbits + 1, uintptr);
|
||||
__PUT(q - 8, tag + 1, uintptr);
|
||||
__PUT(fld, (SYSTEM_PTR)(uintptr)p, SYSTEM_PTR);
|
||||
p = q;
|
||||
q = n;
|
||||
|
|
@ -385,7 +385,7 @@ static void Heap_Mark (int64 q)
|
|||
|
||||
static void Heap_MarkP (SYSTEM_PTR p)
|
||||
{
|
||||
Heap_Mark((int64)(uintptr)p);
|
||||
Heap_Mark((uintptr)(uintptr)p);
|
||||
}
|
||||
|
||||
static void Heap_Scan (void)
|
||||
|
|
@ -410,14 +410,14 @@ static void Heap_Scan (void)
|
|||
start = adr - freesize;
|
||||
__PUT(start, start + 8, uintptr);
|
||||
__PUT(start + 8, freesize, uintptr);
|
||||
__PUT(start + 16, -8, int64);
|
||||
__PUT(start + 16, -8, uintptr);
|
||||
i = __ASHR(freesize, 5);
|
||||
freesize = 0;
|
||||
if (i < 9) {
|
||||
__PUT(start + 24, Heap_freeList[i], int64);
|
||||
__PUT(start + 24, Heap_freeList[i], uintptr);
|
||||
Heap_freeList[i] = start;
|
||||
} else {
|
||||
__PUT(start + 24, Heap_bigBlocks, int64);
|
||||
__PUT(start + 24, Heap_bigBlocks, uintptr);
|
||||
Heap_bigBlocks = start;
|
||||
}
|
||||
}
|
||||
|
|
@ -436,14 +436,14 @@ static void Heap_Scan (void)
|
|||
start = adr - freesize;
|
||||
__PUT(start, start + 8, uintptr);
|
||||
__PUT(start + 8, freesize, uintptr);
|
||||
__PUT(start + 16, -8, int64);
|
||||
__PUT(start + 16, -8, uintptr);
|
||||
i = __ASHR(freesize, 5);
|
||||
freesize = 0;
|
||||
if (i < 9) {
|
||||
__PUT(start + 24, Heap_freeList[i], int64);
|
||||
__PUT(start + 24, Heap_freeList[i], uintptr);
|
||||
Heap_freeList[i] = start;
|
||||
} else {
|
||||
__PUT(start + 24, Heap_bigBlocks, int64);
|
||||
__PUT(start + 24, Heap_bigBlocks, uintptr);
|
||||
Heap_bigBlocks = start;
|
||||
}
|
||||
}
|
||||
|
|
@ -451,9 +451,9 @@ static void Heap_Scan (void)
|
|||
}
|
||||
}
|
||||
|
||||
static void Heap_Sift (int64 l, int64 r, int64 *a, LONGINT a__len)
|
||||
static void Heap_Sift (uintptr l, uintptr r, uintptr *a, LONGINT a__len)
|
||||
{
|
||||
int64 i, j, x;
|
||||
uintptr i, j, x;
|
||||
j = l;
|
||||
x = a[j];
|
||||
for (;;) {
|
||||
|
|
@ -470,9 +470,9 @@ static void Heap_Sift (int64 l, int64 r, int64 *a, LONGINT a__len)
|
|||
a[i] = x;
|
||||
}
|
||||
|
||||
static void Heap_HeapSort (int64 n, int64 *a, LONGINT a__len)
|
||||
static void Heap_HeapSort (uintptr n, uintptr *a, LONGINT a__len)
|
||||
{
|
||||
int64 l, r, x;
|
||||
uintptr l, r, x;
|
||||
l = __ASHR(n, 1);
|
||||
r = n - 1;
|
||||
while (l > 0) {
|
||||
|
|
@ -488,9 +488,9 @@ static void Heap_HeapSort (int64 n, int64 *a, LONGINT a__len)
|
|||
}
|
||||
}
|
||||
|
||||
static void Heap_MarkCandidates (int64 n, int64 *cand, LONGINT cand__len)
|
||||
static void Heap_MarkCandidates (uintptr n, uintptr *cand, LONGINT cand__len)
|
||||
{
|
||||
int64 chnk, adr, tag, next, lim, lim1, i, ptr, size;
|
||||
uintptr chnk, adr, tag, next, lim, lim1, i, ptr, size;
|
||||
chnk = Heap_heap;
|
||||
i = 0;
|
||||
lim = cand[n - 1];
|
||||
|
|
@ -528,7 +528,7 @@ static void Heap_MarkCandidates (int64 n, int64 *cand, LONGINT cand__len)
|
|||
static void Heap_CheckFin (void)
|
||||
{
|
||||
Heap_FinNode n;
|
||||
int64 tag;
|
||||
uintptr tag;
|
||||
n = Heap_fin;
|
||||
while (n != NIL) {
|
||||
tag = Heap_FetchAddress(n->obj - 8);
|
||||
|
|
@ -577,10 +577,10 @@ void Heap_FINALL (void)
|
|||
}
|
||||
}
|
||||
|
||||
static void Heap_MarkStack (int64 n, int64 *cand, LONGINT cand__len)
|
||||
static void Heap_MarkStack (uintptr n, uintptr *cand, LONGINT cand__len)
|
||||
{
|
||||
SYSTEM_PTR frame;
|
||||
int64 inc, nofcand, sp, p, stack0;
|
||||
uintptr inc, nofcand, sp, p, stack0;
|
||||
struct Heap__1 align;
|
||||
if (n > 0) {
|
||||
Heap_MarkStack(n - 1, cand, cand__len);
|
||||
|
|
@ -597,7 +597,7 @@ static void Heap_MarkStack (int64 n, int64 *cand, LONGINT cand__len)
|
|||
inc = -inc;
|
||||
}
|
||||
while (sp != stack0) {
|
||||
__GET(sp, p, int64);
|
||||
__GET(sp, p, uintptr);
|
||||
if ((p > Heap_heap && p < Heap_heapend)) {
|
||||
if (nofcand == cand__len) {
|
||||
Heap_HeapSort(nofcand, (void*)cand, cand__len);
|
||||
|
|
@ -619,8 +619,8 @@ static void Heap_MarkStack (int64 n, int64 *cand, LONGINT cand__len)
|
|||
void Heap_GC (BOOLEAN markStack)
|
||||
{
|
||||
Heap_Module m;
|
||||
int64 i0, i1, i2, i3, i4, i5, i6, i7, i8, i9, i10, i11, i12, i13, i14, i15, i16, i17, i18, i19, i20, i21, i22, i23;
|
||||
int64 cand[10000];
|
||||
uintptr i0, i1, i2, i3, i4, i5, i6, i7, i8, i9, i10, i11, i12, i13, i14, i15, i16, i17, i18, i19, i20, i21, i22, i23;
|
||||
uintptr cand[10000];
|
||||
if (Heap_lockdepth == 0 || (Heap_lockdepth == 1 && !markStack)) {
|
||||
Heap_Lock();
|
||||
m = (Heap_Module)(uintptr)Heap_modules;
|
||||
|
|
@ -700,7 +700,7 @@ void Heap_RegisterFinalizer (SYSTEM_PTR obj, Heap_Finalizer finalize)
|
|||
{
|
||||
Heap_FinNode f;
|
||||
__NEW(f, Heap_FinDesc);
|
||||
f->obj = (int64)(uintptr)obj;
|
||||
f->obj = (uintptr)(uintptr)obj;
|
||||
f->finalize = finalize;
|
||||
f->marked = 1;
|
||||
f->next = Heap_fin;
|
||||
|
|
@ -711,7 +711,7 @@ void Heap_InitHeap (void)
|
|||
{
|
||||
Heap_heap = Heap_NewChunk(256000);
|
||||
Heap_heapend = Heap_FetchAddress(Heap_heap + 8);
|
||||
__PUT(Heap_heap, 0, int64);
|
||||
__PUT(Heap_heap, 0, uintptr);
|
||||
Heap_allocated = 0;
|
||||
Heap_firstTry = 1;
|
||||
Heap_freeList[9] = 1;
|
||||
|
|
|
|||
|
|
@ -51,15 +51,15 @@ typedef
|
|||
Heap_ModuleName name;
|
||||
int32 refcnt;
|
||||
Heap_Cmd cmds;
|
||||
int32 types;
|
||||
uintptr types;
|
||||
Heap_EnumProc enumPtrs;
|
||||
int32 reserved1, reserved2;
|
||||
} Heap_ModuleDesc;
|
||||
|
||||
|
||||
export SYSTEM_PTR Heap_modules;
|
||||
static int32 Heap_freeList[10];
|
||||
static int32 Heap_bigBlocks;
|
||||
static uintptr Heap_freeList[10];
|
||||
static uintptr Heap_bigBlocks;
|
||||
export uintptr Heap_allocated;
|
||||
static BOOLEAN Heap_firstTry;
|
||||
static uintptr Heap_heap, Heap_heapend;
|
||||
|
|
@ -75,18 +75,18 @@ export LONGINT *Heap_FinDesc__typ;
|
|||
export LONGINT *Heap__1__typ;
|
||||
|
||||
static void Heap_CheckFin (void);
|
||||
static void Heap_ExtendHeap (int32 blksz);
|
||||
static void Heap_ExtendHeap (uintptr blksz);
|
||||
export void Heap_FINALL (void);
|
||||
static void Heap_Finalize (void);
|
||||
export void Heap_GC (BOOLEAN markStack);
|
||||
static void Heap_HeapSort (int32 n, int32 *a, LONGINT a__len);
|
||||
static void Heap_HeapSort (uintptr n, uintptr *a, LONGINT a__len);
|
||||
export void Heap_INCREF (Heap_Module m);
|
||||
export void Heap_InitHeap (void);
|
||||
export void Heap_Lock (void);
|
||||
static void Heap_Mark (int32 q);
|
||||
static void Heap_MarkCandidates (int32 n, int32 *cand, LONGINT cand__len);
|
||||
static void Heap_Mark (uintptr q);
|
||||
static void Heap_MarkCandidates (uintptr n, uintptr *cand, LONGINT cand__len);
|
||||
static void Heap_MarkP (SYSTEM_PTR p);
|
||||
static void Heap_MarkStack (int32 n, int32 *cand, LONGINT cand__len);
|
||||
static void Heap_MarkStack (uintptr n, uintptr *cand, LONGINT cand__len);
|
||||
export SYSTEM_PTR Heap_NEWBLK (uintptr size);
|
||||
export SYSTEM_PTR Heap_NEWREC (uintptr tag);
|
||||
static uintptr Heap_NewChunk (uintptr blksz);
|
||||
|
|
@ -95,11 +95,11 @@ export SYSTEM_PTR Heap_REGMOD (Heap_ModuleName name, Heap_EnumProc enumPtrs);
|
|||
export void Heap_REGTYP (Heap_Module m, uintptr typ);
|
||||
export void Heap_RegisterFinalizer (SYSTEM_PTR obj, Heap_Finalizer finalize);
|
||||
static void Heap_Scan (void);
|
||||
static void Heap_Sift (int32 l, int32 r, int32 *a, LONGINT a__len);
|
||||
static void Heap_Sift (uintptr l, uintptr r, uintptr *a, LONGINT a__len);
|
||||
export void Heap_Unlock (void);
|
||||
|
||||
extern void *Heap__init();
|
||||
extern LONGINT Platform_MainStackFrame;
|
||||
extern uintptr Platform_MainStackFrame;
|
||||
extern uintptr Platform_OSAllocate(uintptr size);
|
||||
#define Heap_FetchAddress(pointer) (uintptr)(*((void**)((uintptr)pointer)))
|
||||
#define Heap_HeapModuleInit() Heap__init()
|
||||
|
|
@ -156,7 +156,7 @@ void Heap_REGCMD (Heap_Module m, Heap_CmdName name, Heap_Command cmd)
|
|||
|
||||
void Heap_REGTYP (Heap_Module m, uintptr typ)
|
||||
{
|
||||
__PUT(typ, m->types, int32);
|
||||
__PUT(typ, m->types, uintptr);
|
||||
m->types = typ;
|
||||
}
|
||||
|
||||
|
|
@ -174,8 +174,8 @@ static uintptr Heap_NewChunk (uintptr blksz)
|
|||
__PUT(chnk + 4, chnk + (12 + blksz), uintptr);
|
||||
__PUT(chnk + 12, chnk + 16, uintptr);
|
||||
__PUT(chnk + 16, blksz, uintptr);
|
||||
__PUT(chnk + 20, -4, int32);
|
||||
__PUT(chnk + 24, Heap_bigBlocks, int32);
|
||||
__PUT(chnk + 20, -4, uintptr);
|
||||
__PUT(chnk + 24, Heap_bigBlocks, uintptr);
|
||||
Heap_bigBlocks = chnk + 12;
|
||||
Heap_heapsize += blksz;
|
||||
}
|
||||
|
|
@ -183,9 +183,9 @@ static uintptr Heap_NewChunk (uintptr blksz)
|
|||
return _o_result;
|
||||
}
|
||||
|
||||
static void Heap_ExtendHeap (int32 blksz)
|
||||
static void Heap_ExtendHeap (uintptr blksz)
|
||||
{
|
||||
int32 size, chnk, j, next;
|
||||
uintptr size, chnk, j, next;
|
||||
if (blksz > 160000) {
|
||||
size = blksz;
|
||||
} else {
|
||||
|
|
@ -203,8 +203,8 @@ static void Heap_ExtendHeap (int32 blksz)
|
|||
j = next;
|
||||
next = Heap_FetchAddress(j);
|
||||
}
|
||||
__PUT(chnk, next, int32);
|
||||
__PUT(j, chnk, int32);
|
||||
__PUT(chnk, next, uintptr);
|
||||
__PUT(j, chnk, uintptr);
|
||||
}
|
||||
if (next == 0) {
|
||||
Heap_heapend = Heap_FetchAddress(chnk + 4);
|
||||
|
|
@ -236,10 +236,10 @@ SYSTEM_PTR Heap_NEWREC (uintptr tag)
|
|||
restsize = __ASHL(di, 4);
|
||||
end = adr + restsize;
|
||||
__PUT(end + 4, blksz, uintptr);
|
||||
__PUT(end + 8, -4, int32);
|
||||
__PUT(end, end + 4, int32);
|
||||
__PUT(end + 8, -4, uintptr);
|
||||
__PUT(end, end + 4, uintptr);
|
||||
__PUT(adr + 4, restsize, uintptr);
|
||||
__PUT(adr + 12, Heap_freeList[di], int32);
|
||||
__PUT(adr + 12, Heap_freeList[di], uintptr);
|
||||
Heap_freeList[di] = adr;
|
||||
adr += restsize;
|
||||
}
|
||||
|
|
@ -280,8 +280,8 @@ SYSTEM_PTR Heap_NEWREC (uintptr tag)
|
|||
restsize = t - blksz;
|
||||
end = adr + restsize;
|
||||
__PUT(end + 4, blksz, uintptr);
|
||||
__PUT(end + 8, -4, int32);
|
||||
__PUT(end, end + 4, int32);
|
||||
__PUT(end + 8, -4, uintptr);
|
||||
__PUT(end, end + 4, uintptr);
|
||||
if (restsize > 144) {
|
||||
__PUT(adr + 4, restsize, uintptr);
|
||||
} else {
|
||||
|
|
@ -294,7 +294,7 @@ SYSTEM_PTR Heap_NEWREC (uintptr tag)
|
|||
if (restsize > 0) {
|
||||
di = __ASHR(restsize, 4);
|
||||
__PUT(adr + 4, restsize, uintptr);
|
||||
__PUT(adr + 12, Heap_freeList[di], int32);
|
||||
__PUT(adr + 12, Heap_freeList[di], uintptr);
|
||||
Heap_freeList[di] = adr;
|
||||
}
|
||||
}
|
||||
|
|
@ -303,16 +303,16 @@ SYSTEM_PTR Heap_NEWREC (uintptr tag)
|
|||
i = adr + 16;
|
||||
end = adr + blksz;
|
||||
while (i < end) {
|
||||
__PUT(i, 0, int32);
|
||||
__PUT(i + 4, 0, int32);
|
||||
__PUT(i + 8, 0, int32);
|
||||
__PUT(i + 12, 0, int32);
|
||||
__PUT(i, 0, uintptr);
|
||||
__PUT(i + 4, 0, uintptr);
|
||||
__PUT(i + 8, 0, uintptr);
|
||||
__PUT(i + 12, 0, uintptr);
|
||||
i += 16;
|
||||
}
|
||||
__PUT(adr + 12, 0, int32);
|
||||
__PUT(adr + 12, 0, uintptr);
|
||||
__PUT(adr, tag, uintptr);
|
||||
__PUT(adr + 4, 0, int32);
|
||||
__PUT(adr + 8, 0, int32);
|
||||
__PUT(adr + 4, 0, uintptr);
|
||||
__PUT(adr + 8, 0, uintptr);
|
||||
Heap_allocated += blksz;
|
||||
Heap_Unlock();
|
||||
_o_result = (SYSTEM_PTR)(uintptr)(adr + 4);
|
||||
|
|
@ -327,29 +327,29 @@ SYSTEM_PTR Heap_NEWBLK (uintptr size)
|
|||
Heap_Lock();
|
||||
blksz = __ASHL(__ASHR(size + 31, 4), 4);
|
||||
new = Heap_NEWREC((uintptr)&blksz);
|
||||
tag = (((int32)(uintptr)new) + blksz) - 12;
|
||||
__PUT(tag - 4, 0, int32);
|
||||
tag = ((uintptr)(uintptr)new + blksz) - 12;
|
||||
__PUT(tag - 4, 0, uintptr);
|
||||
__PUT(tag, blksz, uintptr);
|
||||
__PUT(tag + 4, -4, int32);
|
||||
__PUT((int32)(uintptr)new - 4, tag, uintptr);
|
||||
__PUT(tag + 4, -4, uintptr);
|
||||
__PUT((uintptr)(uintptr)new - 4, tag, uintptr);
|
||||
Heap_Unlock();
|
||||
_o_result = new;
|
||||
return _o_result;
|
||||
}
|
||||
|
||||
static void Heap_Mark (int32 q)
|
||||
static void Heap_Mark (uintptr q)
|
||||
{
|
||||
int32 p, tag, fld, n, offset, tagbits;
|
||||
uintptr p, tag, offset, fld, n, tagbits;
|
||||
if (q != 0) {
|
||||
tagbits = Heap_FetchAddress(q - 4);
|
||||
if (!__ODD(tagbits)) {
|
||||
__PUT(q - 4, tagbits + 1, int32);
|
||||
__PUT(q - 4, tagbits + 1, uintptr);
|
||||
p = 0;
|
||||
tag = tagbits + 4;
|
||||
for (;;) {
|
||||
__GET(tag, offset, int32);
|
||||
if (offset < 0) {
|
||||
__PUT(q - 4, (tag + offset) + 1, int32);
|
||||
__GET(tag, offset, uintptr);
|
||||
if (__BIT((uintptr)&offset, 31)) {
|
||||
__PUT(q - 4, (tag + offset) + 1, uintptr);
|
||||
if (p == 0) {
|
||||
break;
|
||||
}
|
||||
|
|
@ -357,7 +357,7 @@ static void Heap_Mark (int32 q)
|
|||
q = p;
|
||||
tag = Heap_FetchAddress(q - 4);
|
||||
tag -= 1;
|
||||
__GET(tag, offset, int32);
|
||||
__GET(tag, offset, uintptr);
|
||||
fld = q + offset;
|
||||
p = Heap_FetchAddress(fld);
|
||||
__PUT(fld, (SYSTEM_PTR)(uintptr)n, SYSTEM_PTR);
|
||||
|
|
@ -367,8 +367,8 @@ static void Heap_Mark (int32 q)
|
|||
if (n != 0) {
|
||||
tagbits = Heap_FetchAddress(n - 4);
|
||||
if (!__ODD(tagbits)) {
|
||||
__PUT(n - 4, tagbits + 1, int32);
|
||||
__PUT(q - 4, tag + 1, int32);
|
||||
__PUT(n - 4, tagbits + 1, uintptr);
|
||||
__PUT(q - 4, tag + 1, uintptr);
|
||||
__PUT(fld, (SYSTEM_PTR)(uintptr)p, SYSTEM_PTR);
|
||||
p = q;
|
||||
q = n;
|
||||
|
|
@ -384,7 +384,7 @@ static void Heap_Mark (int32 q)
|
|||
|
||||
static void Heap_MarkP (SYSTEM_PTR p)
|
||||
{
|
||||
Heap_Mark((int32)(uintptr)p);
|
||||
Heap_Mark((uintptr)(uintptr)p);
|
||||
}
|
||||
|
||||
static void Heap_Scan (void)
|
||||
|
|
@ -409,14 +409,14 @@ static void Heap_Scan (void)
|
|||
start = adr - freesize;
|
||||
__PUT(start, start + 4, uintptr);
|
||||
__PUT(start + 4, freesize, uintptr);
|
||||
__PUT(start + 8, -4, int32);
|
||||
__PUT(start + 8, -4, uintptr);
|
||||
i = __ASHR(freesize, 4);
|
||||
freesize = 0;
|
||||
if (i < 9) {
|
||||
__PUT(start + 12, Heap_freeList[i], int32);
|
||||
__PUT(start + 12, Heap_freeList[i], uintptr);
|
||||
Heap_freeList[i] = start;
|
||||
} else {
|
||||
__PUT(start + 12, Heap_bigBlocks, int32);
|
||||
__PUT(start + 12, Heap_bigBlocks, uintptr);
|
||||
Heap_bigBlocks = start;
|
||||
}
|
||||
}
|
||||
|
|
@ -435,14 +435,14 @@ static void Heap_Scan (void)
|
|||
start = adr - freesize;
|
||||
__PUT(start, start + 4, uintptr);
|
||||
__PUT(start + 4, freesize, uintptr);
|
||||
__PUT(start + 8, -4, int32);
|
||||
__PUT(start + 8, -4, uintptr);
|
||||
i = __ASHR(freesize, 4);
|
||||
freesize = 0;
|
||||
if (i < 9) {
|
||||
__PUT(start + 12, Heap_freeList[i], int32);
|
||||
__PUT(start + 12, Heap_freeList[i], uintptr);
|
||||
Heap_freeList[i] = start;
|
||||
} else {
|
||||
__PUT(start + 12, Heap_bigBlocks, int32);
|
||||
__PUT(start + 12, Heap_bigBlocks, uintptr);
|
||||
Heap_bigBlocks = start;
|
||||
}
|
||||
}
|
||||
|
|
@ -450,9 +450,9 @@ static void Heap_Scan (void)
|
|||
}
|
||||
}
|
||||
|
||||
static void Heap_Sift (int32 l, int32 r, int32 *a, LONGINT a__len)
|
||||
static void Heap_Sift (uintptr l, uintptr r, uintptr *a, LONGINT a__len)
|
||||
{
|
||||
int32 i, j, x;
|
||||
uintptr i, j, x;
|
||||
j = l;
|
||||
x = a[j];
|
||||
for (;;) {
|
||||
|
|
@ -469,9 +469,9 @@ static void Heap_Sift (int32 l, int32 r, int32 *a, LONGINT a__len)
|
|||
a[i] = x;
|
||||
}
|
||||
|
||||
static void Heap_HeapSort (int32 n, int32 *a, LONGINT a__len)
|
||||
static void Heap_HeapSort (uintptr n, uintptr *a, LONGINT a__len)
|
||||
{
|
||||
int32 l, r, x;
|
||||
uintptr l, r, x;
|
||||
l = __ASHR(n, 1);
|
||||
r = n - 1;
|
||||
while (l > 0) {
|
||||
|
|
@ -487,9 +487,9 @@ static void Heap_HeapSort (int32 n, int32 *a, LONGINT a__len)
|
|||
}
|
||||
}
|
||||
|
||||
static void Heap_MarkCandidates (int32 n, int32 *cand, LONGINT cand__len)
|
||||
static void Heap_MarkCandidates (uintptr n, uintptr *cand, LONGINT cand__len)
|
||||
{
|
||||
int32 chnk, adr, tag, next, lim, lim1, i, ptr, size;
|
||||
uintptr chnk, adr, tag, next, lim, lim1, i, ptr, size;
|
||||
chnk = Heap_heap;
|
||||
i = 0;
|
||||
lim = cand[n - 1];
|
||||
|
|
@ -527,7 +527,7 @@ static void Heap_MarkCandidates (int32 n, int32 *cand, LONGINT cand__len)
|
|||
static void Heap_CheckFin (void)
|
||||
{
|
||||
Heap_FinNode n;
|
||||
int32 tag;
|
||||
uintptr tag;
|
||||
n = Heap_fin;
|
||||
while (n != NIL) {
|
||||
tag = Heap_FetchAddress(n->obj - 4);
|
||||
|
|
@ -576,10 +576,10 @@ void Heap_FINALL (void)
|
|||
}
|
||||
}
|
||||
|
||||
static void Heap_MarkStack (int32 n, int32 *cand, LONGINT cand__len)
|
||||
static void Heap_MarkStack (uintptr n, uintptr *cand, LONGINT cand__len)
|
||||
{
|
||||
SYSTEM_PTR frame;
|
||||
int32 inc, nofcand, sp, p, stack0;
|
||||
uintptr inc, nofcand, sp, p, stack0;
|
||||
struct Heap__1 align;
|
||||
if (n > 0) {
|
||||
Heap_MarkStack(n - 1, cand, cand__len);
|
||||
|
|
@ -596,7 +596,7 @@ static void Heap_MarkStack (int32 n, int32 *cand, LONGINT cand__len)
|
|||
inc = -inc;
|
||||
}
|
||||
while (sp != stack0) {
|
||||
__GET(sp, p, int32);
|
||||
__GET(sp, p, uintptr);
|
||||
if ((p > Heap_heap && p < Heap_heapend)) {
|
||||
if (nofcand == cand__len) {
|
||||
Heap_HeapSort(nofcand, (void*)cand, cand__len);
|
||||
|
|
@ -618,8 +618,8 @@ static void Heap_MarkStack (int32 n, int32 *cand, LONGINT cand__len)
|
|||
void Heap_GC (BOOLEAN markStack)
|
||||
{
|
||||
Heap_Module m;
|
||||
int32 i0, i1, i2, i3, i4, i5, i6, i7, i8, i9, i10, i11, i12, i13, i14, i15, i16, i17, i18, i19, i20, i21, i22, i23;
|
||||
int32 cand[10000];
|
||||
uintptr i0, i1, i2, i3, i4, i5, i6, i7, i8, i9, i10, i11, i12, i13, i14, i15, i16, i17, i18, i19, i20, i21, i22, i23;
|
||||
uintptr cand[10000];
|
||||
if (Heap_lockdepth == 0 || (Heap_lockdepth == 1 && !markStack)) {
|
||||
Heap_Lock();
|
||||
m = (Heap_Module)(uintptr)Heap_modules;
|
||||
|
|
@ -699,7 +699,7 @@ void Heap_RegisterFinalizer (SYSTEM_PTR obj, Heap_Finalizer finalize)
|
|||
{
|
||||
Heap_FinNode f;
|
||||
__NEW(f, Heap_FinDesc);
|
||||
f->obj = (int32)(uintptr)obj;
|
||||
f->obj = (uintptr)(uintptr)obj;
|
||||
f->finalize = finalize;
|
||||
f->marked = 1;
|
||||
f->next = Heap_fin;
|
||||
|
|
@ -710,7 +710,7 @@ void Heap_InitHeap (void)
|
|||
{
|
||||
Heap_heap = Heap_NewChunk(128000);
|
||||
Heap_heapend = Heap_FetchAddress(Heap_heap + 4);
|
||||
__PUT(Heap_heap, 0, int32);
|
||||
__PUT(Heap_heap, 0, uintptr);
|
||||
Heap_allocated = 0;
|
||||
Heap_firstTry = 1;
|
||||
Heap_freeList[9] = 1;
|
||||
|
|
|
|||
|
|
@ -52,15 +52,15 @@ typedef
|
|||
Heap_ModuleName name;
|
||||
int64 refcnt;
|
||||
Heap_Cmd cmds;
|
||||
int64 types;
|
||||
uintptr types;
|
||||
Heap_EnumProc enumPtrs;
|
||||
int64 reserved1, reserved2;
|
||||
} Heap_ModuleDesc;
|
||||
|
||||
|
||||
export SYSTEM_PTR Heap_modules;
|
||||
static int64 Heap_freeList[10];
|
||||
static int64 Heap_bigBlocks;
|
||||
static uintptr Heap_freeList[10];
|
||||
static uintptr Heap_bigBlocks;
|
||||
export uintptr Heap_allocated;
|
||||
static BOOLEAN Heap_firstTry;
|
||||
static uintptr Heap_heap, Heap_heapend;
|
||||
|
|
@ -76,18 +76,18 @@ export LONGINT *Heap_FinDesc__typ;
|
|||
export LONGINT *Heap__1__typ;
|
||||
|
||||
static void Heap_CheckFin (void);
|
||||
static void Heap_ExtendHeap (int64 blksz);
|
||||
static void Heap_ExtendHeap (uintptr blksz);
|
||||
export void Heap_FINALL (void);
|
||||
static void Heap_Finalize (void);
|
||||
export void Heap_GC (BOOLEAN markStack);
|
||||
static void Heap_HeapSort (int64 n, int64 *a, LONGINT a__len);
|
||||
static void Heap_HeapSort (uintptr n, uintptr *a, LONGINT a__len);
|
||||
export void Heap_INCREF (Heap_Module m);
|
||||
export void Heap_InitHeap (void);
|
||||
export void Heap_Lock (void);
|
||||
static void Heap_Mark (int64 q);
|
||||
static void Heap_MarkCandidates (int64 n, int64 *cand, LONGINT cand__len);
|
||||
static void Heap_Mark (uintptr q);
|
||||
static void Heap_MarkCandidates (uintptr n, uintptr *cand, LONGINT cand__len);
|
||||
static void Heap_MarkP (SYSTEM_PTR p);
|
||||
static void Heap_MarkStack (int64 n, int64 *cand, LONGINT cand__len);
|
||||
static void Heap_MarkStack (uintptr n, uintptr *cand, LONGINT cand__len);
|
||||
export SYSTEM_PTR Heap_NEWBLK (uintptr size);
|
||||
export SYSTEM_PTR Heap_NEWREC (uintptr tag);
|
||||
static uintptr Heap_NewChunk (uintptr blksz);
|
||||
|
|
@ -96,11 +96,11 @@ export SYSTEM_PTR Heap_REGMOD (Heap_ModuleName name, Heap_EnumProc enumPtrs);
|
|||
export void Heap_REGTYP (Heap_Module m, uintptr typ);
|
||||
export void Heap_RegisterFinalizer (SYSTEM_PTR obj, Heap_Finalizer finalize);
|
||||
static void Heap_Scan (void);
|
||||
static void Heap_Sift (int64 l, int64 r, int64 *a, LONGINT a__len);
|
||||
static void Heap_Sift (uintptr l, uintptr r, uintptr *a, LONGINT a__len);
|
||||
export void Heap_Unlock (void);
|
||||
|
||||
extern void *Heap__init();
|
||||
extern LONGINT Platform_MainStackFrame;
|
||||
extern uintptr Platform_MainStackFrame;
|
||||
extern uintptr Platform_OSAllocate(uintptr size);
|
||||
#define Heap_FetchAddress(pointer) (uintptr)(*((void**)((uintptr)pointer)))
|
||||
#define Heap_HeapModuleInit() Heap__init()
|
||||
|
|
@ -157,7 +157,7 @@ void Heap_REGCMD (Heap_Module m, Heap_CmdName name, Heap_Command cmd)
|
|||
|
||||
void Heap_REGTYP (Heap_Module m, uintptr typ)
|
||||
{
|
||||
__PUT(typ, m->types, int64);
|
||||
__PUT(typ, m->types, uintptr);
|
||||
m->types = typ;
|
||||
}
|
||||
|
||||
|
|
@ -175,8 +175,8 @@ static uintptr Heap_NewChunk (uintptr blksz)
|
|||
__PUT(chnk + 8, chnk + (24 + blksz), uintptr);
|
||||
__PUT(chnk + 24, chnk + 32, uintptr);
|
||||
__PUT(chnk + 32, blksz, uintptr);
|
||||
__PUT(chnk + 40, -8, int64);
|
||||
__PUT(chnk + 48, Heap_bigBlocks, int64);
|
||||
__PUT(chnk + 40, -8, uintptr);
|
||||
__PUT(chnk + 48, Heap_bigBlocks, uintptr);
|
||||
Heap_bigBlocks = chnk + 24;
|
||||
Heap_heapsize += blksz;
|
||||
}
|
||||
|
|
@ -184,9 +184,9 @@ static uintptr Heap_NewChunk (uintptr blksz)
|
|||
return _o_result;
|
||||
}
|
||||
|
||||
static void Heap_ExtendHeap (int64 blksz)
|
||||
static void Heap_ExtendHeap (uintptr blksz)
|
||||
{
|
||||
int64 size, chnk, j, next;
|
||||
uintptr size, chnk, j, next;
|
||||
if (blksz > 320000) {
|
||||
size = blksz;
|
||||
} else {
|
||||
|
|
@ -204,8 +204,8 @@ static void Heap_ExtendHeap (int64 blksz)
|
|||
j = next;
|
||||
next = Heap_FetchAddress(j);
|
||||
}
|
||||
__PUT(chnk, next, int64);
|
||||
__PUT(j, chnk, int64);
|
||||
__PUT(chnk, next, uintptr);
|
||||
__PUT(j, chnk, uintptr);
|
||||
}
|
||||
if (next == 0) {
|
||||
Heap_heapend = Heap_FetchAddress(chnk + 8);
|
||||
|
|
@ -237,10 +237,10 @@ SYSTEM_PTR Heap_NEWREC (uintptr tag)
|
|||
restsize = __ASHL(di, 5);
|
||||
end = adr + restsize;
|
||||
__PUT(end + 8, blksz, uintptr);
|
||||
__PUT(end + 16, -8, int64);
|
||||
__PUT(end, end + 8, int64);
|
||||
__PUT(end + 16, -8, uintptr);
|
||||
__PUT(end, end + 8, uintptr);
|
||||
__PUT(adr + 8, restsize, uintptr);
|
||||
__PUT(adr + 24, Heap_freeList[di], int64);
|
||||
__PUT(adr + 24, Heap_freeList[di], uintptr);
|
||||
Heap_freeList[di] = adr;
|
||||
adr += restsize;
|
||||
}
|
||||
|
|
@ -281,8 +281,8 @@ SYSTEM_PTR Heap_NEWREC (uintptr tag)
|
|||
restsize = t - blksz;
|
||||
end = adr + restsize;
|
||||
__PUT(end + 8, blksz, uintptr);
|
||||
__PUT(end + 16, -8, int64);
|
||||
__PUT(end, end + 8, int64);
|
||||
__PUT(end + 16, -8, uintptr);
|
||||
__PUT(end, end + 8, uintptr);
|
||||
if (restsize > 288) {
|
||||
__PUT(adr + 8, restsize, uintptr);
|
||||
} else {
|
||||
|
|
@ -295,7 +295,7 @@ SYSTEM_PTR Heap_NEWREC (uintptr tag)
|
|||
if (restsize > 0) {
|
||||
di = __ASHR(restsize, 5);
|
||||
__PUT(adr + 8, restsize, uintptr);
|
||||
__PUT(adr + 24, Heap_freeList[di], int64);
|
||||
__PUT(adr + 24, Heap_freeList[di], uintptr);
|
||||
Heap_freeList[di] = adr;
|
||||
}
|
||||
}
|
||||
|
|
@ -304,16 +304,16 @@ SYSTEM_PTR Heap_NEWREC (uintptr tag)
|
|||
i = adr + 32;
|
||||
end = adr + blksz;
|
||||
while (i < end) {
|
||||
__PUT(i, 0, int64);
|
||||
__PUT(i + 8, 0, int64);
|
||||
__PUT(i + 16, 0, int64);
|
||||
__PUT(i + 24, 0, int64);
|
||||
__PUT(i, 0, uintptr);
|
||||
__PUT(i + 8, 0, uintptr);
|
||||
__PUT(i + 16, 0, uintptr);
|
||||
__PUT(i + 24, 0, uintptr);
|
||||
i += 32;
|
||||
}
|
||||
__PUT(adr + 24, 0, int64);
|
||||
__PUT(adr + 24, 0, uintptr);
|
||||
__PUT(adr, tag, uintptr);
|
||||
__PUT(adr + 8, 0, int64);
|
||||
__PUT(adr + 16, 0, int64);
|
||||
__PUT(adr + 8, 0, uintptr);
|
||||
__PUT(adr + 16, 0, uintptr);
|
||||
Heap_allocated += blksz;
|
||||
Heap_Unlock();
|
||||
_o_result = (SYSTEM_PTR)(uintptr)(adr + 8);
|
||||
|
|
@ -328,29 +328,29 @@ SYSTEM_PTR Heap_NEWBLK (uintptr size)
|
|||
Heap_Lock();
|
||||
blksz = __ASHL(__ASHR(size + 63, 5), 5);
|
||||
new = Heap_NEWREC((uintptr)&blksz);
|
||||
tag = (((int64)(uintptr)new) + blksz) - 24;
|
||||
__PUT(tag - 8, 0, int64);
|
||||
tag = ((uintptr)(uintptr)new + blksz) - 24;
|
||||
__PUT(tag - 8, 0, uintptr);
|
||||
__PUT(tag, blksz, uintptr);
|
||||
__PUT(tag + 8, -8, int64);
|
||||
__PUT((int64)(uintptr)new - 8, tag, uintptr);
|
||||
__PUT(tag + 8, -8, uintptr);
|
||||
__PUT((uintptr)(uintptr)new - 8, tag, uintptr);
|
||||
Heap_Unlock();
|
||||
_o_result = new;
|
||||
return _o_result;
|
||||
}
|
||||
|
||||
static void Heap_Mark (int64 q)
|
||||
static void Heap_Mark (uintptr q)
|
||||
{
|
||||
int64 p, tag, fld, n, offset, tagbits;
|
||||
uintptr p, tag, offset, fld, n, tagbits;
|
||||
if (q != 0) {
|
||||
tagbits = Heap_FetchAddress(q - 8);
|
||||
if (!__ODD(tagbits)) {
|
||||
__PUT(q - 8, tagbits + 1, int64);
|
||||
__PUT(q - 8, tagbits + 1, uintptr);
|
||||
p = 0;
|
||||
tag = tagbits + 8;
|
||||
for (;;) {
|
||||
__GET(tag, offset, int64);
|
||||
if (offset < 0) {
|
||||
__PUT(q - 8, (tag + offset) + 1, int64);
|
||||
__GET(tag, offset, uintptr);
|
||||
if (__BIT((uintptr)&offset, 63)) {
|
||||
__PUT(q - 8, (tag + offset) + 1, uintptr);
|
||||
if (p == 0) {
|
||||
break;
|
||||
}
|
||||
|
|
@ -358,7 +358,7 @@ static void Heap_Mark (int64 q)
|
|||
q = p;
|
||||
tag = Heap_FetchAddress(q - 8);
|
||||
tag -= 1;
|
||||
__GET(tag, offset, int64);
|
||||
__GET(tag, offset, uintptr);
|
||||
fld = q + offset;
|
||||
p = Heap_FetchAddress(fld);
|
||||
__PUT(fld, (SYSTEM_PTR)(uintptr)n, SYSTEM_PTR);
|
||||
|
|
@ -368,8 +368,8 @@ static void Heap_Mark (int64 q)
|
|||
if (n != 0) {
|
||||
tagbits = Heap_FetchAddress(n - 8);
|
||||
if (!__ODD(tagbits)) {
|
||||
__PUT(n - 8, tagbits + 1, int64);
|
||||
__PUT(q - 8, tag + 1, int64);
|
||||
__PUT(n - 8, tagbits + 1, uintptr);
|
||||
__PUT(q - 8, tag + 1, uintptr);
|
||||
__PUT(fld, (SYSTEM_PTR)(uintptr)p, SYSTEM_PTR);
|
||||
p = q;
|
||||
q = n;
|
||||
|
|
@ -385,7 +385,7 @@ static void Heap_Mark (int64 q)
|
|||
|
||||
static void Heap_MarkP (SYSTEM_PTR p)
|
||||
{
|
||||
Heap_Mark((int64)(uintptr)p);
|
||||
Heap_Mark((uintptr)(uintptr)p);
|
||||
}
|
||||
|
||||
static void Heap_Scan (void)
|
||||
|
|
@ -410,14 +410,14 @@ static void Heap_Scan (void)
|
|||
start = adr - freesize;
|
||||
__PUT(start, start + 8, uintptr);
|
||||
__PUT(start + 8, freesize, uintptr);
|
||||
__PUT(start + 16, -8, int64);
|
||||
__PUT(start + 16, -8, uintptr);
|
||||
i = __ASHR(freesize, 5);
|
||||
freesize = 0;
|
||||
if (i < 9) {
|
||||
__PUT(start + 24, Heap_freeList[i], int64);
|
||||
__PUT(start + 24, Heap_freeList[i], uintptr);
|
||||
Heap_freeList[i] = start;
|
||||
} else {
|
||||
__PUT(start + 24, Heap_bigBlocks, int64);
|
||||
__PUT(start + 24, Heap_bigBlocks, uintptr);
|
||||
Heap_bigBlocks = start;
|
||||
}
|
||||
}
|
||||
|
|
@ -436,14 +436,14 @@ static void Heap_Scan (void)
|
|||
start = adr - freesize;
|
||||
__PUT(start, start + 8, uintptr);
|
||||
__PUT(start + 8, freesize, uintptr);
|
||||
__PUT(start + 16, -8, int64);
|
||||
__PUT(start + 16, -8, uintptr);
|
||||
i = __ASHR(freesize, 5);
|
||||
freesize = 0;
|
||||
if (i < 9) {
|
||||
__PUT(start + 24, Heap_freeList[i], int64);
|
||||
__PUT(start + 24, Heap_freeList[i], uintptr);
|
||||
Heap_freeList[i] = start;
|
||||
} else {
|
||||
__PUT(start + 24, Heap_bigBlocks, int64);
|
||||
__PUT(start + 24, Heap_bigBlocks, uintptr);
|
||||
Heap_bigBlocks = start;
|
||||
}
|
||||
}
|
||||
|
|
@ -451,9 +451,9 @@ static void Heap_Scan (void)
|
|||
}
|
||||
}
|
||||
|
||||
static void Heap_Sift (int64 l, int64 r, int64 *a, LONGINT a__len)
|
||||
static void Heap_Sift (uintptr l, uintptr r, uintptr *a, LONGINT a__len)
|
||||
{
|
||||
int64 i, j, x;
|
||||
uintptr i, j, x;
|
||||
j = l;
|
||||
x = a[j];
|
||||
for (;;) {
|
||||
|
|
@ -470,9 +470,9 @@ static void Heap_Sift (int64 l, int64 r, int64 *a, LONGINT a__len)
|
|||
a[i] = x;
|
||||
}
|
||||
|
||||
static void Heap_HeapSort (int64 n, int64 *a, LONGINT a__len)
|
||||
static void Heap_HeapSort (uintptr n, uintptr *a, LONGINT a__len)
|
||||
{
|
||||
int64 l, r, x;
|
||||
uintptr l, r, x;
|
||||
l = __ASHR(n, 1);
|
||||
r = n - 1;
|
||||
while (l > 0) {
|
||||
|
|
@ -488,9 +488,9 @@ static void Heap_HeapSort (int64 n, int64 *a, LONGINT a__len)
|
|||
}
|
||||
}
|
||||
|
||||
static void Heap_MarkCandidates (int64 n, int64 *cand, LONGINT cand__len)
|
||||
static void Heap_MarkCandidates (uintptr n, uintptr *cand, LONGINT cand__len)
|
||||
{
|
||||
int64 chnk, adr, tag, next, lim, lim1, i, ptr, size;
|
||||
uintptr chnk, adr, tag, next, lim, lim1, i, ptr, size;
|
||||
chnk = Heap_heap;
|
||||
i = 0;
|
||||
lim = cand[n - 1];
|
||||
|
|
@ -528,7 +528,7 @@ static void Heap_MarkCandidates (int64 n, int64 *cand, LONGINT cand__len)
|
|||
static void Heap_CheckFin (void)
|
||||
{
|
||||
Heap_FinNode n;
|
||||
int64 tag;
|
||||
uintptr tag;
|
||||
n = Heap_fin;
|
||||
while (n != NIL) {
|
||||
tag = Heap_FetchAddress(n->obj - 8);
|
||||
|
|
@ -577,10 +577,10 @@ void Heap_FINALL (void)
|
|||
}
|
||||
}
|
||||
|
||||
static void Heap_MarkStack (int64 n, int64 *cand, LONGINT cand__len)
|
||||
static void Heap_MarkStack (uintptr n, uintptr *cand, LONGINT cand__len)
|
||||
{
|
||||
SYSTEM_PTR frame;
|
||||
int64 inc, nofcand, sp, p, stack0;
|
||||
uintptr inc, nofcand, sp, p, stack0;
|
||||
struct Heap__1 align;
|
||||
if (n > 0) {
|
||||
Heap_MarkStack(n - 1, cand, cand__len);
|
||||
|
|
@ -597,7 +597,7 @@ static void Heap_MarkStack (int64 n, int64 *cand, LONGINT cand__len)
|
|||
inc = -inc;
|
||||
}
|
||||
while (sp != stack0) {
|
||||
__GET(sp, p, int64);
|
||||
__GET(sp, p, uintptr);
|
||||
if ((p > Heap_heap && p < Heap_heapend)) {
|
||||
if (nofcand == cand__len) {
|
||||
Heap_HeapSort(nofcand, (void*)cand, cand__len);
|
||||
|
|
@ -619,8 +619,8 @@ static void Heap_MarkStack (int64 n, int64 *cand, LONGINT cand__len)
|
|||
void Heap_GC (BOOLEAN markStack)
|
||||
{
|
||||
Heap_Module m;
|
||||
int64 i0, i1, i2, i3, i4, i5, i6, i7, i8, i9, i10, i11, i12, i13, i14, i15, i16, i17, i18, i19, i20, i21, i22, i23;
|
||||
int64 cand[10000];
|
||||
uintptr i0, i1, i2, i3, i4, i5, i6, i7, i8, i9, i10, i11, i12, i13, i14, i15, i16, i17, i18, i19, i20, i21, i22, i23;
|
||||
uintptr cand[10000];
|
||||
if (Heap_lockdepth == 0 || (Heap_lockdepth == 1 && !markStack)) {
|
||||
Heap_Lock();
|
||||
m = (Heap_Module)(uintptr)Heap_modules;
|
||||
|
|
@ -700,7 +700,7 @@ void Heap_RegisterFinalizer (SYSTEM_PTR obj, Heap_Finalizer finalize)
|
|||
{
|
||||
Heap_FinNode f;
|
||||
__NEW(f, Heap_FinDesc);
|
||||
f->obj = (int64)(uintptr)obj;
|
||||
f->obj = (uintptr)(uintptr)obj;
|
||||
f->finalize = finalize;
|
||||
f->marked = 1;
|
||||
f->next = Heap_fin;
|
||||
|
|
@ -711,7 +711,7 @@ void Heap_InitHeap (void)
|
|||
{
|
||||
Heap_heap = Heap_NewChunk(256000);
|
||||
Heap_heapend = Heap_FetchAddress(Heap_heap + 8);
|
||||
__PUT(Heap_heap, 0, int64);
|
||||
__PUT(Heap_heap, 0, uintptr);
|
||||
Heap_allocated = 0;
|
||||
Heap_firstTry = 1;
|
||||
Heap_freeList[9] = 1;
|
||||
|
|
|
|||
|
|
@ -6,30 +6,30 @@ MODULE Heap;
|
|||
CONST
|
||||
ModNameLen = 20;
|
||||
CmdNameLen = 24;
|
||||
SZL = SIZE(LONGINT);
|
||||
Unit = 4*SZL; (* smallest possible heap block *)
|
||||
nofLists = 9; (* number of free_lists *)
|
||||
heapSize0 = 8000*Unit; (* startup heap size *)
|
||||
SZA = SIZE(SYSTEM.UINTPTR); (* Size of address *)
|
||||
Unit = 4*SZA; (* smallest possible heap block *)
|
||||
nofLists = 9; (* number of free_lists *)
|
||||
heapSize0 = 8000*Unit; (* startup heap size *)
|
||||
|
||||
(* all blocks look the same:
|
||||
free blocks describe themselves: size = Unit
|
||||
tag = &tag++
|
||||
->block size
|
||||
sentinel = -SZL
|
||||
sentinel = -SZA
|
||||
next
|
||||
*)
|
||||
|
||||
(* heap chunks *)
|
||||
nextChnkOff = SYSTEM.VAL(SYSTEM.UINTPTR, 0); (* next heap chunk, sorted ascendingly! *)
|
||||
endOff = SYSTEM.VAL(SYSTEM.UINTPTR, SZL); (* end of heap chunk *)
|
||||
blkOff = SYSTEM.VAL(SYSTEM.UINTPTR, 3*SZL); (* first block in a chunk *)
|
||||
endOff = SYSTEM.VAL(SYSTEM.UINTPTR, SZA); (* end of heap chunk *)
|
||||
blkOff = SYSTEM.VAL(SYSTEM.UINTPTR, 3*SZA); (* first block in a chunk *)
|
||||
|
||||
(* heap blocks *)
|
||||
tagOff = SYSTEM.VAL(SYSTEM.UINTPTR, 0); (* block starts with tag *)
|
||||
sizeOff = SYSTEM.VAL(SYSTEM.UINTPTR, SZL); (* block size in free block relative to block start *)
|
||||
sntlOff = SYSTEM.VAL(SYSTEM.UINTPTR, 2*SZL); (* pointer offset table sentinel in free block relative to block start *)
|
||||
nextOff = SYSTEM.VAL(SYSTEM.UINTPTR, 3*SZL); (* next pointer in free block relative to block start *)
|
||||
NoPtrSntl = SYSTEM.VAL(SYSTEM.UINTPTR, -SZL);
|
||||
sizeOff = SYSTEM.VAL(SYSTEM.UINTPTR, SZA); (* block size in free block relative to block start *)
|
||||
sntlOff = SYSTEM.VAL(SYSTEM.UINTPTR, 2*SZA); (* pointer offset table sentinel in free block relative to block start *)
|
||||
nextOff = SYSTEM.VAL(SYSTEM.UINTPTR, 3*SZA); (* next pointer in free block relative to block start *)
|
||||
NoPtrSntl = SYSTEM.VAL(SYSTEM.UINTPTR, -SZA);
|
||||
AddressZero = SYSTEM.VAL(SYSTEM.UINTPTR, 0);
|
||||
|
||||
TYPE
|
||||
|
|
@ -46,7 +46,7 @@ MODULE Heap;
|
|||
name: ModuleName;
|
||||
refcnt: LONGINT;
|
||||
cmds: Cmd;
|
||||
types: LONGINT;
|
||||
types: SYSTEM.UINTPTR;
|
||||
enumPtrs: EnumProc;
|
||||
reserved1, reserved2: LONGINT
|
||||
END ;
|
||||
|
|
@ -73,8 +73,8 @@ MODULE Heap;
|
|||
(* the list of loaded (=initialization started) modules *)
|
||||
modules*: SYSTEM.PTR;
|
||||
|
||||
freeList: ARRAY nofLists + 1 OF LONGINT; (* dummy, 16, 32, 48, 64, 80, 96, 112, 128, sentinel *)
|
||||
bigBlocks: LONGINT;
|
||||
freeList: ARRAY nofLists + 1 OF SYSTEM.UINTPTR; (* dummy, 16, 32, 48, 64, 80, 96, 112, 128, sentinel *)
|
||||
bigBlocks: SYSTEM.UINTPTR;
|
||||
allocated*: SYSTEM.UINTPTR;
|
||||
firstTry: BOOLEAN;
|
||||
|
||||
|
|
@ -193,8 +193,8 @@ MODULE Heap;
|
|||
*)
|
||||
PROCEDURE -FetchAddress(pointer: SYSTEM.UINTPTR): SYSTEM.UINTPTR "(uintptr)(*((void**)((uintptr)pointer)))";
|
||||
|
||||
PROCEDURE ExtendHeap(blksz: LONGINT);
|
||||
VAR size, chnk, j, next: LONGINT;
|
||||
PROCEDURE ExtendHeap(blksz: SYSTEM.UINTPTR);
|
||||
VAR size, chnk, j, next: SYSTEM.UINTPTR;
|
||||
BEGIN
|
||||
IF blksz > 10000*Unit THEN size := blksz
|
||||
ELSE size := 10000*Unit (* additional heuristics *)
|
||||
|
|
@ -293,13 +293,13 @@ MODULE Heap;
|
|||
END ;
|
||||
INC(adr, restsize)
|
||||
END ;
|
||||
i := adr + 4*SZL; end := adr + blksz;
|
||||
i := adr + 4*SZA; end := adr + blksz;
|
||||
WHILE i < end DO (*deliberately unrolled*)
|
||||
SYSTEM.PUT(i, AddressZero);
|
||||
SYSTEM.PUT(i + SZL, AddressZero);
|
||||
SYSTEM.PUT(i + 2*SZL, AddressZero);
|
||||
SYSTEM.PUT(i + 3*SZL, AddressZero);
|
||||
INC(i, 4*SZL)
|
||||
SYSTEM.PUT(i + SZA, AddressZero);
|
||||
SYSTEM.PUT(i + 2*SZA, AddressZero);
|
||||
SYSTEM.PUT(i + 3*SZA, AddressZero);
|
||||
INC(i, 4*SZA)
|
||||
END ;
|
||||
SYSTEM.PUT(adr + nextOff, AddressZero);
|
||||
SYSTEM.PUT(adr, tag);
|
||||
|
|
@ -307,57 +307,58 @@ MODULE Heap;
|
|||
SYSTEM.PUT(adr + sntlOff, AddressZero);
|
||||
INC(allocated, blksz);
|
||||
Unlock();
|
||||
RETURN SYSTEM.VAL(SYSTEM.PTR, adr + SZL)
|
||||
RETURN SYSTEM.VAL(SYSTEM.PTR, adr + SZA)
|
||||
END NEWREC;
|
||||
|
||||
PROCEDURE NEWBLK*(size: SYSTEM.UINTPTR): SYSTEM.PTR;
|
||||
VAR blksz, tag: SYSTEM.UINTPTR; new: SYSTEM.PTR;
|
||||
BEGIN
|
||||
Lock();
|
||||
blksz := (size + (4*SZL + Unit - 1)) DIV Unit * Unit; (*size + tag + meta + blksz + sntnl + UnitAlignment*)
|
||||
blksz := (size + (4*SZA + Unit - 1)) DIV Unit * Unit; (*size + tag + meta + blksz + sntnl + UnitAlignment*)
|
||||
new := NEWREC(SYSTEM.ADR(blksz));
|
||||
tag := SYSTEM.VAL(LONGINT, new) + blksz - 3*SZL;
|
||||
SYSTEM.PUT(tag - SZL, AddressZero); (*reserved for meta info*)
|
||||
tag := SYSTEM.VAL(SYSTEM.UINTPTR, new) + blksz - 3*SZA;
|
||||
SYSTEM.PUT(tag - SZA, AddressZero); (*reserved for meta info*)
|
||||
SYSTEM.PUT(tag, blksz);
|
||||
SYSTEM.PUT(tag + SZL, NoPtrSntl);
|
||||
SYSTEM.PUT(SYSTEM.VAL(LONGINT, new) - SZL, tag);
|
||||
SYSTEM.PUT(tag + SZA, NoPtrSntl);
|
||||
SYSTEM.PUT(SYSTEM.VAL(SYSTEM.UINTPTR, new) - SZA, tag);
|
||||
Unlock();
|
||||
RETURN new
|
||||
END NEWBLK;
|
||||
|
||||
PROCEDURE Mark(q: LONGINT);
|
||||
VAR p, tag, fld, n, offset, tagbits: LONGINT;
|
||||
PROCEDURE Mark(q: SYSTEM.UINTPTR);
|
||||
VAR p, tag, offset, fld, n, tagbits: SYSTEM.UINTPTR;
|
||||
BEGIN
|
||||
IF q # 0 THEN
|
||||
tagbits := FetchAddress(q - SZL); (* Load the tag for the record at q *)
|
||||
tagbits := FetchAddress(q - SZA); (* Load the tag for the record at q *)
|
||||
IF ~ODD(tagbits) THEN (* If it has not already been marked *)
|
||||
SYSTEM.PUT(q - SZL, tagbits + 1); (* Mark it *)
|
||||
SYSTEM.PUT(q - SZA, tagbits + 1); (* Mark it *)
|
||||
p := 0;
|
||||
tag := tagbits + SZL; (* Tag addresses first offset *)
|
||||
tag := tagbits + SZA; (* Tag addresses first offset *)
|
||||
LOOP
|
||||
SYSTEM.GET(tag, offset); (* Get next ptr field offset *)
|
||||
IF offset < 0 THEN (* If sentinel. (Value is -8*(#fields+1) *)
|
||||
SYSTEM.PUT(q - SZL, tag + offset + 1); (* Rotate base ptr into tag *)
|
||||
IF SYSTEM.BIT(SYSTEM.ADR(offset), SIZE(SYSTEM.UINTPTR)*8 - 1) THEN
|
||||
(* Sentinel reached: Value is -8*(#fields+1) *)
|
||||
SYSTEM.PUT(q - SZA, tag + offset + 1); (* Rotate base ptr into tag *)
|
||||
IF p = 0 THEN EXIT END ;
|
||||
n := q; q := p;
|
||||
tag := FetchAddress(q - SZL); DEC(tag, 1);
|
||||
tag := FetchAddress(q - SZA); DEC(tag, 1);
|
||||
SYSTEM.GET(tag, offset); fld := q + offset;
|
||||
p := FetchAddress(fld); SYSTEM.PUT(fld, SYSTEM.VAL(SYSTEM.PTR, n))
|
||||
ELSE (* offset references a ptr field *)
|
||||
fld := q + offset; (* Address the pointer *)
|
||||
n := FetchAddress(fld); (* Load the pointer *)
|
||||
IF n # 0 THEN (* If pointer is not NIL *)
|
||||
tagbits := FetchAddress(n - SZL); (* Consider record pointed to by this field *)
|
||||
tagbits := FetchAddress(n - SZA); (* Consider record pointed to by this field *)
|
||||
IF ~ODD(tagbits) THEN
|
||||
SYSTEM.PUT(n - SZL, tagbits + 1);
|
||||
SYSTEM.PUT(q - SZL, tag + 1);
|
||||
SYSTEM.PUT(n - SZA, tagbits + 1);
|
||||
SYSTEM.PUT(q - SZA, tag + 1);
|
||||
SYSTEM.PUT(fld, SYSTEM.VAL(SYSTEM.PTR, p));
|
||||
p := q; q := n;
|
||||
tag := tagbits
|
||||
END
|
||||
END
|
||||
END ;
|
||||
INC(tag, SZL)
|
||||
INC(tag, SZA)
|
||||
END
|
||||
END
|
||||
END
|
||||
|
|
@ -365,7 +366,7 @@ MODULE Heap;
|
|||
|
||||
PROCEDURE MarkP(p: SYSTEM.PTR); (* for compatibility with EnumPtrs in ANSI mode *)
|
||||
BEGIN
|
||||
Mark(SYSTEM.VAL(LONGINT, p))
|
||||
Mark(SYSTEM.VAL(SYSTEM.UINTPTR, p))
|
||||
END MarkP;
|
||||
|
||||
PROCEDURE Scan;
|
||||
|
|
@ -381,7 +382,7 @@ MODULE Heap;
|
|||
IF ODD(tag) THEN (*marked*)
|
||||
IF freesize > 0 THEN
|
||||
start := adr - freesize;
|
||||
SYSTEM.PUT(start, start+SZL);
|
||||
SYSTEM.PUT(start, start+SZA);
|
||||
SYSTEM.PUT(start+sizeOff, freesize);
|
||||
SYSTEM.PUT(start+sntlOff, NoPtrSntl);
|
||||
i := freesize DIV Unit; freesize := 0;
|
||||
|
|
@ -402,7 +403,7 @@ MODULE Heap;
|
|||
END ;
|
||||
IF freesize > 0 THEN (*collect last block*)
|
||||
start := adr - freesize;
|
||||
SYSTEM.PUT(start, start+SZL);
|
||||
SYSTEM.PUT(start, start+SZA);
|
||||
SYSTEM.PUT(start+sizeOff, freesize);
|
||||
SYSTEM.PUT(start+sntlOff, NoPtrSntl);
|
||||
i := freesize DIV Unit; freesize := 0;
|
||||
|
|
@ -414,8 +415,8 @@ MODULE Heap;
|
|||
END
|
||||
END Scan;
|
||||
|
||||
PROCEDURE Sift (l, r: LONGINT; VAR a: ARRAY OF LONGINT);
|
||||
VAR i, j, x: LONGINT;
|
||||
PROCEDURE Sift (l, r: SYSTEM.UINTPTR; VAR a: ARRAY OF SYSTEM.UINTPTR);
|
||||
VAR i, j, x: SYSTEM.UINTPTR;
|
||||
BEGIN j := l; x := a[j];
|
||||
LOOP i := j; j := 2*j + 1;
|
||||
IF (j < r) & (a[j] < a[j+1]) THEN INC(j) END;
|
||||
|
|
@ -425,15 +426,15 @@ MODULE Heap;
|
|||
a[i] := x
|
||||
END Sift;
|
||||
|
||||
PROCEDURE HeapSort (n: LONGINT; VAR a: ARRAY OF LONGINT);
|
||||
VAR l, r, x: LONGINT;
|
||||
PROCEDURE HeapSort (n: SYSTEM.UINTPTR; VAR a: ARRAY OF SYSTEM.UINTPTR);
|
||||
VAR l, r, x: SYSTEM.UINTPTR;
|
||||
BEGIN l := n DIV 2; r := n - 1;
|
||||
WHILE l > 0 DO DEC(l); Sift(l, r, a) END;
|
||||
WHILE r > 0 DO x := a[0]; a[0] := a[r]; a[r] := x; DEC(r); Sift(l, r, a) END
|
||||
END HeapSort;
|
||||
|
||||
PROCEDURE MarkCandidates(n: LONGINT; VAR cand: ARRAY OF LONGINT);
|
||||
VAR chnk, adr, tag, next, lim, lim1, i, ptr, size: LONGINT;
|
||||
PROCEDURE MarkCandidates(n: SYSTEM.UINTPTR; VAR cand: ARRAY OF SYSTEM.UINTPTR);
|
||||
VAR chnk, adr, tag, next, lim, lim1, i, ptr, size: SYSTEM.UINTPTR;
|
||||
BEGIN
|
||||
chnk := heap; i := 0; lim := cand[n-1];
|
||||
WHILE (chnk # 0 ) & (chnk < lim) DO
|
||||
|
|
@ -446,7 +447,7 @@ MODULE Heap;
|
|||
size := FetchAddress(tag-1); INC(adr, size)
|
||||
ELSE
|
||||
size := FetchAddress(tag);
|
||||
ptr := adr + SZL;
|
||||
ptr := adr + SZA;
|
||||
WHILE cand[i] < ptr DO INC(i) END ;
|
||||
IF i = n THEN RETURN END ;
|
||||
next := adr + size;
|
||||
|
|
@ -459,11 +460,11 @@ MODULE Heap;
|
|||
END MarkCandidates;
|
||||
|
||||
PROCEDURE CheckFin;
|
||||
VAR n: FinNode; tag: LONGINT;
|
||||
VAR n: FinNode; tag: SYSTEM.UINTPTR;
|
||||
BEGIN
|
||||
n := fin;
|
||||
WHILE n # NIL DO
|
||||
tag := FetchAddress(n.obj - SZL);
|
||||
tag := FetchAddress(n.obj - SZA);
|
||||
IF ~ODD(tag) THEN n.marked := FALSE; Mark(n.obj)
|
||||
ELSE n.marked := TRUE
|
||||
END ;
|
||||
|
|
@ -495,14 +496,14 @@ MODULE Heap;
|
|||
END
|
||||
END FINALL;
|
||||
|
||||
PROCEDURE -ExternMainStackFrame "extern LONGINT Platform_MainStackFrame;";
|
||||
PROCEDURE -PlatformMainStackFrame(): LONGINT "Platform_MainStackFrame";
|
||||
PROCEDURE -ExternMainStackFrame "extern uintptr Platform_MainStackFrame;";
|
||||
PROCEDURE -PlatformMainStackFrame(): SYSTEM.UINTPTR "Platform_MainStackFrame";
|
||||
|
||||
PROCEDURE MarkStack(n: LONGINT; VAR cand: ARRAY OF LONGINT);
|
||||
PROCEDURE MarkStack(n: SYSTEM.UINTPTR; VAR cand: ARRAY OF SYSTEM.UINTPTR);
|
||||
VAR
|
||||
frame: SYSTEM.PTR;
|
||||
inc, nofcand: LONGINT;
|
||||
sp, p, stack0: LONGINT;
|
||||
inc, nofcand: SYSTEM.UINTPTR;
|
||||
sp, p, stack0: SYSTEM.UINTPTR;
|
||||
align: RECORD ch: CHAR; p: SYSTEM.PTR END ;
|
||||
BEGIN
|
||||
IF n > 0 THEN MarkStack(n-1, cand); (* flush register windows by means of recursive calls *)
|
||||
|
|
@ -529,8 +530,8 @@ MODULE Heap;
|
|||
PROCEDURE GC*(markStack: BOOLEAN);
|
||||
VAR
|
||||
m: Module;
|
||||
i0, i1, i2, i3, i4, i5, i6, i7, i8, i9, i10, i11, i12, i13, i14, i15, i16, i17, i18, i19, i20, i21, i22, i23: LONGINT;
|
||||
cand: ARRAY 10000 OF LONGINT;
|
||||
i0, i1, i2, i3, i4, i5, i6, i7, i8, i9, i10, i11, i12, i13, i14, i15, i16, i17, i18, i19, i20, i21, i22, i23: SYSTEM.UINTPTR;
|
||||
cand: ARRAY 10000 OF SYSTEM.UINTPTR;
|
||||
BEGIN
|
||||
IF (lockdepth = 0) OR (lockdepth = 1) & ~markStack THEN
|
||||
Lock();
|
||||
|
|
@ -565,7 +566,7 @@ MODULE Heap;
|
|||
PROCEDURE RegisterFinalizer*(obj: SYSTEM.PTR; finalize: Finalizer);
|
||||
VAR f: FinNode;
|
||||
BEGIN NEW(f);
|
||||
f.obj := SYSTEM.VAL(LONGINT, obj); f.finalize := finalize; f.marked := TRUE;
|
||||
f.obj := SYSTEM.VAL(SYSTEM.UINTPTR, obj); f.finalize := finalize; f.marked := TRUE;
|
||||
f.next := fin; fin := f;
|
||||
END RegisterFinalizer;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue