Skip to content

Commit 31cea77

Browse files
author
Luis Eduardo de Souza Amorim
committed
Moving jl_genericmemory_t objects to the immix space
1 parent 130fb2a commit 31cea77

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

src/gc-mmtk.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -877,6 +877,8 @@ static void jl_gc_free_memory(jl_genericmemory_t *m, int isaligned) JL_NOTSAFEPO
877877
gc_num.freecall++;
878878
}
879879

880+
extern void* mmtk_get_possibly_forwarded(void* object);
881+
880882
JL_DLLEXPORT void jl_gc_mmtk_sweep_malloced_memory(void) JL_NOTSAFEPOINT
881883
{
882884
void* iter = mmtk_new_mutator_iterator();
@@ -889,6 +891,11 @@ JL_DLLEXPORT void jl_gc_mmtk_sweep_malloced_memory(void) JL_NOTSAFEPOINT
889891
while (n < l) {
890892
jl_genericmemory_t *m = (jl_genericmemory_t*)((uintptr_t)lst[n] & ~1);
891893
if (mmtk_is_live_object(m)) {
894+
jl_genericmemory_t *maybe_forwarded = (jl_genericmemory_t*)mmtk_get_possibly_forwarded(m);
895+
if(maybe_forwarded != m) {
896+
int isaligned = (uintptr_t)lst[n] & 1;
897+
lst[n] = (void*)((uintptr_t)maybe_forwarded | !!isaligned);
898+
}
892899
n++;
893900
}
894901
else {
@@ -925,6 +932,11 @@ JL_DLLEXPORT void jl_gc_update_inlined_array(void* from, void* to) {
925932
b->ptr = (void*)((size_t) b + offset_of_data);
926933
}
927934
}
935+
936+
// make sure we update the owner pointer when we're copying the generic memory
937+
if (how == 1) {
938+
jl_genericmemory_data_owner_field(b) = (jl_value_t*)b;
939+
}
928940
}
929941
}
930942

src/genericmemory.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ JL_DLLEXPORT jl_genericmemory_t *jl_alloc_genericmemory_unchecked(jl_ptls_t ptls
3838
data = (char*)jl_gc_managed_malloc(nbytes);
3939
tot = sizeof(jl_genericmemory_t) + sizeof(void*);
4040
}
41-
m = (jl_genericmemory_t*)jl_gc_alloc_nonmoving(ptls, tot, mtype);
41+
m = (jl_genericmemory_t*)jl_gc_alloc(ptls, tot, mtype);
4242
if (pooled) {
4343
data = (char*)m + JL_SMALL_BYTE_ALIGNMENT;
4444
}

src/julia_internal.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -586,8 +586,6 @@ typedef void jl_gc_tracked_buffer_t; // For the benefit of the static analyzer
586586
STATIC_INLINE jl_gc_tracked_buffer_t *jl_gc_alloc_buf(jl_ptls_t ptls, size_t sz)
587587
{
588588
jl_gc_tracked_buffer_t *buf = jl_gc_alloc_nonmoving(ptls, sz, (void*)jl_buff_tag);
589-
// FIXME: we might not need to pin buffers since the introduction of jl_genericmemory_t objects
590-
// but removing the pin below will currently fail an assertion in the binding
591589
return buf;
592590
}
593591

0 commit comments

Comments
 (0)