summaryrefslogtreecommitdiff
path: root/src/eval.c
Commit message (Collapse)AuthorAgeFilesLines
* * src/eval.c (Fapply): Simplify last changeStefan Monnier2020-09-281-5/+1
|
* Handle single-argument `apply' consistently (bug#40968)Pip Cet2020-09-271-0/+6
| | | | | | | | | * src/eval.c (Fapply): Handle (apply nil) without crashing. Document single-argument form. * lisp/emacs-lisp/byte-opt.el (byte-optimize-apply): Don't attempt to optimize single-argument apply. * doc/lispref/functions.texi (Calling Functions): Document single-argument apply. Provide example (bug#40968).
* Fix builds without modulesGlenn Morris2020-09-131-0/+2
| | | | | * src/data.c (Finteractive_form): * src/eval.c (Fcommandp): Fix builds without modules.
* Add facility to make module functions interactive (Bug#23486).Philipp Stephani2020-09-131-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | * src/module-env-28.h: Add field for 'make_interactive' function. * src/emacs-module.c (Lisp_Module_Function): Add new field holding the interactive form. (allocate_module_function): Adapt to structure layout change. (module_make_interactive, module_function_interactive_form): New functions. (initialize_environment): Use them. * src/eval.c (Fcommandp): * src/data.c (Finteractive_form): Also handle interactive module functions. * test/data/emacs-module/mod-test.c (Fmod_test_identity): New test function. (emacs_module_init): Create two interactive module test functions. * test/src/emacs-module-tests.el (module/interactive/return-t) (module/interactive/return-t-int, module/interactive/identity): New unit tests. * doc/lispref/internals.texi (Module Functions): Document new function. Rework paragraph about wrapping module functions, as the example no longer applies. * etc/NEWS: Document new facility.
* Reinstall recent GC-related changesPaul Eggert2020-09-051-3/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | The report that they broke macOS was a false alarm, as the previous commit was also broken (Bug#43152#62). * src/alloc.c (live_string_holding, live_cons_holding) (live_symbol_holding): Count only pointers that point to a struct component, or are a tagged pointer to the start of the struct. Exception: for non-bool-vector pseudovectors, count any pointer past the header, since it’s too much of a pain to write code for every pseudovector. (live_float_holding, live_vector_pointer): New functions, which are similar about counting pointers. (live_float_p, live_large_vector_holding) (live_small_vector_pointer, mark_maybe_pointer): Use them. (mark_maybe_object, mark_maybe_objects): Remove, and remove all callers; mark_maybe_pointer now suffices. (mark_objects): New function. * src/alloc.c (mark_vectorlike, mark_face_cache): * src/eval.c (mark_specpdl): * src/fringe.c (mark_fringe_data): * src/keyboard.c (mark_kboards): Simplify by using mark_objects. * src/lisp.h (SAFE_ALLOCA_LISP_EXTRA): Clear any Lisp_Object arrays large enough to not fit into the stack, so that GC need not worry about whether they contain objects.
* Revert recent GC-related changes (Bug#43152)Paul Eggert2020-09-031-2/+3
| | | | | | | | | | | | | | | | | | * src/alloc.c (live_string_holding, live_cons_holding) (live_symbol_holding, live_large_vector_holding) (live_small_vector_holding): Go back to old approach of treating every would-be pointer to any byte in the object (though not to just past the object end) as addressing the object. (live_float_p): Require that the would-be float point to the start of the Lisp_Float, and not anywhere else. (live_vector_pointer, live_float_holding, mark_objects): Remove. All uses removed. (mark_maybe_object, mark_maybe_objects): Bring back these functions. * src/lisp.h (SAFE_ALLOCA_LISP_EXTRA): Do not clear the new slots, as they're now checked via mark_maybe_objects, not via mark_objects.
* Use mark_objects elsewhere tooPaul Eggert2020-08-311-2/+1
| | | | | | | | * src/alloc.c (mark_vectorlike, mark_face_cache): * src/eval.c (mark_specpdl): * src/fringe.c (mark_fringe_data): * src/keyboard.c (mark_kboards): Use mark_objects instead of doing it by hand.
* Remove mark_maybe_objectPaul Eggert2020-08-311-1/+1
| | | | | | | | | | | * src/alloc.c (mark_maybe_object, mark_maybe_objects): Remove. (mark_objects): New function. * src/eval.c (mark_specpdl): Use mark_objects instead of mark_maybe_objects, since the array now has only valid Lisp objects. * src/lisp.h (SAFE_ALLOCA_LISP_EXTRA): When allocating a large array, clear it so that it contains only valid Lisp objects. This is simpler and safer, and does not hurt performance significantly on my usual benchmark as the code is executed so rarely.
* Merge from origin/emacs-27Glenn Morris2020-06-261-0/+1
|\ | | | | | | | | | | | | | | | | | | | | | | | | 5280e118c0 (origin/emacs-27) ; * src/xdisp.c (pos_visible_p): Fix las... bb1a9481c9 Fix posn-at-point at beginning of a display string 0c4b033670 Improve documentation of Info node movement commands 632b0119e1 Add Jansson dependency to Windows Build dbfcdab837 Unbreak 'reverse-region' c37de84845 Fix typos and markup in fill column indicator docs f61bff3ee9 ; * CONTRIBUTE: Clarify the preferences for patch formatting. 368e140660 Avoid crashes in 'defconst' 11e3413cff Fix text about Lisp archives in the Emacs FQ 4c81724675 Don't use 'cl' functions in ELisp manual's examples
| * Avoid crashes in 'defconst'Stephen Berman2020-06-201-0/+1
| | | | | | | | | | * src/eval.c (Fdefconst): Verify that SYMBOL is a known symbol. (Bug#41817)
* | Restore check for Emacs 20.2 bytecodesPaul Eggert2020-05-231-1/+13
| | | | | | | | | | | | * src/eval.c (Ffetch_bytecode): Check for multibyte bytecodes here too. Problem reported by Stefan Monnier in: https://lists.gnu.org/r/emacs-devel/2020-05/msg02876.html
* | Hoist some byte-code checking out of evalPaul Eggert2020-05-191-29/+19
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Check Lisp_Compiled objects better as they’re created, so that the byte-code interpreter needn’t do the checks each time it executes them. This improved performance of ‘make compile-always’ by 1.5% on my platform. Also, improve the quality of the (still-incomplete) checks, as this is more practical now that they’re done less often. * src/alloc.c (make_byte_code): Remove. All uses removed. (Fmake_byte_code): Put a better (though still incomplete) check here instead. Simplify by using Fvector instead of make_uninit_vector followed by memcpy, and by using XSETPVECTYPE instead of make_byte_code followed by XSETCOMPILED. * src/bytecode.c (Fbyte_code): Do sanity check and conditional translation to unibyte here instead of each time the function is executed. (exec_byte_code): Omit no-longer-necessary sanity and unibyte checking. Use SCHARS instead of SBYTES where either will do, as SCHARS is faster. * src/eval.c (fetch_and_exec_byte_code): New function. (funcall_lambda): Use it. (funcall_lambda, lambda_arity, Ffetch_bytecode): Omit no-longer-necessary sanity checks. (Ffetch_bytecode): Add sanity check if actually fetching. * src/lisp.h (XSETCOMPILED): Remove. All uses removed. * src/lread.c (read1): Check byte-code objects more thoroughly, albeit still incompletely, and do translation to unibyte here instead of each time the function is executed. (read1): Use XSETPVECYPE instead of make_byte_code. (read_vector): Omit no-longer-necessary sanity check.
* ; Fix some typos and doc issues (bug#40695)Štěpán Němec2020-04-181-1/+1
|
* Don't signal during backtrace unrewind (Bug#40088)Noam Postavsky2020-03-221-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | backtrace_eval_unrewind is used to temporarily reverse let-bindings (it's called with a positive argument to reverse bindings, and then a negative argument to re-apply them) by backtrace--locals and backtrace-eval. For the SPECPDL_LET_DEFAULT and SPECPDL_LET_LOCAL cases (which occur for let-bindings on buffer-local variables), the code calls Fdefault_value and Fbuffer_local_value on the symbol. For symbols which are unbound at top-level, the first (with positive argument) call to backtrace_eval_unrewind will set the symbol's value to unbound (putting the current value in the specpdl's "old value" slot). On the second (with negative argument) call, backtrace_eval_unrewind attempts to retrieve the symbol's value with Fdefault_value or Fbuffer_local_value, but that raises a void-variable signal. This interrupts the restoration of the let-bindings, so any other variables more recent on the stack will now have the wrong value. * src/data.c (default_value): Make non-static. * src/lisp.h: Declare it. * src/eval.c (backtrace_eval_unrewind): Replace the calls to Fdefault_value and Fbuffer_local_value with default_value and buffer_local_value, respectively. The latter do exactly the same as the former, except if the symbol's value is Qunbound they just return it instead of signaling void-variable.
* Revert "Raise default max-specpdl-size value"Mattias Engdegård2020-01-011-1/+1
| | | | This reverts commit bb9402e6e9c12938aee31b81e25511eb1f6335d2.
* Raise default max-specpdl-size valueMattias Engdegård2020-01-011-1/+1
| | | | | | | | | Occasionally, loading cl-generic.el from source requires max_specpdl_size > 1600 when bootstrapping, and thus fails. In any case we are very close to the limit. * src/eval.c (init_eval_once): Raise max_specpdl_size to 1800. * doc/lispref/variables.texi (Local Variables): Update docs.
* Update copyright year to 2020Paul Eggert2020-01-011-1/+1
| | | | Run "TZ=UTC0 admin/update-copyright $(git ls-files)".
* Bump up max_specpdl_size to 1600Juanma Barranquero2019-10-011-1/+1
| | | | | * src/eval.c (init_eval_once): Set max_specpdl_size to 1600. * doc/lispref/variables.texi (Local Variables): Document it.
* Remove obsolete Lint directivesPaul Eggert2019-09-161-9/+0
| | | | | | | | | | | | | Most of the directives were wrong anyway. Apparently traditional lint hasn’t been used to check Emacs for years. * src/callint.c (Finteractive): * src/cm.c (evalcost): * src/emacs.c (main): * src/eval.c (call1, call2, call3, call4, call5, call6, call7, call8): * src/fns.c (concat2, concat3, nconc2): * src/term.c (calculate_ins_del_char_costs): Omit ARGSUSED comments. * src/eval.c (call1): Omit VARARGS comment.
* Attempt to fix assertion violation in eval.cEli Zaretskii2019-08-181-1/+1
| | | | | * src/eval.c (Fautoload): Fix an assertion violation in make_fixnum. Reported by martin rudalics <rudalics@gmx.at>.
* Say that while returns nilLars Ingebrigtsen2019-08-011-0/+3
| | | | | * src/eval.c (Fwhile): Say that while always returns nil (bug#22006).
* Avoid intern calls for builtin symsPaul Eggert2019-07-311-1/+1
| | | | | | * src/casefiddle.c (Fdowncase_region): * src/eval.c (Fdefvaralias): Use builtin symbol rather than calling intern.
* Fix lifetime error in previous patchPaul Eggert2019-07-211-0/+16
| | | | | | | | | | | | | Problem reported by Pip Cet in: https://lists.gnu.org/r/emacs-devel/2019-07/msg00520.html * src/alloc.c (inhibit_garbage_collection): Use new function. (allow_garbage_collection): Accept intmax_t, not pointer. * src/eval.c (default_toplevel_binding, do_one_unbind) (backtrace_eval_unrewind, Fbacktrace__locals, mark_specpdl): Support SPECPDL_UNWIND_INTMAX. (record_unwind_protect_excursion): New function. * src/lisp.h (enum specbind_tag): New constant SPECPDL_UNWIND_INTMAX. (union specbinding): New member unwind_intmax.
* Do not alter match data in Fcapitalize etc.Paul Eggert2019-07-091-4/+1
| | | | | | | | | | | | | Without this patch, (capitalize "x") can alter the match data, which is not what users expect. Problem found by running morse-tests-unnato-region in a stripped-down Emacs. Perhaps ‘load’ should also save and restore the match data? That would be a simpler fix, though arguably incompatible. * src/lread.c (save_match_data_load): New function. * src/chartab.c (uniprop_table): * src/doc.c (reread_doc_file): * src/eval.c (Fautoload_do_load): * src/fns.c (Frequire): Use it.
* Avoid some unnecessary stdio.h includesPaul Eggert2019-07-081-1/+0
| | | | | | | | | * src/atimer.c, src/callproc.c, src/coding.c, src/dired.c, src/eval.c: * src/fringe.c, src/ftcrfont.c, src/ftfont.c, src/ftxfont.c: * src/gfilenotify.c, src/indent.c, src/kqueue.c, src/menu.c: * src/scroll.c, src/terminal.c, src/unexcoff.c, src/window.c: * src/xfont.c, src/xftfont.c: Do not include stdio.h since it is unused.
* Bump up max_specpdl_size to 1500. (Bug#36216)Juanma Barranquero2019-06-161-1/+1
| | | | | * src/eval.c (init_eval_once): Set max_specpdl_size to 1500. * doc/lispref/variables.texi (Local Variables): Document it.
* Improve documentation of the 'function' special formMichael Heerdegen2019-05-241-2/+2
| | | | | | | | Point out that 'function' quoting is beneficial also for symbols. * src/eval.c (function): Enhance docstring. * doc/lispref/functions.texi (Anonymous Functions): Improve documentation.
* * lisp/custom.el: Avoid adding vars to load-history multiple timesStefan Monnier2019-05-061-22/+28
| | | | | | | | | | | | | | | Avoid the abuse of (eval `(defvar ...)) which tends to end up adding redundant entries in `load-history`, as discussed in https://lists.gnu.org/r/help-gnu-emacs/2019-03/msg00237.html (custom-initialize-default): Don't add to load-history. (custom-declare-variable): Use internal--define-uninitialized-variable and only add the var to load-history once. Do it before calling `initialize` so the special-variable-p flag is set. * src/eval.c (Finternal__define_uninitialized_variable): New function. (Fdefvar, Fdefconst): Use it. (syms_of_eval): Defsubr' it.
* Revert Vinternal_interpreter_environment tweakPaul Eggert2019-04-221-2/+2
| | | | | | | | Stefan Monnier pointed out examples like (funcall `(closure ,(let ((cycle (list nil))) (setcdr cycle cycle)) () a)), where the user can set Vinternal_interpreter_environment indirectly. * src/eval.c (Fsetq): Revert recent change, going back to Fassq.
* Tweak Vinternal_interpreter_environment lookupPaul Eggert2019-04-221-8/+10
| | | | | * src/eval.c (Fsetq, eval_sub): Use assq_no_quit instead of Fassq for a list that cannot contain cycles or be that long.
* Remove --enablechecking=conslist configure optionPaul Eggert2019-04-211-9/+0
| | | | | | | | | * configure.ac: Remove the option. * configure.ac (ac_gc_check_cons_list, GC_CHECK_CONS_LIST): * src/alloc.c (check_cons_list) [GC_CHECK_CONS_LIST]: * src/lisp.h (lisp_h_check_cons_list, check_cons_list): Remove. All uses removed. * etc/NEWS: Mention this.
* Fix comment and tweak eval_subPaul Eggert2019-04-191-17/+10
| | | | | | | | | * src/eval.c (eval_sub): Check whether Fassq returns Qnil, not whether it returns a cons, as NILP is faster than CONSP nowadays. Remove incorrect comment “only original_fun and original_args have values that will be used below”; instead, move declarations around so that the set of variables with useful values is obvious.
* Refactoring: simplify definition of some internal variables.Philipp Stephani2019-04-191-2/+8
| | | | | | | | | | | | | In some cases, we never specbind internal objects, so they don't have to be symbols. Rather than using DEFSYM/DEFVAR and then uninterning the symbols, use plain static variables. Call staticpro for all of them, to protect them from the garbage collector. * src/eval.c (syms_of_eval): Use a static variable for Qcatch_all_memory_full. * src/emacs-module.c (syms_of_module): Use static variables for Vmodule_refs_hash, Vmodule_runtimes, and Vmodule_environments.
* Refactoring: have CATCHER_ALL also catch signals.Philipp Stephani2019-04-191-32/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | In all cases where we use a CATCHER_ALL handler we also want to catch signals. Therefore have 'signal' respect CATCHER_ALL. Adapt internal interfaces so that handlers can distinguish among the two types of nonlocal exits in CATCHER_ALL handlers. * src/lisp.h (enum nonlocal_exit): New enum. (struct handler): Add member 'nonlocal_exit' to hold the type of nonlocal exit during stack unwinding. * src/eval.c (signal_or_quit): Also respect CATCHER_ALL handlers. (unwind_to_catch): Store nonlocal exit type in catch structure. (Fthrow, signal_or_quit): Adapt callers. (internal_catch_all): Install only one handler. Give handler a nonlocal exit type argument. (internal_catch_all_1): Remove, no longer needed. * src/emacs-module.c (MODULE_SETJMP): Install only one handler. (module_handle_nonlocal_exit): New function to handle all nonlocal exits. (MODULE_SETJMP_1): Pass nonlocal exit type to handler function. (module_handle_signal, module_handle_throw): Remove, no longer needed. * src/json.c (json_handle_nonlocal_exit): New helper function. (json_insert_callback): Adapt to change in 'internal_catch_all'.
* Mark _Noreturn error functions as coldPaul Eggert2019-04-181-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | On my platform this made ‘make compile-always’ 1.3% faster. Suggested by Alex Gramiak in: https://lists.gnu.org/r/emacs-devel/2019-04/msg00684.html * configure.ac (nw): Don’t use -Wsuggest-attribute=cold. * lib-src/make-docfile.c (write_globals): Mark noreturn functions as cold. * src/callproc.c (exec_failed): * src/data.c (wrong_length_argument, wrong_type_argument): * src/emacs-module.c (module_abort): * src/emacs.c (terminate_due_to_signal): * src/eval.c (unwind_to_catch): * src/image.c (my_png_error, my_error_exit): * src/json.c (json_out_of_memory, json_parse_error): * src/keyboard.c (quit_throw_to_read_char, user_error): * src/lisp.h (die, wrong_type_argument, wrong_choice) (args_out_of_range, args_out_of_range_3, circular_list) (buffer_overflow, memory_full, buffer_memory_full) (string_overflow, xsignal, xsignal0, xsignal1, xsignal2) (xsignal3, signal_error, overflow_error, error, verror) (nsberror, report_file_errno, report_file_error) (report_file_notify_error, terminate_due_to_signal) (emacs_abort, fatal): * src/lread.c (load_error_old_style_backquotes) (end_of_file_error, invalid_syntax): * src/pdumper.c (error_unsupported_dump_object): * src/puresize.h (pure_write_error): * src/search.c (matcher_overflow): * src/sound.c (sound_perror, alsa_sound_perror): * src/sysdep.c (handle_arith_signal): * src/systime.h (time_overflow): * src/term.c (maybe_fatal, vfatal): * src/textprop.c (text_read_only): * src/timefns.c (invalid_time_zone_specification) (time_error, invalid_hz): * src/xterm.c (x_connection_closed): Use AVOID instead of _Noreturn void, so that it’s marked cold. * src/conf_post.h (__has_attribute_cold) [!__has_attribute]: New macro. (ATTRIBUTE_COLD): New macro. * src/frame.h (WINDOW_SYSTEM_RETURN): Add ATTRIBUTE_COLD. * src/lisp.h (AVOID): New macro. * src/xterm.c: Omit unnecessary static decls, so that we needn’t worry about which functions should be marked cold. (x_io_error_quitter): Mark as cold.
* Let debugger handle process spawn errors on w32 (Bug#33016)Noam Postavsky2019-04-141-10/+14
| | | | | | | | | | | | | | | | | | | | | | Since child_setup() is called between block_input()...unblock_input(), when an error is signaled the Lisp debugger is prevented from starting. Therefore, let the callers signal the error instead (which they already do for non-w32 platforms, just the error message needs an update). * src/callproc.c (child_setup) [WINDOWSNT]: Don't call report_file_error here. (call_process) [WINDOWNT]: * src/process.c (create_process) [WINDOWSNT]: Call report_file_errno here instead, after the unblock_input() call, same as for !WINDOWSNT. * src/lisp.h (CHILD_SETUP_ERROR_DESC): New preprocessor define. Flip the containing ifndef DOS_NT branches so that it's ifdef DOS_NT. * src/eval.c (when_entered_debugger): Remove. (syms_of_eval) <internal-when-entered-debugger>: Define it as a Lisp integer variable instead. (maybe_call_debugger): Update comment. * test/src/process-tests.el (make-process-w32-debug-spawn-error): * test/src/callproc-tests.el (call-process-w32-debug-spawn-error): New tests.
* * lisp/subr.el (prog2): Define as a macroStefan Monnier2019-04-021-12/+0
| | | | | | | | | | | | | * src/eval.c (Fprog2): Delete function. (syms_of_eval): Don't register it. * lisp/emacs-lisp/byte-opt.el (byte-optimize-form-code-walker): * lisp/emacs-lisp/generator.el (cps--transform-1): Remove `prog2` case. * lisp/emacs-lisp/bytecomp.el (prog2): Remove handlers. (byte-compile-prog2): Delete. * lisp/emacs-lisp/lisp-mode.el (prog2): Remove property.
* Fix some integer issues in regex-emacsPaul Eggert2019-03-251-6/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Also, remove some duplicate comments related to thread.h. * src/regex-emacs.h (struct re_registers): * src/regex-emacs.c (SIGN_EXTEND_CHAR): Remove. (TALLOC, RETALLOC): Remove. All uses replaced by usual allocators, which check for integer overflow. (extract_number): Redo without using ‘unsigned’. (CHARSET_RANGE_TABLE_EXISTS_P): Clearly return a boolean. (print_fastmap, print_partial_compiled_pattern, CHECK_INFINITE_LOOP) (regex_compile, analyze_first, bcmp_translate, mutually_exclusive_p) (re_match_2_internal): Use bool for booleans. (print_fastmap, regex_compile, execute_charset): Prefer int to unsigned where either will do. (print_double_string): Prefer ptrdiff_t to ssize_t, since the latter can in theory be narrower than the former. Use fwrite instead of repeated putchar. (emacs_re_max_failures, fail_stack_type, compile_stack_type) (re_wctype_parse, regex_compile, re_search, re_search_2) (re_match_2, re_match_2_internal, re_compile_pattern): Prefer ptrdiff_t to size_t where either will do. (union fail_stack_elt, PUSH_FAILURE_REG, POP_FAILURE_REG_OR_COUNT): Make the integer an intptr_t, not long. (GET_BUFFER_SPACE, EXTEND_BUFFER, regex_compile): Use xpalloc to simplify allocation. (regex_compile): Check for integer overflow when calculating register numbers. * src/regex-emacs.c (re_set_registers, re_match_2_internal): * src/regex-emacs.h (struct re_registers, struct re_pattern_buffer): * src/search.c (Freplace_match): Prefer ptrdiff_t to unsigned where either will do. * src/regex-emacs.h (struct re_pattern_buffer): Prefer bool_bf to unsigned where either will do.
* Simplify list creation in C codePaul Eggert2019-03-041-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The main new thing here is that C code can now say ‘list (a, b, c, d, e, f)’ instead of ‘listn (CONSTYPE_HEAP, 6, a, b, c, d, e, f)’, thus relieving callers of the responsibility of counting arguments (plus, the code feels more like Lisp). The old list1 ... list5 functions remain, as they’re probably a bit faster for small lists. * src/alloc.c (cons_listn, pure_listn): New functions. (listn): Omit enum argument. All callers changed to use either new ‘list’ or ‘pure_list’ macros. * src/charset.c (Fdefine_charset_internal): * src/coding.c (detect_coding_system) (Fset_terminal_coding_system_internal): * src/frame.c (frame_size_history_add, adjust_frame_size): * src/gtkutil.c (xg_frame_set_char_size): * src/keyboard.c (command_loop_1): * src/nsfns.m (frame_geometry): * src/widget.c (set_frame_size): * src/xfaces.c (Fcolor_distance): * src/xfns.c (frame_geometry): * src/xterm.c (x_set_window_size_1): * src/xwidget.c (Fxwidget_size_request): Prefer list1i, list2i, etc. to open-coding them. * src/charset.c (Fset_charset_priority): * src/nsterm.m (append2): * src/window.c (window_list): * src/xfaces.c (Fx_list_fonts): Use nconc2 instead of open-coding it. * src/eval.c (eval_sub, backtrace_frame_apply): * src/kqueue.c (kqueue_generate_event): * src/nsterm.m (performDragOperation:): * src/pdumper.c (Fpdumper_stats): * src/w32.c (init_environment): Prefer list1, list2, etc. to open-coding them. * src/font.c (font_list_entities): Parenthesize to avoid expanding new ‘list’ macro. * src/gtkutil.c (GETSETUP): Rename from MAKE_FLOAT_PAGE_SETUP to get lines to fit. Move outside the ‘list’ call, since it’s now a macro. * src/keymap.c (Fmake_keymap): Simplify. * src/lisp.h (list, pure_list): New macros. (list1i): New function.
* Avoid rare crashes in xbacktraceEli Zaretskii2019-02-281-1/+7
| | | | | | * src/eval.c (backtrace_thread_p, backtrace_top): Don't segfault in "xbacktrace" if called before the specpdl machinery is initialized in pdumped Emacs.
* DEFVAR_INT variables are now intmax_tPaul Eggert2019-02-271-36/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Formerly they were fixnums, which led to problems when dealing with values that might not fit on 32-bit platforms, such as string-chars-consed or floats_consed. 64-bit counters should be good enough for these (for a while, anyway...). While we’re at it, fix some unlikely integer overflow bugs that have been in the code for a while. * lib-src/make-docfile.c (write_globals): * src/data.c (do_symval_forwarding, store_symval_forwarding): * src/eval.c (restore_stack_limits, call_debugger): * src/frame.h (struct frame.cost_calculation_baud_rate): * src/keyboard.c (last_auto_save, bind_polling_period, read_char): * src/lisp.h (struct Lisp_Intfwd.intvar): * src/lread.c (defvar_int): * src/pdumper.c (dump_fwd_int): * src/thread.h (struct thread_state.m_lisp_eval_depth): * src/undo.c (truncate_undo_list): * src/xselect.c (wait_for_property_change) (x_get_foreign_selection): * src/xterm.c (x_emacs_to_x_modifiers): DEFVAR_INT variables now have the C type intmax_t, not EMACS_INT. * src/data.c (store_symval_forwarding): * src/gnutls.c (Fgnutls_boot): * src/keyboard.c (bind_polling_period): * src/macros.c (pop_kbd_macro, Fexecute_kbd_macro): * src/undo.c (truncate_undo_list): Allow any integer that fits into intmax_t, instead of requiring it to be a Lisp fixnum. * src/dispnew.c (update_window): * src/frame.c (x_figure_window_size): * src/gnutls.c (init_gnutls_functions) (emacs_gnutls_handle_error): * src/keyboard.c (make_lisp_event): * src/nsterm.m (ns_dumpglyphs_image): * src/profiler.c (make_log): * src/scroll.c (calculate_scrolling) (calculate_direct_scrolling): * src/termcap.c (tputs): * src/xterm.c (x_draw_image_relief): Avoid implementation-defined behavior on conversion of out-of-range integers. * src/eval.c (when_entered_debugger): Now intmax_t. (max_ensure_room): New function, that avoids signed integer overflow. (call_debugger, signal_or_quit): Use it. * src/fileio.c (Fdo_auto_save): * src/keyboard.c (make_lisp_event): * src/term.c (calculate_costs): * src/xdisp.c (build_desired_tool_bar_string) (hscroll_window_tree, try_scrolling, decode_mode_spec) (x_produce_glyphs): Avoid signed integer overflow. * src/lisp.h (clip_to_bounds): Generalize to intmax_t. * src/pdumper.c (dump_emacs_reloc_immediate_emacs_int): Remove, ... (dump_emacs_reloc_immediate_intmax_t): ... replacing with this function. All uses changed. * src/profiler.c (make_log): Omit args. All callers changed. * src/termcap.c: Include stdlib.h, for atoi. Include intprops.h. * src/window.c (sanitize_next_screen_context_lines): New function. (window_scroll_pixel_based, window_scroll_line_based): Use it to avoid signed integer overflow.
* Ignore pending_signals when checking for quits.Philipp Stephani2019-02-241-4/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Add portable dumperDaniel Colascione2019-01-151-14/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Use shortcuts for FlengthPaul Eggert2019-01-091-27/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Merge from origin/emacs-26Paul Eggert2018-12-311-1/+1
|\ | | | | | | | | | | 2fcf2df Fix copyright years by hand 26bed8b Update copyright year to 2019 2814292 Fix value of default frame height. (Bug#33921)
| * Update copyright year to 2019Paul Eggert2019-01-011-1/+1
| | | | | | | | Run 'TZ=UTC0 admin/update-copyright $(git ls-files)'.
* | Improve fix for Bug#33014Paul Eggert2018-10-301-5/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | Keep a stack reference to bytecode objects being executed (Bug#33014)Gemini Lasswell2018-10-291-2/+5
| | | | | | | | | | | | | | | | | | * src/eval.c (Ffuncall): Make local variable 'fun' volatile. * test/src/eval-tests.el (eval-tests-byte-code-being-evaluated-is-protected-from-gc): Add regression test for Bug#33014. (eval-tests-33014-var): New variable. (eval-tests-33014-func, eval-tests-33014-redefine): New functions.
* | Fix lisp_eval_depth in unwind-protect cleanupPaul Eggert2018-10-141-0/+3
| | | | | | | | | | | | | | 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.
* | Merge from origin/emacs-26Glenn Morris2018-10-091-1/+4
|\ \ | |/ | | | | | | | | | | | | 14c032d Avoid assertion violations in nonsensical calls to 'signal' b99192f * lisp/simple.el (transient-mark-mode): Correct documentation... 7e42294 Update the locale and language database 8c53d9f Fix a typo in a doc string. 79bda3b Make nneething allow CRLF-encoded files (bug#32940)