[webkit-dev] Question about JITStackFrame

Patrick East patricke at bsquare.com
Tue Jul 24 13:08:03 PDT 2012


We've been working on trying to get SH4 JIT working on another platform that uses the microsoft compiler.  As part of this effort we could really use someones help in understanding a little of the fundamentals for the JIT stackframe.  We have it partially working right now but there are still a few pieces we haven't been able to put together.  Specifically for the DEFINE_STUB_FUNCTION functions it looks like it receives the address of JITStackFrame as the parameter, but I don't know where you are supposed to setup and pass the stack frame into these DEFINE_STUB_FUNCTION functions.

Just to make sure I'm understanding how this works correctly, is my assessment below correct?
 
We have these defines:
 
#define SETUP_VA_LISTL_ARGS
 
#define STUB_ARGS_DECLARATION void** args
 
#define STUB_ARGS (args)
 
#define STUB_INIT_STACK_FRAME(stackFrame) SETUP_VA_LISTL_ARGS; JITStackFrame& stackFrame = *reinterpret_cast<JITStackFrame*>(STUB_ARGS)
 
#define STUB_SET_RETURN_ADDRESS(returnAddress) *stackFrame.returnAddressSlot() = ReturnAddressPtr(returnAddress)
 
#define STUB_RETURN_ADDRESS *stackFrame.returnAddressSlot()
 
#define DEFINE_STUB_FUNCTION(rtype, op) extern "C" rtype JITStubThunked_##op(STUB_ARGS_DECLARATION)  
 
 
Then we have a function such as this:
 
 
DEFINE_STUB_FUNCTION(void, op_end)  
{
    STUB_INIT_STACK_FRAME(stackFrame);
    DEBUGMSG(PRINT_DEBUG,(L"op_end\r\n"));
    ScopeChainNode* scopeChain = stackFrame.callFrame->scopeChain();
    ASSERT(scopeChain->refCount > 1);
    scopeChain->deref();
}
 
And if we fill in all the macros for the function we end up with something like:
 
 
void JITStubThunked_ op_end (void** args)  
{
    JITStackFrame& stackFrame = *reinterpret_cast<JITStackFrame*>(args)
    DEBUGMSG(PRINT_DEBUG,(L"op_end\r\n"));
    ScopeChainNode* scopeChain = stackFrame.callFrame->scopeChain();
    ASSERT(scopeChain->refCount > 1);
    scopeChain->deref();
}
 
So I can see from "JITStackFrame& stackFrame = *reinterpret_cast<JITStackFrame*>( args)" that the args parameter is supposed to be the address of the JITStackFrame. If my understanding is correct, there needs to be some assembly code to setup the JITStackFrame before we call this. How and where is this supposed to be handled?

Any help explaining this would be much appreciated!

Thanks,

Patrick East
patricke at bsquare,com


More information about the webkit-dev mailing list