Move MaxFetch calculation into fetchdecode - simplify the logic
This commit is contained in:
parent
0e5859302b
commit
c3c9c40674
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: cpu.cc,v 1.192 2007-12-22 12:43:17 sshwarts Exp $
|
||||
// $Id: cpu.cc,v 1.193 2007-12-22 17:17:40 sshwarts Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2001 MandrakeSoft S.A.
|
||||
@ -126,8 +126,6 @@ bxICacheEntry_c* BX_CPU_C::fetchInstructionTrace(bxInstruction_c *iStorage, bx_a
|
||||
InstrICache_Increment(iCacheMisses);
|
||||
|
||||
unsigned remainingInPage = (unsigned)(BX_CPU_THIS_PTR eipPageWindowSize - eipBiased);
|
||||
unsigned maxFetch = 15;
|
||||
if (remainingInPage < 15) maxFetch = remainingInPage;
|
||||
Bit8u *fetchPtr = BX_CPU_THIS_PTR eipFetchPtr + eipBiased;
|
||||
unsigned ret;
|
||||
|
||||
@ -142,10 +140,10 @@ bxICacheEntry_c* BX_CPU_C::fetchInstructionTrace(bxInstruction_c *iStorage, bx_a
|
||||
{
|
||||
#if BX_SUPPORT_X86_64
|
||||
if (BX_CPU_THIS_PTR cpu_mode == BX_MODE_LONG_64)
|
||||
ret = fetchDecode64(fetchPtr, i, maxFetch);
|
||||
ret = fetchDecode64(fetchPtr, i, remainingInPage);
|
||||
else
|
||||
#endif
|
||||
ret = fetchDecode32(fetchPtr, i, maxFetch);
|
||||
ret = fetchDecode32(fetchPtr, i, remainingInPage);
|
||||
|
||||
if (ret==0) {
|
||||
// Fetching instruction on segment/page boundary
|
||||
@ -168,10 +166,7 @@ bxICacheEntry_c* BX_CPU_C::fetchInstructionTrace(bxInstruction_c *iStorage, bx_a
|
||||
|
||||
// ... and continue to the next instruction
|
||||
remainingInPage -= iLen;
|
||||
if (remainingInPage < 15) {
|
||||
if (remainingInPage == 0) break;
|
||||
maxFetch = remainingInPage;
|
||||
}
|
||||
if (remainingInPage == 0) break;
|
||||
pAddr += iLen;
|
||||
fetchPtr += iLen;
|
||||
|
||||
@ -276,8 +271,6 @@ bxInstruction_c* BX_CPU_C::fetchInstruction(bxInstruction_c *iStorage, bx_addres
|
||||
// is in the iCache. Or we're not compiling iCache support in, in which
|
||||
// case we always have an iCache miss. :^)
|
||||
unsigned remainingInPage = (unsigned)(BX_CPU_THIS_PTR eipPageWindowSize - eipBiased);
|
||||
unsigned maxFetch = 15;
|
||||
if (remainingInPage < 15) maxFetch = remainingInPage;
|
||||
Bit8u *fetchPtr = BX_CPU_THIS_PTR eipFetchPtr + eipBiased;
|
||||
|
||||
#if BX_SUPPORT_ICACHE
|
||||
@ -288,10 +281,10 @@ bxInstruction_c* BX_CPU_C::fetchInstruction(bxInstruction_c *iStorage, bx_addres
|
||||
|
||||
#if BX_SUPPORT_X86_64
|
||||
if (BX_CPU_THIS_PTR cpu_mode == BX_MODE_LONG_64)
|
||||
ret = fetchDecode64(fetchPtr, i, maxFetch);
|
||||
ret = fetchDecode64(fetchPtr, i, remainingInPage);
|
||||
else
|
||||
#endif
|
||||
ret = fetchDecode32(fetchPtr, i, maxFetch);
|
||||
ret = fetchDecode32(fetchPtr, i, remainingInPage);
|
||||
|
||||
if (ret==0) {
|
||||
// return iStorage and leave icache entry invalid (do not cache instr)
|
||||
@ -934,14 +927,11 @@ void BX_CPU_C::boundaryFetch(Bit8u *fetchPtr, unsigned remainingInPage, bxInstru
|
||||
fetchBuffer[j] = *fetchPtr++;
|
||||
}
|
||||
#if BX_SUPPORT_X86_64
|
||||
if (BX_CPU_THIS_PTR cpu_mode == BX_MODE_LONG_64) {
|
||||
if (BX_CPU_THIS_PTR cpu_mode == BX_MODE_LONG_64)
|
||||
ret = fetchDecode64(fetchBuffer, i, 15);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
ret = fetchDecode32(fetchBuffer, i, 15);
|
||||
}
|
||||
|
||||
if (ret==0) {
|
||||
BX_INFO(("fetchDecode #GP(0): too many instruction prefixes"));
|
||||
|
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: cpu.h,v 1.402 2007-12-21 18:24:19 sshwarts Exp $
|
||||
// $Id: cpu.h,v 1.403 2007-12-22 17:17:40 sshwarts Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2001 MandrakeSoft S.A.
|
||||
@ -3104,9 +3104,9 @@ public: // for now...
|
||||
BX_SMF void MONITOR(bxInstruction_c *);
|
||||
BX_SMF void MWAIT(bxInstruction_c *);
|
||||
|
||||
BX_SMF unsigned fetchDecode32(Bit8u *, bxInstruction_c *, unsigned);
|
||||
BX_SMF unsigned fetchDecode32(Bit8u *fetchPtr, bxInstruction_c *i, unsigned remainingInPage);
|
||||
#if BX_SUPPORT_X86_64
|
||||
BX_SMF unsigned fetchDecode64(Bit8u *, bxInstruction_c *, unsigned);
|
||||
BX_SMF unsigned fetchDecode64(Bit8u *fetchPtr, bxInstruction_c *i, unsigned remainingInPage);
|
||||
#endif
|
||||
#if BX_SUPPORT_TRACE_CACHE
|
||||
BX_SMF bxICacheEntry_c* fetchInstructionTrace(bxInstruction_c *, bx_address);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: fetchdecode.cc,v 1.155 2007-12-21 18:24:19 sshwarts Exp $
|
||||
// $Id: fetchdecode.cc,v 1.156 2007-12-22 17:17:40 sshwarts Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2001 MandrakeSoft S.A.
|
||||
@ -2448,9 +2448,10 @@ static const BxOpcodeInfo_t BxOpcodeInfo32M[512*2] = {
|
||||
};
|
||||
|
||||
unsigned
|
||||
BX_CPU_C::fetchDecode32(Bit8u *iptr, bxInstruction_c *i, unsigned remain)
|
||||
BX_CPU_C::fetchDecode32(Bit8u *iptr, bxInstruction_c *i, unsigned remainingInPage)
|
||||
{
|
||||
// remain must be at least 1
|
||||
unsigned remain = (remainingInPage < 15) ? remainingInPage : 15;
|
||||
|
||||
bx_bool is_32, lock=0;
|
||||
unsigned b1, b2, ilen=0, attr, os_32;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: fetchdecode64.cc,v 1.162 2007-12-21 18:24:19 sshwarts Exp $
|
||||
// $Id: fetchdecode64.cc,v 1.163 2007-12-22 17:17:40 sshwarts Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2001 MandrakeSoft S.A.
|
||||
@ -3354,9 +3354,10 @@ static const BxOpcodeInfo_t BxOpcodeInfo64M[512*3] = {
|
||||
};
|
||||
|
||||
unsigned
|
||||
BX_CPU_C::fetchDecode64(Bit8u *iptr, bxInstruction_c *i, unsigned remain)
|
||||
BX_CPU_C::fetchDecode64(Bit8u *iptr, bxInstruction_c *i, unsigned remainingInPage)
|
||||
{
|
||||
// remain must be at least 1
|
||||
unsigned remain = (remainingInPage < 15) ? remainingInPage : 15;
|
||||
|
||||
unsigned b1, b2, ilen=0, attr, lock=0;
|
||||
unsigned imm_mode, offset, rex_r = 0, rex_x = 0, rex_b = 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user