Skip to content

Commit

Permalink
Add Cthulhu.ascend integration
Browse files Browse the repository at this point in the history
Closes #511
  • Loading branch information
timholy committed Jul 14, 2024
1 parent 3d8adb6 commit 4942d58
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,18 @@ Preferences = "21216c6a-2e73-6563-6e65-726566657250"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[weakdeps]
Cthulhu = "f68482b8-f384-11e8-15f7-abe071a5a75f"
Revise = "295af30f-e4ad-537b-8983-00126c2a3abe"

[extensions]
JETCthulhuExt = "Cthulhu"
ReviseExt = "Revise"

[compat]
Aqua = "0.8.2"
BenchmarkTools = "1.3.2"
CodeTracking = "1.3.1"
Cthulhu = "2.12.7"
Example = "0.5.3"
InteractiveUtils = "1.10"
JuliaInterpreter = "0.9"
Expand All @@ -43,6 +46,7 @@ julia = "1.10"
[extras]
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
Cthulhu = "f68482b8-f384-11e8-15f7-abe071a5a75f"
Example = "7876af07-990d-54b4-ab0e-23690620f79a"
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
Expand All @@ -52,4 +56,4 @@ StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Aqua", "BenchmarkTools", "Example", "Libdl", "Logging", "Random", "Revise", "StaticArrays", "Test"]
test = ["Aqua", "BenchmarkTools", "Cthulhu", "Example", "Libdl", "Logging", "Random", "Revise", "StaticArrays", "Test"]
25 changes: 25 additions & 0 deletions ext/JETCthuhluExt.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
module JETCthulhuExt

using JET: JET, RuntimeDispatchReport, VirtualFrame
using Cthulhu: Cthulhu, Node, Data, callstring
using Core: MethodInstance

const _emptybackedges = MethodInstance[]

struct CallFrames
frames::Vector{VirtualFrame}
end

function Cthulhu.treelist(r::RuntimeDispatchReport)
io = IOBuffer()
cf = CallFrames(r.vst)
frame = r.vst[end]
str = callstring(io, frame.linfo)
Cthulhu.treelist!(Node(Data(str, frame.linfo)), io, cf, "", Base.IdSet{MethodInstance}())
end

Cthulhu.instance(cf::CallFrames) = cf.frames[end].linfo
Cthulhu.backedges(cf::CallFrames) = isempty(cf.frames) ? _emptybackedges : [cf.frames[end].linfo]
Cthulhu.nextnode(cf::CallFrames, ::MethodInstance) = CallFrames(cf.frames[1:end-1])

end

0 comments on commit 4942d58

Please sign in to comment.