From d8dca099d842136bfbcbc70d32a58a0a6f8f803a Mon Sep 17 00:00:00 2001 From: Yi Lin Date: Tue, 3 Dec 2024 02:54:20 +0000 Subject: [PATCH] Cleanup --- src/gc-mmtk.c | 28 ++++++++++++++-------------- src/gc-stock.c | 2 +- src/llvm-late-gc-lowering-mmtk.cpp | 2 +- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/gc-mmtk.c b/src/gc-mmtk.c index d61f5be6813f1..eaa755a656839 100644 --- a/src/gc-mmtk.c +++ b/src/gc-mmtk.c @@ -860,6 +860,19 @@ inline void* bump_alloc_fast(MMTkMutatorContext* mutator, uintptr_t* cursor, uin } } +inline void mmtk_set_side_metadata(const void* side_metadata_base, void* obj) { + intptr_t addr = (intptr_t) obj; + uint8_t* meta_addr = (uint8_t*) side_metadata_base + (addr >> 6); + intptr_t shift = (addr >> 3) & 0b111; + while(1) { + uint8_t old_val = *meta_addr; + uint8_t new_val = old_val | (1 << shift); + if (jl_atomic_cmpswap((_Atomic(uint8_t)*)meta_addr, &old_val, new_val)) { + break; + } + } +} + inline void* mmtk_immix_alloc_fast(MMTkMutatorContext* mutator, size_t size, size_t align, size_t offset) { ImmixAllocator* allocator = &mutator->allocators.immix[MMTK_DEFAULT_IMMIX_ALLOCATOR]; return bump_alloc_fast(mutator, (uintptr_t*)&allocator->cursor, (intptr_t)allocator->limit, size, align, offset, 0); @@ -876,19 +889,6 @@ inline void* mmtk_immortal_alloc_fast(MMTkMutatorContext* mutator, size_t size, return bump_alloc_fast(mutator, (uintptr_t*)&allocator->cursor, (uintptr_t)allocator->limit, size, align, offset, 1); } -inline void mmtk_set_side_metadata(void* side_metadata_base, void* obj) { - intptr_t addr = (intptr_t) obj; - uint8_t* meta_addr = (uint8_t*) side_metadata_base + (addr >> 6); - intptr_t shift = (addr >> 3) & 0b111; - while(1) { - uint8_t old_val = *meta_addr; - uint8_t new_val = old_val | (1 << shift); - if (jl_atomic_cmpswap((_Atomic(uint8_t)*)meta_addr, &old_val, new_val)) { - break; - } - } -} - inline void mmtk_immortal_post_alloc_fast(MMTkMutatorContext* mutator, void* obj, size_t size) { if (MMTK_NEEDS_WRITE_BARRIER == MMTK_OBJECT_BARRIER) { mmtk_set_side_metadata(MMTK_SIDE_LOG_BIT_BASE_ADDRESS, obj); @@ -1077,7 +1077,7 @@ jl_value_t *jl_gc_permobj(size_t sz, void *ty) JL_NOTSAFEPOINT jl_value_t *jl_gc_permsymbol(size_t sz) JL_NOTSAFEPOINT { jl_taggedvalue_t *tag = (jl_taggedvalue_t*)jl_gc_perm_alloc(sz, 0, sizeof(void*), 0); - jl_value_t *sym = (jl_sym_t*)jl_valueof(tag); + jl_value_t *sym = jl_valueof(tag); jl_ptls_t ptls = jl_current_task->ptls; jl_set_typetagof(sym, jl_symbol_tag, 0); mmtk_immortal_post_alloc_fast(&ptls->gc_tls.mmtk_mutator, sym, sz); diff --git a/src/gc-stock.c b/src/gc-stock.c index a03ba07a0e14c..01ad8ea1a725a 100644 --- a/src/gc-stock.c +++ b/src/gc-stock.c @@ -3839,7 +3839,7 @@ jl_value_t *jl_gc_permobj(size_t sz, void *ty) JL_NOTSAFEPOINT jl_value_t *jl_gc_permsymbol(size_t sz) JL_NOTSAFEPOINT { jl_taggedvalue_t *tag = (jl_taggedvalue_t*)jl_gc_perm_alloc(sz, 0, sizeof(void*), 0); - jl_value_t *sym = (jl_sym_t*)jl_valueof(tag); + jl_value_t *sym = jl_valueof(tag); // set to old marked so that we won't look at it in the GC or write barrier. jl_set_typetagof(sym, jl_symbol_tag, GC_OLD_MARKED); return sym; diff --git a/src/llvm-late-gc-lowering-mmtk.cpp b/src/llvm-late-gc-lowering-mmtk.cpp index ca333305c631a..49994c63fbff4 100644 --- a/src/llvm-late-gc-lowering-mmtk.cpp +++ b/src/llvm-late-gc-lowering-mmtk.cpp @@ -134,7 +134,7 @@ Value* LateLowerGCFrame::lowerGCAllocBytesLate(CallInst *target, Function &F) auto v_as_ptr = builder.CreateIntToPtr(v_raw, smallAllocFunc->getReturnType()); // Post alloc - if (1) { + if (MMTK_NEEDS_VO_BIT) { auto intptr_ty = Type::getInt64Ty(target->getContext()); auto i8_ty = Type::getInt8Ty(F.getContext()); intptr_t metadata_base_address = reinterpret_cast(MMTK_SIDE_VO_BIT_BASE_ADDRESS);