[JAEGER] Multiple cases failed in JaegerMonkey on Solaris x86 compiled with Sun Studio 12. r=dvander

This commit is contained in:
Leon Sha 2010-08-06 11:13:32 +08:00
parent e2ce3a3d92
commit dd23db1af5
6 changed files with 61 additions and 3 deletions

View File

@ -110,6 +110,11 @@ class BaseAssembler : public JSC::MacroAssembler
Vector<CallPatch, 64, SystemAllocPolicy> callPatches; Vector<CallPatch, 64, SystemAllocPolicy> callPatches;
public: public:
#if defined(JS_NO_FASTCALL) && defined(JS_CPU_X86)
// If there is no fast call, we need to add esp by 8 after the call.
// This callLabel is to record the Label exactly after the call.
Label callLabel;
#endif
BaseAssembler() BaseAssembler()
: callPatches(SystemAllocPolicy()) : callPatches(SystemAllocPolicy())
{ {
@ -259,8 +264,9 @@ static const JSC::MacroAssembler::RegisterID JSReturnReg_Data = JSC::ARMRegister
#endif #endif
Call cl = call(pfun); Call cl = call(pfun);
#if defined(JS_NO_FASTCALL) && defined(JS_CPU_X86) #if defined(JS_NO_FASTCALL) && defined(JS_CPU_X86)
pop(); callLabel = label();
pop(); addPtr(JSC::MacroAssembler::Imm32(8),
JSC::MacroAssembler::stackPointerRegister);
#endif #endif
return cl; return cl;
} }

View File

@ -486,6 +486,16 @@ mjit::Compiler::generateMethod()
masm.move(ImmPtr(PC), Registers::ArgReg1); masm.move(ImmPtr(PC), Registers::ArgReg1);
stubCall(stubs::Trap); stubCall(stubs::Trap);
} }
#if defined(JS_NO_FASTCALL) && defined(JS_CPU_X86)
// In case of no fast call, when we change the return address,
// we need to make sure add esp by 8. For normal call, we need
// to make sure the esp is not changed.
else {
masm.subPtr(Imm32(8), Registers::StackPointer);
masm.callLabel = masm.label();
masm.addPtr(Imm32(8), Registers::StackPointer);
}
#endif
ADD_CALLSITE(false); ADD_CALLSITE(false);
/********************** /**********************
@ -1836,6 +1846,9 @@ mjit::Compiler::inlineCallHelper(uint32 argc, bool callingNew)
masm.addPtr(Imm32(sizeof(void*)), Registers::StackPointer); masm.addPtr(Imm32(sizeof(void*)), Registers::StackPointer);
#endif #endif
masm.call(Registers::ReturnReg); masm.call(Registers::ReturnReg);
#if defined(JS_NO_FASTCALL) && defined(JS_CPU_X86)
masm.callLabel = masm.label();
#endif
ADD_CALLSITE(false); ADD_CALLSITE(false);
/* /*
@ -1887,7 +1900,11 @@ mjit::Compiler::addCallSite(uint32 id, bool stub)
{ {
InternalCallSite site; InternalCallSite site;
site.stub = stub; site.stub = stub;
#if defined(JS_NO_FASTCALL) && defined(JS_CPU_X86)
site.location = stub ? stubcc.masm.callLabel : masm.callLabel;
#else
site.location = stub ? stubcc.masm.label() : masm.label(); site.location = stub ? stubcc.masm.label() : masm.label();
#endif
site.pc = PC; site.pc = PC;
site.id = id; site.id = id;
callSites.append(site); callSites.append(site);

View File

@ -860,7 +860,13 @@ mjit::Compiler::booleanJumpScript(JSOp op, jsbytecode *target)
!(fe->isType(JSVAL_TYPE_BOOLEAN) || fe->isType(JSVAL_TYPE_INT32))) { !(fe->isType(JSVAL_TYPE_BOOLEAN) || fe->isType(JSVAL_TYPE_INT32))) {
stubcc.masm.fixScriptStack(frame.frameDepth()); stubcc.masm.fixScriptStack(frame.frameDepth());
stubcc.masm.setupVMFrame(); stubcc.masm.setupVMFrame();
#if defined(JS_NO_FASTCALL) && defined(JS_CPU_X86)
stubcc.masm.push(Registers::ArgReg0);
#endif
stubcc.masm.call(JS_FUNC_TO_DATA_PTR(void *, stubs::ValueToBoolean)); stubcc.masm.call(JS_FUNC_TO_DATA_PTR(void *, stubs::ValueToBoolean));
#if defined(JS_NO_FASTCALL) && defined(JS_CPU_X86)
stubcc.masm.pop();
#endif
jmpCvtExecScript.setJump(stubcc.masm.branchTest32(cond, Registers::ReturnReg, jmpCvtExecScript.setJump(stubcc.masm.branchTest32(cond, Registers::ReturnReg,
Registers::ReturnReg)); Registers::ReturnReg));

View File

@ -284,11 +284,22 @@ ic::CallFastNative(JSContext *cx, JSScript *script, MICInfo &mic, JSFunction *fu
/* Restore stack. */ /* Restore stack. */
ncc.masm.add32(Imm32(stackAdjustment), JSC::X86Registers::esp); ncc.masm.add32(Imm32(stackAdjustment), JSC::X86Registers::esp);
#if defined(JS_NO_FASTCALL) && defined(JS_CPU_X86)
// Usually JaegerThrowpoline got called from return address.
// So in JaegerThrowpoline without fastcall, esp was added by 8.
// If we just want to jump there, we need to sub esp by 8 first.
ncc.masm.sub32(Imm32(8), JSC::X86Registers::esp);
#endif
/* Check if the call is throwing, and jump to the throwpoline. */ /* Check if the call is throwing, and jump to the throwpoline. */
Jump hasException = Jump hasException =
ncc.masm.branchTest32(Assembler::Zero, Registers::ReturnReg, Registers::ReturnReg); ncc.masm.branchTest32(Assembler::Zero, Registers::ReturnReg, Registers::ReturnReg);
ncc.addLink(hasException, JS_FUNC_TO_DATA_PTR(uint8 *, JaegerThrowpoline)); ncc.addLink(hasException, JS_FUNC_TO_DATA_PTR(uint8 *, JaegerThrowpoline));
#if defined(JS_NO_FASTCALL) && defined(JS_CPU_X86)
ncc.masm.add32(Imm32(8), JSC::X86Registers::esp);
#endif
/* Load *vp into the return register pair. */ /* Load *vp into the return register pair. */
Address rval(JSFrameReg, vpOffset); Address rval(JSFrameReg, vpOffset);
ncc.masm.loadPayload(rval, JSReturnReg_Data); ncc.masm.loadPayload(rval, JSReturnReg_Data);

View File

@ -104,6 +104,11 @@ TrampolineCompiler::compileTrampoline(void **where, JSC::ExecutablePool **pool,
bool bool
TrampolineCompiler::generateForceReturn(Assembler &masm) TrampolineCompiler::generateForceReturn(Assembler &masm)
{ {
#if defined(JS_NO_FASTCALL) && defined(JS_CPU_X86)
// In case of no fast call, when we change the return address,
// we need to make sure add esp by 8.
masm.addPtr(Imm32(8), Registers::StackPointer);
#endif
/* if (!callobj) stubs::PutCallObject */ /* if (!callobj) stubs::PutCallObject */
Jump noCallObj = masm.branchPtr(Assembler::Equal, Jump noCallObj = masm.branchPtr(Assembler::Equal,
Address(JSFrameReg, offsetof(JSStackFrame, callobj)), Address(JSFrameReg, offsetof(JSStackFrame, callobj)),

View File

@ -65,11 +65,18 @@ JaegerTrampoline:
pushl %esp pushl %esp
call SetVMFrameRegs call SetVMFrameRegs
popl %edx popl %edx
pushl %esp
call PushActiveVMFrame
popl %edx
popl %edx popl %edx
call *%edx call *%edx
leal -4(%esp), %ecx leal -4(%esp), %ecx
push %ecx push %ecx
call PopActiveVMFrame
popl %ecx
leal -4(%esp), %ecx
push %ecx
call UnsetVMFrameRegs call UnsetVMFrameRegs
popl %ecx popl %ecx
@ -104,6 +111,9 @@ JaegerThrowpoline:
je throwpoline_exit je throwpoline_exit
jmp *%eax jmp *%eax
throwpoline_exit: throwpoline_exit:
pushl %esp
call PopActiveVMFrame
popl %ebx
addl $0x2c, %esp addl $0x2c, %esp
popl %ebx popl %ebx
popl %edi popl %edi
@ -116,10 +126,13 @@ throwpoline_exit:
.global JaegerFromTracer .global JaegerFromTracer
.type JaegerFromTracer, @function .type JaegerFromTracer, @function
JaegerFromTracer: JaegerFromTracer:
movl 0x24(%ebx), %edx
movl 0x28(%ebx), %ecx
movl 0x38(%ebx), %eax
/* For Sun Studio there is no fast call. */ /* For Sun Studio there is no fast call. */
/* We add the stack by 8 before. */ /* We add the stack by 8 before. */
addl $0x8, %esp addl $0x8, %esp
/* Restore frame regs. */ /* Restore frame regs. */
movl 0x20(%esp), %ebx movl 0x20(%esp), %ebx
jmp *%eax ret
.size JaegerFromTracer, . - JaegerFromTracer .size JaegerFromTracer, . - JaegerFromTracer