Hello!

Commit 37a5970c19ca7ad2b5de2f667748c840c199f878 changes the VM engine
such that the jump table address is kept in a register, at least on
x86_64.

Using GCC 4.6.0 on x86_64, before the change, the dispatch code looked
like this:

  movzbl 0x0(%rbp),%edx        ;; %edx <- *IP
  lea    0x0(%rip),%rax        ;; %rax <- &jump_table
  add    $0x1,%rbp             ;; IP++
  mov    (%rax,%rdx,8),%rax    ;; %rax <- jump_table[*IP]
  jmpq   *%rax

After, there’s 3 instructions left, instead of 4, with the jump table
address saved in r12:

  movzbl 0x0(%rbp),%eax
  add    $0x1,%rbp
  mov    (%r12,%rax,8),%rax
  jmpq   *%rax

This leads a ~7% speedup on srfi-1.bm, for instance.

Interestingly, defining IP_REG and SP_REG on x86_64 is not necessary
since GCC already makes the right choice.

Thanks,
Ludo’.


Reply via email to