tcg/i386: use softmmu fast path for unaligned accesses
authorAurelien Jarno <aurelien@aurel32.net>
Thu, 9 Jul 2015 18:39:57 +0000 (20:39 +0200)
committerRichard Henderson <rth@twiddle.net>
Mon, 24 Aug 2015 18:10:54 +0000 (11:10 -0700)
commit8cc580f6a0d8c0e2f590c1472cf5cd8e51761760
treefd167676e1efba2d1fa1c202f2623d7db1b1854c
parentecc7b3aa71f5fdcf9ee87e74ca811d988282641d
tcg/i386: use softmmu fast path for unaligned accesses

Softmmu unaligned load/stores currently goes through through the slow
path for two reasons:
  - to support unaligned access on host with strict alignement
  - to correctly handle accesses crossing pages

x86 is only concerned by the second reason. Unaligned accesses are
avoided by compilers, but are not uncommon. We therefore would like
to see them going through the fast path, if they don't cross pages.

For that we can use the fact that two adjacent TLB entries can't contain
the same page. Therefore accessing the TLB entry corresponding to the
first byte, but comparing its content to page address of the last byte
ensures that we don't cross pages. We can do this check without adding
more instructions in the TLB code (but increasing its length by one
byte) by using the LEA instruction to combine the existing move with the
size addition.

On an x86-64 host, this gives a 3% boot time improvement for a powerpc
guest and 4% for an x86-64 guest.

[rth: Tidied calculation of the offset mask]

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
Message-Id: <1436467197-2183-1-git-send-email-aurelien@aurel32.net>
Signed-off-by: Richard Henderson <rth@twiddle.net>
tcg/i386/tcg-target.c