Fastest way to get CodeInfo from a function call

I think code_lowered is really bare minimal already, it comes down to (as you probably have looked at):

julia> m = first(Base.method_instances(+, (Int, Int))).def
julia> Base.uncompressed_ir(m)
CodeInfo(
    @ int.jl:87 within `+`
1 ─ %1 = Base.add_int(x, y)
└──      return %1
)

and looks like if the function is not generated, the uncompressed_ir is just calling:

_uncompressed_ir(m::Method, s::Array{UInt8,1}) = ccall(:jl_uncompress_ir, Any, (Any, Ptr{Cvoid}, Any), m, C_NULL, s)::CodeInfo

on the byte vector of m.def.source

1 Like