Skip to content

Commit a57adb3

Browse files
authored
Merge pull request #81 from timholy/teh/nightly
Support AbstractInterpreter
2 parents 7785627 + deb69da commit a57adb3

File tree

2 files changed

+41
-17
lines changed

2 files changed

+41
-17
lines changed

Project.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ julia = "1"
1414

1515
[extras]
1616
ColorTypes = "3da002f7-5984-5a60-b8a6-cbb66c0b333f"
17+
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
1718
FixedPointNumbers = "53c48c17-4a7d-5ca2-90c5-79b7896eea93"
1819
JLD = "4138dd39-2aa7-5051-a626-17a0bb65d9c8"
1920
MatLang = "05b439c0-bb3c-11e9-1d8d-1f0a9ebca87a"
@@ -22,4 +23,4 @@ SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
2223
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
2324

2425
[targets]
25-
test = ["Pkg", "ColorTypes", "Test", "FixedPointNumbers", "JLD", "SparseArrays", "MatLang"]
26+
test = ["Pkg", "ColorTypes", "Documenter", "Test", "FixedPointNumbers", "JLD", "SparseArrays", "MatLang"]

src/snoopi.jl

Lines changed: 39 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,41 @@ export @snoopi
22

33
const __inf_timing__ = Tuple{Float64,Core.MethodInstance}[]
44

5-
function typeinf_ext_timed(linfo::Core.MethodInstance, params::Core.Compiler.Params)
6-
tstart = time()
7-
ret = Core.Compiler.typeinf_ext(linfo, params)
8-
tstop = time()
9-
push!(__inf_timing__, (tstop-tstart, linfo))
10-
return ret
11-
end
12-
function typeinf_ext_timed(linfo::Core.MethodInstance, world::UInt)
13-
tstart = time()
14-
ret = Core.Compiler.typeinf_ext(linfo, world)
15-
tstop = time()
16-
push!(__inf_timing__, (tstop-tstart, linfo))
17-
return ret
5+
if isdefined(Core.Compiler, :Params)
6+
function typeinf_ext_timed(linfo::Core.MethodInstance, params::Core.Compiler.Params)
7+
tstart = time()
8+
ret = Core.Compiler.typeinf_ext(linfo, params)
9+
tstop = time()
10+
push!(__inf_timing__, (tstop-tstart, linfo))
11+
return ret
12+
end
13+
function typeinf_ext_timed(linfo::Core.MethodInstance, world::UInt)
14+
tstart = time()
15+
ret = Core.Compiler.typeinf_ext(linfo, world)
16+
tstop = time()
17+
push!(__inf_timing__, (tstop-tstart, linfo))
18+
return ret
19+
end
20+
@noinline stop_timing() = ccall(:jl_set_typeinf_func, Cvoid, (Any,), Core.Compiler.typeinf_ext)
21+
else
22+
function typeinf_ext_timed(interp::Core.Compiler.AbstractInterpreter, linfo::Core.MethodInstance)
23+
tstart = time()
24+
ret = Core.Compiler.typeinf_ext_toplevel(interp, linfo)
25+
tstop = time()
26+
push!(__inf_timing__, (tstop-tstart, linfo))
27+
return ret
28+
end
29+
function typeinf_ext_timed(linfo::Core.MethodInstance, world::UInt)
30+
tstart = time()
31+
ret = Core.Compiler.typeinf_ext_toplevel(linfo, world)
32+
tstop = time()
33+
push!(__inf_timing__, (tstop-tstart, linfo))
34+
return ret
35+
end
36+
@noinline stop_timing() = ccall(:jl_set_typeinf_func, Cvoid, (Any,), Core.Compiler.typeinf_ext_toplevel)
1837
end
1938

2039
@noinline start_timing() = ccall(:jl_set_typeinf_func, Cvoid, (Any,), typeinf_ext_timed)
21-
@noinline stop_timing() = ccall(:jl_set_typeinf_func, Cvoid, (Any,), Core.Compiler.typeinf_ext)
2240

2341
function sort_timed_inf(tmin)
2442
data = __inf_timing__
@@ -68,8 +86,13 @@ function __init__()
6886
# typeinf_ext_timed must be compiled before it gets run
6987
# We do this in __init__ to make sure it gets compiled to native code
7088
# (the *.ji file stores only the inferred code)
71-
precompile(typeinf_ext_timed, (Core.MethodInstance, Core.Compiler.Params))
72-
precompile(typeinf_ext_timed, (Core.MethodInstance, UInt))
89+
if isdefined(Core.Compiler, :Params)
90+
@assert precompile(typeinf_ext_timed, (Core.MethodInstance, Core.Compiler.Params))
91+
@assert precompile(typeinf_ext_timed, (Core.MethodInstance, UInt))
92+
else
93+
@assert precompile(typeinf_ext_timed, (Core.Compiler.NativeInterpreter, Core.MethodInstance))
94+
@assert precompile(typeinf_ext_timed, (Core.MethodInstance, UInt))
95+
end
7396
precompile(start_timing, ())
7497
precompile(stop_timing, ())
7598
nothing

0 commit comments

Comments
 (0)