Skip to content

Commit 4da969a

Browse files
author
Luis Eduardo de Souza Amorim
committed
Pinning buffers; removing transitive pinning of global_roots_table; Pinning wr
1 parent d444806 commit 4da969a

File tree

3 files changed

+7
-22
lines changed

3 files changed

+7
-22
lines changed

src/gc-mmtk.c

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -510,19 +510,6 @@ static void add_node_to_roots_buffer(RootsWorkClosure* closure, RootsWorkBuffer*
510510
}
511511
}
512512

513-
static void add_node_to_tpinned_roots_buffer(RootsWorkClosure* closure, RootsWorkBuffer* buf, size_t* buf_len, void* root) {
514-
if (root == NULL)
515-
return;
516-
517-
buf->ptr[*buf_len] = root;
518-
*buf_len += 1;
519-
if (*buf_len >= buf->cap) {
520-
RootsWorkBuffer new_buf = (closure->report_tpinned_nodes_func)(buf->ptr, *buf_len, buf->cap, closure->data, true);
521-
*buf = new_buf;
522-
*buf_len = 0;
523-
}
524-
}
525-
526513
// staticdata_utils.c
527514
extern jl_array_t *internal_methods;
528515
extern jl_array_t *newly_inferred;
@@ -824,15 +811,8 @@ JL_DLLEXPORT void jl_gc_scan_vm_specific_roots(RootsWorkClosure* closure)
824811
// add_node_to_roots_buffer(closure, &buf, &len, cmpswap_names);
825812
// add_node_to_roots_buffer(closure, &buf, &len, precompile_field_replace);
826813

827-
// jl_global_roots_table must be transitively pinned
828-
// FIXME: We need to remove transitive pinning of global roots. Otherwise they may pin most of the objects in the heap.
829-
RootsWorkBuffer tpinned_buf = (closure->report_tpinned_nodes_func)((void**)0, 0, 0, closure->data, true);
830-
size_t tpinned_len = 0;
831-
add_node_to_tpinned_roots_buffer(closure, &tpinned_buf, &tpinned_len, jl_global_roots_list);
832-
add_node_to_tpinned_roots_buffer(closure, &tpinned_buf, &tpinned_len, jl_global_roots_keyset);
833814
// Push the result of the work.
834815
(closure->report_nodes_func)(buf.ptr, len, buf.cap, closure->data, false);
835-
(closure->report_tpinned_nodes_func)(tpinned_buf.ptr, tpinned_len, tpinned_buf.cap, closure->data, false);
836816
}
837817

838818
JL_DLLEXPORT void jl_gc_scan_julia_exc_obj(void* obj_raw, void* closure, ProcessSlotFn process_slot) {
@@ -1086,6 +1066,7 @@ JL_DLLEXPORT jl_weakref_t *jl_gc_new_weakref_th(jl_ptls_t ptls, jl_value_t *valu
10861066
{
10871067
jl_weakref_t *wr = (jl_weakref_t*)jl_gc_alloc(ptls, sizeof(void*), jl_weakref_type);
10881068
wr->value = value; // NOTE: wb not needed here
1069+
OBJ_PIN(wr)
10891070
// Note: we are using MMTk's weak ref processing. If we switch to Julia's weak ref processing,
10901071
// we need to make sure the value and the weak ref won't be moved (e.g. pin them)
10911072
mmtk_add_weak_candidate(wr);

src/julia_internal.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,11 @@ JL_DLLEXPORT uintptr_t jl_get_buff_tag(void) JL_NOTSAFEPOINT;
585585
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
{
588-
return jl_gc_alloc(ptls, sz, (void*)jl_buff_tag);
588+
jl_gc_tracked_buffer_t *buf = jl_gc_alloc(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
591+
OBJ_PIN(buf);
592+
return buf;
589593
}
590594

591595
jl_value_t *jl_permbox8(jl_datatype_t *t, uintptr_t tag, uint8_t x);

src/llvm-late-gc-lowering-stock.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ Value* LateLowerGCFrame::lowerGCAllocBytesLate(CallInst *target, Function &F)
1010

1111
void LateLowerGCFrame::CleanupGCPreserve(Function &F, CallInst *CI, Value *callee, Type *T_size) {
1212
// Do nothing for the stock GC
13-
}
13+
}

0 commit comments

Comments
 (0)