Skip to content

Commit 6b78715

Browse files
authored
use copy instead of copy_codeinfo (#69)
* use copy instead of copy_codeinfo * fix for 1.0
1 parent 8ee5829 commit 6b78715

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/JuliaInterpreter.jl

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -554,14 +554,19 @@ function get_source(g::GeneratedFunctionStub)
554554
end
555555

556556
function copy_codeinfo(code::CodeInfo)
557-
newcode = ccall(:jl_new_struct_uninit, Any, (Any,), CodeInfo)::CodeInfo
558-
for (i, name) in enumerate(fieldnames(CodeInfo))
559-
if isdefined(code, name)
560-
val = getfield(code, name)
561-
ccall(:jl_set_nth_field, Cvoid, (Any, Csize_t, Any), newcode, i-1, val===nothing || isa(val, Type) ? val : copy(val))
557+
@static if VERSION < v"1.1.0-DEV.762"
558+
newcode = ccall(:jl_new_struct_uninit, Any, (Any,), CodeInfo)::CodeInfo
559+
for (i, name) in enumerate(fieldnames(CodeInfo))
560+
if isdefined(code, name)
561+
val = getfield(code, name)
562+
ccall(:jl_set_nth_field, Cvoid, (Any, Csize_t, Any), newcode, i-1, val===nothing || isa(val, Union{Type, Method}) ? val : copy(val))
563+
end
562564
end
565+
return newcode
566+
else
567+
# Inline this when support for VERSION above is dropped
568+
return copy(code)
563569
end
564-
return newcode
565570
end
566571

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

0 commit comments

Comments
 (0)