Skip to content

Commit

Permalink
Instrument jl_gc_big_alloc() when called from generated code for Allo…
Browse files Browse the repository at this point in the history
…cations Profiler

Add _maybe_record_alloc_to_profile() call into jl_gc_big_alloc() to
allow us to instrument it in the Allocations Profiler.

Followup to #43868

Finishes fixing #43688 (gets the stacks, though not the types, of big allocs).
  • Loading branch information
NHDaly committed Feb 4, 2022
1 parent c0c854e commit 4da776a
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -944,7 +944,7 @@ static void sweep_weak_refs(void)
// big value list

// Size includes the tag and the tag is not cleared!!
JL_DLLEXPORT jl_value_t *jl_gc_big_alloc(jl_ptls_t ptls, size_t sz)
static inline jl_value_t *jl_gc_big_alloc_inner(jl_ptls_t ptls, size_t sz)
{
maybe_collect(ptls);
size_t offs = offsetof(bigval_t, header);
Expand Down Expand Up @@ -972,6 +972,22 @@ JL_DLLEXPORT jl_value_t *jl_gc_big_alloc(jl_ptls_t ptls, size_t sz)
return jl_valueof(&v->header);
}

// Instrumented version of jl_gc_big_alloc_inner, called into by LLVM-generated code.
JL_DLLEXPORT jl_value_t *jl_gc_big_alloc(jl_ptls_t ptls, size_t sz)
{
jl_value_t *val = jl_gc_big_alloc_inner(ptls, sz);

maybe_record_alloc_to_profile(val, sz, jl_gc_unknown_type_tag);
return val;
}

// This wrapper exists only to prevent `jl_gc_big_alloc_inner` from being inlined into
// its callers. We provide an external-facing interface for callers, and inline `jl_gc_big_alloc_inner`
// into this. (See https://github.com/JuliaLang/julia/pull/43868 for more details.)
jl_value_t *jl_gc_big_alloc_noinline(jl_ptls_t ptls, size_t sz) {
return jl_gc_big_alloc_inner(ptls, sz);
}

// Sweep list rooted at *pv, removing and freeing any unmarked objects.
// Return pointer to last `next` field in the culled list.
static bigval_t **sweep_big_list(int sweep_full, bigval_t **pv) JL_NOTSAFEPOINT
Expand Down

0 comments on commit 4da776a

Please sign in to comment.