Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
qinsoon committed Dec 3, 2024
1 parent ca994fa commit d8dca09
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
28 changes: 14 additions & 14 deletions src/gc-mmtk.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/gc-stock.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/llvm-late-gc-lowering-mmtk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<intptr_t>(MMTK_SIDE_VO_BIT_BASE_ADDRESS);
Expand Down

0 comments on commit d8dca09

Please sign in to comment.