1. 24 Feb, 2019 1 commit
    • Philipp Stephani's avatar
      Ignore pending_signals when checking for quits. · 72ec233f
      Philipp Stephani authored
      pending_signals is often set if no quit is pending.  This results in
      bugs in module code if the module returns but no quit is actually
      pending.
      
      As a better alternative, add a new process_input environment function
      for Emacs 27.  That function processes signals (like maybe_quit).
      
      * configure.ac: Add module snippet for Emacs 27.
      
      * src/module-env-27.h: New file.
      
      * src/emacs-module.h.in: Add process_input function to environment
      interface.
      
      * src/emacs-module.c (module_should_quit): Use QUITP macro to check
      whether the caller should quit.
      (module_process_input): New function.
      (initialize_environment): Use it.
      
      * src/eval.c: Remove obsolete comment.
      
      * test/data/emacs-module/mod-test.c (signal_wrong_type_argument)
      (signal_errno): New helper functions.
      (Fmod_test_sleep_until): New test module function.
      
      * test/src/emacs-module-tests.el (mod-test-sleep-until): New unit
      test.
      
      * doc/lispref/internals.texi (Module Misc): Document process_input.
      72ec233f
  2. 15 Jan, 2019 1 commit
    • Daniel Colascione's avatar
      Add portable dumper · d12e5d00
      Daniel Colascione authored
      Add a new portable dumper as an alternative to unexec.  Use it by default.
      
      * src/dmpstruct.awk: New file.
      * src/doc.c (get_doc_string): use will_dump_p().
      * src/editfns.c (styled_format): silence compiler warning
      with UNINIT.
      * src/emacs-module.c (syms_of_module): staticpro ltv_mark.
      * src/emacs.c (gflags): new variable.
      (init_cmdargs): unwrap
      (string_starts_with_p, find_argument, dump_error_to_string)
      (load_pdump): new functions.
      (main): detect pdumper and --temacs invocation; actually load
      portable dump when detected; set gflags as appropriate; changes to
      init functions throughout to avoid passing explicit
      'initialized' argument.
      * src/eval.c (inhibit_lisp_code): remove unused variable.
      (init_eval_once_for_pdumper): new function.
      (init_eval_once): call it.
      * src/filelock.c: CANNOT_DUMP -> will_dump_p()
      * src/fingerprint-dummy.c: new file
      * src/fingerprint.h: new file
      * src/fns.c: CANNOT_DUMP -> will_dump_p(), etc.
      (weak_hash_tables): remove
      (hashfn_equal, hashfn_eql): un-staticify
      (make_hash_table): set new 'next_weak' hash table field; drop
      global weak_hash_tables logic.
      (copy_hash_table): drop global weak_hash_tables logic.
      (hash_table_rehash): new function.
      (hash_lookup, hash_put, hash_remove_from_table, hash_clear):
      rehash if needed.
      (sweep_weak_table): un-staticify; explain logic; bool-ify.
      (sweep_weak_hash_tables): remove function.
      * src/font.c (syms_of_font): remember pdumper stuff.
      * src/fontset.c (syms_of_fontset): remember pdumper stuff.
      * src/frame.c (make_initial_frame): don't reset Vframe_list.
      (init_frame_once_for_pdumper, init_frame_once): new functions.
      (syms_of_frame): remove redundant staticpro.
      * src/fringe.c (init_fringe_once_for_pdumper): new functin.
      (init_fringe_once): call it.
      * src/ftcrfont.c (syms_of_ftcrfont_for_pdumper): new function.
      (syms_of_ftcrfont): call it.
      * src/ftfont.c (syms_of_ftfont_for_pdumper): new function.
      (syms_of_ftfont): call it.
      * src/ftxont.c (syms_of_ftxfont_for_pdumper): new function.
      (syms_of_ftxfont): call it.
      * src/gmalloc.c: adjust for pdumper througout
      (DUMPED): remove weird custom dumped indicator.
      * src/gnutls.c (syms_of_gnutls): pdumper note for
      gnutls_global_initialized.
      * src/image.c (syms_of_image): add pdumper comment,
      initializer note.
      * src/insdel.c (prepare_to_modify_buffer_1): account
      for buffer contents possibly being in dump image.
      * src/keyboard.c (syms_of_keyboard_for_pdumper): new function.
      (syms_of_keyboard): staticpro more; call pdumper syms function.
      * src/lisp.h: add comments throughout
      (gflags): declare.
      (will_dump_p, will_bootstrap_p, will_dump_with_pdumper_p)
      (dumped_with_pdumper_p, will_dump_with_unexec_p)
      (dumped_with_unexec_p, definitely_will_not_unexec_p): new
      functions.
      (POWER_OF_2, ROUNDUP): move macros.
      (PSEUDOVECTOR_TYPE, PSEUDOVECTOR_TYPEP): take vectorlike header
      pointer instead of vector; constify.
      (Lisp_Hash_Table): add comment about need to rehash on access; add
      comment for next_weak.
      (HASH_KEY, HASH_VALUE, HASH_HASH, HASH_TABLE_SIZE): const-ify.
      (hash_table_rehash): declare.
      (hash_rehash_needed_p, hash_rehash_if_needed): new functions.
      (finalizers, doomed_finalizers): declare extern.
      (SUBR_SECTION_ATTRIBUTE): new macro.
      (staticvec, staticidx): un-static-ify.
      (sweep_weak_hash_tables): remove declaration.
      (sweep_weak_table): declare.
      (hashfn_eql, hashfn_equal): declare.
      (number_finalizers_run): new variable.
      (Vdead): externify when ENABLE_CHECKING.
      (gc_root_type): new enumeration.
      (gc_root_visitor): new struct.
      (visit_static_gc_roots): declare.
      (vectorlike_nbytes): declare.
      (vector_nbytes): define as trivial inline function wrapper for
      vectorlike_nbytes.
      (init_obarray_once): change signature.
      (primary_thread): extern-ify.
      (init_buffer): change signature.
      (init_frame_once): declare.
      * src/lread.c (readevalloop): adjust for new dumped predicates.
      (init_obarray_once): new function.
      (ndefsubr): new variable.
      (defsubr): increment it.
      (load_path_check): adjust for pdumper.
      (load_path_default): use pdumper functions; adjust for
      dump search.
      * src/macfont.m (macfont_init_font_change_handler): avoid
      shadowing global.
      (syms_of_macfont_for_pdumper): new function.
      (syms_of_macfont): call it.
      * src/menu.c (syms_of_menu): staticpro more stuff.
      * src/minibuf.c (Ftry_completion): rehash if needed.
      (init_minibuf_once_for_pdumper): new function.
      (init_minibuf_once): call it.
      * src/nsfont.m (syms_of_nsfns): staticpro more.
      * src/nsfont.m (syms_of_nsfont_for_pdumper): new function.
      (syms_of_nsfont): call it.
      * src/nsterm.m (syms_of_nsfont): remember pdumper stuff.
      * src/pdumper.c: new file.
      * src/pdumper.h: new file.
      * src/process.c (init_process_emacs): use new pdumper functions
      instead of CANNOT_DUMP.
      * src/profiler.c (syms_of_profiler_for_pdumper): new function.
      (syms_of_profiler_for_pdumper): call it.
      * src/search.c (syms_of_search_for_pdumper): new function.
      (syms_of_search_for_pdumper): call it.
      * src/sheap.c (bss_sbrk_did_unexec): remove.
      * src/sheap.h (bss_sbrk_did_unexec): remove.
      * src/syntax.c (syms_of_syntax): don't redundantly staticpro
      re_match_object.
      * src/sysdep.c: use will_dump_with_unexec_p() instead of bss
      hack thing.
      * src/syssignals.h (init_sigsegv): declare.
      * src/systime.h (init_timefns): remove bool from signature.
      * src/textprop.c (syms_of_textprop): move staticpro.
      * src/thread.c (main_thread_p): constify.
      * src/thread.h (main_thread_p): constify.
      * src/timefns.c (init_timefns): remove bool from signature.
      (syms_of_timefns_for_pdumper): new function.
      (syms_of_timefns): call it.
      * src/w32.c: rearrange code.
      * src/w32.h (w32_relocate): declare.
      * src/w32fns.c (syms_of_w32fns): add pdumper note.
      * src/w32font.c (syms_of_w32font_for_pdumper): new function.
      (syms_of_w32font): call it.
      * src/w32heap.c (using_dynamic_heap): new variable.
      (init_heap): use it.
      * src/w32menu.c (syms_of_w32menu): add pdumper note.
      * src/w32proc.c
      (ctrl_c_handler, mainCRTStartup, _start, open_input_file)
      (rva_to_section, close_file_data): move here.
      * src/w32uniscribe.c (syms_of_w32uniscribe_for_pdumper):
      new function.
      (syms_of_w32uniscribe): call it.
      * src/window.c (init_window_once_for_pdumper): new function.
      (init_window_once): call it; staticpro more stuff.
      * src/xfont.c (syms_of_xfont_for_pdumper): new function.
      (syms_of_xfont): call it.
      * src/xftfont.c (syms_of_xftfont_for_pdumper): new function.
      (syms_of_xftfont): call it.
      * src/xmenu.c (syms_of_xmenu_for_pdumper): new function.
      (syms_of_xmenu): call it.
      * src/xselect.c (syms_of_xselect_for_pdumper): new function.
      (syms_of_xselect): call it.
      * src/xsettings.c (syms_of_xsettings): add more pdumper notes.
      * src/term.c (syms_of_xterm): add pdumper note.
      
      * src/dispnew.c (init_faces_initial): new function.
      (init_display_interactive): rename from init_display; use
      will_dump_p instead of !initialized.  Initialize faces early for
      pdumper if needed.
      (init_display): new function.
      (syms_of_display_for_pdumper): new function.
      (syms_of_display): call it.
      
      * src/dbusbind.c (syms_of_dbusbind): Add TODO for bus reset
      on pdumper load.
      
      * src/data.c (Fdefalias): Use will_dump_p
      instead of Vpurify_flag.
      (Fmake_variable_buffer_local): silence compiler warning with -Og
      by making valcontents UNINIT.
      (arith_driver): silence compiler warning with UNINIT.
      
      * src/conf_post.h (ATTRIBUTE_SECTION): new macro.
      
      * src/composite.c (composition_gstring_put_cache): rehash hash
      table if needed.
      
      * src/coding.c (init_coding_once, syms_of_coding): remember
      pdumper stuff.
      
      * src/charset.h (charset_table_size, charset_table_user): declare.
      
      * src/charset.c (charset_table_used, charset_table_size): un-static.
      (init_charset_oncem, syms_of_charset): remember pdumper stuff.
      
      * src/category.c (category_table_version): remove obsolete
      variable.
      
      * src/callint.c (syms_of_callint): staticpro 'preserved_fns'
      (init_callproc): use will_dump_p instead of !CANNOT_DUMP.
      
      * src/bytecode.c (exec_byte_code): rehash table tables if needed
      
      * src/buffer.c (alloc_buffer_text, free_buffer_text): account for
      pdumper
      (init_buffer_once): add TODO; remember stuff for pdumper.
      (init_buffer): don't take initialized argument; adjust
      for pdumper.
      
      * src/atimer.c (init_atimer): initialize subr only if
      !initialized.
      
      * src/alloc.c: (vector_marked_p, set_vector_marked)
      (vectorlike_marked_p, set_vectorlike_marked, cons_marked_p)
      (set_cons_marked, string_marked_p, set_string_marked)
      (symbol_marked_p, set_symbol_marked, interval_marked_p)
      (set_interval_marked): new accessor routines.  Use them
      instead of raw GC access throughout.
      (Vdead): make non-static when ENABLE_CHECKING.
      (vectorlike_nbytes): rename of 'vector_nbytes'; take a vectorlike
      header as input instead of a vector.
      (number_finalizers_run): new internal C variable.
      (mark_maybe_object): check for pdumper objects.
      (valid_pointer_p): don't be gratuitously inefficient under rr(1).
      (make_pure_c_string): add support for size_byte = -2 mode
      indicating that string data points into Emacs image rodata.
      (visit_vectorlike_root): visits GC roots embedded in
      vectorlike objects.
      (visit_buffer_root): visits GC roots embedded in
      our totally-not-a-buffer buffer global objects.
      (visit_static_gc_roots): visit GC roots in the Emacs data section.
      (mark_object_root_visitor): root callback used for conventional GC
      marking
      (weak_hash_tables): new internal variable for tracking found weak
      hash tables during GC.
      (mark_and_sweep_weak_table_contents): new weak hash table marking.
      (garbage_collect_1): use new GC root visitor machinery.
      (mark_vectorlike): accept a vectorlike_header instead of a
      Lisp_Vector.
      (mark_frame, mark_window, mark_hash_table): new functions.
      (mark_object): initialize 'm'; check for pdumper objects and use
      new mark-bit accessors throughout.  Remove some object-specific
      marking code and move to helper functions above.
      (survives_gc_p): check for pdumper objects.
      (gc-sweep): clear pdumper mark bits.
      (init_alloc_once_for_pdumper): new helper function for early init
      called both during normal init and pdumper load.
      (init_alloc_once): pdumper integration.
      
      * src/Makefile.in: Rewrite dumping for pdumper; add pdumper.o;
      invoke temacs with --temacs command line option; build dmpstruct.h
      from dmpstruct.awk; stop relying on CANNOT_DUMP; clean up pdumper
      intermediate files during build.
      
      * nextstep/Makefile.in: build emacs.pdmp into NS packages
      
      * lisp/startup.el: account for new '--temacs' and '--dump-file'
      command line option.
      
      * lisp/loadup.el: rewrite early init to account for pdumper; use
      injected 'dump-mode' variable (set via the new '--temacs' option)
      instead of parsing command line.
      
      * lisp/cus-start.el: Check 'dump-mode' instead of 'purify-flag',
      since the new 'dump-mode'
      
      * lib-src/make-fingerprint.c: new program
      
      * lib-src/Makefile.in: built make-fingerprint utility program
      
      * configure.ac: Add --with-pdumper toggle to control pdumper
      support; add --with-unexec toggle to control unexec support.
      Add --with-dumping option to control which dumping strategy we use
      by default.  Adjust for pdumper throughout.  Check for
      posix_madvise.
      
      * Makefile.in: Add @DUMPING@ substitution; add pdumper mode.
      
      * .gitignore: Add make-fingerprint, temacs.in, fingerprint.c,
      dmpstruct.h, and pdumper dump files.
      d12e5d00
  3. 09 Jan, 2019 1 commit
    • Paul Eggert's avatar
      Use shortcuts for Flength · a8465033
      Paul Eggert authored
      When calculating the length of a Lisp object whose type is
      known, use a specialized length operation on it to save a bit
      of runtime overhead.
      * src/callint.c (Fcall_interactively):
      * src/minibuf.c (read_minibuf_unwind):
      Use ASIZE rather than Flength on values that must be vectors.
      * src/charset.c (Fsort_charsets):
      * src/coding.c (detect_coding_sjis):
      (Fdefine_coding_system_internal):
      * src/data.c (wrong_choice):
      * src/eval.c (Flet, eval_sub, Fapply, apply_lambda):
      * src/fns.c (sort_list):
      * src/font.c (font_vconcat_entity_vectors)
      (font_find_for_lface):
      * src/frame.c (Fmodify_frame_parameters):
      * src/fringe.c (get_logical_fringe_bitmap):
      * src/ftfont.c (ftfont_get_open_type_spec):
      * src/gtkutil.c (xg_print_frames_dialog):
      * src/lread.c (read1, read_vector):
      * src/keymap.c (Fkey_description):
      * src/kqueue.c (Fkqueue_add_watch):
      * src/macfont.m (macfont_get_open_type_spec):
      * src/menu.c (parse_single_submenu, x_popup_menu_1):
      * src/minibuf.c (Finternal_complete_buffer):
      * src/nsfont.m (ns_findfonts, nsfont_list_family):
      * src/process.c (Fmake_process):
      * src/search.c (Fset_match_data):
      * src/xfaces.c (Fx_family_fonts):
      Use list_length rather than Flength on values that must be lists.
      * src/fns.c (list_length): New function.
      (Flength): Use it.
      * src/nsfont.m (ns_findfonts):
      Use !NILP (x) rather than XFIXNUM (Flength (x)) != 0.
      * src/xdisp.c (store_mode_line_string):
      Use SCHARS rather than Flength on values that must be strings.
      a8465033
  4. 01 Jan, 2019 1 commit
  5. 31 Oct, 2018 1 commit
    • Paul Eggert's avatar
      Improve fix for Bug#33014 · cf486a7a
      Paul Eggert authored
      Although the previously-applied fix worked for its platform,
      it doesn’t suffice in general.
      * src/bytecode.c (exec_byte_code): Save VECTOR into stack slot
      so that it survives GC.  The stack slot was otherwise unused,
      so this doesn’t cost us memory, only a store insn.
      * src/eval.c (Ffuncall): Do not make FUN volatile, reverting
      2018-10-14T19:12:04Z!gazally@runbox.com.  Adding ‘volatile’
      does not suffice, since storage for a volatile local can be
      reclaimed after its last access (e.g., by tail recursion
      elimination), which would make VECTOR invisible to GC.
      cf486a7a
  6. 29 Oct, 2018 1 commit
  7. 14 Oct, 2018 1 commit
    • Paul Eggert's avatar
      Fix lisp_eval_depth in unwind-protect cleanup · f1ea2b9e
      Paul Eggert authored
      Problem reported by Paul Pogonyshev (Bug#33034).
      * src/lisp.h (union specbinding): New member unwind.eval_depth.
      * src/eval.c (record_unwind_protect, set_unwind_protect): Set it.
      (do_one_unbind): Use it.
      f1ea2b9e
  8. 07 Oct, 2018 1 commit
  9. 17 Sep, 2018 1 commit
  10. 11 Sep, 2018 1 commit
    • Paul Eggert's avatar
      Use overflow-error for bignum overflow · fa3785ea
      Paul Eggert authored
      This better corresponds to what emacs-26 did in the
      rare cases where it checked for integer overflow.
      * src/alloc.c (range_error): Remove.
      All uses changed to overflow_error.
      * src/eval.c (overflow_error): New function.
      fa3785ea
  11. 09 Sep, 2018 1 commit
    • Gemini Lasswell's avatar
      Show backtraces of threads from thread list buffer · 3fb8f306
      Gemini Lasswell authored
      * src/eval.c (backtrace_thread_p, backtrace_thread_top)
      (backtrace_thread_next, Fbacktrace_frames_from_thread): New functions.
      * lisp/thread.el (thread-list-mode-map): Add keybinding and
      menu item for 'thread-list-pop-to-backtrace'.
      (thread-list-mode): Make "Thread Name" column wide enough
      for the result of printing a thread with no name with 'prin1'.
      (thread-list--get-entries): Use 'thread-list--name'.
      (thread-list--send-signal): Remove unnecessary calls to 'threadp'.
      (thread-list-backtrace--thread): New variable.
      (thread-list-pop-to-backtrace): New command.
      (thread-list-backtrace--revert-hook-function)
      (thread-list--make-backtrace-frame)
      (thread-list-backtrace--insert-header, thread-list--name): New
      functions.
      3fb8f306
  12. 04 Sep, 2018 1 commit
  13. 28 Aug, 2018 1 commit
    • Eli Zaretskii's avatar
      Avoid crashes in malformed defvar · 63e59c8c
      Eli Zaretskii authored
      * src/eval.c (Fdefvar): Don't call XSYMBOL on something that
      might not be a symbol.  This avoids crashes due to malformed
      'defvar' forms.  (Bug#32552)
      63e59c8c
  14. 08 Aug, 2018 1 commit
    • Tom Tromey's avatar
      More macro renamings for bignum · d1ec3a0a
      Tom Tromey authored
      * src/alloc.c, src/bidi.c, src/buffer.c, src/buffer.h, src/bytecode.c,
      src/callint.c, src/callproc.c, src/casefiddle.c, src/casetab.c,
      src/category.c, src/ccl.c, src/character.c, src/character.h,
      src/charset.c, src/charset.h, src/chartab.c, src/cmds.c, src/coding.c,
      src/composite.c, src/composite.h, src/data.c, src/dbusbind.c,
      src/decompress.c, src/dired.c, src/dispextern.h, src/dispnew.c,
      src/disptab.h, src/doc.c, src/dosfns.c, src/editfns.c,
      src/emacs-module.c, src/emacs.c, src/eval.c, src/fileio.c,
      src/floatfns.c, src/fns.c, src/font.c, src/font.h, src/fontset.c,
      src/frame.c, src/frame.h, src/fringe.c, src/ftcrfont.c, src/ftfont.c,
      src/gfilenotify.c, src/gnutls.c, src/gtkutil.c, src/image.c,
      src/indent.c, src/insdel.c, src/intervals.c, src/json.c,
      src/keyboard.c, 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/syntax.h, src/sysdep.c, src/term.c,
      src/termhooks.h, src/textprop.c, src/undo.c, src/w32.c,
      src/w32console.c, src/w32fns.c, src/w32font.c, src/w32inevt.c,
      src/w32proc.c, src/w32select.c, src/w32term.c, src/w32term.h,
      src/w32uniscribe.c, src/window.c, src/xdisp.c, src/xfaces.c,
      src/xfns.c, src/xfont.c, src/xftfont.c, src/xmenu.c, src/xml.c,
      src/xrdb.c, src/xselect.c, src/xsettings.c, src/xterm.c, src/xwidget.c
      Rename XINT->XFIXNUM, XFASTINT->XFIXNAT, XUINT->XUFIXNUM.
      d1ec3a0a
  15. 24 Jul, 2018 1 commit
    • Paul Eggert's avatar
      Move proper-list-p to C · 200195e8
      Paul Eggert authored
      Since C code can use it and it’s simple, we might as well use C.
      * lisp/subr.el (proper-list-p): Move to C code.
      * src/eval.c (signal_error): Simplify by using Fproper_list_p.
      * src/fns.c (Fproper_list_p): New function, moved here from Lisp.
      
      Simplify signal_error
      * src/eval.c (signal_error): Simplify by using FOR_EACH_TAIL_SAFE.
      200195e8
  16. 13 Jul, 2018 1 commit
    • 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
  17. 30 Jun, 2018 2 commits
    • Gemini Lasswell's avatar
      Increase max-lisp-eval-depth adjustment while in debugger (bug#31919) · 4bd43b03
      Gemini Lasswell authored
      * src/eval.c (call_debugger): Increase the amount of extra Lisp
      evaluation depth given to the debugger to allow it to call cl-print.
      * lisp/emacs-lisp/debug.el (debugger-setup-buffer): Add a comment
      to suggest updating call_debugger when changing print-level.
      4bd43b03
    • 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
  18. 28 Jun, 2018 1 commit
    • Paul Eggert's avatar
      Tune SAFE_FREE · 76eda952
      Paul Eggert authored
      On my platform (Fedora 28 x86-64, AMD Phenom II X4 910e) this sped
      up a SAFE_FREE-using microbenchmark (string-distance "abc" "abc")
      by about 18%, and shrank the Emacs text size by about 0.1%.
      * src/callint.c (Fcall_interactively):
      * src/callproc.c (call_process):
      * src/doc.c (get_doc_string, Fsnarf_documentation):
      * src/editfns.c (Freplace_buffer_contents):
      * src/emacs-module.c (funcall_module):
      * src/eval.c (Flet):
      * src/process.c (Fmake_process):
      * src/term.c (tty_menu_show):
      * src/xdisp.c (safe__call):
      * src/xmenu.c (x_menu_show):
      Use SAFE_FREE_UNBIND_TO.
      * src/data.c (wrong_choice): No need to call SAFE_FREE here.
      * src/lisp.h (USE_SAFE_ALLOCA):
      * src/regex.c (REGEX_USE_SAFE_ALLOCA):
      Do not declare sa_must_free local; no longer needed.
      All uses removed.
      (SAFE_FREE): Rewrite in terms of safe_free.
      (safe_free): New function, optimized to use xfree.
      (SAFE_FREE_UNBIND_TO): New macro.
      (safe_free_unbind_to): New function.
      76eda952
  19. 15 Jun, 2018 2 commits
    • 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
    • Paul Eggert's avatar
      Avoid allocating Lisp_Save_Value for excursions · aca938d1
      Paul Eggert authored
      * src/editfns.c (save_excursion_save): New arg PDL,
      specifying where to save the state.  All uses changed.
      (save_excursion_restore): Args are now the marker and info
      rather than a pointer to a Lisp_Save_Value containing them.
      All uses changed.
      * src/eval.c (default_toplevel_binding, Fbacktrace__locals):
      Treat excursions like other miscellaneous pdl types.
      (record_unwind_protect_excursion): Save data directly
      into the pdl rather than creating an object on the heap.
      This avoids the need to allocate and free an object.
      (do_one_unbind, backtrace_eval_unrewind):
      Unwind excursions directly.
      (mark_specpdl): Mark excursions directly.
      * src/lisp.h (SPECPDL_UNWIND_EXCURSION): New constant.
      (union specbinding): New member unwind_excursion.
      aca938d1
  20. 12 Jun, 2018 1 commit
  21. 08 Jun, 2018 1 commit
    • Paul Eggert's avatar
      New function record_unwind_protect_excursion · a0aa1d4e
      Paul Eggert authored
      This simplifies callers a bit, and will simplify future changes.
      * src/eval.c (record_unwind_protect_excursion): New function.
      * src/buffer.c (Fkill_buffer):
      * src/bytecode.c (exec_byte_code):
      * src/editfns.c (Fsave_excursion, Freplace_buffer_contents):
      * src/lread.c (readevalloop, Feval_buffer):
      * src/window.c (scroll_command):
      Use it.
      a0aa1d4e
  22. 16 Apr, 2018 1 commit
  23. 25 Mar, 2018 1 commit
    • Noam Postavsky's avatar
      Allow `&rest' or `&optional' without following variable (Bug#29165) · 1d47d777
      Noam Postavsky authored
      This is sometimes convenient when writing macros, so that the empty
      variable case doesn't need to be handled specially.  Older versions of
      Emacs accepted this in some cases (especially the interpreter in Emacs
      25 and below was very accepting).
      
                                  |   interpreted/compiled   |
      | arglist                   | 25 & earlier | 26  | 27  |
      |---------------------------+--------------+-----+-----|
      | (&rest)                   | y/n          | n/n | y/y |
      | (&rest &rest)             | y/n          | n/n | n/n |
      | (&rest &rest x)           | y/n          | n/n | n/n |
      | (&rest x &rest)           | y/n          | n/n | n/n |
      | (&rest x &rest y)         | y/n          | n/n | n/n |
      |---------------------------+--------------+-----+-----|
      | (&optional)               | y/n          | n/n | y/y |
      | (&optional &optional)     | y/n          | n/n | n/n |
      | (&optional x &optional)   | y/n          | n/n | n/n |
      | (&optional x &optional y) | y/y          | n/n | n/n |
      |---------------------------+--------------+-----+-----|
      | (&optional &rest)         | y/n          | n/n | y/y |
      | (&optional x &rest)       | y/n          | n/n | y/y |
      | (&optional &rest y)       | y/y          | n/n | y/y |
      |---------------------------+--------------+-----+-----|
      | (&rest &optional)         | y/n          | n/n | n/n |
      | (&rest &optional y)       | y/n          | n/n | n/n |
      | (&rest x &optional y)     | y/n          | n/n | n/n |
      
      The values in the table above can be produced with the following code:
      
      (with-current-buffer (get-buffer-create "*ck-args*")
        (erase-buffer)
        (dolist (arglist '((&rest)
                           (&rest &rest)
                           (&rest &rest x)
                           (&rest x &rest)
                           (&rest x &rest y)
                           (&optional)
                           (&optional &optional)
                           (&optional x &optional)
                           (&optional x &optional y)
                           (&optional &rest)
                           (&optional x &rest)
                           (&optional &rest y)
                           (&rest &optional)
                           (&rest &optional y)
                           (&rest x &optional y)))
          (insert
           (format "%c/%c\n"
                   (condition-case err
                       (progn (funcall `(lambda ,arglist 'ok))
                              ?y)
                     (error ?n))
                   (condition-case err
                       (progn (byte-compile-check-lambda-list arglist)
                              ?y)
                     (error ?n))))
          (display-buffer (current-buffer))))
      
      * src/eval.c (funcall_lambda):
      * lisp/emacs-lisp/bytecomp.el (byte-compile-check-lambda-list): Don't
      check for missing variables after `&rest' and `&optional'.
      * test/src/eval-tests.el (eval-tests--bugs-24912-and-24913)
      (eval-tests-accept-empty-optional-rest): Update tests accordingly.
      * etc/NEWS: Update announcement accordingly.
      * doc/lispref/functions.texi (Argument List): Update manual to
      indicate that variable names are optional.
      1d47d777
  24. 17 Feb, 2018 1 commit
    • Noam Postavsky's avatar
      Avoid memory corruption with specpdl overflow + edebug (Bug#30481) · c352434a
      Noam Postavsky authored
      If grow_specpdl fails due to outgrowing max_specpdl_size, it will
      signal an error *before* growing the specpdl array.  Therefore, when
      handling the signal, specpdl_ptr points past the end of the specpdl
      array and any further use of of specpdl before unwinding (e.g., if
      edebug binds signal-hook-function) will cause memory corruption.
      * src/eval.c (signal_or_quit): Don't call `signal-hook-function' if
      the specpdl_ptr is already past the end of the specpdl array.
      * test/src/eval-tests.el (eval-tests--exceed-specbind-limit)
      (eval-exceed-specbind-with-signal-hook): New test & helper function.
      c352434a
  25. 01 Jan, 2018 1 commit
  26. 10 Dec, 2017 1 commit
    • Philipp Stephani's avatar
      Implement native JSON support using Jansson · ab203e36
      Philipp Stephani authored
      * configure.ac: New option --with-json.
      
      * src/json.c (Fjson_serialize, Fjson_insert, Fjson_parse_string)
      (Fjson_parse_buffer): New defuns.
      (json_malloc, json_free, json_has_prefix, json_has_suffix)
      (json_make_string, json_build_string, json_encode)
      (json_out_of_memory, json_parse_error)
      (json_release_object, check_string_without_embedded_nulls, json_check)
      (lisp_to_json, lisp_to_json_toplevel, lisp_to_json_toplevel_1)
      (json_insert, json_insert_callback, json_to_lisp)
      (json_read_buffer_callback, Fjson_parse_buffer, define_error): New
      helper functions.
      (init_json, syms_of_json): New file.
      
      * src/lisp.h: Declaration for init_json and syms_of_json.
      
      * src/emacs.c (main): Enable JSON functions.
      
      * src/eval.c (internal_catch_all, internal_catch_all_1): New helper
      functions to catch all signals.
      (syms_of_eval): Add uninterned symbol to signify out of memory.
      
      * src/Makefile.in (JSON_LIBS, JSON_CFLAGS, JSON_OBJ, EMACS_CFLAGS)
      (base_obj, LIBES): Compile json.c if --with-json is enabled.
      
      * test/src/json-tests.el (json-serialize/roundtrip)
      (json-serialize/object, json-parse-string/object)
      (json-parse-string/string, json-serialize/string)
      (json-parse-string/incomplete, json-parse-string/trailing)
      (json-parse-buffer/incomplete, json-parse-buffer/trailing): New unit
      tests.
      
      * doc/lispref/text.texi (Parsing JSON): New manual section.
      ab203e36
  27. 26 Nov, 2017 1 commit
  28. 13 Nov, 2017 1 commit
    • 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
  29. 25 Oct, 2017 1 commit
  30. 11 Oct, 2017 1 commit
  31. 02 Oct, 2017 1 commit
    • Paul Eggert's avatar
      Prefer HTTPS to HTTP for gnu.org · 5172fa02
      Paul Eggert authored
      This fixes some URLs I omitted from my previous pass,
      notably those in lists.gnu.org.  Although lists.gnu.org
      does not yet support TLS 1.1, TLS 1.0 is better than nothing.
      * lisp/erc/erc.el (erc-official-location):
      * lisp/mail/emacsbug.el (report-emacs-bug):
      Use https:, not http:.
      5172fa02
  32. 17 Sep, 2017 1 commit
  33. 13 Sep, 2017 1 commit
    • Paul Eggert's avatar
      Prefer HTTPS to FTP and HTTP in documentation · bc511a64
      Paul Eggert authored
      Most of this change is to boilerplate commentary such as license URLs.
      This change was prompted by ftp://ftp.gnu.org's going-away party,
      planned for November.  Change these FTP URLs to https://ftp.gnu.org
      instead.  Make similar changes for URLs to other organizations moving
      away from FTP.  Also, change HTTP to HTTPS for URLs to gnu.org and
      fsf.org when this works, as this will further help defend against
      man-in-the-middle attacks (for this part I omitted the MS-DOS and
      MS-Windows sources and the test tarballs to keep the workload down).
      HTTPS is not fully working to lists.gnu.org so I left those URLs alone
      for now.
      bc511a64
  34. 09 Sep, 2017 2 commits
    • Paul Eggert's avatar
      Improve --enable-gcc-warnings for MinGW64 · d6312354
      Paul Eggert authored
      This partially reverts my 2016-05-30 patch.  Apparently MinGW64
      still requires pacifications that GCC 7.1.1 x86-64 (Fedora 26)
      does not.  Also, pacify tparam.c, which isn’t used on Fedora.
      * lib-src/etags.c (process_file_name, TeX_commands):
      * src/buffer.c (fix_overlays_before):
      * src/data.c (Fmake_variable_buffer_local, cons_to_unsigned)
      (cons_to_signed):
      * src/editfns.c (Ftranslate_region_internal):
      Prefer UNINIT to some stray value, as this simplifies
      code-reading later.
      * src/eval.c (CACHEABLE): New macro.
      (internal_lisp_condition_case): Use it.
      * src/tparam.c (tparam1): Use FALLTHROUGH to pacify GCC.
      d6312354
    • Eli Zaretskii's avatar
      Fix compilation warnings in MinGW64 build using GCC 7 · 2b84c166
      Eli Zaretskii authored
      Reported by Richard Copley <rcopley@gmail.com>.
      * src/w32heap.c (init_heap): Declare enable_lfh only for
      mingw.org's MinGW build.
      
      * src/w32console.c (w32con_write_glyphs):
      * src/unexw32.c (get_section_info, COPY_CHUNK, unexec): Fix some
      mismatches of data type vs format spec.
      
      * src/w32fns.c (compute_tip_xy):
      * src/w32proc.c (stop_timer_thread):
      * src/w32notify.c (remove_watch):
      * src/eval.c (internal_lisp_condition_case):
      * src/editfns.c (Ftranslate_region_internal):
      * src/data.c (Fmake_variable_buffer_local, cons_to_unsigned)
      (cons_to_signed):
      * src/buffer.c (fix_overlays_before): Initialize variables to
      avoid compiler warnings.
      
      * lib-src/etags.c (TeX_commands, process_file_name): Initialize
      variables to avoid compilation warnings.
      2b84c166
  35. 12 Aug, 2017 1 commit
    • Michael Albinus's avatar
      Implement EXCL of write-region for Tramp · ec5cfaa4
      Michael Albinus authored
      * lisp/net/ange-ftp.el (ange-ftp-write-region):
      * lisp/net/tramp-adb.el (tramp-adb-handle-write-region)
      * lisp/net/tramp-gvfs.el (tramp-gvfs-handle-write-region):
      * lisp/net/tramp-sh.el (tramp-sh-handle-write-region)
      * lisp/net/tramp-smb.el (tramp-smb-handle-write-region):
      Implement MUSTBENEW.
      
      * lisp/net/tramp-gvfs.el (tramp-gvfs-do-copy-or-rename-file)
      * lisp/net/tramp-sh.el (tramp-sh-handle-make-symbolic-link)
      (tramp-sh-handle-add-name-to-file)
      (tramp-do-copy-or-rename-file)
      * lisp/net/tramp-smb.el (tramp-smb-handle-make-symbolic-link):
      Adapt error message for `file-already-exists'.
      
      * src/lisp.h:
      * src/eval.c (call8): New function.
      
      * src/fileio.c (write_region): Pass also lockname and
      mustbenew to the file name handler.
      
      * test/lisp/net/tramp-tests.el (tramp-test10-write-region):
      Add tests for MUSTBENEW.
      ec5cfaa4
  36. 06 Aug, 2017 1 commit
    • Paul Eggert's avatar
      Fix some crashes on self-modifying Elisp code · 93511e94
      Paul Eggert authored
      Prompted by a problem report by Alex in:
      http://lists.gnu.org/archive/html/emacs-devel/2017-08/msg00143.html
      * src/eval.c (For, Fprogn, Fsetq, FletX, eval_sub):
      Compute XCDR (x) near XCAR (x); although this doesn't fix any bugs,
      it is likely to run a bit faster with typical hardware caches.
      (Fif): Use Fcdr instead of XCDR, to avoid crashing on
      self-modifying S-expressions.
      (Fsetq, Flet, eval_sub): Count the number of arguments as we go
      instead of trusting an Flength prepass, to avoid problems when the
      code is self-modifying.
      (Fquote, Ffunction, Fdefvar, Fdefconst): Prefer !NILP to CONSP
      where either will do.  This is mostly to document the fact that
      the value must be a proper list.  It's also a tiny bit faster on
      typical machines nowadays.
      (Fdefconst, FletX): Prefer XCAR+XCDR to Fcar+Fcdr when either will do.
      (eval_sub): Check that the args are a list as opposed to some
      other object that has a length. This prevents e.g. (if . "string")
      from making Emacs dump core in some cases.
      * test/src/eval-tests.el (eval-tests--if-dot-string)
      (eval-tests--let-with-circular-defs, eval-tests--mutating-cond):
      New tests.
      93511e94
  37. 14 Jul, 2017 1 commit
    • Paul Eggert's avatar
      Improve stack-overflow heuristic on GNU/Linux · 9dee1c88
      Paul Eggert authored
      Problem reported by Steve Kemp (Bug#27585).
      * src/eval.c (near_C_stack_top): Remove.  All uses replaced
      by current_thread->stack_top.
      (record_in_backtrace): Set current_thread->stack_top.
      This is for when the Lisp interpreter calls itself.
      * src/lread.c (read1): Set current_thread->stack_top.
      This is for recursive s-expression reads.
      * src/print.c (print_object): Set current_thread->stack_top.
      This is for recursive s-expression printing.
      * src/thread.c (mark_one_thread): Get stack top first.
      * src/thread.h (struct thread_state.stack_top): Now void *, not char *.
      9dee1c88