• Aurelien Jarno's avatar
    tcg/i386: use softmmu fast path for unaligned accesses · 8cc580f6
    Aurelien Jarno authored
    
    
    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: default avatarAurelien Jarno <aurelien@aurel32.net>
    Message-Id: <1436467197-2183-1-git-send-email-aurelien@aurel32.net>
    Signed-off-by: default avatarRichard Henderson <rth@twiddle.net>
    8cc580f6