summaryrefslogtreecommitdiff
path: root/macros
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2008-07-17 14:22:10 -0700
committerH. Peter Anvin <hpa@zytor.com>2008-07-17 14:22:10 -0700
commitca66ec5eec6f7407d4bdbb1e091a9ccde66a5194 (patch)
tree0720db5314d6102e24eb408d2f00273ae91f4df3 /macros
parent1ac41d34baf3a1ba387105526dec344d935c14c5 (diff)
downloadnasm-ca66ec5eec6f7407d4bdbb1e091a9ccde66a5194.tar.gz
nasm-ca66ec5eec6f7407d4bdbb1e091a9ccde66a5194.tar.bz2
nasm-ca66ec5eec6f7407d4bdbb1e091a9ccde66a5194.zip
smartalign: adjust the alignment threshold
Apparently the current recommendation is for a smaller threshold when using the "generic"-style alignment macros (short jumps are cheaper on newer CPUs.) Also change the alignment threshold definition to reflect the maximum number of padding instead of when to start using jumps.
Diffstat (limited to 'macros')
-rw-r--r--macros/smartalign.mac13
1 files changed, 11 insertions, 2 deletions
diff --git a/macros/smartalign.mac b/macros/smartalign.mac
index 6ff294a..1285086 100644
--- a/macros/smartalign.mac
+++ b/macros/smartalign.mac
@@ -4,8 +4,9 @@
USE: smartalign
%imacro alignmode 1-2.nolist
- %define __ALIGN_JMP_THRESHOLD__ 17
%ifidni %1,nop
+ %define __ALIGN_JMP_THRESHOLD__ 16
+
%define __ALIGN_16BIT_1B__ 0x90
%define __ALIGN_16BIT_2B__ 0x90,0x90
%define __ALIGN_16BIT_3B__ 0x90,0x90,0x90
@@ -33,6 +34,8 @@ USE: smartalign
%define __ALIGN_64BIT_7B__ 0x90,0x90,0x90,0x90,0x90,0x90,0x90
%define __ALIGN_64BIT_8B__ 0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90
%elifidni %1,generic
+ %define __ALIGN_JMP_THRESHOLD__ 8
+
%define __ALIGN_16BIT_1B__ 0x90
%define __ALIGN_16BIT_2B__ 0x89,0xf6
%define __ALIGN_16BIT_3B__ 0x8d,0x74,0x00
@@ -60,6 +63,8 @@ USE: smartalign
%define __ALIGN_64BIT_7B__ 0x66,0x66,0x66,0x90,0x66,0x66,0x90
%define __ALIGN_64BIT_8B__ 0x66,0x66,0x66,0x90,0x66,0x66,0x66,0x90
%elifidni %1,k8
+ %define __ALIGN_JMP_THRESHOLD__ 16
+
%define __ALIGN_16BIT_1B__ 0x90
%define __ALIGN_16BIT_2B__ 0x66,0x90
%define __ALIGN_16BIT_3B__ 0x66,0x66,0x90
@@ -87,6 +92,8 @@ USE: smartalign
%define __ALIGN_64BIT_7B__ 0x66,0x66,0x66,0x90,0x66,0x66,0x90
%define __ALIGN_64BIT_8B__ 0x66,0x66,0x66,0x90,0x66,0x66,0x66,0x90
%elifidni %1,k7
+ %define __ALIGN_JMP_THRESHOLD__ 16
+
%define __ALIGN_16BIT_1B__ 0x90
%define __ALIGN_16BIT_2B__ 0x66,0x90
%define __ALIGN_16BIT_3B__ 0x66,0x66,0x90
@@ -114,6 +121,8 @@ USE: smartalign
%define __ALIGN_64BIT_7B__ 0x66,0x66,0x66,0x90,0x66,0x66,0x90
%define __ALIGN_64BIT_8B__ 0x66,0x66,0x66,0x90,0x66,0x66,0x66,0x90
%elifidni %1,p6
+ %define __ALIGN_JMP_THRESHOLD__ 16
+
%define __ALIGN_16BIT_1B__ 0x90
%define __ALIGN_16BIT_2B__ 0x66,0x90
%define __ALIGN_16BIT_3B__ 0x0f,0x1f,0x00
@@ -156,7 +165,7 @@ USE: smartalign
%else
%push
%assign %$pad ($$-$) % %1
- %if %$pad >= __ALIGN_JMP_THRESHOLD__
+ %if %$pad > __ALIGN_JMP_THRESHOLD__
jmp %%end
; We can't re-use %$pad here as $ will have changed!
times ($$-$) % %1 db 90h