Skip to content

Commit 97dbf1b

Browse files
authored
Implement fix_ptr_lookup for raw fname (#2740)
1 parent f06de8a commit 97dbf1b

File tree

1 file changed

+9
-15
lines changed

1 file changed

+9
-15
lines changed

src/compiler/orcv2.jl

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -47,29 +47,23 @@ function absolute_symbol_materialization(name, ptr)
4747
end
4848

4949
const hnd_string_map = Dict{String, Ref{Ptr{Cvoid}}}()
50+
const hnd_int_map = Dict{Int, Ref{Ptr{Cvoid}}}()
5051

5152
function fix_ptr_lookup(name)
5253
if startswith(name, "ejlstr\$") || startswith(name, "ejlptr\$")
5354
_, fname, arg1 = split(name, "\$")
5455
if startswith(name, "ejlstr\$")
55-
ptr = if haskey(hnd_string_map, arg1)
56-
hnd_string_map[arg1]
57-
else
58-
val = Ref{Ptr{Cvoid}}(C_NULL)
59-
hnd_string_map[arg1] = val
60-
val
56+
hnd_cache = get!(hnd_string_map, arg1) do
57+
Ref{Ptr{Cvoid}}(C_NULL)
6158
end
62-
63-
return ccall(
64-
:ijl_load_and_lookup,
65-
Ptr{Cvoid},
66-
(Cstring, Cstring, Ptr{Cvoid}),
67-
arg1,
68-
fname,
69-
ptr
70-
)
7159
else
60+
arg1 = parse(Int, arg1)
61+
hnd_cache = get!(hnd_int_map, arg1) do
62+
Ref{Ptr{Cvoid}}(C_NULL)
63+
end
64+
arg1 = reinterpret(Ptr{Cchar}, arg1)
7265
end
66+
return @ccall jl_load_and_lookup(arg1::Cstring, fname::Cstring, hnd_cache::Ptr{Cvoid})::Ptr{Cvoid}
7367
end
7468
return nothing
7569
end

0 commit comments

Comments
 (0)