Skip to content

Commit

Permalink
Align up alloc size (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
qinsoon authored Jun 29, 2023
1 parent 98a66ba commit 0d8bbd9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/julia.h
Original file line number Diff line number Diff line change
Expand Up @@ -2414,6 +2414,14 @@ STATIC_INLINE void mmtk_gc_wb(const void *parent, const void *ptr) JL_NOTSAFEPOI
{
mmtk_gc_wb_fast(parent, ptr);
}

#define MMTK_MIN_ALIGNMENT 4
// MMTk assumes allocation size is aligned to min alignment.
STATIC_INLINE size_t mmtk_align_alloc_sz(size_t sz) JL_NOTSAFEPOINT
{
return (sz + MMTK_MIN_ALIGNMENT - 1) & ~(MMTK_MIN_ALIGNMENT - 1);
}

#endif

#ifdef __cplusplus
Expand Down
3 changes: 2 additions & 1 deletion src/mmtk-gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,8 @@ JL_DLLEXPORT void jl_gc_wb2_slow(const void *parent, const void* ptr) JL_NOTSAFE
void *jl_gc_perm_alloc_nolock(size_t sz, int zero, unsigned align, unsigned offset)
{
jl_ptls_t ptls = jl_current_task->ptls;
void* addr = mmtk_alloc(&ptls->mmtk_mutator, sz, align, offset, 1);
size_t allocsz = mmtk_align_alloc_sz(sz);
void* addr = mmtk_alloc(&ptls->mmtk_mutator, allocsz, align, offset, 1);
return addr;
}

Expand Down

0 comments on commit 0d8bbd9

Please sign in to comment.