[Mono-dev] Where is trampoline x86 pseudo code documented?

Kornél Pál kornelpal at gmail.com
Sat Mar 6 07:05:56 EST 2010


Hi,

I wouldn't say that this is pseudo-code. This is more like using a code 
generator like using System.Reflection.Emit.ILGenerator for managed code.

Most of these instruction emitters are just preprocessor macros located 
in mono/arch/x86/x86-codegen.h.

I believe that the names are quite intuitive but if you need to know the 
exact instructions used just have a look at the above header file.

Kornél

cpMon wrote:
> Is there a document that describes the x86 pseudo code your JIT engine uses.
> For example, it would be a lot easier for me to find bugs for you if I
> didn't have to reverse-engineer things such as:
> 
> Thanks,
> Cal Page
> 
> 
>         if ( 0 && mono_thread_get_tls_offset () != -1) {
>                 /* MonoObject* obj is in EAX */
>                 /* is obj null? */
>                 x86_test_reg_reg (buf, X86_EAX, X86_EAX);
>                 /* if yes, jump to actual trampoline */
>                 jump_obj_null = buf;
>                 x86_branch8 (buf, X86_CC_Z, -1, 1);
> 
>                 /* load obj->synchronization to ECX */
>                 x86_mov_reg_membase (buf, X86_ECX, X86_EAX, G_STRUCT_OFFSET
> (MonoObject, synchronisation), 4);
>                 /* is synchronization null? */
>                 x86_test_reg_reg (buf, X86_ECX, X86_ECX);
>                 /* if not, jump to next case */
>                 jump_next = buf;
>                 x86_branch8 (buf, X86_CC_NZ, -1, 1);
>                 /* if yes, just return */
>                 x86_ret (buf);
> 
>                 /* next case: synchronization is not null */
>                 x86_patch (jump_next, buf);
>                 /* load MonoThread* into EDX */
>                 buf = mono_x86_emit_tls_get (buf, X86_EDX,
> mono_thread_get_tls_offset ());
>                 /* load TID into EDX */
>                 x86_mov_reg_membase (buf, X86_EDX, X86_EDX, G_STRUCT_OFFSET
> (MonoThread, tid), 4);
>                 /* is synchronization->owner == TID */
>                 x86_alu_membase_reg (buf, X86_CMP, X86_ECX, owner_offset,
> X86_EDX);
>                 /* if yes, jump to next case */
>                 jump_next = buf;
>                 x86_branch8 (buf, X86_CC_Z, -1, 1);
>                 /* if not, just return */
>                 x86_ret (buf);
> 
>                 /* next case: synchronization->owner == TID */
>                                                                                                                         
> 759,2-16      92%
> 


More information about the Mono-devel-list mailing list