This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Thread Rating:
  • 10 Vote(s) - 3.7 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Why are you making a PS3 emulator?
#37
I'm not sure about what a caching interpreter is. But it may be a case of JIT (like the one in Xenia) which allows to reduce the overhead of decoding a contiguous set of instructions (usually called a basic block) by decoding them only once then execute them every time the address is hit by the instruction fetcher. Under certain architectures, you need to use a special instruction to flush icache so you can also discard a basic block from the instruction cache this way.

The simplest way is probably something like that:

Code:
struct insn { void (*interpret_insn)(Context & context); };
...
std::unordered_map< u32, std::vector< insn > > insn_cache;
...
do
{
    auto pc = context.pc;
    auto bb = insn_cache.find(pc);
    if (bb == insn_cache.end())
    {
        insn_cache[pc] = decode_insn(pc);
    }
    else
    {
        for (auto i : bb) i->interpret_insn(context);
    }
}
while (context.no_external_event);
...
}

P.S.: decode_insn returns a vector of decoded insns which represents a basic block (there is no branch-like instruction in the block except for the last instruction)


Messages In This Thread
Why are you making a PS3 emulator? - by mushroom - 04-03-2014, 06:30 PM
RE: Why are you making a PS3 emulator? - by derpf - 04-11-2014, 04:34 AM
RE: Why are you making a PS3 emulator? - by derpf - 04-16-2014, 01:47 AM
RE: Why are you making a PS3 emulator? - by derpf - 04-16-2014, 07:19 AM
RE: Why are you making a PS3 emulator? - by Hykem - 04-16-2014, 10:04 PM
RE: Why are you making a PS3 emulator? - by derpf - 04-20-2014, 08:25 AM
RE: Why are you making a PS3 emulator? - by derpf - 04-22-2014, 04:28 AM
RE: Why are you making a PS3 emulator? - by derpf - 04-23-2014, 01:51 AM
RE: Why are you making a PS3 emulator? - by hlide - 04-23-2014, 04:17 PM
RE: Why are you making a PS3 emulator? - by derpf - 04-23-2014, 12:11 PM
RE: Why are you making a PS3 emulator? - by d875j - 04-24-2014, 07:41 AM
RE: Why are you making a PS3 emulator? - by derpf - 04-24-2014, 08:40 AM
RE: Why are you making a PS3 emulator? - by hlide - 04-24-2014, 08:42 PM
RE: Why are you making a PS3 emulator? - by derpf - 04-25-2014, 01:18 AM
RE: Why are you making a PS3 emulator? - by hlide - 04-25-2014, 07:09 PM
RE: Why are you making a PS3 emulator? - by derpf - 04-30-2014, 12:25 AM
RE: Why are you making a PS3 emulator? - by Hykem - 05-01-2014, 03:46 PM
RE: Why are you making a PS3 emulator? - by Hykem - 05-02-2014, 04:33 PM
RE: Why are you making a PS3 emulator? - by derpf - 05-03-2014, 11:35 PM
RE: Why are you making a PS3 emulator? - by Hykem - 05-04-2014, 04:32 PM
RE: Why are you making a PS3 emulator? - by hlide - 05-05-2014, 11:10 PM

Forum Jump:


Users browsing this thread: 6 Guest(s)