Skip to content

Commit 9460689

Browse files
authored
Merge pull request #31 from udesou/fix/remove-sizeclasses
Stop using Julia's size classes when using MMTk
2 parents 861f151 + f470eb4 commit 9460689

File tree

5 files changed

+24
-18
lines changed

5 files changed

+24
-18
lines changed

src/array.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -506,9 +506,7 @@ JL_DLLEXPORT jl_value_t *jl_alloc_string(size_t len)
506506
// the Allocations Profiler. (See https://github.com/JuliaLang/julia/pull/43868 for more details.)
507507
s = jl_gc_pool_alloc_noinline(ptls, (char*)p - (char*)ptls, osize);
508508
#else
509-
int pool_id = jl_gc_szclass_align8(allocsz);
510-
int osize = jl_gc_sizeclasses[pool_id];
511-
s = jl_mmtk_gc_alloc_default(ptls, pool_id, osize, jl_string_type);
509+
s = jl_mmtk_gc_alloc_default(ptls, allocsz, 8, jl_string_type);
512510
#endif
513511
}
514512
else {

src/gc-common.c

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -450,16 +450,6 @@ jl_value_t *jl_gc_pool_alloc_noinline(jl_ptls_t ptls, int pool_offset, int osize
450450
return jl_gc_pool_alloc_inner(ptls, pool_offset, osize);
451451
}
452452

453-
int jl_gc_classify_pools(size_t sz, int *osize)
454-
{
455-
if (sz > GC_MAX_SZCLASS)
456-
return -1;
457-
size_t allocsz = sz + sizeof(jl_taggedvalue_t);
458-
int klass = jl_gc_szclass(allocsz);
459-
*osize = jl_gc_sizeclasses[klass];
460-
return (int)(intptr_t)(&((jl_ptls_t)0)->heap.norm_pools[klass]);
461-
}
462-
463453
// TODO: jl_gc_track_malloced_array needed? Eliminate heap.mallocarrays,
464454
// heap.mafreelist, mallocarray_t?
465455
void jl_gc_track_malloced_array(jl_ptls_t ptls, jl_array_t *a) JL_NOTSAFEPOINT

src/gc.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -902,6 +902,16 @@ static NOINLINE jl_taggedvalue_t *gc_add_page(jl_gc_pool_t *p) JL_NOTSAFEPOINT
902902
return fl;
903903
}
904904

905+
int jl_gc_classify_pools(size_t sz, int *osize)
906+
{
907+
if (sz > GC_MAX_SZCLASS)
908+
return -1;
909+
size_t allocsz = sz + sizeof(jl_taggedvalue_t);
910+
int klass = jl_gc_szclass(allocsz);
911+
*osize = jl_gc_sizeclasses[klass];
912+
return (int)(intptr_t)(&((jl_ptls_t)0)->heap.norm_pools[klass]);
913+
}
914+
905915
// Size includes the tag and the tag is not cleared!!
906916
inline jl_value_t *jl_gc_pool_alloc_inner(jl_ptls_t ptls, int pool_offset,
907917
int osize)

src/julia_internal.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ jl_value_t *jl_gc_pool_alloc_noinline(jl_ptls_t ptls, int pool_offset,
337337
int osize);
338338
jl_value_t *jl_gc_big_alloc_noinline(jl_ptls_t ptls, size_t allocsz);
339339
#ifdef MMTK_GC
340-
JL_DLLIMPORT jl_value_t *jl_mmtk_gc_alloc_default(jl_ptls_t ptls, int pool_offset, int osize, void* ty);
340+
JL_DLLIMPORT jl_value_t *jl_mmtk_gc_alloc_default(jl_ptls_t ptls, int osize, size_t align, void* ty);
341341
JL_DLLIMPORT jl_value_t *jl_mmtk_gc_alloc_big(jl_ptls_t ptls, size_t allocsz);
342342
JL_DLLIMPORT extern void mmtk_post_alloc(void* mutator, void* obj, size_t bytes, int allocator);
343343
JL_DLLIMPORT extern void mmtk_initialize_collection(void* tls);
@@ -491,9 +491,7 @@ STATIC_INLINE jl_value_t *jl_gc_alloc_(jl_ptls_t ptls, size_t sz, void *ty)
491491
jl_value_t *v;
492492
const size_t allocsz = sz + sizeof(jl_taggedvalue_t);
493493
if (sz <= GC_MAX_SZCLASS) {
494-
int pool_id = jl_gc_szclass(allocsz);
495-
int osize = jl_gc_sizeclasses[pool_id];
496-
v = jl_mmtk_gc_alloc_default(ptls, pool_id, osize, ty);
494+
v = jl_mmtk_gc_alloc_default(ptls, allocsz, 16, ty);
497495
}
498496
else {
499497
if (allocsz < sz) // overflow in adding offs, size was "negative"

src/mmtk-gc.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,16 @@ static inline void malloc_maybe_collect(jl_ptls_t ptls, size_t sz)
5353
}
5454
}
5555

56+
// allocation
57+
int jl_gc_classify_pools(size_t sz, int *osize)
58+
{
59+
if (sz > GC_MAX_SZCLASS)
60+
return -1; // call big alloc function
61+
size_t allocsz = sz + sizeof(jl_taggedvalue_t);
62+
*osize = LLT_ALIGN(allocsz, 16);
63+
return 0; // use MMTk's fastpath logic
64+
}
65+
5666
// malloc wrappers, aligned allocation
5767
// We currently just duplicate what Julia GC does. We will in the future replace the malloc calls with MMTK's malloc.
5868

@@ -157,7 +167,7 @@ inline jl_value_t *jl_gc_pool_alloc_inner(jl_ptls_t ptls, int pool_offset, int o
157167
// TODO: drop this okay?
158168
// maybe_collect(ptls);
159169

160-
jl_value_t *v = jl_mmtk_gc_alloc_default(ptls, pool_offset, osize, NULL);
170+
jl_value_t *v = jl_mmtk_gc_alloc_default(ptls, osize, 16, NULL);
161171
// TODO: this is done (without atomic operations) in jl_mmtk_gc_alloc_default; enable
162172
// here when that's edited?
163173
/*

0 commit comments

Comments
 (0)