Dynamic Translation

From ES40 Emulator

Jump to: navigation, search

[edit] Introduction

The idea behind Dynamic Translation of instructions, rather than Interpretation is to translate instructions into host-platform machine language (or an intermediary language?) once, and then execute these translated bits of code each time they are used. This could give a huge increase in performance for bits of code that are frequently used (for example, OS routines like $QIO, or the scheduler).

[edit] Random Thoughts

Here are a couple of thoughts on dynamic instruction translation. Please add to these as you like:


  • A way to do it:
 if the instruction at the current address is a jump/branch instruction
 {
   execute the instruction (same way it is done now)
 }
 else
 {
   If the current address hasn't been translated yet
   {
      count the number of instructions starting with the current instruction, until a jump/branch instruction is encountered
      allocate enough memory for the translation of these instructions translate these instructions into machine language and store it in the allocated memory
      register the allocated memory as being the translation for the current instruction address
   }
 
   call the translation as a function
 }
  • I'm excluding jumps/branches on purpose, mainly because we still need to check for external interrupts occasionally, and because it helps to keep the code blocks a reasonable size. For the allocation we should implement a fast memory allocation function (probably a bucket allocator).
  • There's a __lot__ of planning and work involved in this approach; like:
    • The actual translated code is different for each host processor architecture --> architecture dependent code to create the translated code
    • Keeping track of translated code that has changed in memory
    • How to handle exceptions

Camiel 08:49, 23 April 2008 (UTC)


Personal tools