@@ -319,20 +319,31 @@ function closures_to_opaque(ex::Expr, return_type = nothing)
319319 return Expr (head, Any[closures_to_opaque (x, return_type) for x in args]. .. )
320320end
321321
322- # We write an explicit deserialize() here to trigger caching of the body on a
323- # remote node when using Serialialization.jl (in Distributed.jl and elsewhere)
322+ # We write an explicit serialize() and deserialize() here to manage caching of
323+ # the body on a remote node when using Serialialization.jl (in Distributed.jl
324+ # and elsewhere)
325+ function Serialization. serialize (s:: AbstractSerializer ,
326+ rgf:: RuntimeGeneratedFunction{argnames, cache_tag, context_tag, id, B} ) where {
327+ argnames, cache_tag, context_tag, id, B}
328+ body = _lookup_body (cache_tag, id)
329+ Serialization. serialize_type (s, RuntimeGeneratedFunction{argnames, cache_tag, context_tag, id, B})
330+ serialize (s, body)
331+ end
332+
324333function Serialization. deserialize (s:: AbstractSerializer ,
325334 :: Type {
326335 <: RuntimeGeneratedFunction {argnames, cache_tag,
327- context_tag, id}}) where {
336+ context_tag, id, B }}) where {
328337 argnames,
329338 cache_tag,
330339 context_tag,
331- id
340+ id,
341+ B
332342 }
333343 body = deserialize (s)
334344 cached_body = _cache_body (cache_tag, id, body)
335- RuntimeGeneratedFunction {argnames, cache_tag, context_tag, id} (cached_body)
345+ f = RuntimeGeneratedFunction {argnames, cache_tag, context_tag, id} (cached_body)
346+ B === Nothing ? drop_expr (f) : f
336347end
337348
338349@specialize
0 commit comments