want to port JIT to MIPS - stack/code segment

http://marc.info/?l=webkit-dev&m=123572053829137&w=2

want to port JIT to MIPS - stack/code segment


in ARM, we have a rule set called EABI (Embedded Application Binary
Interface). It says the stack must always be word aligned, and must be 2
words (8 bytes) aligned if you call other functions. The WebKit
interpreter callbacks returns either a single pointer (sometimes an int
contains a boolean value) or double pointers. These return values can be
passed through registers, no need to pre-allocate stack space for them.
The functions generated by g++ are also EABI compilant, so we don't need
worry about the stack at all.

I think AssemblerBuffer is only temporary hold the generated machine
instructions. When the compilation phase is done, you need to call
AssemblerBuffer::executableCopy, which allocates a new executable memory
space and that space is aligned by ExecutableAllocator.

Cheers,
Zoltan

> Zoltan,
> thanks a lot! yeah the issue is just JIT related.
> Do I need to take care of stack in JIT code, say before emit asm call I
> align the stack? I guess no need because Mips always aligned to 32bits,
> and the only double functions in webkit return result in registers not
> memory.
> For AssemblerBuffer.h I think it is different because the initial 256bytes
> buffer may be not aligned to 32bit. I'll add __attribute__ ((aligned (4)))
> or 8.
> rgds
> joe


I am not sure I understand your questions. The code blocks are allocated
by mmap() or VirtualAlloc(), thus they are aligned to 4K. Smaller chunks
are aligned by roundUpAllocationSize() function. Now the alignemt is
sizeof(void*) in both x86 and ARM. See ExecutableAllocator.h

The current jit implementations don't store temporary variables on the
stack, they allocate a fixed size buffer after the entry, and only free
that when you leave the jit. This approach is much easier than keep
tracking of the stack.

Cheers,
Zoltan

> gcc handles it well for X86. now on Mips I need to do followings right?
> 1. make sure (re)allocated code buffer aligned to 64bits and gcc malloc()
> only guarantee 32bits
> 2. before any call instruction in JIT code, make sure stack is aligned to
> 64bit also.
> PPC no JIT thus no problem right?
> rgds
> joe

你可能感兴趣的:(want to port JIT to MIPS - stack/code segment)