Skip to content

Commit

Permalink
use copy instead of copy_codeinfo (#69)
Browse files Browse the repository at this point in the history
* use copy instead of copy_codeinfo

* fix for 1.0
  • Loading branch information
KristofferC authored Feb 26, 2019
1 parent 8ee5829 commit 6b78715
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/JuliaInterpreter.jl
Original file line number Diff line number Diff line change
Expand Up @@ -554,14 +554,19 @@ function get_source(g::GeneratedFunctionStub)
end

function copy_codeinfo(code::CodeInfo)
newcode = ccall(:jl_new_struct_uninit, Any, (Any,), CodeInfo)::CodeInfo
for (i, name) in enumerate(fieldnames(CodeInfo))
if isdefined(code, name)
val = getfield(code, name)
ccall(:jl_set_nth_field, Cvoid, (Any, Csize_t, Any), newcode, i-1, val===nothing || isa(val, Type) ? val : copy(val))
@static if VERSION < v"1.1.0-DEV.762"
newcode = ccall(:jl_new_struct_uninit, Any, (Any,), CodeInfo)::CodeInfo
for (i, name) in enumerate(fieldnames(CodeInfo))
if isdefined(code, name)
val = getfield(code, name)
ccall(:jl_set_nth_field, Cvoid, (Any, Csize_t, Any), newcode, i-1, val===nothing || isa(val, Union{Type, Method}) ? val : copy(val))
end
end
return newcode
else
# Inline this when support for VERSION above is dropped
return copy(code)
end
return newcode
end

const calllike = Set([:call, :foreigncall])
Expand Down

0 comments on commit 6b78715

Please sign in to comment.