Make %EMIT-ALIGNMENT be more friendly to multi-byte NOPs.
authorLutz Euler <lutz.euler@freenet.de>
Mon, 6 May 2013 12:04:02 +0000 (14:04 +0200)
committerLutz Euler <lutz.euler@freenet.de>
Mon, 6 May 2013 12:04:02 +0000 (14:04 +0200)
commit61ca6a411cc0e8c746e480d7a05423242e49ea45
tree6a185564aafe85e66fb32a537935198b49f08bd5
parentf32ee7df37cdc62596e849c079f365000424a712
Make %EMIT-ALIGNMENT be more friendly to multi-byte NOPs.

When %EMIT-ALIGNMENT needs to tighten the alignment, it used to emit
a fixed-size skip first and an alignment note afterwards. On x86-64,
where block headers are aligned using multi-byte NOPs, this could
lead to emitting one more such NOP than needed to span the desired
range, unnecessarily increasing the number of machine instructions
the processor needs to decode.

To avoid that, change %EMIT-ALIGNMENT to only emit an alignment note
(covering both the fixed-size skip and the alignment note from the
original version) in this situation.

An example of the difference, from the disassembly of
SB-C::FLATTEN-LIST:

Before:

  896: L0:   8F4508           POP QWORD PTR [RBP+8]
  899:       0F1F00           NOP
  89C:       0F1F4000         NOP
  8A0: L1:   4881F917001020   CMP RCX, 537919511

Afterwards:

  896: L0:   8F4508           POP QWORD PTR [RBP+8]
  899:       0F1F8000000000   NOP
  8A0: L1:   4881F917001020   CMP RCX, 537919511
NEWS
src/compiler/assem.lisp