• Paul Eggert's avatar
    Remove some wrong 8-byte alignment assumptions · 967d2c55
    Paul Eggert authored
    Do not assume that 8-byte alignment suffices for all C objects,
    as some platforms require 16-byte alignment for some objects,
    and this will start to bite us as time goes on (e.g., if an
    Emacs module ever uses an object containing a long
    double, which requires 16-byte alignment on x86-64).
    Conversely, on !USE_LSB_TAG platforms, do not insist on
    aligning Lisp objects to a multiple of 8, as this is not
    needed for high-order tag bits.
    * src/alloc.c (LISP_ALIGNMENT, MALLOC_IS_LISP_ALIGNED):
    New constants.
    (XMALLOC_BASE_ALIGNMENT, XMALLOC_HEADER_ALIGNMENT):
    Removed.  All uses replaced by LISP_ALIGNMENT.
    (aligned_alloc, laligned, lmalloc, lrealloc, union aligned_Lisp_Misc)
    (maybe_lisp_pointer, pure_alloc):
    Use LISP_ALIGNMENT rather than GCALIGNMENT.
    (aligned_alloc): Do not worry about an alignment of
    LISP_ALIGNMENT when MALLOC_IS_LISP_ALIGNED, as the code never
    uses aligned_alloc with alignment == LISP_ALIGNMENT in that case.
    (__alignof__): Remove.  All uses removed.
    (MALLOC_IS_GC_ALIGNED): Remove.
    All uses replaced with MALLOC_IS_LISP_ALIGNED.
    (vector_alignment): Remove.
    All uses replaced with LISP_ALIGNMENT.
    * src/alloc.c (mark_maybe_pointer):
    * src/emacs-module.c (value_to_lisp_bits):
    Do not assume GCALIGNMENT == 1 << GCTYPEBITS, as GCALIGNMENT
    is 1 on !USE_LSB_TAG platforms now.
    * src/lisp.h (GCALIGNMENT) [!USE_LSB_TAG]: Now 1.
    (struct Lisp_Symbol, union vectorlike_header, struct Lisp_Cons)
    (struct Lisp_String): Simplify test for verifying alignment.
    967d2c55
alloc.c 207 KB