From 3e68f3c024268e4753dcfd80b24e50acc33189fc Mon Sep 17 00:00:00 2001 From: Eduardo Souza Date: Fri, 29 Nov 2024 03:24:38 +0000 Subject: [PATCH] Refactor bigval_t struct and move it to gc-common.h --- src/gc-common.h | 25 +++++++++++++++++++++++++ src/gc-mmtk.c | 1 - src/gc-mmtk.h | 29 ----------------------------- src/gc-stock.h | 22 +--------------------- src/llvm-late-gc-lowering-mmtk.cpp | 2 +- src/llvm-late-gc-lowering-stock.cpp | 2 +- 6 files changed, 28 insertions(+), 53 deletions(-) delete mode 100644 src/gc-mmtk.h diff --git a/src/gc-common.h b/src/gc-common.h index 01bde817b0269a..9c6065373ce054 100644 --- a/src/gc-common.h +++ b/src/gc-common.h @@ -24,6 +24,31 @@ extern "C" { #endif +// =========================================================================== // +// GC Big objects +// =========================================================================== // + +JL_EXTENSION typedef struct _bigval_t { + struct _bigval_t *next; + struct _bigval_t *prev; + size_t sz; +#ifdef _P64 // Add padding so that the value is 64-byte aligned + // (8 pointers of 8 bytes each) - (4 other pointers in struct) + void *_padding[8 - 4]; +#else + // (16 pointers of 4 bytes each) - (4 other pointers in struct) + void *_padding[16 - 4]; +#endif + //struct jl_taggedvalue_t <>; + union { + uintptr_t header; + struct { + uintptr_t gc:2; + } bits; + }; + // must be 64-byte aligned here, in 32 & 64 bit modes +} bigval_t; + // =========================================================================== // // GC Callbacks // =========================================================================== // diff --git a/src/gc-mmtk.c b/src/gc-mmtk.c index 379e06ae08db84..49e54335f80581 100644 --- a/src/gc-mmtk.c +++ b/src/gc-mmtk.c @@ -1,6 +1,5 @@ #include "gc-common.h" #include "mmtkMutator.h" -#include "gc-mmtk.h" #include "threading.h" // File exists in the binding diff --git a/src/gc-mmtk.h b/src/gc-mmtk.h deleted file mode 100644 index 826b21cd4945a9..00000000000000 --- a/src/gc-mmtk.h +++ /dev/null @@ -1,29 +0,0 @@ -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -JL_EXTENSION typedef struct _bigval_t { - size_t sz; -#ifdef _P64 // Add padding so that the value is 64-byte aligned - // (8 pointers of 8 bytes each) - (2 other pointers in struct) - void *_padding[8 - 2]; -#else - // (16 pointers of 4 bytes each) - (2 other pointers in struct) - void *_padding[16 - 2]; -#endif - //struct jl_taggedvalue_t <>; - union { - uintptr_t header; - struct { - uintptr_t gc:2; - } bits; - }; - // must be 64-byte aligned here, in 32 & 64 bit modes -} bigval_t; - -#ifdef __cplusplus -} -#endif diff --git a/src/gc-stock.h b/src/gc-stock.h index 710c3adf46af3d..d478ee1366da02 100644 --- a/src/gc-stock.h +++ b/src/gc-stock.h @@ -19,6 +19,7 @@ #include "julia_internal.h" #include "julia_assert.h" #include "threading.h" +#include "gc-common.h" #ifdef __cplusplus extern "C" { @@ -84,27 +85,6 @@ typedef struct _jl_gc_chunk_t { extern uintptr_t gc_bigval_sentinel_tag; -JL_EXTENSION typedef struct _bigval_t { - struct _bigval_t *next; - struct _bigval_t *prev; - size_t sz; -#ifdef _P64 // Add padding so that the value is 64-byte aligned - // (8 pointers of 8 bytes each) - (4 other pointers in struct) - void *_padding[8 - 4]; -#else - // (16 pointers of 4 bytes each) - (4 other pointers in struct) - void *_padding[16 - 4]; -#endif - //struct jl_taggedvalue_t <>; - union { - uintptr_t header; - struct { - uintptr_t gc:2; - } bits; - }; - // must be 64-byte aligned here, in 32 & 64 bit modes -} bigval_t; - // pool page metadata typedef struct _jl_gc_pagemeta_t { // next metadata structure in per-thread list diff --git a/src/llvm-late-gc-lowering-mmtk.cpp b/src/llvm-late-gc-lowering-mmtk.cpp index fb75ca73d5b585..a2966e2a45bb3f 100644 --- a/src/llvm-late-gc-lowering-mmtk.cpp +++ b/src/llvm-late-gc-lowering-mmtk.cpp @@ -96,4 +96,4 @@ Value* LateLowerGCFrame::lowerGCAllocBytesLate(CallInst *target, Function &F) } } return target; -} \ No newline at end of file +} diff --git a/src/llvm-late-gc-lowering-stock.cpp b/src/llvm-late-gc-lowering-stock.cpp index f307146b5839f5..2a114877733961 100644 --- a/src/llvm-late-gc-lowering-stock.cpp +++ b/src/llvm-late-gc-lowering-stock.cpp @@ -6,4 +6,4 @@ Value* LateLowerGCFrame::lowerGCAllocBytesLate(CallInst *target, Function &F) { // Do nothing for the stock GC return target; -} \ No newline at end of file +}