-
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
Implementing the change proposed in #502 #503
Implementing the change proposed in #502 #503
Conversation
Codecov Report
@@ Coverage Diff @@
## master #503 +/- ##
==========================================
+ Coverage 82.76% 83.53% +0.76%
==========================================
Files 12 12
Lines 2443 2447 +4
==========================================
+ Hits 2022 2044 +22
+ Misses 421 403 -18
Continue to review full report at Codecov.
|
Co-authored-by: Kristoffer Carlsson <[email protected]>
We want to add testcase that demonstrates how these added option can be used. I just come up with something like this: @testset "interpretation of unoptimized frame" begin
let # should be able to interprete nested calls within `:foreigncall` expressions
# even if `JuliaInterpreter.optimize!` doesn't flatten them
M = Module()
lwr = Meta.@lower M begin
global foo = @ccall strlen("foo"::Cstring)::Csize_t
foo == 3
end
src = lwr.args[1]::Core.CodeInfo
frame = Frame(M, src; optimize=false)
@test length(frame.framecode.src.code) == length(src.code)
@test JuliaInterpreter.finish_and_return!(frame, true)
M = Module()
lwr = Meta.@lower M begin
strp = Ref{Ptr{Cchar}}(0)
fmt = "hi+%hhd-%hhd-%hhd-%hhd-%hhd-%hhd-%hhd-%hhd-%hhd-%hhd-%hhd-%hhd-%hhd-%hhd-%hhd-%.1f-%.1f-%.1f-%.1f-%.1f-%.1f-%.1f-%.1f-%.1f\n"
len = @ccall asprintf(
strp::Ptr{Ptr{Cchar}},
fmt::Cstring,
; # begin varargs
0x1::UInt8, 0x2::UInt8, 0x3::UInt8, 0x4::UInt8, 0x5::UInt8, 0x6::UInt8, 0x7::UInt8, 0x8::UInt8, 0x9::UInt8, 0xa::UInt8, 0xb::UInt8, 0xc::UInt8, 0xd::UInt8, 0xe::UInt8, 0xf::UInt8,
1.1::Cfloat, 2.2::Cfloat, 3.3::Cfloat, 4.4::Cfloat, 5.5::Cfloat, 6.6::Cfloat, 7.7::Cfloat, 8.8::Cfloat, 9.9::Cfloat,
)::Cint
str = unsafe_string(strp[], len)
@ccall free(strp[]::Cstring)::Cvoid
str == "hi+1-2-3-4-5-6-7-8-9-10-11-12-13-14-15-1.1-2.2-3.3-4.4-5.5-6.6-7.7-8.8-9.9\n"
end
src = lwr.args[1]::Core.CodeInfo
frame = Frame(M, src; optimize=false)
@test length(frame.framecode.src.code) == length(src.code)
@test JuliaInterpreter.finish_and_return!(frame, true)
end
end |
Co-authored-by: Shuhei Kadowaki <[email protected]>
Co-authored-by: Shuhei Kadowaki <[email protected]>
Here are the errors:
|
Interesting question: shouldn't
|
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.
If the ambiguity about call expressions can be resolved, this LGTM.
args = frame.framedata.callargs | ||
resize!(args, length(call_expr.args)) | ||
mod = moduleof(frame) | ||
args[1] = isfc ? resolvefc(frame, call_expr.args[1]) : @lookup(mod, frame, call_expr.args[1]) | ||
for i = 2:length(args) | ||
args[i] = @lookup(mod, frame, call_expr.args[i]) | ||
if isexpr(call_expr.args[i], :call) | ||
args[i] = lookup_or_eval(recurse, frame, call_expr.args[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.
With this change, we might need to test
iscallexpr(ex::Expr) = ex.head === :call
@interpret iscallexpr(:(sin(3.14))
We need to be sure we distinguish a call expression intended as an argument from one produced by lowering.
Thanks @goerch! |
No description provided.