First some facts:
- all JIT platforms *except* i386 have a register reserved for the
  runtime interpreter
- Parrot register addressing is done relative to that CPU register
- that would allow to reuse the JITted code for different threads
  aka interpreters
- but because of i386 is using absolute addresses that's not done
- the latter point also is the cause for zillions of text relocations
  currently needed for the EXEC/i386 run core. I can't imagine that
  this will speed up program start :)

Proposal:
* we mandate that JIT code uses interpreter-relative addressing
- because almost all platforms do it
- because some platforms just can't do anything else
- and of course to avoid re-JITting for every new thread

* src/jit.c calls some platform interface functions, which copy between
  Parrot registers and CPU registers. These are called at the begin
  and end of JITted code sections and are now based on absolute
  memory addresses.
  This should be changed to use offsets. To accomodate platforms that
  have the interpreter cached in a CPU register, I'm thinking of the
  following interface:

  MACRO int Parrot_jit_emit_get_base_reg_no(jit_info *pc)
    // possibly emit code  and return register number of base pointer
    // this register should be one of the scratch registers
    // this must be a macro used as C<reg = foo(pc);>
  Parrot_jit_emit_mov_MR(,..int base_reg_no, size_t offset, int src_reg_no)
  ... other 3 move functions similar

  Register addressing is done relative to the base pointer, which currently
  is &REG_INT(0) or the interpreter, but that might change.

  The code to load this register will be emitted just before the actual
  register moves are done. It's currenlty a noop for all but i386, which
  would need one instruction "mov 16(%ebp), %eax"

* Currently all platforms are using homegrown defines to calculate the
  register offset, some of these are even readable ;)
  To get rid of that, we should provide a set of macros that calculate
  the register offset relative to the base pointer.

     REG_OFFS_INT(x)   // get offset for INTVAL reg no x
     REG_OFFS_STR(x)
     ...
* Implementation
  First the framework should be implemented.
  To allow some transition time the old register move semantics remain
  for some time. Depending on the defined()ness of
  C<Parrot_jit_emit_get_base_reg_no> the new code will be used.

Comments welcome
leo



Reply via email to