[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

VM jump table address kept in a register

From: Ludovic Courtès
Subject: VM jump table address kept in a register
Date: Wed, 06 Jul 2011 13:02:21 +0200
User-agent: Gnus/5.110017 (No Gnus v0.17) Emacs/24.0.50 (gnu/linux)


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

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, for instance.

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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]