Codegen memory functions as soon as possible to avoid malloc being used in closure contexts at the top-level