Skip to content

Commit

Permalink
minor rebase fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Diogo Netto authored and Diogo Netto committed Nov 18, 2022
1 parent 5bb5bab commit c0cf1ed
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 73 deletions.
85 changes: 13 additions & 72 deletions src/gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2461,7 +2461,7 @@ STATIC_INLINE void gc_mark_outrefs(jl_ptls_t ptls, jl_gc_markqueue_t *mq, void *
assert(nroots <= UINT32_MAX);
gc_mark_stack(ptls, s, (uint32_t)nroots, offset, lb, ub);
}
if (ta->excstack) {
if (ta->excstack != NULL) {
jl_excstack_t *excstack = ta->excstack;
gc_heap_snapshot_record_task_to_frame_edge(ta, excstack);
size_t itr = ta->excstack->top;
Expand Down Expand Up @@ -2684,9 +2684,20 @@ static void gc_queue_remset(jl_ptls_t ptls, jl_ptls_t ptls2)
jl_binding_t *ptr = (jl_binding_t *)items[i];
// A null pointer can happen here when the binding is cleaned up
// as an exception is thrown after it was already queued (#10221)
int bnd_refyoung = 0;
jl_value_t *v = jl_atomic_load_relaxed(&ptr->value);
gc_try_claim_and_push(&ptls->mark_queue, v, NULL);
if (v != NULL && !gc_old(jl_astaggedvalue(v)->header)) {
if (v != NULL && !gc_old(jl_astaggedvalue(v)->header))
bnd_refyoung = 1;
jl_value_t *ty = jl_atomic_load_relaxed(&ptr->ty);
gc_try_claim_and_push(&ptls->mark_queue, ty, NULL);
if (ty != NULL && !gc_old(jl_astaggedvalue(ty)->header))
bnd_refyoung = 1;
jl_value_t *globalref = jl_atomic_load_relaxed(&ptr->globalref);
gc_try_claim_and_push(&ptls->mark_queue, globalref, NULL);
if (globalref != NULL && !gc_old(jl_astaggedvalue(globalref)->header))
bnd_refyoung = 1;
if (bnd_refyoung) {
items[n_bnd_refyoung] = ptr;
n_bnd_refyoung++;
}
Expand Down Expand Up @@ -2856,76 +2867,6 @@ JL_DLLEXPORT int64_t jl_gc_live_bytes(void)
return live_bytes;
}

static void jl_gc_premark(jl_ptls_t ptls2)
{
arraylist_t *remset = ptls2->heap.remset;
ptls2->heap.remset = ptls2->heap.last_remset;
ptls2->heap.last_remset = remset;
ptls2->heap.remset->len = 0;
ptls2->heap.remset_nptr = 0;

// avoid counting remembered objects & bindings twice
// in `perm_scanned_bytes`
size_t len = remset->len;
void **items = remset->items;
for (size_t i = 0; i < len; i++) {
jl_value_t *item = (jl_value_t*)items[i];
objprofile_count(jl_typeof(item), 2, 0);
jl_astaggedvalue(item)->bits.gc = GC_OLD_MARKED;
}
len = ptls2->heap.rem_bindings.len;
items = ptls2->heap.rem_bindings.items;
for (size_t i = 0; i < len; i++) {
void *ptr = items[i];
jl_astaggedvalue(ptr)->bits.gc = GC_OLD_MARKED;
}
}

static void jl_gc_queue_remset(jl_gc_mark_cache_t *gc_cache, jl_gc_mark_sp_t *sp, jl_ptls_t ptls2)
{
size_t len = ptls2->heap.last_remset->len;
void **items = ptls2->heap.last_remset->items;
for (size_t i = 0; i < len; i++)
gc_mark_queue_scan_obj(gc_cache, sp, (jl_value_t*)items[i]);
int n_bnd_refyoung = 0;
len = ptls2->heap.rem_bindings.len;
items = ptls2->heap.rem_bindings.items;
for (size_t i = 0; i < len; i++) {
jl_binding_t *ptr = (jl_binding_t*)items[i];
// A null pointer can happen here when the binding is cleaned up
// as an exception is thrown after it was already queued (#10221)
int bnd_refyoung = 0;
jl_value_t *v = jl_atomic_load_relaxed(&ptr->value);
if (v != NULL && gc_mark_queue_obj(gc_cache, sp, v))
bnd_refyoung = 1;
jl_value_t *ty = jl_atomic_load_relaxed(&ptr->ty);
if (ty != NULL && gc_mark_queue_obj(gc_cache, sp, ty))
bnd_refyoung = 1;
jl_value_t *globalref = jl_atomic_load_relaxed(&ptr->globalref);
if (globalref != NULL && gc_mark_queue_obj(gc_cache, sp, globalref))
bnd_refyoung = 1;
if (bnd_refyoung) {
items[n_bnd_refyoung] = ptr;
n_bnd_refyoung++;
}
}
ptls2->heap.rem_bindings.len = n_bnd_refyoung;
}

static void jl_gc_queue_bt_buf(jl_gc_mark_cache_t *gc_cache, jl_gc_mark_sp_t *sp, jl_ptls_t ptls2)
{
jl_bt_element_t *bt_data = ptls2->bt_data;
size_t bt_size = ptls2->bt_size;
for (size_t i = 0; i < bt_size; i += jl_bt_entry_size(bt_data + i)) {
jl_bt_element_t *bt_entry = bt_data + i;
if (jl_bt_is_native(bt_entry))
continue;
size_t njlvals = jl_bt_num_jlvals(bt_entry);
for (size_t j = 0; j < njlvals; j++)
gc_mark_queue_obj(gc_cache, sp, jl_bt_entry_jlvalue(bt_entry, j));
}
}

size_t jl_maxrss(void);

// Only one thread should be running in this function
Expand Down
2 changes: 1 addition & 1 deletion src/julia_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -1128,7 +1128,7 @@ size_t rec_backtrace_ctx_dwarf(jl_bt_element_t *bt_data, size_t maxsize, bt_cont
#endif
JL_DLLEXPORT jl_value_t *jl_get_backtrace(void);
void jl_critical_error(int sig, int si_code, bt_context_t *context, jl_task_t *ct);
JL_DLLEXPORT void jl_raise_debugger(void);
JL_DLLEXPORT void jl_raise_debugger(void) JL_NOTSAFEPOINT;
int jl_getFunctionInfo(jl_frame_t **frames, uintptr_t pointer, int skipC, int noInline) JL_NOTSAFEPOINT;
JL_DLLEXPORT void jl_gdblookup(void* ip) JL_NOTSAFEPOINT;
void jl_print_native_codeloc(uintptr_t ip) JL_NOTSAFEPOINT;
Expand Down

0 comments on commit c0cf1ed

Please sign in to comment.