]> granicus.if.org Git - python/commitdiff
bpo-27987: pymalloc: align by 16bytes on 64bit platform (GH-12850)
authorInada Naoki <songofacandy@gmail.com>
Tue, 14 May 2019 09:51:15 +0000 (18:51 +0900)
committerGitHub <noreply@github.com>
Tue, 14 May 2019 09:51:15 +0000 (18:51 +0900)
Misc/NEWS.d/next/Core and Builtins/2019-04-16-11-52-21.bpo-27987.n2_DcQ.rst [new file with mode: 0644]
Objects/obmalloc.c

diff --git a/Misc/NEWS.d/next/Core and Builtins/2019-04-16-11-52-21.bpo-27987.n2_DcQ.rst b/Misc/NEWS.d/next/Core and Builtins/2019-04-16-11-52-21.bpo-27987.n2_DcQ.rst
new file mode 100644 (file)
index 0000000..b0f32a5
--- /dev/null
@@ -0,0 +1,3 @@
+pymalloc returns memory blocks aligned by 16 bytes, instead of 8 bytes, on
+64-bit platforms to conform x86-64 ABI. Recent compilers assume this alignment
+more often. Patch by Inada Naoki.
index 7cfd28965967f9580aeb06a0cef8b20fa234f4ae..bd15bcf1363bdecf7cd05e65dc6316830003511e 100644 (file)
@@ -795,8 +795,14 @@ static int running_on_valgrind = -1;
  *
  * You shouldn't change this unless you know what you are doing.
  */
+
+#if SIZEOF_VOID_P > 4
+#define ALIGNMENT              16               /* must be 2^N */
+#define ALIGNMENT_SHIFT         4
+#else
 #define ALIGNMENT               8               /* must be 2^N */
 #define ALIGNMENT_SHIFT         3
+#endif
 
 /* Return the number of bytes in size class I, as a uint. */
 #define INDEX2SIZE(I) (((uint)(I) + 1) << ALIGNMENT_SHIFT)