Skip to content

Commit 439f06b

Browse files
committed
get sizes to work again
1 parent ba03edf commit 439f06b

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

src/gc-alloc-profiler.cpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ void push_raw_alloc(struct RawAllocProfile *profile, size_t type_tag, size_t byt
4040
} else {
4141
jl_array_ptr_1d_push(profile->alloc_types, (jl_value_t*)jl_nothing_type);
4242
}
43-
// jl_array_ptr_1d_push(profile->alloc_sizes, bytes_allocated);
43+
// TODO: push this onto this array without boxing it
44+
jl_array_ptr_1d_push(profile->alloc_sizes, jl_box_uint64(bytes_allocated));
4445
jl_array_ptr_1d_push(profile->alloc_bts, (jl_value_t *)bt);
4546
jl_array_ptr_1d_push(profile->alloc_bt2s, (jl_value_t *)bt2);
4647
}
@@ -76,8 +77,6 @@ void _record_allocated_value(jl_value_t *val, size_t size) JL_NOTSAFEPOINT {
7677

7778
// profile->type_address_by_value_address[(size_t)val] = (size_t)type;
7879

79-
auto bytes_allocated = 5; // TODO: where were we getting this from?
80-
8180
g_alloc_profile_enabled = false;
8281
push_raw_alloc(profile, type_tag, size);
8382
g_alloc_profile_enabled = true;

stdlib/AllocProfile/src/AllocProfile.jl

+10-4
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const ExtendedEntryObj = Union{
1313
# matches RawAllocResults on the C side
1414
struct RawAllocProfile
1515
alloc_types::Vector{Ptr{Type}}
16-
alloc_sizes::Vector{Csize_t}
16+
alloc_sizes::Vector{Ptr{Csize_t}}
1717
alloc_bts::Vector{Vector{Ptr{Cvoid}}}
1818
alloc_bt2s::Vector{Vector{ExtendedEntryObj}}
1919

@@ -135,15 +135,21 @@ function decode(raw_results::RawAllocProfile)::AllocResults
135135
cache = BacktraceCache()
136136
allocs = Vector{Alloc}()
137137

138-
@assert length(raw_results.alloc_bts) == length(raw_results.alloc_bt2s) == length(raw_results.alloc_types)
138+
@assert length(raw_results.alloc_bts) ==
139+
length(raw_results.alloc_bt2s) ==
140+
length(raw_results.alloc_types) ==
141+
length(raw_results.alloc_sizes)
139142

140143
for i in 1:length(raw_results.alloc_bts)
141144
bt = raw_results.alloc_bts[i]
142145
bt2 = raw_results.alloc_bt2s[i]
143-
type = load_type(raw_results.alloc_types[i])
146+
type_tag = raw_results.alloc_types[i]
147+
size = ccall(:jl_unbox_uint64, UInt64, (Ptr{Csize_t},), raw_results.alloc_sizes[i])
148+
149+
type = load_type(type_tag)
144150
back_trace = _reformat_bt_custom(bt, bt2)
145151
stack_trace = stacktrace_memoized(cache, back_trace)
146-
size = 5 # TODO: grab this
152+
147153
push!(allocs, Alloc(
148154
type,
149155
stack_trace,

0 commit comments

Comments
 (0)