1. 04 Aug, 2018 1 commit
    • Andy Moreton's avatar
      Make bignums work better when EMACS_INT is larger than long · bc8ff54e
      Andy Moreton authored
      * lisp/international/ccl.el (ccl-fixnum): New function.
      (ccl-embed-data, ccl-embed-current-address, ccl-dump): Use it.
      * src/alloc.c (make_number): Handle case where EMACS_INT is
      larger than long.
      * src/data.c (bignumcompare): Handle case where EMACS_INT is
      larger than long.
      (arith_driver): Likewise.  Coerce markers.
      (float_arith_driver): Coerce markers.
      (Flogcount): Use mpz_sgn.
      (ash_lsh_impl): Fix bugs.
      (Fsub1): Fix underflow check.
      * src/lisp.h (NUMBERP): Don't check BIGNUMP.
      (CHECK_FIXNUM_OR_FLOAT_COERCE_MARKER): Fix indentation.
      * test/lisp/international/ccl-tests.el: New file.
      bc8ff54e
  2. 19 Jul, 2018 1 commit
    • Tom Tromey's avatar
      Fix bignum creation when EMACS_INT is wider than long · 76715f89
      Tom Tromey authored
      * src/alloc.c (mpz_set_intmax_slow, mpz_set_uintmax_slow): New
      functions.
      * src/data.c (arith_driver, Frem, Fmod, ash_lsh_impl, Fadd1)
      (Fsub1): Use mpz_set_intmax, mpz_set_uintmax.
      * src/emacs-module.c (module_make_integer): Use mpz_set_intmax.
      * src/floatfns.c (Fabs): Use mpz_set_intmax.
      * src/lisp.h (mpz_set_intmax, mpz_set_uintmax): New inline
      functions.
      (mpz_set_uintmax_slow, mpz_set_intmax_slow): Declare.
      76715f89
  3. 13 Jul, 2018 3 commits
    • Tom Tromey's avatar
      Provide new functions to create bignums · b2f3f4ee
      Tom Tromey authored
      * src/alloc.c (make_bignum_str, make_number): New functions.
      * src/lisp.h (make_bignum_str, make_number): Declare.
      b2f3f4ee
    • Tom Tromey's avatar
      Introduce the bignum type · a0f2adbf
      Tom Tromey authored
      * src/alloc.c (mark_object): Handle Lisp_Misc_Bignum.
      (sweep_misc): Call mpz_clear for Lisp_Misc_Bignum.
      * src/data.c (Ftype_of): Handle Lisp_Misc_Bignum.
      (Fintegerp, Finteger_or_marker_p, Fnatnump, Fnumberp)
      (Fnumber_or_marker_p): Update for bignum.
      (Ffixnump, Fbignump): New defuns.
      (syms_of_data): Update.
      * src/emacs.c (xrealloc_for_gmp, xfree_for_gmp): New functions.
      (main): Call mp_set_memory_functions.
      * src/lisp.h (enum Lisp_Misc_Type) <Lisp_Misc_Bignum>: New constant.
      (struct Lisp_Bignum): New.
      (union Lisp_Misc): Add u_bignum.
      (BIGNUMP, XBIGNUM, INTEGERP, NATNUMP, NUMBERP, CHECK_NUMBER)
      (CHECK_INTEGER, CHECK_NUMBER_COERCE_MARKER): New functions.
      * src/print.c (print_object): Handle Lisp_Misc_Bignum.
      a0f2adbf
    • Tom Tromey's avatar
      Rename integerp->fixnum, etc, in preparation for bignums · 42fe787b
      Tom Tromey authored
      * src/json.c, src/keyboard.c, src/keyboard.h, src/keymap.c,
      src/kqueue.c, src/lcms.c, src/lisp.h, src/lread.c, src/macros.c,
      src/marker.c, src/menu.c, src/minibuf.c, src/msdos.c, src/print.c,
      src/process.c, src/profiler.c, src/search.c, src/sound.c,
      src/syntax.c, src/sysdep.c, src/term.c, src/terminal.c,
      src/textprop.c, src/undo.c, src/w16select.c, src/w32.c,
      src/w32console.c, src/w32cygwinx.c, src/w32fns.c, src/w32font.c,
      src/w32inevt.c, src/w32proc.c, src/w32select.c, src/w32term.c,
      src/w32uniscribe.c, src/widget.c, src/window.c, src/xdisp.c,
      src/xfaces.c, src/xfns.c, src/xfont.c, src/xftfont.c, src/xmenu.c,
      src/xrdb.c, src/xselect.c, src/xterm.c, src/xwidget.c: Rename
      INTEGERP->FIXNUM, make_number->make_fixnum, CHECK_NUMBER->CHECK_FIXNUM,
      make_natnum->make_fixed_natum, NUMBERP->FIXED_OR_FLOATP,
      NATNUMP->FIXNATP, CHECK_NATNUM->CHECK_FIXNAT.
      42fe787b
  4. 30 Jun, 2018 1 commit
    • Paul Eggert's avatar
      unbind_to performance tuning · 2e281186
      Paul Eggert authored
      * src/alloc.c (which_symbols):
      * src/dispnew.c (Fredisplay):
      * src/editfns.c (Fsubst_char_in_region):
      * src/fileio.c (Fdo_auto_save):
      * src/indent.c (Fvertical_motion):
      * src/keymap.c (Fcurrent_active_maps):
      * src/lread.c (Feval_buffer):
      * src/minibuf.c (get_minibuffer):
      * src/sysdep.c (system_process_attributes):
      * src/textprop.c (Fnext_single_char_property_change)
      (Fprevious_single_char_property_change):
      * src/window.c (Fscroll_other_window, Fscroll_other_window_down):
      * src/xdisp.c (Fformat_mode_line):
      Help the compiler eliminate tail recursion in call to unbind_to.
      * src/coding.c (decode_coding_gap):
      Omit unnecessary unbind_to, as we’re about to call unbind_to anyway.
      * src/coding.c (Fread_coding_system):
      * src/eval.c (eval_sub):
      * src/xdisp.c (handle_single_display_spec, decode_mode_spec):
      * src/xselect.c (x_get_local_selection):
      Avoid need to save a machine register when calling unbind_to.
      * src/minibuf.c (Ftry_completion, Fall_completions):
      Omit unnecessary assignment.
      2e281186
  5. 16 Jun, 2018 1 commit
    • Paul Eggert's avatar
      Rewrite memory-limit in Lisp · ec1b4d9a
      Paul Eggert authored
      Have it return Emacs virtual memory size, not the sbrk value
      which is often useless newadays.
      * doc/lispref/internals.texi (Garbage Collection):
      * etc/NEWS: Document this.
      * lisp/subr.el (memory-limit): New implementation in Lisp,
      written in terms of process-attributes, and which returns
      virtual memory size.
      * src/alloc.c (Fmemory_limit): Remove C implementation.
      ec1b4d9a
  6. 15 Jun, 2018 4 commits
    • Paul Eggert's avatar
      Minor CANNOT_DUMP cleanups · b8b960e5
      Paul Eggert authored
      Mostly, this avoids munging executables when CANNOT_DUMP = yes,
      as the munging is needed only for unexec.
      * configure.ac (PAXCTL_dumped, PAXCTL_notdumped) [CANNOT_DUMP]:
      Leave these empty.
      (LD_SWITCH_SYSTEM_TEMACS) [CANNOT_DUMP]:
      Do not append -no-pie or -nopie.
      * src/alloc.c (my_heap_start) [CANNOT_DUMP]: Omit; not used.
      b8b960e5
    • Paul Eggert's avatar
      Remove Lisp_Misc_Save_Value · 4139c98e
      Paul Eggert authored
      This type and its associated routines are no longer used.
      * src/alloc.c (voidfuncptr): Move here from src/lisp.h.
      (free_misc, make_save_int_int_int)
      (make_save_obj_obj_obj_obj, make_save_ptr)
      (make_save_ptr_int, make_save_ptr_ptr)
      (make_save_funcptr_ptr_obj, make_save_memory)
      (free_save_value, mark_save_value):
      Remove.
      (mark_object): Remove mention of Lisp_Misc_Save_Value.
      * src/lisp.h (Lisp_Misc_Save_Value, SAVE_SLOT_BITS)
      (SAVE_VALUE_SLOTS, SAVE_TYPE_BITS, enum Lisp_Save_Type)
      (struct Lisp_Save_Value, SAVE_VALUEP, XSAVE_VALUE)
      (save_type, XSAVE_POINTER, set_save_pointer)
      (XSAVE_FUNCPOINTER, XSAVE_INTEGER, set_save_integer)
      (XSAVE_OBJECT): Remove.
      (union Lisp_Misc): Remove u_save_value.
      (voidfuncptr): Move from here to src/alloc.c.
      * src/print.c (print_object):
      Remove support for printing Lisp_Misc_Save_Value.
      4139c98e
    • Paul Eggert's avatar
      New type Lisp_Misc_Ptr · f8ad6b31
      Paul Eggert authored
      This is a streamlined version of Lisp_Save_Value, which contains just
      a pointer, as that is all Lisp_Save_Values are used for any more.
      With the previous changes, these objects are not primarily used as
      save values, so just call them "Misc" rather than "Save".
      * src/alloc.c (make_misc_ptr): New function.
      (mark_object): Mark Lisp_Misc_Ptr too.
      * src/lisp.h (Lisp_Misc_Ptr): New constant.
      (struct Lisp_Misc_Ptr): New type.
      (make_mint_ptr, mint_ptrp, xmint_pointer):
      Use Lisp_Misc_Ptr, not Lisp_Save_Value.
      (union Lisp_Misc): Add Lisp_Misc_Ptr.
      * src/print.c (print_object): Print Lisp_Misc_Ptr.
      f8ad6b31
    • Paul Eggert's avatar
      Avoid allocating Lisp_Save_Value for arrays · d98670eb
      Paul Eggert authored
      * src/alloc.c (mark_maybe_objects): New function.
      * src/eval.c (default_toplevel_binding)
      (backtrace_eval_unrewind, Fbacktrace__locals):
      Treat array unwindings like other miscellaneous pdl types.
      (record_unwind_protect_array): New function.
      (do_one_unbind): Free the array while unwinding.
      (mark_specpdl): Mark arrays directly.
      * src/lisp.h (SPECPDL_UNWIND_ARRAY): New constant.
      (union specbinding): New member unwind_array.
      (SAFE_ALLOCA_LISP_EXTRA): Use record_unwind_protect_array
      instead of make_save_memory + record_unwind_protect.
      d98670eb
  7. 13 Jun, 2018 1 commit
    • 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
  8. 10 Jun, 2018 1 commit
    • Paul Eggert's avatar
      Use native alignment to access Lisp object data · 0303fab3
      Paul Eggert authored
      Instead of using __builtin_assume_aligned (P, GCALIGNMENT) to
      tell GCC that P has alignment 8, use (T *) P where T is the
      type of the pointed-to object, to tell GCC that P has native
      alignment.  This is simpler, matches the intent better, and
      should help simplify future improvements.  Some of these
      changes are to pacify gcc -Wnull-dereference, since GCC is
      smarter about pointers now that Emacs no longer uses
      __builtin_assume_aligned; these minor changes should improve
      code efficiency slightly.  On Fedora 28 x86-64 with default
      optimization this patch shrinks the size of the Emacs text
      segment by 0.36%.
      * src/conf_post.h (__has_builtin, __builtin_assume_aligned):
      Remove; no longer used.
      * src/dbusbind.c (XD_OBJECT_TO_DBUS_TYPE):
      Pacify -Wnull-dereference by using XCAR instead of CAR_SAFE
      and XCDR instead of CDR_SAFE when this is safe.
      * src/fileio.c (Fexpand_file_name):
      * src/font.c (clear_font_cache):
      Pacify -Wnull-dereference by removing unnecessary NILP test.
      * src/keyboard.c (xevent_start): New function.
      (read_char, read_key_sequence): Pacify -Wnull-dereference by
      using xevent_start instead of EVENT_START.
      * src/lisp.h (lisp_h_XUNTAG): Remove; XUNTAG is always a macro
      now, since it can no longer be implemented as a function.
      (XUNTAG): New third argument CTYPE.  All uses changed.
      Cast result to CTYPE * instead of using __builtin_assume_aligned.
      Simplify by using LISP_WORD_TAG.
      (LISP_WORD_TAG): New macro.
      (TAG_PTR): Use it.
      * src/menu.c (x_popup_menu_1):
      Pacify -Wnull-dereference by using XCAR instead of Fcar and
      XCDR instead of Fcdr where this is safe.
      0303fab3
  9. 09 Jun, 2018 1 commit
  10. 03 Jun, 2018 2 commits
    • Stefan Monnier's avatar
      Fix bug#30846, along with misc cleanups found along the way · ed962f2b
      Stefan Monnier authored
      * test/src/data-tests.el (data-tests-kill-all-local-variables): New test.
      
      * src/buffer.c (swap_out_buffer_local_variables): Remove.
      Fuse the body of its loop into that of reset_buffer_local_variables.
      (Fkill_buffer, Fkill_all_local_variables): Don't call it any more.
      (reset_buffer_local_variables): Make sure the buffer's local binding
      is swapped out before removing it from the alist (bug#30846).
      Call watchers before actually killing the var.
      
      * src/data.c (Fmake_local_variable): Simplify.
      Use swap_in_global_binding to swap out any local binding, instead of
      a mix of find_symbol_value followed by messing with where&found.
      Don't call swap_in_symval_forwarding since the currently swapped
      binding is never one we've modified.
      (Fkill_local_variable): Use swap_in_global_binding rather than messing
      with where&found to try and trick find_symbol_value into doing the same.
      
      * src/alloc.c (mark_localized_symbol): 'where' can't be a frame any more.
      
      (cherry picked from commit 3ddff080)
      ed962f2b
    • Noam Postavsky's avatar
      Fix another case of freed markers in the undo-list (Bug#30931) · daa60233
      Noam Postavsky authored
      * src/alloc.c (free_marker): Remove.
      * src/editfns.c (save_restriction_restore):
      * src/insdel.c (signal_before_change): Detach the markers from the
      buffer when we're done with them instead of calling free_marker on
      them.
      * test/src/editfns-tests.el (delete-region-undo-markers-1)
      (delete-region-undo-markers-2): New tests.
      
      (cherry picked from commit 96b8747d)
      daa60233
  11. 22 May, 2018 1 commit
  12. 18 May, 2018 2 commits
    • Paul Eggert's avatar
      * src/alloc.c: Fix comment. · 593c367b
      Paul Eggert authored
      593c367b
    • Paul Eggert's avatar
      Port to GCC 8 -fsanitize=undefined · a1c925fd
      Paul Eggert authored
      In GCC 8, gcc -fsanitize=undefined flags the undefined behavior
      that Emacs relies on in its XPNTR and XSYMBOL low-level functions.
      Disable undefined sanitization in these functions.  Although this
      disabling doesn’t suffice if DEFINE_KEY_OPS_AS_MACROS is true, it
      works for -fsanitize=undefined -DINLINING=0, which is good enough.
      * src/alloc.c (macro_PNTR_ADD): New macro.
      (PNTR_ADD): New function and macro.
      The function disables -fsanitize=undefined.
      (macro_XPNTR): Use it.
      * src/conf_post.h (ATTRIBUTE_NO_SANITIZE_UNDEFINED): New macro.
      * src/lisp.h (XSYMBOL): Disable -fsanitize=undefined.
      a1c925fd
  13. 18 Apr, 2018 1 commit
  14. 30 Mar, 2018 1 commit
    • Noam Postavsky's avatar
      Fix another case of freed markers in the undo-list (Bug#30931) · 96b8747d
      Noam Postavsky authored
      * src/alloc.c (free_marker): Remove.
      * src/editfns.c (save_restriction_restore):
      * src/insdel.c (signal_before_change): Detach the markers from the
      buffer when we're done with them instead of calling free_marker on
      them.
      * test/src/editfns-tests.el (delete-region-undo-markers-1)
      (delete-region-undo-markers-2): New tests.
      96b8747d
  15. 23 Mar, 2018 2 commits
    • Stefan Monnier's avatar
      Fix bug#30846, along with misc cleanups found along the way · 3ddff080
      Stefan Monnier authored
      * test/src/data-tests.el (data-tests-kill-all-local-variables): New test.
      
      * src/buffer.c (swap_out_buffer_local_variables): Remove.
      Fuse the body of its loop into that of reset_buffer_local_variables.
      (Fkill_buffer, Fkill_all_local_variables): Don't call it any more.
      (reset_buffer_local_variables): Make sure the buffer's local binding
      is swapped out before removing it from the alist (bug#30846).
      Call watchers before actually killing the var.
      
      * src/data.c (Fmake_local_variable): Simplify.
      Use swap_in_global_binding to swap out any local binding, instead of
      a mix of find_symbol_value followed by messing with where&found.
      Don't call swap_in_symval_forwarding since the currently swapped
      binding is never one we've modified.
      (Fkill_local_variable): Use swap_in_global_binding rather than messing
      with where&found to try and trick find_symbol_value into doing the same.
      
      * src/alloc.c (mark_localized_symbol): 'where' can't be a frame any more.
      3ddff080
    • Stefan Monnier's avatar
      * src/alloc.c: Avoid O(N²) complexity when unchaining markers (bug#24548). · cf316452
      Stefan Monnier authored
      Unchain all dead markers with a single scan of the markers list,
      instead of calling the O(N) 'unchain_marker' N times.
      
      (unchain_dead_markers): New function.
      (sweep_buffers): Use it.
      (gc_sweep): Sweep buffers before markers.
      (sweep_misc): Check that markers have been unchained when reclaiming them.
      cf316452
  16. 20 Mar, 2018 2 commits
    • Paul Eggert's avatar
      Port to 32-bit sparc64 · d09c488c
      Paul Eggert authored
      Backport from master.
      Problem reported by Ulrich Mueller; fix suggested by Eli Zaretskii
      and Andreas Schwab (Bug#30855).
      * src/alloc.c (mark_memory): Call mark_maybe_object only on
      pointers that are properly aligned for Lisp_Object.
      d09c488c
    • Paul Eggert's avatar
      Port to 32-bit sparc64 · db64a866
      Paul Eggert authored
      Problem reported by Ulrich Mueller; fix suggested by Eli Zaretskii
      and Andreas Schwab (Bug#30855).
      * src/alloc.c (mark_memory): Call mark_maybe_object only on
      pointers that are properly aligned for Lisp_Object.
      db64a866
  17. 05 Mar, 2018 1 commit
  18. 19 Jan, 2018 1 commit
  19. 01 Jan, 2018 1 commit
  20. 12 Dec, 2017 4 commits
    • Paul Eggert's avatar
      Fix recently-introduced cast typo · 8e78d497
      Paul Eggert authored
      * src/alloc.c (SDATA_OF_STRING): Put cast in right spot.
      This matters only if GC_CHECK_STRING_BYTES, which is sort
      of a coals-to-Newcastle situation if pointer bounds checking
      is also enabled.
      8e78d497
    • Paul Eggert's avatar
      Narrow pointer bounds when appropriate · 4295050e
      Paul Eggert authored
      This typically occurs in a storage manager, where the caller
      is expected to access only the newly-allocated object,
      instead of using the returned value to access unrelated
      parts of the heap.
      * src/alloc.c (allocate_string, allocate_string_data)
      (compact_small_strings, find_string_data_in_pure)
      (sweep_strings, setup_on_free_list, allocate_vectorlike
      (pure_alloc):
      * src/bytecode.c (exec_byte_code):
      * src/callint.c (Fcall_interactively):
      * src/dispnew.c (scrolling):
      * src/editfns.c (styled_format):
      * src/frame.c (xrdb_get_resource, x_get_resource_string):
      * src/fringe.c (Fdefine_fringe_bitmap):
      * src/gmalloc.c (malloc, realloc, aligned_alloc):
      Narrow pointer bounds when appropriate.
      * src/alloc.c (SDATA_OF_STRING):
      * src/lisp.h (make_lisp_symbol) [__CHKP__]:
      Widen bounds here, though.
      * src/bytecode.c, src/callint.c, src/dispnew.c, src/editfns.c:
      * src/emacs.c, src/frame.c, src/fringe.c:
      Include ptr-bounds.h.
      * src/ptr-bounds.h (ptr_bounds_clip): New function.
      4295050e
    • Paul Eggert's avatar
      Port to gcc -fcheck-pointer-bounds · 881abfc7
      Paul Eggert authored
      This is a minimal port, just to get Emacs running;
      it does not attempt to make the pointer bounds at all tight.
      * src/ptr-bounds.h: New file.
      * src/alloc.c, src/gmalloc.c: Include it.
      * src/alloc.c (live_string_holding, live_cons_holding)
      (live_symbol_holding, live_misc_holding, garbage_collect_1)
      (sweep_conses, sweep_floats):
      * src/gmalloc.c (malloc_initialize_1, _free_internal_nolock)
      (_realloc_internal_nolock):
      Widen pointer bounds as necessary.
      We're in a memory allocator so this is OK.
      * src/lisp.h (lisp_h_XSYMBOL, make_lisp_symbol) [__CHKP__]:
      Do not convert from pointer to integer and back again, so
      that GCC does not lose track of pointer bounds.
      (XSYMBOL) [__CHKP__ && !USE_LSB_TAG]: Now a compile-time error.
      Although it's possible to support both -fcheck-pointer-bounds and
      --with-wide-int, it's more work; keep things simple for now.
      (DEFINE_LISP_SYMBOL) [__CHKP__]: Now a no-op, to avoid
      trouble with unbounded pointers.
      881abfc7
    • Paul Eggert's avatar
      Reimplement Lisp_Object as pointer-to-incomplete · 244346c7
      Paul Eggert authored
      This makes Lisp_Object values opaque pointers instead of integers,
      which helps avoid the same sort of typos that
      CHECK_LISP_OBJECT_TYPE helps to avoid, without having to wrap
      pointers inside structures.  This also looks forward to supporting
      -fcheck-pointer-bounds.
      * etc/DEBUG:
      * src/.gdbinit (Lisp_Object_Printer.to_string):
      Lisp_Object can be a pointer type now.
      * src/alloc.c (macro_XPNTR, XPNTR):
      * src/emacs-module.c (value_to_lisp_bits, lisp_to_value_bits):
      * src/lisp.h (lisp_h_XLI, lisp_h_XIL):
      (lisp_h_XUNTAG) [USE_LSB_TAG]:
      (XUNTAG) [!USE_LSB_TAG]:
      (Lisp_Object, TAG_PTR, make_lisp_symbol):
      Support new Lisp_Object implementation as a pointer to an
      incomplete type.  Keep pointers pointers, as much as possible.
      * src/alloc.c (macro_XPNTR_OR_SYMBOL_OFFSET, XPNTR_OR_SYMBOL_OFFSET):
      Remove.  All uses replaced by plain XPNTR.
      * src/emacs-module.c: Work around GCC bug 83162.
      * src/lisp.h (LISP_WORDS_ARE_POINTERS, lisp_h_XLP, lisp_h_XPL):
      (XLP, XPL) [DEFINE_KEY_OPS_AS_MACROS]:
      New macros.
      (Lisp_Word, untagged_ptr, Lisp_Word_tag): New types.
      (XLP, XPL): New inline functions.
      (TAG_PTR): Now expands to an initializer, not an expression.
      All uses changed.
      (TAG_SYMOFFSET, XLI_BUILTIN_LISPSYM): Remove.  All uses removed.
      (LISPSYM_INITIALLY): Redo in terms of the new TAG_PTR.
      (NIL_IS_ZERO): Redo without XLI_BUILTIN_LISPSYM.
      * src/xwidget.c (webkit_javascript_finished_cb): Use XPL
      instead of XIL with a non-EMACS_INT arg.
      (Fxwidget_webkit_execute_script): Use XLP instead of XLI
      followed by two conversions.
      244346c7
  21. 04 Dec, 2017 1 commit
    • Paul Eggert's avatar
      allocate_vectorlike minor cleanup · a597969f
      Paul Eggert authored
      * src/alloc.c (allocate_vectorlike): Move a bit of code out of the
      critical section.  Although this doesn’t really help performance,
      it cleans up the code a bit and should make it easier to add
      pointer bounds checking.
      a597969f
  22. 26 Nov, 2017 1 commit
  23. 13 Nov, 2017 2 commits
    • Paul Eggert's avatar
      Port to IBM xlc 12.01 · 79108894
      Paul Eggert authored
      Work around a compiler bug by using a separate enum for alignment.
      * src/alloc.c (roundup_size): Declare in a separate enum.
      79108894
    • Paul Eggert's avatar
      Use alignas to fix GCALIGN-related bugs · b1573a97
      Paul Eggert authored
      Use alignas and unions to specify alignments of objects needing
      addresses that are at least a multiple of GCALIGNMENT.  Using
      these standard C facilities should be safer than relying on ad hoc
      and poorly-understood features like GCC’s __attribute__
      ((aligned (N))), the root cause for recent porting bugs like
      Bug#29040.  The alignas macro was standardized by C11 and Gnulib
      supports alignas for pre-C11 platforms.  I have tested this on Sun
      Studio 12 sparc (2007) and GCC 4.4.7 x86-64 (2012) as well as on
      more recent platforms like GCC 7.2.1 (2017) on Fedora 26 (both
      x86-64 and x86).
      * lib-src/make-docfile.c (close_emacs_globals): lispsym is now
      just an array of struct Lisp_Symbol, since struct Lisp_Symbol is
      now properly aligned.  All uses changed.
      * src/alloc.c (NEXT_FREE_LISP_STRING): Just use the new u.next
      member; this is simpler and safer than casting a pointer that
      might not be aligned properly.
      (aligned_Lisp_Symbol): Remove.  No longer needed, now that struct
      Lisp_Symbol is aligned properly.  All uses replaced with struct
      Lisp_Symbol.
      * src/lisp.h (GCALIGNED): Remove, as it does not work as expected:
      it can cause the natural alignment to be ignored.  All uses
      replaced by unions with a ‘char alignas (GCALIGNMENT)’ member as
      described below.
      (struct Lisp_Symbol, struct Lisp_Cons, struct Lisp_String):
      Change definition from ‘struct TAG { MEMBERS };’ to
      ‘struct TAG { union { struct { MEMBERS } s; char alignas
      (GCALIGNMENT) gcaligned; } u; };’.  This guarantees ‘struct TAG’
      to have an alignment that at least max (GCALIGNMENT, N) where N is
      its old alignment.  All uses like ‘PTR->MEMBER’ changed to
      ‘PTR->u.s.MEMBER’; these uses were supposed to be mostly private
      anyway.  Verify that the resulting ‘struct TAG’ is properly
      aligned for Emacs.
      (union vectorlike_header): New member ‘gcaligned’ to guarantee
      that this type, and its containing types like ‘struct Lisp_Subr’,
      ‘struct buffer’ and ‘struct thread_state’, are all properly
      aligned for Emacs.
      (struct Lisp_String): New union member ‘next’, for the benefit
      of NEXT_FREE_LISP_STRING.
      (union Aligned_Cons, union Aligned_String): Remove.  All uses
      replaced by struct Lisp_Cons and struct Lisp_String, since they
      are now properly aligned.
      (USE_STACK_CONS, USE_STACK_STRING): Simplify now that we can
      assume struct Lisp_Cons and struct Lisp_String are properly
      aligned.
      b1573a97
  24. 10 Nov, 2017 1 commit
    • Paul Eggert's avatar
      Fix off-by-1 bug in --enable-checking=stringbytes · 05aa6d4a
      Paul Eggert authored
      Evidently nobody builds Emacs with --enable-checking=all,
      which is no surprise as it is so slow as to be unusable nowadays.
      Perhaps we should remove the slowest checks, or move them into
      another category, or speed them up, or something.
      * src/alloc.c (SDATA_SIZE) [GC_CHECK_STRING_BYTES]: Fix off-by-one
      error in size calculation, which caused a failure when
      --enable-checking=stringbytes was used.  I introduced this bug in
      2016-09-08T01:08:45!eggert@cs.ucla.edu "Port flexible array
      members to GCC + valgrind".
      05aa6d4a
  25. 04 Nov, 2017 1 commit
    • Eli Zaretskii's avatar
      Allow 'make-string' callers force creation of multibyte strings · bd886c6f
      Eli Zaretskii authored
      * src/alloc.c (Fmake_string): Accept additional argument
      MULTIBYTE, and produce a multibyte string if it is non-nil.
      (make_event_array):
      * src/lread.c (read0):
      * src/editfns.c (Ftranslate_region_internal):
      * src/coding.c (Fdefine_coding_system_internal):
      * src/cmds.c (internal_self_insert):
      * src/xdisp.c (build_desired_tool_bar_string)
      (store_mode_line_string): All C callers changed.
      
      * doc/lispref/strings.texi (Creating Strings): Document the new
      optional argument.
      
      * etc/NEWS: Mention the new optional argument.
      
      * lisp/ruler-mode.el (ruler-mode-ruler): Call make-string with the
      3rd argument non-nil.
      bd886c6f
  26. 02 Nov, 2017 2 commits
    • Paul Eggert's avatar
      Fix alignment portability problems · 6b08ad52
      Paul Eggert authored
      Do not assume that the natural alignment of Lisp objects is a
      multiple of GCALIGNMENT.  This improves on the portability of the
      recent fix for Bug#29040.
      * lib-src/make-docfile.c (close_emacs_globals):
      * src/buffer.c (buffer_defaults, buffer_local_symbols):
      * src/lisp.h (DEFUN):
      * src/thread.c (main_thread):
      Use GCALIGNED, not alignas (GCALIGNMENT).
      * src/alloc.c (COMMON_MULTIPLE):
      Move back here from lisp.h, since it is no longer used elsewhere.
      * src/lisp.h (GCALIGNMENT): No longer a macro, since we need not
      worry about MSVC.  Omit no-longer-needed consistency check.
      * src/thread.c (THREAD_ALIGNMENT): Remove.
      6b08ad52
    • Eli Zaretskii's avatar
      9031dec5