Merge mips and arm/sh4 paths in nativeForGenerator and privateCompileCTINativeCall functions.

https://bugs.webkit.org/show_bug.cgi?id=125067

Patch by Julien Brianceau <jbriance@cisco.com> on 2013-12-03
Reviewed by Michael Saboff.

* jit/JITOpcodes32_64.cpp:
(JSC::JIT::privateCompileCTINativeCall):
* jit/ThunkGenerators.cpp:
(JSC::nativeForGenerator):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@159995 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 1be1dbcf
2013-12-03 Julien Brianceau <jbriance@cisco.com>
Merge mips and arm/sh4 paths in nativeForGenerator and privateCompileCTINativeCall functions.
https://bugs.webkit.org/show_bug.cgi?id=125067
Reviewed by Michael Saboff.
* jit/JITOpcodes32_64.cpp:
(JSC::JIT::privateCompileCTINativeCall):
* jit/ThunkGenerators.cpp:
(JSC::nativeForGenerator):
2013-12-02 Mark Lam <mark.lam@apple.com>
Build failure when disabling JIT, YARR_JIT, and ASSEMBLER.
......
......@@ -74,7 +74,7 @@ JIT::CodeRef JIT::privateCompileCTINativeCall(VM* vm, NativeFunction func)
addPtr(TrustedImm32(16 - sizeof(void*)), stackPointerRegister);
#elif CPU(ARM) || CPU(SH4)
#elif CPU(ARM) || CPU(SH4) || CPU(MIPS)
// Load caller frame's scope chain into this callframe so that whatever we call can get to its global data.
emitGetCallerFrameFromCallFrameHeaderPtr(regT2);
emitGetFromCallFrameHeaderPtr(JSStack::ScopeChain, regT1, regT2);
......@@ -83,6 +83,11 @@ JIT::CodeRef JIT::privateCompileCTINativeCall(VM* vm, NativeFunction func)
preserveReturnAddressAfterCall(regT3); // Callee preserved
emitPutReturnPCToCallFrameHeader(regT3);
#if CPU(MIPS)
// Allocate stack space for (unused) 16 bytes (8-byte aligned) for 4 arguments.
subPtr(TrustedImm32(16), stackPointerRegister);
#endif
// Calling convention is f(argumentGPR0, argumentGPR1, ...).
// Host function signature is f(ExecState*).
move(callFrameRegister, argumentGPR0);
......@@ -94,37 +99,10 @@ JIT::CodeRef JIT::privateCompileCTINativeCall(VM* vm, NativeFunction func)
// call the function
nativeCall = call();
restoreReturnAddressBeforeReturn(regT3);
#elif CPU(MIPS)
// Load caller frame's scope chain into this callframe so that whatever we call can
// get to its global data.
emitGetCallerFrameFromCallFrameHeaderPtr(regT0);
emitGetFromCallFrameHeaderPtr(JSStack::ScopeChain, regT1, regT0);
emitPutCellToCallFrameHeader(regT1, JSStack::ScopeChain);
preserveReturnAddressAfterCall(regT3); // Callee preserved
emitPutReturnPCToCallFrameHeader(regT3);
// Calling convention: f(a0, a1, a2, a3);
// Host function signature: f(ExecState*);
// Allocate stack space for 16 bytes (8-byte aligned)
// 16 bytes (unused) for 4 arguments
subPtr(TrustedImm32(16), stackPointerRegister);
// Setup arg0
move(callFrameRegister, MIPSRegisters::a0);
// Call
emitGetFromCallFrameHeaderPtr(JSStack::Callee, MIPSRegisters::a2);
loadPtr(Address(MIPSRegisters::a2, OBJECT_OFFSETOF(JSFunction, m_executable)), regT2);
move(regT0, callFrameRegister); // Eagerly restore caller frame register to avoid loading from stack.
// call the function
nativeCall = call();
#if CPU(MIPS)
// Restore stack space
addPtr(TrustedImm32(16), stackPointerRegister);
#endif
restoreReturnAddressBeforeReturn(regT3);
#else
......
......@@ -343,7 +343,7 @@ static MacroAssemblerCodeRef nativeForGenerator(VM* vm, CodeSpecializationKind k
jit.restoreReturnAddressBeforeReturn(JSInterfaceJIT::regT3);
#elif CPU(ARM) || CPU(SH4)
#elif CPU(ARM) || CPU(SH4) || CPU(MIPS)
// Load caller frame's scope chain into this callframe so that whatever we call can get to its global data.
jit.emitGetCallerFrameFromCallFrameHeaderPtr(JSInterfaceJIT::regT2);
jit.emitGetFromCallFrameHeaderPtr(JSStack::ScopeChain, JSInterfaceJIT::regT1, JSInterfaceJIT::regT2);
......@@ -352,6 +352,11 @@ static MacroAssemblerCodeRef nativeForGenerator(VM* vm, CodeSpecializationKind k
jit.preserveReturnAddressAfterCall(JSInterfaceJIT::regT3); // Callee preserved
jit.emitPutReturnPCToCallFrameHeader(JSInterfaceJIT::regT3);
#if CPU(MIPS)
// Allocate stack space for (unused) 16 bytes (8-byte aligned) for 4 arguments.
jit.subPtr(JSInterfaceJIT::TrustedImm32(16), JSInterfaceJIT::stackPointerRegister);
#endif
// Calling convention is f(argumentGPR0, argumentGPR1, ...).
// Host function signature is f(ExecState*).
jit.move(JSInterfaceJIT::callFrameRegister, JSInterfaceJIT::argumentGPR0);
......@@ -361,35 +366,10 @@ static MacroAssemblerCodeRef nativeForGenerator(VM* vm, CodeSpecializationKind k
jit.loadPtr(JSInterfaceJIT::Address(JSInterfaceJIT::argumentGPR1, JSFunction::offsetOfExecutable()), JSInterfaceJIT::regT2);
jit.call(JSInterfaceJIT::Address(JSInterfaceJIT::regT2, executableOffsetToFunction));
jit.restoreReturnAddressBeforeReturn(JSInterfaceJIT::regT3);
#elif CPU(MIPS)
// Load caller frame's scope chain into this callframe so that whatever we call can
// get to its global data.
jit.emitGetCallerFrameFromCallFrameHeaderPtr(JSInterfaceJIT::regT0);
jit.emitGetFromCallFrameHeaderPtr(JSStack::ScopeChain, JSInterfaceJIT::regT1, JSInterfaceJIT::regT0);
jit.emitPutCellToCallFrameHeader(JSInterfaceJIT::regT1, JSStack::ScopeChain);
jit.preserveReturnAddressAfterCall(JSInterfaceJIT::regT3); // Callee preserved
jit.emitPutReturnPCToCallFrameHeader(JSInterfaceJIT::regT3);
// Calling convention: f(a0, a1, a2, a3);
// Host function signature: f(ExecState*);
// Allocate stack space for 16 bytes (8-byte aligned)
// 16 bytes (unused) for 4 arguments
jit.subPtr(JSInterfaceJIT::TrustedImm32(16), JSInterfaceJIT::stackPointerRegister);
// Setup arg0
jit.move(JSInterfaceJIT::callFrameRegister, MIPSRegisters::a0);
// Call
jit.emitGetFromCallFrameHeaderPtr(JSStack::Callee, MIPSRegisters::a2);
jit.loadPtr(JSInterfaceJIT::Address(MIPSRegisters::a2, JSFunction::offsetOfExecutable()), JSInterfaceJIT::regT2);
jit.move(JSInterfaceJIT::regT0, JSInterfaceJIT::callFrameRegister); // Eagerly restore caller frame register to avoid loading from stack.
jit.call(JSInterfaceJIT::Address(JSInterfaceJIT::regT2, executableOffsetToFunction));
#if CPU(MIPS)
// Restore stack space
jit.addPtr(JSInterfaceJIT::TrustedImm32(16), JSInterfaceJIT::stackPointerRegister);
#endif
jit.restoreReturnAddressBeforeReturn(JSInterfaceJIT::regT3);
#else
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment