Skip to content

Commit 606aae0

Browse files
RMortenBRoyMortenBrennaWDrijver
authored
Allocator update (#141)
* Changed the alignment of allocations back to 8 bytes. * Removed free list consistency checks, removed handling of MEMF_MANAGED, as it is never set. --------- Co-authored-by: Morten Brenna <morten.brenna@hexagon.com> Co-authored-by: Willem Drijver <60568860+WDrijver@users.noreply.github.com>
1 parent aec8042 commit 606aae0

15 files changed

Lines changed: 187 additions & 64 deletions

File tree

arch/m68k-all/include/aros/cpu.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#define AROS_PTRALIGN 2 /* Alignment for PTR */
2424
#define AROS_IPTRALIGN 2 /* Alignment for IPTR */
2525
#define AROS_DOUBLEALIGN 2 /* Alignment for double */
26-
#define AROS_WORSTALIGN 32 /* Worst case alignment - ApolloOS = 32 Bytes */
26+
#define AROS_WORSTALIGN 4 /* Worst case alignment - ApolloOS = 32 Bytes */
2727

2828
#define AROS_SLOWSTACKFORMAT 1
2929

compiler/include/aros/cpu.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
#define AROS_PTRALIGN 8 /* Alignment for PTR */
5151
#define AROS_IPTRALIGN 8 /* Alignment for IPTR */
5252
#define AROS_DOUBLEALIGN 8 /* Alignment for double */
53-
#define AROS_WORSTALIGN 32 /* Worst case alignment */
53+
#define AROS_WORSTALIGN 4 /* Worst case alignment */
5454
#define AROS_STACKALIGN 16 /* Clean stack alignment */
5555
#elif defined __arm__
5656
# if defined __thumb2__

compiler/include/exec/memory.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ struct MemChunk
3030
};
3131

3232
/* Total size of struct MemChunk, including padding */
33-
#define MEMCHUNK_TOTAL 32 //[WD] ApolloOS is set to 32 Byte Memory Boundary from Core 11350+ | (AROS_WORSTALIGN > sizeof(struct MemChunk) ? AROS_WORSTALIGN : sizeof(struct MemChunk))
33+
#define MEMCHUNK_TOTAL (AROS_WORSTALIGN > sizeof(struct MemChunk) ? AROS_WORSTALIGN : sizeof(struct MemChunk))
3434
/* Total size of struct MemHeader, including padding */
3535
#define MEMHEADER_TOTAL (AROS_ROUNDUP2(sizeof(struct MemHeader), MEMCHUNK_TOTAL))
3636

rom/exec/allocate.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@
8484
{
8585
AROS_LIBFUNC_INIT
8686

87+
#ifdef HANDLE_MANAGED_MEM
8788
if ((freeList->mh_Node.ln_Type == NT_MEMORY) && IsManagedMem(freeList))
8889
{
8990
struct MemHeaderExt *mhe = (struct MemHeaderExt *)freeList;
@@ -94,7 +95,8 @@
9495
return NULL;
9596
}
9697
else
97-
{
98+
#endif
99+
{
98100
struct TraceLocation tp = CURRENT_LOCATION("Allocate");
99101
APTR res;
100102

rom/exec/allocpooled.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
if(!memSize)
7676
return NULL;
7777

78+
#ifdef HANDLE_MANAGED_MEM
7879
if (IsManagedMem(mhe))
7980
{
8081
ULONG poolrequirements = (ULONG)(IPTR)mhe->mhe_MemHeader.mh_First;
@@ -85,7 +86,8 @@
8586
return NULL;
8687
}
8788
else
88-
{
89+
#endif
90+
{
8991
struct TraceLocation tp = CURRENT_LOCATION("AllocPooled");
9092
struct Pool *pool = poolHeader + MEMHEADER_TOTAL;
9193

rom/exec/allocvecpooled.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
/* 0-sized allocation results in returning NULL (API guarantee) */
5757
if(!memSize)
5858
return NULL;
59-
59+
#ifdef HANDLE_MANAGED_MEM
6060
if (IsManagedMem(mhe))
6161
{
6262
ULONG poolrequirements = (ULONG)(IPTR)mhe->mhe_MemHeader.mh_First;
@@ -67,7 +67,8 @@
6767
return NULL;
6868
}
6969
else
70-
{
70+
#endif
71+
{
7172
IPTR *memory;
7273

7374
if (poolHeader == NULL) return NULL;

rom/exec/createpool.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@
139139
* If the pool is in managed memory, don't bother any further setup. The
140140
* pool should do the rest self.
141141
*/
142+
#ifdef HANDLE_MANAGED_MEM
142143
if (IsManagedMem(firstPuddle))
143144
{
144145
D(bug("Managed pool\n");)
@@ -152,7 +153,8 @@
152153
firstPuddle->mh_First = (APTR)(IPTR)requirements;
153154
}
154155
else
155-
{
156+
#endif
157+
{
156158
/*
157159
* Add the puddle to the list (yes, contained in itself).
158160
* This is the first puddle so it's safe to use AddTail() here.

rom/exec/deallocate.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
{
5959
AROS_LIBFUNC_INIT
6060

61+
#ifdef HANDLE_MANAGED_MEM
6162
if ((freeList->mh_Node.ln_Type == NT_MEMORY) && IsManagedMem(freeList))
6263
{
6364
struct MemHeaderExt *mhe = (struct MemHeaderExt *)freeList;
@@ -66,7 +67,8 @@
6667
mhe->mhe_Free(mhe, memoryBlock, byteSize);
6768
}
6869
else
69-
{
70+
#endif
71+
{
7072
struct TraceLocation tp = CURRENT_LOCATION("Deallocate");
7173

7274
/* If there is no memory free nothing */

rom/exec/deletepool.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,14 @@
6161
{
6262
struct TraceLocation tp = CURRENT_LOCATION("DeletePool");
6363

64+
#ifdef HANDLE_MANAGED_MEM
6465
if (IsManagedMem(poolHeader))
6566
{
6667
/* Do nothing, everything is handled in FreeMemHeader */
6768
}
6869
else
69-
{
70+
#endif
71+
{
7072
struct Pool *pool = poolHeader + MEMHEADER_TOTAL;
7173
struct Node *p, *p2; /* Avoid casts */
7274

rom/exec/freepooled.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,15 @@
6161
if(!memSize || !memory)
6262
return;
6363

64+
#ifdef HANDLE_MANAGED_MEM
6465
if (IsManagedMem(mhe))
6566
{
6667
if (mhe->mhe_Free)
6768
mhe->mhe_Free(mhe, memory, memSize);
6869
}
6970
else
70-
{
71+
#endif
72+
{
7173
struct TraceLocation tp = CURRENT_LOCATION("FreePooled");
7274

7375
InternalFreePooled(poolHeader, memory, memSize, &tp, SysBase);

0 commit comments

Comments
 (0)