From cfe6380ddcf8f4c487b65b636c09a83d040066c1 Mon Sep 17 00:00:00 2001 From: Aidan Lee Date: Thu, 10 Sep 2026 12:31:22 +0100 Subject: [PATCH 1/2] 1D array for row data --- src/hx/gc/Immix.cpp | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/hx/gc/Immix.cpp b/src/hx/gc/Immix.cpp index 1e0ed9791..3145b6169 100644 --- a/src/hx/gc/Immix.cpp +++ b/src/hx/gc/Immix.cpp @@ -624,9 +624,9 @@ union BlockData BlockIdType mId; // First 2/4 rows contain a byte-flag-per-row - unsigned char mRowMarked[IMMIX_LINES]; + unsigned char mRowMarked[IMMIX_LINES]; // Row data as union - don't use first 2/4 rows - unsigned char mRow[IMMIX_LINES][IMMIX_LINE_LEN]; + unsigned char mRow[IMMIX_LINES * IMMIX_LINE_LEN]; }; @@ -1031,7 +1031,7 @@ struct BlockDataInfo unsigned int &starts = allocStart[r]; if (starts) { - unsigned int *headerPtr = ((unsigned int *)mPtr->mRow[r]); + unsigned int* headerPtr{ reinterpret_cast(mPtr->mRow + (r * IMMIX_LINE_LEN)) }; #define CHECK_FLAG(i,byteMask) \ { \ unsigned int mask = 1<mRow[0][inOffset + HX_ENDIAN_MARK_ID_BYTE_HEADER] }; + unsigned char time{ mPtr->mRow[inOffset + HX_ENDIAN_MARK_ID_BYTE_HEADER] }; if (((time + 1) & MARK_BYTE_MASK) != (gByteMarkID & MARK_BYTE_MASK)) { // Object is either out-of-date, or already marked.... @@ -1155,10 +1155,10 @@ struct BlockDataInfo if (!allowPrevious) return allocNone; - if (*reinterpret_cast(mPtr->mRow[0] + inOffset) & IMMIX_ALLOC_IS_CONTAINER) + if (*reinterpret_cast(mPtr->mRow + inOffset) & IMMIX_ALLOC_IS_CONTAINER) { // See if object::new has been called, but not constructed yet ... - void** vtable{ reinterpret_cast(mPtr->mRow[0] + inOffset + sizeof(int)) }; + void** vtable{ reinterpret_cast(mPtr->mRow + inOffset + sizeof(int)) }; if (nullptr == vtable[0]) { // GCLOG("Partially constructed object."); @@ -1199,7 +1199,7 @@ struct BlockDataInfo while(scan<=inOffset) { // Trace along the hole... - unsigned int header{ *reinterpret_cast(mPtr->mRow[0] + scan) }; + unsigned int header{ *reinterpret_cast(mPtr->mRow + scan) }; unsigned int size{ !(header & 0xff000000) ? (header & 0x0000ffff) @@ -1216,13 +1216,13 @@ struct BlockDataInfo if (nullptr != outPtr) { - *outPtr = reinterpret_cast(mPtr->mRow[0] + scan + sizeof(int)); + *outPtr = reinterpret_cast(mPtr->mRow + scan + sizeof(int)); } if (header & IMMIX_ALLOC_IS_CONTAINER) { // See if object::new has been called, but not constructed yet ... - void **vtable = (void **)(mPtr->mRow[0] + scan + sizeof(int)); + void **vtable{ reinterpret_cast(mPtr->mRow + scan + sizeof(int)) }; if (vtable[0]==0) { // GCLOG("Partially constructed object."); @@ -1301,7 +1301,7 @@ struct BlockDataInfo { if (nullptr != outPtr) { - *outPtr = reinterpret_cast(mPtr->mRow[0] + blockOffset + sizeof(int)); + *outPtr = reinterpret_cast(mPtr->mRow + blockOffset + sizeof(int)); } return result; @@ -1334,10 +1334,10 @@ struct BlockDataInfo { if (rowMarked[r]) { - unsigned int starts = allocStart[r]; + unsigned int starts{ allocStart[r] }; if (!starts) continue; - unsigned char *row = mPtr->mRow[r]; + unsigned char* row{ mPtr->mRow + (r * IMMIX_LINE_LEN) }; for(int i=0;i<32;i++) { int pos = i<<2; @@ -3754,8 +3754,8 @@ class GlobalAllocator { if ( starts & (1<mPtr->mRow[r]; - unsigned int &header = row[i]; + unsigned int *row{ reinterpret_cast(from->mPtr->mRow + (r * IMMIX_LINE_LEN)) }; + unsigned int &header{ row[i] }; if ((header&IMMIX_ALLOC_MARK_ID) == hx::gMarkID) { @@ -3964,8 +3964,8 @@ class GlobalAllocator for(int loc=0;loc<32;loc++) if (startFlags & (1<mPtr->mRow[r]; - unsigned int &header = row[loc]; + unsigned int *row{ reinterpret_cast(from->mPtr->mRow + (r * IMMIX_LINE_LEN)) }; + unsigned int &header{ row[loc] }; if ((header&IMMIX_ALLOC_MARK_ID) == hx::gMarkID) { From 6eff43664764ffbbab0bb65eec0e7eb11aeacec2 Mon Sep 17 00:00:00 2001 From: Aidan Lee Date: Thu, 10 Sep 2026 14:11:28 +0100 Subject: [PATCH 2/2] mRow rename and add row helper function --- src/hx/gc/Immix.cpp | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/hx/gc/Immix.cpp b/src/hx/gc/Immix.cpp index 3145b6169..fab5d8812 100644 --- a/src/hx/gc/Immix.cpp +++ b/src/hx/gc/Immix.cpp @@ -626,8 +626,12 @@ union BlockData // First 2/4 rows contain a byte-flag-per-row unsigned char mRowMarked[IMMIX_LINES]; // Row data as union - don't use first 2/4 rows - unsigned char mRow[IMMIX_LINES * IMMIX_LINE_LEN]; + unsigned char mData[IMMIX_LINES * IMMIX_LINE_LEN]; + inline unsigned char* row(size_t r) + { + return mData + (r * IMMIX_LINE_LEN); + } }; struct BlockDataStats @@ -1031,7 +1035,7 @@ struct BlockDataInfo unsigned int &starts = allocStart[r]; if (starts) { - unsigned int* headerPtr{ reinterpret_cast(mPtr->mRow + (r * IMMIX_LINE_LEN)) }; + unsigned int* headerPtr{ reinterpret_cast(mPtr->row(static_cast(r))) }; #define CHECK_FLAG(i,byteMask) \ { \ unsigned int mask = 1<mRow[inOffset + HX_ENDIAN_MARK_ID_BYTE_HEADER] }; + unsigned char time{ mPtr->mData[inOffset + HX_ENDIAN_MARK_ID_BYTE_HEADER] }; if (((time + 1) & MARK_BYTE_MASK) != (gByteMarkID & MARK_BYTE_MASK)) { // Object is either out-of-date, or already marked.... @@ -1155,10 +1159,10 @@ struct BlockDataInfo if (!allowPrevious) return allocNone; - if (*reinterpret_cast(mPtr->mRow + inOffset) & IMMIX_ALLOC_IS_CONTAINER) + if (*reinterpret_cast(mPtr->mData + inOffset) & IMMIX_ALLOC_IS_CONTAINER) { // See if object::new has been called, but not constructed yet ... - void** vtable{ reinterpret_cast(mPtr->mRow + inOffset + sizeof(int)) }; + void** vtable{ reinterpret_cast(mPtr->mData + inOffset + sizeof(int)) }; if (nullptr == vtable[0]) { // GCLOG("Partially constructed object."); @@ -1199,7 +1203,7 @@ struct BlockDataInfo while(scan<=inOffset) { // Trace along the hole... - unsigned int header{ *reinterpret_cast(mPtr->mRow + scan) }; + unsigned int header{ *reinterpret_cast(mPtr->mData + scan) }; unsigned int size{ !(header & 0xff000000) ? (header & 0x0000ffff) @@ -1216,13 +1220,13 @@ struct BlockDataInfo if (nullptr != outPtr) { - *outPtr = reinterpret_cast(mPtr->mRow + scan + sizeof(int)); + *outPtr = reinterpret_cast(mPtr->mData + scan + sizeof(int)); } if (header & IMMIX_ALLOC_IS_CONTAINER) { // See if object::new has been called, but not constructed yet ... - void **vtable{ reinterpret_cast(mPtr->mRow + scan + sizeof(int)) }; + void **vtable{ reinterpret_cast(mPtr->mData + scan + sizeof(int)) }; if (vtable[0]==0) { // GCLOG("Partially constructed object."); @@ -1301,7 +1305,7 @@ struct BlockDataInfo { if (nullptr != outPtr) { - *outPtr = reinterpret_cast(mPtr->mRow + blockOffset + sizeof(int)); + *outPtr = reinterpret_cast(mPtr->mData + blockOffset + sizeof(int)); } return result; @@ -1337,7 +1341,7 @@ struct BlockDataInfo unsigned int starts{ allocStart[r] }; if (!starts) continue; - unsigned char* row{ mPtr->mRow + (r * IMMIX_LINE_LEN) }; + unsigned char* row{ mPtr->row(static_cast(r)) }; for(int i=0;i<32;i++) { int pos = i<<2; @@ -3754,7 +3758,7 @@ class GlobalAllocator { if ( starts & (1<(from->mPtr->mRow + (r * IMMIX_LINE_LEN)) }; + unsigned int* row{ reinterpret_cast(from->mPtr->row(static_cast(r))) }; unsigned int &header{ row[i] }; if ((header&IMMIX_ALLOC_MARK_ID) == hx::gMarkID) @@ -3964,7 +3968,7 @@ class GlobalAllocator for(int loc=0;loc<32;loc++) if (startFlags & (1<(from->mPtr->mRow + (r * IMMIX_LINE_LEN)) }; + unsigned int* row{ reinterpret_cast(from->mPtr->row(static_cast(r))) }; unsigned int &header{ row[loc] }; if ((header&IMMIX_ALLOC_MARK_ID) == hx::gMarkID)