@@ -349,34 +349,19 @@ function getdict(data::Vector{UInt})
349
349
end
350
350
351
351
function getdict! (dict:: LineInfoDict , data:: Vector{UInt} )
352
- # we don't want metadata here as we're just looking up ips
353
- unique_ips = unique (has_meta (data) ? strip_meta (data) : data)
354
- n_unique_ips = length (unique_ips)
355
- n_unique_ips == 0 && return dict
356
- iplookups = similar (unique_ips, Vector{StackFrame})
357
- @sync for indexes_part in Iterators. partition (eachindex (unique_ips), div (n_unique_ips, Threads. nthreads (), RoundUp))
358
- Threads. @spawn begin
359
- for i in indexes_part
360
- iplookups[i] = _lookup_corrected (unique_ips[i])
361
- end
362
- end
363
- end
364
- for i in eachindex (unique_ips)
365
- dict[unique_ips[i]] = iplookups[i]
352
+ for ip in data
353
+ # Lookup is expensive, so do it only once per ip.
354
+ haskey (dict, UInt64 (ip)) && continue
355
+ st = lookup (convert (Ptr{Cvoid}, ip))
356
+ # To correct line numbers for moving code, put it in the form expected by
357
+ # Base.update_stackframes_callback[]
358
+ stn = map (x-> (x, 1 ), st)
359
+ try Base. invokelatest (Base. update_stackframes_callback[], stn) catch end
360
+ dict[UInt64 (ip)] = map (first, stn)
366
361
end
367
362
return dict
368
363
end
369
364
370
- function _lookup_corrected (ip:: UInt )
371
- st = lookup (convert (Ptr{Cvoid}, ip))
372
- # To correct line numbers for moving code, put it in the form expected by
373
- # Base.update_stackframes_callback[]
374
- stn = map (x-> (x, 1 ), st)
375
- # Note: Base.update_stackframes_callback[] should be data-race free
376
- try Base. invokelatest (Base. update_stackframes_callback[], stn) catch end
377
- return map (first, stn)
378
- end
379
-
380
365
"""
381
366
flatten(btdata::Vector, lidict::LineInfoDict) -> (newdata::Vector{UInt64}, newdict::LineInfoFlatDict)
382
367
0 commit comments