[Mono-devel-list] Question about x86 version of mono_create_trampoline .

zalman at peachfish.com zalman at peachfish.com
Mon Oct 20 00:29:34 EDT 2003


Hi,

I am working on porting Mono to AMD64. (As in long-mode, with 64-bit
address space and new caling convention, more registers, etc.) I noticed
the following code in mono_create_trampoline and am wondering why it is
there:

        /*
         * and align to 16 byte boundary...
         */
        stack_size += 15;
        stack_size &= ~15;

->        if (stack_size)
->                x86_alu_reg_imm (p, X86_SUB, X86_ESP, stack_size);

(At or near line 131 of mono/mono/arch/x86/tramp.c , alignment statements
given for context.)

It looks like the code is trying to allocate space for the incoming
arguments so they can be stored into place. But the code below uses push
instructions, or explicitly decrements the stack for floating point
arguments.

Mostly wondering if I'm missing something here, though perhaps there is a
tiny optimization to use less stack for pinvoked calls.

Another issue with this is that the 16-byte alignment is not guaranteed by
the current code if I understand it correctly. (I'm not sure if plain x86
requires that strict a stack frame alignment. AMD64 *does*.)

Thank you,
-Z-





More information about the Mono-devel-list mailing list