-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add ability to evaluate ssavalues and locals #395
Conversation
KristofferC
commented
May 22, 2020
Expr(:block, map(x->Expr(:(=), x...), [(v.name, maybe_quote(v.value isa Core.Box ? v.value.contents : v.value)) for v in vars])...), | ||
Expr(:block, map(x->Expr(:(=), x...), [(v.name, maybe_quote(v.value isa Core.Box ? v.value.contents : v.value)) for v in vars])..., | ||
map(x->Expr(:(=), x...), [(Symbol("%$i"), data.ssavalues[i]) for i in defined_ssa])..., | ||
map(x->Expr(:(=), x...), [(Symbol("@_$i"), data.locals[i].value) for i in defined_locals])...), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIUC this makes slots available by their number but not their name, right?
julia> function summer(A)
s = zero(eltype(A))
for i in eachindex(A)
s += A[i]
end
return s
end
summer (generic function with 1 method)
julia> src = Base.uncompressed_ast(@which summer([1,2,3]))
CodeInfo(
@ REPL[10]:2 within `summer'
1 ─ %1 = Main.eltype(A)
│ s = Main.zero(%1)
│ @ REPL[10]:3 within `summer'
│ %3 = Main.eachindex(A)
│ @_4 = Base.iterate(%3)
│ %5 = @_4 === nothing
│ %6 = Base.not_int(%5)
└── goto #4 if not %6
2 ┄ %8 = @_4
│ i = Core.getfield(%8, 1)
│ %10 = Core.getfield(%8, 2)
│ @ REPL[10]:4 within `summer'
│ %11 = s
│ %12 = Base.getindex(A, i)
│ s = %11 + %12
│ @_4 = Base.iterate(%3, %10)
│ %15 = @_4 === nothing
│ %16 = Base.not_int(%15)
└── goto #4 if not %16
3 ─ goto #2
@ REPL[10]:6 within `summer'
4 ┄ return s
)
julia> src.slotnames
5-element Array{Symbol,1}:
Symbol("#self#")
:A
:s
Symbol("")
:i
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, for their name you just evaluate with the local variable name, right? I was a bit unsure if I should include this but it seems easy enough and when you see e.g. @_4 = Base.iterate(%3, %10)
in the lowered code, perhaps you just want to look at what @_4
contains.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, duh, you're saying this gets covered the other branch. Carry on 😄
Codecov Report
@@ Coverage Diff @@
## master #395 +/- ##
==========================================
+ Coverage 87.65% 87.68% +0.02%
==========================================
Files 11 11
Lines 2001 2005 +4
==========================================
+ Hits 1754 1758 +4
Misses 247 247
Continue to review full report at Codecov.
|