Commit 04138bf
authored
Support "Functor-like"
This lets you easily inspect IR associated with "Functor-like" methods:
```julia
julia> (f::Foo)(offset::Float64) = f.x + f.y + offset
julia> code_typed((Foo, Float64))
1-element Vector{Any}:
CodeInfo(
1 ─ %1 = Base.getfield(f, :x)::Int64
│ %2 = Base.getfield(f, :y)::Int64
│ %3 = Base.add_int(%1, %2)::Int64
│ %4 = Base.sitofp(Float64, %3)::Float64
│ %5 = Base.add_float(%4, offset)::Float64
└── return %5
) => Float64
```
This is just a small convenience over `code_typed_by_type`, but I'm in
support of it (even though it technically changes the meaning of, e.g.,
`code_typed((1, 2))` which without this PR inspects
`(::Tuple{Int,Int})(::Vararg{Any})`
We should probably update all of our reflection machinery (`code_llvm`,
`code_lowered`, `methodinstance`, etc.) to support this "non-arg0" style
as well, but I wanted to open this first to make sure folks like it.code_typed invocation (#57911)1 parent 958d758 commit 04138bf
1 file changed
+29
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
211 | 211 | | |
212 | 212 | | |
213 | 213 | | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
214 | 235 | | |
215 | 236 | | |
| 237 | + | |
| 238 | + | |
216 | 239 | | |
217 | 240 | | |
218 | 241 | | |
| |||
221 | 244 | | |
222 | 245 | | |
223 | 246 | | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
224 | 253 | | |
225 | 254 | | |
226 | 255 | | |
| |||
0 commit comments