diff --git a/src/gc-alloc-profiler.cpp b/src/gc-alloc-profiler.cpp index 71ba4983923ae..612f42578728e 100644 --- a/src/gc-alloc-profiler.cpp +++ b/src/gc-alloc-profiler.cpp @@ -40,7 +40,8 @@ void push_raw_alloc(struct RawAllocProfile *profile, size_t type_tag, size_t byt } else { jl_array_ptr_1d_push(profile->alloc_types, (jl_value_t*)jl_nothing_type); } - // jl_array_ptr_1d_push(profile->alloc_sizes, bytes_allocated); + // TODO: push this onto this array without boxing it + jl_array_ptr_1d_push(profile->alloc_sizes, jl_box_uint64(bytes_allocated)); jl_array_ptr_1d_push(profile->alloc_bts, (jl_value_t *)bt); jl_array_ptr_1d_push(profile->alloc_bt2s, (jl_value_t *)bt2); } @@ -76,8 +77,6 @@ void _record_allocated_value(jl_value_t *val, size_t size) JL_NOTSAFEPOINT { // profile->type_address_by_value_address[(size_t)val] = (size_t)type; - auto bytes_allocated = 5; // TODO: where were we getting this from? - g_alloc_profile_enabled = false; push_raw_alloc(profile, type_tag, size); g_alloc_profile_enabled = true; diff --git a/stdlib/AllocProfile/src/AllocProfile.jl b/stdlib/AllocProfile/src/AllocProfile.jl index 3e0e24e994735..e1c858fdfb7ab 100644 --- a/stdlib/AllocProfile/src/AllocProfile.jl +++ b/stdlib/AllocProfile/src/AllocProfile.jl @@ -13,7 +13,7 @@ const ExtendedEntryObj = Union{ # matches RawAllocResults on the C side struct RawAllocProfile alloc_types::Vector{Ptr{Type}} - alloc_sizes::Vector{Csize_t} + alloc_sizes::Vector{Ptr{Csize_t}} alloc_bts::Vector{Vector{Ptr{Cvoid}}} alloc_bt2s::Vector{Vector{ExtendedEntryObj}} @@ -135,15 +135,21 @@ function decode(raw_results::RawAllocProfile)::AllocResults cache = BacktraceCache() allocs = Vector{Alloc}() - @assert length(raw_results.alloc_bts) == length(raw_results.alloc_bt2s) == length(raw_results.alloc_types) + @assert length(raw_results.alloc_bts) == + length(raw_results.alloc_bt2s) == + length(raw_results.alloc_types) == + length(raw_results.alloc_sizes) for i in 1:length(raw_results.alloc_bts) bt = raw_results.alloc_bts[i] bt2 = raw_results.alloc_bt2s[i] - type = load_type(raw_results.alloc_types[i]) + type_tag = raw_results.alloc_types[i] + size = ccall(:jl_unbox_uint64, UInt64, (Ptr{Csize_t},), raw_results.alloc_sizes[i]) + + type = load_type(type_tag) back_trace = _reformat_bt_custom(bt, bt2) stack_trace = stacktrace_memoized(cache, back_trace) - size = 5 # TODO: grab this + push!(allocs, Alloc( type, stack_trace,