Is it possible to determine if the Julia JIT will return a heap allocated or stack allocated return value from a function call?

时间: 2025-01-06 admin 业界

I recently asked a similar question about how Julia is able to return values of multiple different types from a function call.

My understanding is that under some circumstances, the compiler is able to determine the possible set of return value types, and therefore it is able to return a value using allocated space on the stack.

In other contexts, where the compiler is not able to obtain this information, my understanding is that the compiler returns a value using heap allocated storage.

In either situation, is it possible to determine if Julia has compiled a function or method such that the return value is stack allocated or heap allocated? Is there some way of obtaining this information, perhaps through a debugging or disassembler method?