parallelize section garbage collection

currently we tag pointers to solve ABA problem however if the list
has more than max_U16 items, the tag will overflow and cause serious issues.
To fix this, we need to use 64-bit tags together with 128-bit interlocked
compare-exchange intrinsic
This commit is contained in:
Nikita Smith authored and Ryan Fleury committed 2025-09-17 15:21:37 -07:00
1 parent cc8fdc6c6f
commit 5a12513306
4 files changed
+299 -128

No files matched your search

+42 -2
View File
@@ -73,8 +73,8 @@ typedef struct LNK_Inputer
#define LNK_IMPORT_STUB "*** RAD_IMPORT_STUB ***"
#define LNK_NULL_SYMBOL "*** RAD_NULL_SYMBOL ***"
#define LNK_SECTION_FLAG_IS_LIVE (1 << 0)
#define LNK_SECTION_FLAG_DEBUG_INFO (1 << 1)
#define LNK_SECTION_FLAG_LIVE (1 << 0)
#define LNK_SECTION_FLAG_DEBUG (1 << 1)
typedef struct LNK_Link
{
@@ -118,6 +118,39 @@ typedef struct LNK_CommonBlockContrib
} u;
} LNK_CommonBlockContrib;
// --- Ref ---------------------------------------------------------------------
#define PointerBitSize 64u
#define PointerFreeBitsSize 16u
#define PointerTagBitSize PointerFreeBitsSize
#define PointerTagMask ((1ull << (PointerTagBitSize)) - 1u)
#define PointerTagShift (PointerBitSize - PointerTagBitSize)
#define PackPointer(ptr, tag) (void *)(IntFromPtr(ptr) | (((tag) & PointerTagMask) << PointerTagShift))
#define UnpackPointerTag(ptr) ((IntFromPtr(ptr) >> PointerTagShift) & PointerTagMask)
#define UnpackPointer(ptr) (void *)(IntFromPtr(ptr) & ~(PointerTagMask << PointerTagShift))
#define BumpPointerTag(ptr) PackPointer(UnpackPointer(ptr), UnpackPointerTag(ptr) + 1)
#define LNK_RELOCS_PER_TASK 0x1000
typedef struct LNK_RelocRefs
{
LNK_Obj *obj;
COFF_RelocArray relocs;
} LNK_RelocRefs;
typedef struct LNK_RelocRefsNode
{
LNK_RelocRefs *v;
struct LNK_RelocRefsNode *next;
} LNK_RelocRefsNode;
typedef struct LNK_RelocRefsList
{
LNK_RelocRefsNode *head;
} LNK_RelocRefsList;
// --- Base Reloc --------------------------------------------------------------
typedef struct LNK_BaseRelocPage
@@ -156,6 +189,13 @@ typedef struct
LNK_LibMemberRefList *member_ref_lists;
} LNK_SearchLibTask;
typedef struct
{
LNK_SymbolTable *symtab;
U32 active_thread_count;
LNK_RelocRefsList reloc_refs;
} LNK_OptRefTask;
typedef struct
{
LNK_SymbolTable *symtab;