want to port JIT to MIPS

want to port JIT to MIPS

> I'd appreaciate your help to clarify the problem I faced:
>
> 1.In JIT.cpp I roughly understand ctiTrampoline() except for  
> sp-0x1C, I guess the 1C includes 6 argument yet the 7th or 1st may  
> be the hidden C++ pointer? And the reserved 1C stack space seems not  
> used? why esi is forced to be 512 rather than use input argument?

The JIT allocates a fixed frame on the stack which is used to pass  
arguments into stub functions.  The 0x1C contains a spare word or two  
to maintain stack alignment.  %esi is used in the timeout check  
mechanism.

> 2.How to understand the stack balance in ctiVMThrowTrampoline()? why  
> after calling we still add 1C w/o sub 1C before calling? where comes  
> _ZN3JSC11Interpreter12cti_vm_throwEPPv and how do I know which name  
> for Mips? does this one relates to variable argument function call?

ctiVMThrowTrampoline is never called as a function (it is declared as  
a function only to provide a symbol that can be manipulated from C  
code).  ctiVMThrowTrampoline is used in returning back from JIT  
generated code, in the case of an exception.

> 3.I know how to handle jump in Mips, but not sure how/when to handle  
> patchAddress/patchImm/patchPointer because I'm not sure the  
> instructions related. I guess all patches are for last 32bit IMM  
> field of instructions.
> Mips can't load 32bit in one instruction, thus I need to know the  
> instruction before I can patch/add in the 32bit data.
>
> 4.I'm kind of want no asm code outside <assembler> folder, any plan  
> for that?

No.  The assembler is intended to be independent of JavaScript types -  
it's just an assembler.  The asm trampolines are specific to the JIT.   
It is currently the intention that architecture specific parts of the  
JIT implementation will remain in the jit folder.

I'd suggest that in attempting to port the jit, WREC would be a good  
place to start.



Thanks a lot otherwise I have misunderstanding. Yes I'll do wrec first. I just want to clean up possible blocking issues.

I see wrec uses regparm(3) and jit always use fastcall for X86?
In JIT.cpp ctiTrampoline put CallFrame in edi, but how about other arguments - where are they be fetched/poped from stack? 

when deal with caller/callee saved regs, gcc MIPS just preserves them when necesasary. The problem is after JIT used gcc may not have enough knowledge on "necessary", do we have a way to force gcc always preserve 
them? 

how to identify a patch (patchimm/patchptr/patchaddr) relates to a data field in an instruction or relates to an element in a data array? In Mips the former means the 32bit needs to be separated into two 16bits and patched into two instructions. But if a 32bit is a pointer in a pointer array, we can save it directly.


你可能感兴趣的:(want to port JIT to MIPS)