From 4cd4c06dac697ef7f0cc3ed74675c902323027e2 Mon Sep 17 00:00:00 2001 From: Tim Besard Date: Mon, 14 Sep 2026 12:38:09 +0200 Subject: [PATCH] Avoid boxing compiler jobs during kernel resolution Specialize compile_or_lookup on the backend target and parameter types. Keep it out of line to avoid duplicating the body in callers specialized per kernel, while preserving the existing GPUCompiler cache path. --- src/compiler/execution.jl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/compiler/execution.jl b/src/compiler/execution.jl index d16283d6..3b88c8eb 100644 --- a/src/compiler/execution.jl +++ b/src/compiler/execution.jl @@ -269,7 +269,9 @@ end # `obj === nothing` identifies an `OpenCLResults` that hasn't been compiled yet. The # `compile_hook` check additionally forces the compile path so reflection-style # consumers (`@device_code_*`) observe the compilation even on a cache hit. -function compile_or_lookup(@nospecialize(job::CompilerJob))::OpenCLResults +# Specialize on the target/parameter types so callers can avoid boxing CompilerJob. +# Keep the body out of callers that specialize per kernel. +@noinline function compile_or_lookup(job::CompilerJob)::OpenCLResults res = GPUCompiler.cached_results(OpenCLResults, job) if res === nothing || res.obj === nothing || GPUCompiler.compile_hook[] !== nothing compiled = compile_to_obj(job)