Also cache native routine descriptor instead of recreating them at each

invokation to ExecuteNative().
This commit is contained in:
gbeauche 2004-01-07 18:24:45 +00:00
parent 9f745bd142
commit 1b0e88041e
4 changed files with 47 additions and 3 deletions

View File

@ -676,6 +676,9 @@ void SheepShaver::Quit(void)
DiskExit();
SonyExit();
// Delete thunks
ThunksExit();
// Delete SheepShaver globals
SheepMem::Exit();

View File

@ -869,6 +869,9 @@ static void Quit(void)
DiskExit();
SonyExit();
// Delete thunks
ThunksExit();
// Delete SheepShaver globals
SheepMem::Exit();

View File

@ -60,6 +60,9 @@ enum {
// Initialize the thunks system
extern bool ThunksInit(void);
// Exit the thunks system
extern void ThunksExit(void);
// Return the fake PowerPC opcode to handle specified native code
#if EMULATED_PPC
extern uint32 NativeOpcode(int selector);
@ -71,6 +74,9 @@ extern uint32 NativeTVECT(int selector);
// Return the native function address
extern uint32 NativeFunction(int selector);
// Return the routine descriptor address of the native function
extern uint32 NativeRoutineDescriptor(int selector);
/*
* Helpers to share 32-bit addressable data with MacOS
@ -82,7 +88,7 @@ protected:
static uintptr zero_page;
static uintptr base;
static uintptr top;
static const uint32 size = 0x40000;
static const uint32 size = 0x40000; // 256 KB
public:
static bool Init(void);
static void Exit(void);

View File

@ -96,6 +96,7 @@ uint32 NativeOpcode(int selector)
struct native_op_t {
uint32 tvect;
uint32 func;
SheepRoutineDescriptor *desc;
};
static native_op_t native_op[NATIVE_OP_MAX];
@ -148,10 +149,29 @@ bool ThunksInit(void)
DEFINE_NATIVE_OP(NATIVE_MAKE_EXECUTABLE, MakeExecutable);
#undef DEFINE_NATIVE_OP
#endif
// Initialize routine descriptors
for (int i = 0; i < NATIVE_OP_MAX; i++)
native_op[i].desc = new SheepRoutineDescriptor(0, NativeTVECT(i));
return true;
}
/*
* Delete generated thunks
*/
void ThunksExit(void)
{
for (int i = 0; i < NATIVE_OP_MAX; i++) {
SheepRoutineDescriptor *desc = native_op[i].desc;
if (desc)
delete desc;
}
}
/*
* Return the native function descriptor (TVECT)
*/
@ -178,13 +198,25 @@ uint32 NativeFunction(int selector)
}
/*
* Return the routine descriptor address of the native function
*/
uint32 NativeRoutineDescriptor(int selector)
{
assert(selector < NATIVE_OP_MAX);
SheepRoutineDescriptor * const desc = native_op[selector].desc;
assert(desc != 0);
return desc->addr();
}
/*
* Execute native code from EMUL_OP routine (real mode switch)
*/
void ExecuteNative(int selector)
{
SheepRoutineDescriptor desc(0, NativeTVECT(selector));
M68kRegisters r;
Execute68k(desc.addr(), &r);
Execute68k(NativeRoutineDescriptor(selector), &r);
}