I understand that we need to push the address to a register then branch using the register. But i am asking why there is a trampoline there such that a call to foo is first branched to an snippet and the snippet branches to the X86CompilationCallback. is this snippet necessary ?<br>
<br>Thanks <br><br>Xin <br><br><br><div class="gmail_quote">On Tue, Feb 22, 2011 at 12:39 PM, Reid Kleckner <span dir="ltr"><<a href="mailto:reid.kleckner@gmail.com">reid.kleckner@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
The address of the callee may be more than 2 GB away in memory, which<br>
cannot be encoded as an immediate offset in the call instruction.  So,<br>
the value is first materialized with a mov instruction which can<br>
encode the immediate and then jumped to through a register.<br>
<br>
Reid<br>
<div><div></div><div class="h5"><br>
On Tue, Feb 22, 2011 at 12:03 PM, Xin Tong Utoronto <<a href="mailto:x.tong@utoronto.ca">x.tong@utoronto.ca</a>> wrote:<br>
> I have a question on the LLVM JIT<br>
><br>
> I did some brief memory reading one day and I found that a call to a<br>
> non-library function is resolved by the X86CompilationCallback, but the<br>
> X86CompilationCallback is reached through a trampoline. why can not  the<br>
> generated code jump to the X86CompilationCallback function directly ?<br>
><br>
>           0x2b0a6a4d103b: mov    $0x2b0a6a561010,%rax<br>
>           0x2b0a6a4d1045: callq  *%rax<br>
> // call foo<br>
>><br>
>><br>
>> ==><br>
>><br>
>> 0x2b0a6a561010: mov    $0xa743a0,%r10                   // some kind of<br>
>> trampoline<br>
>> 0x2b0a6a56101a: callq  *%r10<br>
>><br>
>> ==><br>
>><br>
>> 0xa743a0 <X86CompilationCallback>:        push   %rbp<br>
>> 0xa743a1 <X86CompilationCallback+1>:    mov    %rsp,%rbp<br>
>> 0xa743a4 <X86CompilationCallback+4>:    push   %rdi<br>
>> 0xa743a5 <X86CompilationCallback+5>:    push   %rsi<br>
><br>
> --<br>
> Kind Regards<br>
><br>
> Xin Tong<br>
><br>
</div></div>> _______________________________________________<br>
> LLVM Developers mailing list<br>
> <a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
><br>
><br>
</blockquote></div><br><br clear="all"><br>-- <br>Kind Regards <br><br>Xin Tong <br>