Skip to content

Commit

Permalink
Improve register handling when calling external code/fpu so that the …
Browse files Browse the repository at this point in the history
…stack is more accurate when a pagefault occurs. (jmarsh)

git-svn-id: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@4348 ed541006-0bf7-43e9-8c4d-6fc63c346d47
  • Loading branch information
qbix79 committed May 29, 2020
1 parent 2976121 commit ba50dca
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/cpu/core_dyn_x86/cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -427,8 +427,8 @@ static void cache_closeblock(void) {
Bitu written=cache.pos-block->cache.start;
if (written>block->cache.size) {
if (!block->cache.next) {
if (written>block->cache.size+CACHE_MAXSIZE) E_Exit("CacheBlock overrun 1 %d",written-block->cache.size);
} else E_Exit("CacheBlock overrun 2 written %d size %d",written,block->cache.size);
if (written > block->cache.size + CACHE_MAXSIZE) E_Exit("CacheBlock overrun 1 %" sBitfs(d),written-block->cache.size);
} else E_Exit("CacheBlock overrun 2 written %" sBitfs(d) " size %" sBitfs(d),written,block->cache.size);
} else {
Bitu new_size;
Bitu left=block->cache.size-written;
Expand Down
7 changes: 5 additions & 2 deletions src/cpu/core_dyn_x86/risc_x64.h
Original file line number Diff line number Diff line change
Expand Up @@ -1020,6 +1020,9 @@ static void gen_call_ptr(void *func=NULL, Bit8u ptr=0) {
x64gen.regs[X64_REG_R9]->Clear();
x64gen.regs[X64_REG_R10]->Clear();
x64gen.regs[X64_REG_R11]->Clear();
/* Make sure reg_esp is current */
if (DynRegs[G_ESP].flags & DYNFLG_CHANGED)
DynRegs[G_ESP].genreg->Save();

/* Do the actual call to the procedure */
if (func!=NULL) {
Expand Down Expand Up @@ -1135,7 +1138,7 @@ static void gen_fill_branch(Bit8u * data,Bit8u * from=cache.pos) {
Bits len=from-data-1;
if (len<0) len=~len;
if (len>127)
LOG_MSG("Big jump %d",len);
LOG_MSG("Big jump %" sBitfs(d),len);
#endif
*data=(Bit8u)(from-data-1);
}
Expand Down Expand Up @@ -1171,7 +1174,7 @@ static void gen_fill_short_jump(Bit8u * data, Bit8u * to=cache.pos) {
Bits len=to-data-1;
if (len<0) len=~len;
if (len>127)
LOG_MSG("Big jump %d",len);
LOG_MSG("Big jump %" sBitfs(d),len);
#endif
data[0] = (Bit8u)(to-data-1);
}
Expand Down
6 changes: 6 additions & 0 deletions src/cpu/core_dyn_x86/risc_x86.h
Original file line number Diff line number Diff line change
Expand Up @@ -868,6 +868,9 @@ static void gen_call_function(void * func,char const* ops,...) {
/* Clear some unprotected registers */
x86gen.regs[X86_REG_ECX]->Clear();
x86gen.regs[X86_REG_EDX]->Clear();
/* Make sure reg_esp is current */
if (DynRegs[G_ESP].flags & DYNFLG_CHANGED)
DynRegs[G_ESP].genreg->Save();
/* Do the actual call to the procedure */
cache_addb(0xe8);
cache_addd((Bit32u)func - (Bit32u)cache.pos-4);
Expand Down Expand Up @@ -939,6 +942,9 @@ static void gen_call_write(DynReg * dr,Bit32u val,Bitu write_size) {
/* Clear some unprotected registers */
x86gen.regs[X86_REG_ECX]->Clear();
x86gen.regs[X86_REG_EDX]->Clear();
/* Make sure reg_esp is current */
if (DynRegs[G_ESP].flags & DYNFLG_CHANGED)
DynRegs[G_ESP].genreg->Save();
/* Do the actual call to the procedure */
cache_addb(0xe8);
switch (write_size) {
Expand Down

0 comments on commit ba50dca

Please sign in to comment.