Skip to content

Commit 6bd0882

Browse files
committed
Write out a cache header
1 parent 088e62c commit 6bd0882

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

src/execution.jl

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,12 @@ end
150150
string(h, ".jls"))
151151
end
152152

153+
struct OnDiskCacheEntry
154+
src::MethodInstance
155+
cfg::CompilerConfig
156+
asm
157+
end
158+
153159
@noinline function actual_compilation(cache::AbstractDict, src::MethodInstance, world::UInt,
154160
cfg::CompilerConfig, compiler::Function, linker::Function)
155161
job = CompilerJob(src, cfg, world)
@@ -176,7 +182,12 @@ end
176182
ondisk_hit = true
177183
try
178184
@debug "Loading compiled kernel" job path
179-
asm = deserialize(path)
185+
entry = deserialize(path)::OnDiskCacheEntry
186+
if entry.src == src && entry.cfg == cfg
187+
asm = entry.asm
188+
else
189+
@warn "Cache missmatch" src cfg entry
190+
end
180191
catch ex
181192
@warn "Failed to load compiled kernel" job path exception=(ex, catch_backtrace())
182193
end
@@ -196,9 +207,9 @@ end
196207
@static if VERSION >= v"1.11.0-"
197208
if !ondisk_hit && path !== nothing && disk_cache()
198209
@debug "Writing out on-disk cache" job path
199-
# TODO: Do we want to serialize some more metadata to make sure the asm matches?
200210
tmppath, io = mktemp(;cleanup=false)
201-
serialize(io, asm)
211+
entry = OnDiskCacheEntry(src, cfg, asm)
212+
serialize(io, entry)
202213
close(io)
203214
# atomic move
204215
mkpath(dirname(path))

0 commit comments

Comments
 (0)