@@ -319,20 +319,39 @@ 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,
327+ context_tag, id, B}) where {
328+ argnames,
329+ cache_tag,
330+ context_tag,
331+ id,
332+ B
333+ }
334+ body = _lookup_body (cache_tag, id)
335+ Serialization. serialize_type (s,
336+ RuntimeGeneratedFunction{argnames, cache_tag, context_tag,
337+ id, B})
338+ serialize (s, body)
339+ end
340+
324341function Serialization. deserialize (s:: AbstractSerializer ,
325342 :: Type {
326343 <: RuntimeGeneratedFunction {argnames, cache_tag,
327- context_tag, id}}) where {
328- argnames,
329- cache_tag,
330- context_tag,
331- id
332- }
344+ context_tag, id, B}}) where {
345+ argnames,
346+ cache_tag,
347+ context_tag,
348+ id,
349+ B
350+ }
333351 body = deserialize (s)
334352 cached_body = _cache_body (cache_tag, id, body)
335- RuntimeGeneratedFunction {argnames, cache_tag, context_tag, id} (cached_body)
353+ f = RuntimeGeneratedFunction {argnames, cache_tag, context_tag, id} (cached_body)
354+ B === Nothing ? drop_expr (f) : f
336355end
337356
338357@specialize
0 commit comments