diff --git a/cpu/ppc/ppcexec.cpp b/cpu/ppc/ppcexec.cpp index 529cdf902..b3ad1fc57 100644 --- a/cpu/ppc/ppcexec.cpp +++ b/cpu/ppc/ppcexec.cpp @@ -189,10 +189,17 @@ static PPCOpcode OpcodeGrabber[64 * 2048]; everything else is the same.*/ static PPCOpcode OpcodeGrabberNoFPU[64 * 2048]; -static PPCOpcode* curOpcodeGrabber = OpcodeGrabberNoFPU; +/** The contents of either OpcodeGrabber or OpcodeGrabberNoFPU, depending on the MSR::FP bit. + A copy to avoid an memory extra indirection in ppc_main_opcode(). */ +static PPCOpcode curOpcodeGrabber[64 * 2048]; void ppc_msr_did_change() { - curOpcodeGrabber = ppc_state.msr & MSR::FP ? OpcodeGrabber : OpcodeGrabberNoFPU; + static bool curr_has_fp = false; + bool has_fp = ppc_state.msr & MSR::FP; + if (has_fp != curr_has_fp) { + std::memcpy(curOpcodeGrabber, has_fp ? OpcodeGrabber : OpcodeGrabberNoFPU, sizeof(OpcodeGrabber)); + curr_has_fp = has_fp; + } } /** Exception helpers. */ @@ -786,6 +793,8 @@ void initialize_ppc_opcode_table() { if (OpcodeGrabberNoFPU[i] != ppc_fpu_off) { OpcodeGrabberNoFPU[i] = OpcodeGrabber[i]; } + // MSR is initially 0 and thus there's no FPU. + curOpcodeGrabber[i] = OpcodeGrabberNoFPU[i]; } }