#Weird instruction sequence for function calls

1 messages · Page 1 of 1 (latest)

lucid girder
#

Does anyone here know why the Julia compiler always emits

movabs rax, offset j_func_n
call rax

for function calls instead of just a call with a constant offset?

unique flax
#

If I have understood your question correctly, because of dynamic dispatch?! function calls are often resolved at runtime based on the types of arguments. Indirect calls through rax facilitate this flexibility. Debugging and profiling could be another potential reason.

lucid girder
#

This is for fully deduced function, though, so there are no indirect calls. The movabs also just loads a constant

julia> @noinline g(x) = x
julia> f(x) = g(x)
julia> @code_native f(1)
julia_f_168:                            # @julia_f_168
# %bb.0:                                # %top
    push    rbp
    mov    rbp, rsp
    movabs    rax, offset j_g_170
    call    rax
    pop    rbp
    ret
#

And I don't see how this would help with debugging or profiling, tbh

pine glade
#

I would suggest asking on the slack or discourse, as that's where the people more knowledgeable about Julia's internals are

hollow grotto
lucid girder