aligned_stack: no real progress... just reached a point where I need to move dev over to my windows so I can have real debugging/disasm/memory dumping ability. (this is the most horrible job I've ever undertaken, btw)

git-svn-id: http://pcsx2.googlecode.com/svn/branches/aligned_stack@2034 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
Jake.Stine 2009-10-18 19:26:07 +00:00
parent b1fb7f80ae
commit 047726a60c
3 changed files with 48 additions and 41 deletions

View File

@ -1,6 +1,6 @@
/* PCSX2 - PS2 Emulator for PCs /* PCSX2 - PS2 Emulator for PCs
* Copyright (C) 2002-2009 PCSX2 Dev Team * Copyright (C) 2002-2009 PCSX2 Dev Team
* *
* PCSX2 is free software: you can redistribute it and/or modify it under the terms * PCSX2 is free software: you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Found- * of the GNU Lesser General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version. * ation, either version 3 of the License, or (at your option) any later version.
@ -188,6 +188,7 @@ namespace x86Emitter
// ----- Miscellaneous Instructions ----- // ----- Miscellaneous Instructions -----
// Various Instructions with no parameter and no special encoding logic. // Various Instructions with no parameter and no special encoding logic.
extern void xLEAVE();
extern void xRET(); extern void xRET();
extern void xCBW(); extern void xCBW();
extern void xCWD(); extern void xCWD();
@ -244,7 +245,7 @@ namespace x86Emitter
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
// Forward Jump Helpers (act as labels!) // Forward Jump Helpers (act as labels!)
#define DEFINE_FORWARD_JUMP( label, cond ) \ #define DEFINE_FORWARD_JUMP( label, cond ) \
template< typename OperandType > \ template< typename OperandType > \
class xForward##label : public xForwardJump<OperandType> \ class xForward##label : public xForwardJump<OperandType> \
@ -328,7 +329,7 @@ namespace x86Emitter
DEFINE_FORWARD_JUMP( JPE, Jcc_ParityEven ); DEFINE_FORWARD_JUMP( JPE, Jcc_ParityEven );
DEFINE_FORWARD_JUMP( JPO, Jcc_ParityOdd ); DEFINE_FORWARD_JUMP( JPO, Jcc_ParityOdd );
typedef xForwardJPE<s8> xForwardJPE8; typedef xForwardJPE<s8> xForwardJPE8;
typedef xForwardJPE<s32> xForwardJPE32; typedef xForwardJPE<s32> xForwardJPE32;
typedef xForwardJPO<s8> xForwardJPO8; typedef xForwardJPO<s8> xForwardJPO8;
@ -362,7 +363,7 @@ namespace x86Emitter
extern void xMOVQZX( const xRegisterSSE& to, const ModSibBase& src ); extern void xMOVQZX( const xRegisterSSE& to, const ModSibBase& src );
extern void xMOVQZX( const xRegisterSSE& to, const xRegisterSSE& from ); extern void xMOVQZX( const xRegisterSSE& to, const xRegisterSSE& from );
extern void xMOVSS( const xRegisterSSE& to, const xRegisterSSE& from ); extern void xMOVSS( const xRegisterSSE& to, const xRegisterSSE& from );
extern void xMOVSS( const ModSibBase& to, const xRegisterSSE& from ); extern void xMOVSS( const ModSibBase& to, const xRegisterSSE& from );
extern void xMOVSD( const xRegisterSSE& to, const xRegisterSSE& from ); extern void xMOVSD( const xRegisterSSE& to, const xRegisterSSE& from );
@ -421,12 +422,12 @@ namespace x86Emitter
extern void xEXTRACTPS( const ModSibStrict<u32>& dest, const xRegisterSSE& from, u8 imm8 ); extern void xEXTRACTPS( const ModSibStrict<u32>& dest, const xRegisterSSE& from, u8 imm8 );
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
extern const Internal::SimdImpl_DestRegEither<0x66,0xdb> xPAND; extern const Internal::SimdImpl_DestRegEither<0x66,0xdb> xPAND;
extern const Internal::SimdImpl_DestRegEither<0x66,0xdf> xPANDN; extern const Internal::SimdImpl_DestRegEither<0x66,0xdf> xPANDN;
extern const Internal::SimdImpl_DestRegEither<0x66,0xeb> xPOR; extern const Internal::SimdImpl_DestRegEither<0x66,0xeb> xPOR;
extern const Internal::SimdImpl_DestRegEither<0x66,0xef> xPXOR; extern const Internal::SimdImpl_DestRegEither<0x66,0xef> xPXOR;
extern const Internal::SimdImpl_AndNot xANDN; extern const Internal::SimdImpl_AndNot xANDN;
extern const Internal::SimdImpl_COMI<true> xCOMI; extern const Internal::SimdImpl_COMI<true> xCOMI;
@ -434,7 +435,7 @@ namespace x86Emitter
extern const Internal::SimdImpl_rSqrt<0x53> xRCP; extern const Internal::SimdImpl_rSqrt<0x53> xRCP;
extern const Internal::SimdImpl_rSqrt<0x52> xRSQRT; extern const Internal::SimdImpl_rSqrt<0x52> xRSQRT;
extern const Internal::SimdImpl_Sqrt<0x51> xSQRT; extern const Internal::SimdImpl_Sqrt<0x51> xSQRT;
extern const Internal::SimdImpl_MinMax<0x5f> xMAX; extern const Internal::SimdImpl_MinMax<0x5f> xMAX;
extern const Internal::SimdImpl_MinMax<0x5d> xMIN; extern const Internal::SimdImpl_MinMax<0x5d> xMIN;
extern const Internal::SimdImpl_Shuffle<0xc6> xSHUF; extern const Internal::SimdImpl_Shuffle<0xc6> xSHUF;
@ -442,7 +443,7 @@ namespace x86Emitter
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
extern const Internal::SimdImpl_DestRegSSE<0x66,0x1738> xPTEST; extern const Internal::SimdImpl_DestRegSSE<0x66,0x1738> xPTEST;
extern const Internal::SimdImpl_Compare<SSE2_Equal> xCMPEQ; extern const Internal::SimdImpl_Compare<SSE2_Equal> xCMPEQ;
extern const Internal::SimdImpl_Compare<SSE2_Less> xCMPLT; extern const Internal::SimdImpl_Compare<SSE2_Less> xCMPLT;
extern const Internal::SimdImpl_Compare<SSE2_LessOrEqual> xCMPLE; extern const Internal::SimdImpl_Compare<SSE2_LessOrEqual> xCMPLE;
@ -484,9 +485,9 @@ namespace x86Emitter
extern const Internal::SimdImpl_DestRegStrict<0xf2,0x2c,xRegister32, xRegisterSSE,u64> xCVTTSD2SI; extern const Internal::SimdImpl_DestRegStrict<0xf2,0x2c,xRegister32, xRegisterSSE,u64> xCVTTSD2SI;
extern const Internal::SimdImpl_DestRegStrict<0xf3,0x2c,xRegister32, xRegisterSSE,u32> xCVTTSS2SI; extern const Internal::SimdImpl_DestRegStrict<0xf3,0x2c,xRegister32, xRegisterSSE,u32> xCVTTSS2SI;
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
extern const Internal::SimdImpl_Shift<0xf0, 6> xPSLL; extern const Internal::SimdImpl_Shift<0xf0, 6> xPSLL;
extern const Internal::SimdImpl_Shift<0xd0, 2> xPSRL; extern const Internal::SimdImpl_Shift<0xd0, 2> xPSRL;
extern const Internal::SimdImpl_ShiftWithoutQ<0xe0, 4> xPSRA; extern const Internal::SimdImpl_ShiftWithoutQ<0xe0, 4> xPSRA;
@ -502,7 +503,7 @@ namespace x86Emitter
extern const Internal::SimdImpl_PUnpack xPUNPCK; extern const Internal::SimdImpl_PUnpack xPUNPCK;
extern const Internal::SimdImpl_Unpack xUNPCK; extern const Internal::SimdImpl_Unpack xUNPCK;
extern const Internal::SimdImpl_Pack xPACK; extern const Internal::SimdImpl_Pack xPACK;
extern const Internal::SimdImpl_PAbsolute xPABS; extern const Internal::SimdImpl_PAbsolute xPABS;
extern const Internal::SimdImpl_PSign xPSIGN; extern const Internal::SimdImpl_PSign xPSIGN;
extern const Internal::SimdImpl_PInsert xPINSR; extern const Internal::SimdImpl_PInsert xPINSR;
@ -513,7 +514,7 @@ namespace x86Emitter
extern const Internal::SimdImpl_Blend xBLEND; extern const Internal::SimdImpl_Blend xBLEND;
extern const Internal::SimdImpl_DotProduct xDP; extern const Internal::SimdImpl_DotProduct xDP;
extern const Internal::SimdImpl_Round xROUND; extern const Internal::SimdImpl_Round xROUND;
extern const Internal::SimdImpl_PMove<true> xPMOVSX; extern const Internal::SimdImpl_PMove<true> xPMOVSX;
extern const Internal::SimdImpl_PMove<false> xPMOVZX; extern const Internal::SimdImpl_PMove<false> xPMOVZX;

View File

@ -729,6 +729,7 @@ __forceinline void xPOPFD() { xWrite8( 0x9D ); }
////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////
// //
__forceinline void xLEAVE() { xWrite8( 0xC9 ); }
__forceinline void xRET() { xWrite8( 0xC3 ); } __forceinline void xRET() { xWrite8( 0xC3 ); }
__forceinline void xCBW() { xWrite16( 0x9866 ); } __forceinline void xCBW() { xWrite16( 0x9866 ); }
__forceinline void xCWD() { xWrite8( 0x98 ); } __forceinline void xCWD() { xWrite8( 0x98 ); }

View File

@ -328,6 +328,7 @@ static DynGenFunc* DispatcherReg = NULL;
static DynGenFunc* JITCompile = NULL; static DynGenFunc* JITCompile = NULL;
static DynGenFunc* JITCompileInBlock = NULL; static DynGenFunc* JITCompileInBlock = NULL;
static DynGenFunc* EnterRecompiledCode = NULL; static DynGenFunc* EnterRecompiledCode = NULL;
static DynGenFunc* ExitRecompiledCode = NULL;
// parameters: // parameters:
// espORebp - 0 for ESP, or 1 for EBP. // espORebp - 0 for ESP, or 1 for EBP.
@ -427,41 +428,45 @@ static DynGenFunc* _DynGen_EnterRecompiledCode()
// use for supplying parameters to cdecl functions. // use for supplying parameters to cdecl functions.
xPUSH( ebp ); xPUSH( ebp );
xPUSH( edi );
xPUSH( esi );
xPUSH( ebx );
xMOV( ebp, esp ); xMOV( ebp, esp );
xAND( esp, -0x10 ); xAND( esp, -0x10 );
xSUB( esp, 0x10 );
xMOV( &s_store_ebp, ebp ); // First 0x10 is for esi, edi, etc. Second 0x10 is for the return address and ebp. The
// third second 0x10 is for C-style CDECL calls we might make from the recompiler
// (parameters for those calls can be stored there!)
xSUB( esp, 0x30 );
xMOV( ptr[ebp-12], edi );
xMOV( ptr[ebp-8], esi );
xMOV( ptr[ebp-4], ebx );
// Simulate a CALL function by pushing the call address and EBP onto the stack.
xMOV( ptr32[esp+0x10+12], 0xffeeff );
uptr& imm = *(uptr*)(xGetPtr()-4);
xMOV( ptr32[esp+0x10+8], ebp );
xMOV( &s_store_esp, esp ); xMOV( &s_store_esp, esp );
xSUB( ptr32[&s_store_esp], 4 ); // account for the address pushed when we xCALL xMOV( &s_store_ebp, ebp );
//xPUSH( edi ); xJMP( ptr32[&DispatcherReg] );
//xPUSH( esi ); imm = (uptr)xGetPtr();
//xPUSH( ebx ); ExitRecompiledCode = (DynGenFunc*)xGetPtr();
xCALL( ptr32[&DispatcherReg] ); xLEAVE();
//xMOV( esp, ebp );
//xPOP( ebp );
//xPOP( ebx ); //_DynGen_StackFrameCheck();
//xPOP( esi );
//xPOP( edi ); xMOV( edi, ptr[ebp-12] );
xMOV( esi, ptr[ebp-8] );
xMOV( ebx, ptr[ebp-4] );
//xMOV( esp, ebp ); //xMOV( esp, ebp );
//xPOP( ebp ); //xPOP( ebp );
//xRET(); xLEAVE();
xADD( ptr32[&s_store_esp], 4 ); // account for the address pushed when we xCALL
_DynGen_StackFrameCheck();
xMOV( esp, ebp );
xPOP( ebx );
xPOP( esi );
xPOP( edi );
xPOP( ebp );
xRET(); xRET();
return (DynGenFunc*)retval; return (DynGenFunc*)retval;
@ -808,18 +813,16 @@ void recClear(u32 addr, u32 size)
upperextent = min(upperextent, ceiling); upperextent = min(upperextent, ceiling);
#ifdef PCSX2_DEVBUILD
for (int i = 0; pexblock = recBlocks[i]; i++) { for (int i = 0; pexblock = recBlocks[i]; i++) {
if (s_pCurBlock == PC_GETBLOCK(pexblock->startpc)) if (s_pCurBlock == PC_GETBLOCK(pexblock->startpc))
continue; continue;
u32 blockend = pexblock->startpc + pexblock->size * 4; u32 blockend = pexblock->startpc + pexblock->size * 4;
if (pexblock->startpc >= addr && pexblock->startpc < addr + size * 4 if (pexblock->startpc >= addr && pexblock->startpc < addr + size * 4
|| pexblock->startpc < addr && blockend > addr) { || pexblock->startpc < addr && blockend > addr) {
Console.Error( "Impossible block clearing failure" ); DevCon.Error( "Impossible block clearing failure" );
pxFail( "Impossible block clearing failure" ); pxFailDev( "Impossible block clearing failure" );
} }
} }
#endif
if (upperextent > lowerextent) if (upperextent > lowerextent)
ClearRecLUT(PC_GETBLOCK(lowerextent), (upperextent - lowerextent) / 4); ClearRecLUT(PC_GETBLOCK(lowerextent), (upperextent - lowerextent) / 4);
@ -1284,6 +1287,8 @@ void __fastcall dyna_page_reset(u32 start,u32 sz)
// Note: this function is accessed via a JMP, and thus the RET here will exit // Note: this function is accessed via a JMP, and thus the RET here will exit
// recompiled code and take us back to recExecute. // recompiled code and take us back to recExecute.
__asm__ __volatile__( "leave\n jmp %[exitRec]\n" : : [exitRec] "m" (ExitRecompiledCode) : );
} }
void recRecompile( const u32 startpc ) void recRecompile( const u32 startpc )