recVtlb: separate dispatcher generation into a dedicated function

This commit is contained in:
Gregory Hainaut 2016-01-20 09:23:32 +01:00
parent 8a9a56707c
commit d78f887d1c
1 changed files with 34 additions and 27 deletions

View File

@ -285,29 +285,10 @@ static void DynGen_IndirectDispatch( int mode, int bits, bool sign = false )
xJS( GetIndirectDispatcherPtr( mode, szidx, sign ) ); xJS( GetIndirectDispatcherPtr( mode, szidx, sign ) );
} }
// One-time initialization procedure. Multiple subsequent calls during the lifespan of the // ------------------------------------------------------------------------
// process will be ignored. // Generates the various instances of the indirect dispatchers
// static void DynGen_IndirectTlbDispatcher( int mode, int bits, bool sign )
void vtlb_dynarec_init()
{ {
static bool hasBeenCalled = false;
if (hasBeenCalled) return;
hasBeenCalled = true;
// In case init gets called multiple times:
HostSys::MemProtectStatic( m_IndirectDispatchers, PageAccess_ReadWrite() );
// clear the buffer to 0xcc (easier debugging).
memset_8<0xcc,0x1000>( m_IndirectDispatchers );
for( int mode=0; mode<2; ++mode )
{
for( int bits=0; bits<5; ++bits )
{
for (int sign = 0; sign < (!mode && bits < 2 ? 2 : 1); sign++)
{
xSetPtr( GetIndirectDispatcherPtr( mode, bits, !!sign ) );
xMOVZX( eax, al ); xMOVZX( eax, al );
xSUB( ecx, 0x80000000 ); xSUB( ecx, 0x80000000 );
xSUB( ecx, eax ); xSUB( ecx, eax );
@ -336,6 +317,32 @@ void vtlb_dynarec_init()
xJMP( ebx ); xJMP( ebx );
} }
// One-time initialization procedure. Multiple subsequent calls during the lifespan of the
// process will be ignored.
//
void vtlb_dynarec_init()
{
static bool hasBeenCalled = false;
if (hasBeenCalled) return;
hasBeenCalled = true;
// In case init gets called multiple times:
HostSys::MemProtectStatic( m_IndirectDispatchers, PageAccess_ReadWrite() );
// clear the buffer to 0xcc (easier debugging).
memset_8<0xcc,0x1000>( m_IndirectDispatchers );
for( int mode=0; mode<2; ++mode )
{
for( int bits=0; bits<5; ++bits )
{
for (int sign = 0; sign < (!mode && bits < 2 ? 2 : 1); sign++)
{
xSetPtr( GetIndirectDispatcherPtr( mode, bits, !!sign ) );
DynGen_IndirectTlbDispatcher( mode, bits, sign );
}
} }
} }