Why are you making a PS3 emulator?
Started by mushroom




61 posts in this topic
derpf
Unregistered


 
04-25-2014, 01:18 AM -
#38
(04-24-2014, 08:42 PM)hlide Wrote: 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)

It looks like all you're doing is caching the decoded instructions and storing them as function objects or something. At least, that's the only thing I could make out of it. I doubt this would bring any benefit over the amount of memory it uses. Tongue

A JIT, instead, would take a basic block or an entire procedure and recompile it to the target ISA, and then cache that code, so it can simply run that. (And indeed that is a great goal to have -- which rpcs3 will do in the future. Big Grin)


Messages In This Thread
RE: Why are you making a PS3 emulator? - by mushroom - 04-03-2014, 06:30 PM
RE: Why are you making a PS3 emulator? - by mushroom - 04-03-2014, 07:42 PM
RE: Why are you making a PS3 emulator? - by skyeyes83 - 04-03-2014, 08:00 PM
RE: Why are you making a PS3 emulator? - by androidlover - 04-03-2014, 09:05 PM
RE: Why are you making a PS3 emulator? - by mushroom - 04-03-2014, 09:24 PM
RE: Why are you making a PS3 emulator? - by mr.devolver - 04-03-2014, 10:37 PM
RE: Why are you making a PS3 emulator? - by mushroom - 04-10-2014, 09:46 PM
RE: Why are you making a PS3 emulator? - by mushroom - 04-11-2014, 03:29 AM
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 mushroom - 04-14-2014, 07:18 PM
RE: Why are you making a PS3 emulator? - by hlide - 04-15-2014, 10:52 AM
RE: Why are you making a PS3 emulator? - by hlide - 04-15-2014, 12:14 PM
RE: Why are you making a PS3 emulator? - by mushroom - 04-15-2014, 09:52 PM
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 mushroom - 04-16-2014, 05:09 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 mushroom - 04-19-2014, 09:21 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 androidlover - 04-21-2014, 07:57 PM
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 androidlover - 04-22-2014, 03:47 PM
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 derpf - 04-23-2014, 12:11 PM
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 androidlover - 04-23-2014, 06:38 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 mushroom - 04-25-2014, 07:02 PM
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 mushroom - 04-25-2014, 08:26 PM
RE: Why are you making a PS3 emulator? - by androidlover - 04-29-2014, 06:40 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 androidlover - 04-30-2014, 05:48 PM
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 androidlover - 05-01-2014, 07:58 PM
RE: Why are you making a PS3 emulator? - by mushroom - 05-01-2014, 08:06 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 haagens - 05-02-2014, 09:27 PM
RE: Why are you making a PS3 emulator? - by androidlover - 05-02-2014, 09:38 PM
RE: Why are you making a PS3 emulator? - by mushroom - 05-03-2014, 09:49 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 mushroom - 05-05-2014, 07:20 PM
RE: Why are you making a PS3 emulator? - by haagens - 05-05-2014, 07:32 PM
RE: Why are you making a PS3 emulator? - by Bigpet - 05-05-2014, 08:24 PM
RE: Why are you making a PS3 emulator? - by skyeyes83 - 05-05-2014, 09:18 PM
RE: Why are you making a PS3 emulator? - by hlide - 05-05-2014, 11:10 PM
RE: Why are you making a PS3 emulator? - by haagens - 05-05-2014, 11:30 PM
RE: Why are you making a PS3 emulator? - by haagens - 05-06-2014, 12:56 AM

Forum Jump:


Users browsing this thread: 2 Guest(s)