aboutsummaryrefslogtreecommitdiffstats
path: root/src/bytecode.c (unfollow)
Commit message (Collapse)AuthorFilesLines
2025-10-17Disable -Wclobbered around exec_byte_code (bug#79610)scratch/exec-byte-codeMattias Engdegård1-15/+13
* src/bytecode.c (exec_byte_code): The old hack for working around spurious -Wclobbered warnings from GCC no longer suffices; disable the warning locally. This also makes the code slightly smaller and faster.
2025-10-16; exec_byte_code: refactor branch caseMattias Engdegård1-14/+14
2025-10-16exec_byte_code: use fixed registers for top and pc (bug#79610)Mattias Engdegård1-2/+16
GCC seems to have difficulty allocating important global interpreter variables in registers; telling it which ones to use for 'top' and 'pc' makes a big difference and seems to ease pressure enough for it to deal with other variables as well. We do it for AMD64 and ARM64. Clang doesn't seem to need these directives. It does result in -Wclobbered warnings that seem difficult to silence. * src/bytecode.c (BC_REG_TOP, BC_REG_PC): New. (exec_byte_code): Use them.
2025-10-16; exec_byte_code: don't re-use op in FETCH2Mattias Engdegård1-1/+1
2025-10-16exec_byte_code: reduce use of semi-global 'op' (bug#79610)Mattias Engdegård1-56/+65
* src/bytecode.c (exec_byte_code): Re-type op from int to ptrdiff_t, which avoids some useless conversions. Reduce its use by using local variables for intra-block use, and another variable (arg) where it doesn't need to be alive across instruction dispatch. We also eliminate it where performance doesn't matter by re-fetching it from the instruction stream. All this should help the register allocator.
2025-09-19; * src/bytecode.c (exec_byte_code): Revert gratuituous style changeMattias Engdegård1-1/+1
2025-09-19; * src/bytecode.c (exec_byte_code): Fix coding style.Po Lu1-1/+1
2025-09-18* src/bytecode.c (exec_byte_code): Better quitcounter reset value.Mattias Engdegård1-1/+3
This value forces a quit check at the next backward branch, to avoid rare situations being hard to interrupt. Suggested by Pip Cet.
2025-09-18Don't save quitcounter across longjmp in exec_byte_codeMattias Engdegård1-3/+1
* src/bytecode.c (exec_byte_code): Reset quitcounter to 1 after longjmp; the exact value isn't important. This may reduce register pressure a tiny bit or at least remove a useless stack slot.
2025-07-30; * src/bytecode.c: remove unneeded includesMattias Engdegård1-4/+0
2025-06-15* src/bytecode.c (exec_byte_code): Remove superfluous conditionMattias Engdegård1-4/+1
Bytecode should never be able to set anything to Qunbound because that value is not accessible from Lisp. Found by Pip Cet.
2025-04-19Avoid name clashes with static GnuTLSPaul Eggert1-1/+1
Work around a bug in GnuTLS 3.7.11 and earlier: when built statically, its mistakenly exports symbols hash_lookup and hash_string, which collide with Emacs symbols of the same name, preventing temacs from linking statically. Problem reported by Greg A. Woods (Bug#77476). Because GnuTLS never uses hash_lookup or hash_string this issue ordinarily doesn’t seem to prevent temacs from linking to GnuTLS on GNU/Linux, as it’s linked dynamically and the dynamic linker never needs to resolve references to either symbol. However, I suppose a clash or bug could occur even with dynamic linking if Emacs later loads a module that uses either symbol. Although GnuTLS should be fixed, Emacs should link statically to current and older GnuTLS versions in the meantime, and it should avoid potential problems with dynamic linking. Renaming the two clashing names is an easy way to do this. For consistency with the new name for hash_lookup, also rename hash_lookup_with_hash and hash_lookup_get_hash. * src/fns.c (hash_find_with_hash): Rename from hash_lookup_with_hash. (hash_find): Rename from hash_lookup. (hash_find_get_hash): Rename from hash_lookup_get_hash. (hash_char_array): Rename from hash_string. All uses changed.
2025-01-14Use calln instead of calling Ffuncall directlyStefan Kangas1-1/+1
* src/bytecode.c (bcall0): * src/comp.c (bcall0): * src/eval.c (apply1): * src/lisp.h (call0): * src/thread.c (invoke_thread_function): Use calln instead of calling Ffuncall directly. * admin/coccinelle/calln.cocci: New semantic patch.
2025-01-02Update copyright year to 2025Stefan Kangas1-1/+1
Run "TZ=UTC0 admin/update-copyright".
2025-01-01Update copyright year to 2025Paul Eggert1-1/+1
Run "TZ=UTC0 admin/update-copyright".
2024-12-12Pure storage removal: Replace calls to removed functionsPip Cet1-2/+0
* src/alloc.c (string_bytes, pin_string, valid_lisp_object_p) (process_mark_stack, survives_gc_p, syms_of_alloc): * src/androidterm.c (android_term_init): Replace call to 'build_pure_c_string'. * src/buffer.c (init_buffer_once, syms_of_buffer): * src/bytecode.c (exec_byte_code): * src/callint.c (syms_of_callint): * src/callproc.c (syms_of_callproc): * src/category.c (Fdefine_category): * src/coding.c (syms_of_coding): * src/comp.c (Fcomp__compile_ctxt_to_file0) (maybe_defer_native_compilation, syms_of_comp): * src/data.c (Fsetcar, Fsetcdr, Fdefalias, Faset, syms_of_data): * src/dbusbind.c (syms_of_dbusbind): * src/doc.c (Fsnarf_documentation): * src/emacs-module.c (syms_of_module): * src/eval.c (Finternal__define_uninitialized_variable) (Fdefconst_1, define_error, syms_of_eval): * src/fileio.c (syms_of_fileio): * src/fns.c (Ffillarray, Fclear_string, check_mutable_hash_table): * src/fontset.c (syms_of_fontset): * src/frame.c (make_initial_frame): * src/haikufns.c (syms_of_haikufns): * src/intervals.c (create_root_interval): * src/keyboard.c (syms_of_keyboard): * src/keymap.c (Fmake_sparse_keymap, Fset_keymap_parent) (store_in_keymap, syms_of_keymap): * src/lisp.h: * src/lread.c (Fload, read0, intern_c_string_1, define_symbol) (Fintern, defsubr, syms_of_lread): * src/pdumper.c (Fdump_emacs_portable): * src/pgtkfns.c (syms_of_pgtkfns): * src/pgtkterm.c (syms_of_pgtkterm): * src/process.c (syms_of_process): * src/search.c (syms_of_search): * src/sqlite.c (syms_of_sqlite): * src/syntax.c (syms_of_syntax): * src/treesit.c (syms_of_treesit): * src/w32fns.c (syms_of_w32fns): * src/xdisp.c (syms_of_xdisp): * src/xfaces.c (syms_of_xfaces): * src/xfns.c (syms_of_xfns): * src/xftfont.c (syms_of_xftfont): * src/xterm.c (syms_of_xterm): Remove calls to 'PURE_P', 'CHECK_IMPURE', 'Fpurecopy', and replace calls to 'build_pure_c_string', 'pure_list', 'pure_listn', etc., by impure equivalents.
2024-12-12Pure storage removal: Main partPip Cet1-1/+0
* src/alloc.c (pure, PUREBEG, purebeg, pure_size) (pure_bytes_used_before_overflow, pure_bytes_used_lisp) (pure_bytes_used_non_lisp): Remove definitions. (init_strings): Make empty strings impure. (cons_listn): Drop 'cons' argument. (pure_listn): Remove function. (init_vectors): Allocate zero vector manually to avoid freelist issues. (pure_alloc, check_pure_size, find_string_data_in_pure) (make_pure_string, make_pure_c_string, pure_cons, make_pure_float) (make_pure_bignum, make_pure_vector, purecopy_hash_table): Remove functions. (purecopy): Reduce to hash consing our argument. (init_alloc_once_for_pdumper): Adjust to lack of pure space. (pure-bytes-used): Adjust docstring to mark as obsolete. (purify-flag): Keep for hash consing, but adjust docstring. * src/bytecode.c: * src/comp.c: Don't include "puresize.h". * src/conf_post.h (SYSTEM_PURESIZE_EXTRA): Remove definition. * src/data.c (pure_write_error): Remove function. * src/deps.mk: Remove puresize.h dependency throughout. * src/emacs.c: * src/fns.c: * src/intervals.c: * src/keymap.c: Don't include "puresize.h". * src/lisp.h (struct Lisp_Hash_Table): Adjust comment. (pure_listn, pure_list, build_pure_c_string): Remove. * src/w32heap.c (FREEABLE_P): Don't do use 'dumped_data'. (malloc_before_dump, realloc_before_dump, free_before_dump): Remove functions. * src/w32heap.h: Adjust prototype. * lisp/loadup.el: * lisp/startup.el: Remove purespace code.
2024-08-16Don’t ignore -Wclobbered in bytecode.cPaul Eggert1-5/+19
This fix is prompted by Emacs bug#71744. The working hypothesis is that there are some bugs in Emacs, and some in GCC’s diagnostics, and that this patch fixes the Emacs bugs and works around the GCC diagnostic bugs. The hypothesis is that GCC diagnostic bugs occur when GCC coalesces variables or temporaries and some variables are clobbered by setjmp and some vars/temps are not. Part of this hypothesis involves GCC diagnosing the wrong variables. Instead of ignoring the diagnostics, which the hypothesis suggests indicate either problems in Emacs or in GCC, fix the Emacs bugs and pacify the GCC false positives, with comments about the GCC bugs. GCC’s true positives are helpful enough in squashing obscure bugs like Emacs bug#71744, that it’s worth going to some effort to pacify -Wclobbered instead of ignoring it. * src/bytecode.c: Do not ignore -Wclobbered. (exec_byte_code): Fix violations of the C standard, where setjmp clobbered quitcounter and bc. If GCC_LINT && __GNUC__ && !__clang__, work around GCC -Wclobbered warnings for bytestr_data and vectorp.
2024-07-27Simplify and speed up numeric comparisonsMattias Engdegård1-5/+5
This makes comparison functions (=, /=, <, <=, >, >=, min, max) quite a bit faster (10-20 %). Bytecode ops on fixnums are not affected, nor is `value<`. * src/data.c (arithcompare): Simplify the code to reduce the number of branches. Remove the comparison code argument; instead, return the relation encoded as bits, which can be tested cheaply. All callers adapted. * src/lisp.h (enum Arith_Comparison): Remove. (Cmp_Bit_*, cmp_bits_t): New.
2024-05-28Rename `SUBR_NATIVE_COMPILED` to `NATIVE_COMP_FUNCTION` (bug#71123)Stefan Monnier1-1/+1
Keep the name consistent with the naming used in the ELisp world. * src/pdumper.c (dump_object_emacs_ptr, dump_do_fixup): * src/eval.c (eval_sub, funcall_general, funcall_lambda): * src/alloc.c (CHECK_ALLOCATED_AND_LIVE_SYMBOL, survives_gc_p): * src/data.c (Fcl_type_of, Ffset, Fnative_comp_function_p) (Fsubr_native_lambda_list, Finteractive_form): * src/comp.c (check_comp_unit_relocs): * src/bytecode.c (exec_byte_code): * src/lisp.h (NATIVE_COMP_FUNCTIONP, NATIVE_COMP_FUNCTION_DYNP): Rename from `SUBR_NATIVE_COMPILEDP` and `SUBR_NATIVE_COMPILED_DYNP`.
2024-04-28(COMPILED): Rename to CLOSUREStefan Monnier1-10/+10
In preparation for the use of `PVEC_COMPILED` objects for interpreted functions, rename them to use a more neutral name. * src/lisp.h (enum pvec_type): Rename `PVEC_COMPILED` to `PVEC_CLOSURE`. (enum Lisp_Compiled): Use `CLOSURE_` prefix i.s.o `COMPILED_`. Also use `CODE` rather than `BYTECODE`. (CLOSUREP): Rename from `COMPILEDP`. (enum Lisp_Closure): Rename from `Lisp_Compiled`. * src/alloc.c, src/bytecode.c, src/comp.c, src/data.c, src/eval.c, * src/fns.c, src/lisp.h, src/lread.c, src/pdumper.c, src/print.c, * src/profiler.c: Rename all uses accordingly. * src/.gdbinit (xclosure): Rename from `xcompiled`. (xcompiled): New obsolete alias. (xpr): Adjust accordingly. Also adjust to new PVEC_CLOSURE tag name.
2024-04-18Drop unnecessary type check in varref and varset byte opsMattias Engdegård1-4/+2
* src/bytecode.c (exec_byte_code): We can safely assume that the immediate argument to varref and varset is a bare symbol; the byte-compiler should guarantee that.
2024-02-19Slight switch byte op speedupMattias Engdegård1-18/+19
* src/bytecode.c (exec_byte_code): Hoist symbols_with_pos_enabled check from fast loop, and eliminate the initial index check.
2024-01-31Bytecode engine fast-path streamlining of plain symbolsMattias Engdegård1-9/+11
* src/bytecode.c (exec_byte_code): Only use fast-path optimisations for calls and dynamic variable reference and setting where the symbol is plain, which is much faster.
2024-01-31Eliminate lazy bytecode loadingMattias Engdegård1-15/+12
The obsolete lazy-loaded bytecode feature, enabled by `byte-compile-dynamic`, slows down Lisp execution even when not in use because every call to a bytecode function has to check that function for laziness. This change forces up-front loading of all lazy bytecode so that we can remove all those checks. (Dynamically loaded doc strings are not affected.) There is no point in generating lazy bytecode any more so we stop doing that; this simplifies the compiler. `byte-compile-dynamic` now has no effect. This is a fully compatible change; the few remaining users of `byte-compile-dynamic` should not notice any difference. * src/lread.c (bytecode_from_rev_list): Force eager loading of lazy bytecode. * src/bytecode.c (exec_byte_code): Remove lazy bytecode checks. * src/eval.c (fetch_and_exec_byte_code, Ffetch_bytecode): Remove. (funcall_lambda): Call exec_byte_code directly, avoiding checks. * lisp/subr.el (fetch-bytecode): New definition, obsolete no-op. * lisp/emacs-lisp/disass.el (disassemble-1): * lisp/emacs-lisp/bytecomp.el (byte-compile-unfold-bcf): Remove calls to fetch-bytecode. (byte-compile-dynamic): Update doc string. (byte-compile-close-variables, byte-compile-from-buffer) (byte-compile-insert-header, byte-compile-output-file-form) (byte-compile--output-docform-recurse, byte-compile-output-docform) (byte-compile-file-form-defmumble): Remove effects of byte-compile-dynamic. * doc/lispref/compile.texi (Dynamic Loading): Remove node now that the entire `byte-compile-dynamic` facility has been rendered inert. * etc/NEWS: Announce changes.
2024-01-13Share hash table test structsMattias Engdegård1-1/+1
This saves several words in the hash table object at the cost of an indirection at runtime. This seems to be a gain in overall performance. FIXME: We cache hash test objects in a rather clumsy way. A better solution is sought. * src/lisp.h (struct Lisp_Hash_Table): Use a pointer to the test struct. All references adapted. * src/alloc.c (garbage_collect): * src/fns.c (struct hash_table_user_test, hash_table_user_tests) (mark_fns, get_hash_table_user_test): New state for caching test structs, and functions managing it.
2024-01-13Inlined and specialised hash table look-upMattias Engdegård1-1/+1
This improves performance in several ways. Separate functions are used depending on whether the caller has a hash value computed or not. * src/fns.c (hash_lookup_with_hash, hash_lookup_get_hash): New. (hash_lookup): Remove hash return argument. All callers adapted. hash_lookup_with_hash hash_hash_t arg
2024-01-02; Add 2024 to copyright yearsPo Lu1-1/+1
2023-07-26Provide backtrace for byte-ops aref and asetMattias Engdegård1-13/+33
Produce synthetic backtrace entries for `aref` and `aset` byte-ops when the index is non-fixnum, or is out of range for vector or record arguments (bug#64613). * src/bytecode.c (exec_byte_code): Detect type and range errors in-line for aref and aset. * src/data.c (syms_of_data): Declare symbols Qaref and Qaset. * test/lisp/emacs-lisp/bytecomp-tests.el (bytecomp-tests--byte-op-error-cases): Add test cases.
2023-07-14Provide backtrace for byte-ops car, cdr, setcar, setcdr, nth and eltMattias Engdegård1-6/+36
Include calls to these primitives from byte-compiled code in backtraces. For nth and elt, not all errors are covered. (Bug#64613) * src/bytecode.c (exec_byte_code): Add error backtrace records for car, cdr, setcar, setcdr, nth and elt. * src/data.c (syms_of_data): Add missing defsyms for car, setcar, setcdr, nth and elt. * test/lisp/emacs-lisp/bytecomp-tests.el (bytecomp-tests--error-frame, bytecomp-tests--byte-op-error-cases) (bytecomp--byte-op-error-backtrace): New test.
2023-05-17Prefer C23 ckd_* to Gnulib *_WRAPV macrosPaul Eggert1-1/+1
C23 has added ckd_add etc. macros with functionality equivalent to the older Gnulib INT_ADD_WRAPV macros, so switch to the more-standard names. * admin/merge-gnulib (GNULIB_MODULES): Add stdckdint. This merely makes the dependency explicit, as we were already using this Gnulib module indirectly. * lib-src/etags.c, src/lisp.h: Include stdckdint.h. * lib-src/etags.c (xnmalloc, xnrealloc): * src/alloc.c (xnmalloc, xnrealloc, xpalloc, Fmake_string) (mark_memory): * src/bignum.c (emacs_mpz_pow_ui): * src/buffer.c (record_overlay_string, overlay_strings): * src/bytecode.c (exec_byte_code): * src/casefiddle.c (do_casify_multibyte_string): * src/ccl.c (ccl_driver, Fccl_execute_on_string): * src/character.c (char_width, c_string_width) (lisp_string_width, count_size_as_multibyte) (string_escape_byte8): * src/cmds.c (internal_self_insert): * src/coding.c (coding_alloc_by_realloc, produce_chars): * src/data.c (arith_driver): * src/dispnew.c (realloc_glyph_pool, init_display_interactive): * src/doprnt.c (parse_format_integer): * src/editfns.c (Freplace_buffer_contents, str2num) (styled_format): * src/emacs-module.c (module_global_reference_p) (module_make_global_ref, module_funcall): * src/eval.c (max_ensure_room): * src/fileio.c (blocks_to_bytes): * src/fns.c (Ffillarray): * src/font.c (font_intern_prop): * src/frame.c (check_frame_pixels): * src/gnutls.c (gnutls_hex_string, gnutls_symmetric_aead): * src/gtkutil.c (get_utf8_string): * src/haikuterm.c (haiku_term_init): * src/image.c (xbm_scan, image_to_emacs_colors) (image_detect_edges, png_load_body): * src/keyboard.c (Frecursion_depth): * src/keymap.c (Flookup_key, Fkey_description): * src/lisp.h (modiff_incr, SAFE_ALLOCA_LISP_EXTRA): * src/lread.c (read_bool_vector): * src/pgtkterm.c (pgtk_term_init): * src/regex-emacs.c (regex_compile): * src/term.c (encode_terminal_code): * src/termcap.c (tputs): * src/textconv.c (textconv_query): * src/timefns.c (timespec_ticks, lisp_time_hz_ticks) (Fdecode_time, check_tm_member): * src/tparam.c (tparam1): * src/w32term.c (w32_initialize_display_info): * src/xdisp.c (fill_column_indicator_column, decode_mode_spec): * src/xselect.c (selection_data_size, x_property_data_to_lisp): * src/xsmfns.c (smc_save_yourself_CB): * src/xterm.c (xm_setup_dnd_targets, x_sync_get_monotonic_time) (x_sync_current_monotonic_time, x_sync_note_frame_times) (x_display_set_last_user_time, x_term_init): Prefer the C23 stdckdint macros to their Gnulib intprops.h counterparts, since C23 is standard.
2023-03-01Replace C++ comments with C style equivalentsPo Lu1-2/+2
* src/alloc.c (Fmake_byte_code, purecopy): * src/bytecode.c (exec_byte_code): * src/xdisp.c (face_at_pos): Do not use C++-style comments!
2023-02-14Improve backward compatibility of save-restrictionGregory Heytings1-2/+0
* src/editfns.c (save_restriction_save_1): Renamed from 'save_restrictions_save'. Make it static. (save_restriction_restore_1): Renamed from 'save_restriction_restore'. Make it static. (save_restriction_restore): New function, combining 'save_restriction_save_1' and 'narrowing_locks_save'. (save_restriction_save): New function, combining 'save_restriction_restore_1' and 'narrowing_locks_restore'. (Fsave_restriction): Restore the previous code. (narrowing_locks_save, narrowing_locks_restore): Make them static. * src/lisp.h: Remove two functions that are not externally visible anymore. * src/comp.c (helper_save_restriction): Restore the previous code. * src/bytecode.c (exec_byte_code): Restore the previous code. * lisp/emacs-lisp/bytecomp.el (byte-compile-save-restriction): Decrement unbinding count.
2023-02-09Fix 'save-restriction' for narrowing locksGregory Heytings1-0/+2
* src/editfns.c (narrowing_locks_save): (narrowing_locks_restore): Make them non-static. * src/lisp.h: Make them externally visible. * src/bytecode.c (exec_byte_code): Save and restore narrowing locks. * lisp/emacs-lisp/bytecomp.el (byte-compile-save-restriction): Increment unbinding count. * src/comp.c (helper_save_restriction): Save and restore narrowing locks.
2023-01-01; Add 2023 to copyright years.Eli Zaretskii1-1/+1
2022-09-19Remove calls to intern with a static string from code that runs on XPo Lu1-1/+3
* Makefile.in (actual-all): Reword build failure advice. * src/bytecode.c (exec_byte_code, syms_of_bytecode): * src/font.c (syms_of_font): * src/hbfont.c (uni_combining): * src/xfns.c (Fx_display_backing_store, Fx_display_visual_class) (x_create_tip_frame, Fx_show_tip, syms_of_xfns): * src/xfont.c (xfont_supported_scripts, xfont_driver) (syms_of_xfont): * src/xsmfns.c (Fhandle_save_session, syms_of_xsmfns): Remove calls to intern with a static string.
2022-08-01Fix the bytecode incompatibility due to the change to 'narrow-to-region'.Gregory Heytings1-2/+2
* src/editfns.c (narrow_to_region_internal): New function, which contains the body previously in 'Fnarrow_to_region' but accepts a third argument. (Fnarrow_to_region): Use the new function. Update the docstring. (Fwiden): Update the docstring. * src/lisp.h: Prototype of the new function. * src/xdisp.c (handle_fontified_prop): Use the new function instead of 'Fnarrow_to_region'. * src/process.c (Finternal_default_process_filter): * src/lread.c (readevalloop): Remove the third argument to 'Fnarrow_to_region'. * src/bytecode.c (exec_byte_code): * lisp/emacs-lisp/comp.el (comp-limplify-lap-inst): * lisp/emacs-lisp/bytecomp.el: Restore the statu quo ante. * etc/NEWS: Remove the entry about the new optional argument. * doc/lispref/positions.texi (Narrowing): Update the documentation.
2022-07-30Handle the optional argument of 'narrow-to-region' in byte-compiled code.Gregory Heytings1-2/+2
* lisp/emacs-lisp/bytecomp.el: Adapt the specifications. * src/bytecode.c (exec_byte_code): Get the optional argument.
2022-07-28Add an optional 'lock' parameter to 'narrow-to-region'Gregory Heytings1-1/+1
* src/editfns.c (Fnarrow_to_region): Add the parameter to the function, and handle it. Update docstring. (unwind_locked_begv, unwind_locked_zv): New functions. (Fwiden): Do nothing when restrictions are locked. Update docstring. (syms_of_editfns): Replace the 'inhibit-widen' symbol and variable with a 'restrictions-locked' symbol and variable. Update docstring. * src/xdisp.c (handle_fontified_prop): Use Fnarrow_to_region with the new parameter. (unwind_narrowed_zv): Remove function. * src/process.c (Finternal_default_process_filter): Add a third argument to Fnarrow_to_region. * src/lread.c (readevalloop): Add a third argument to Fnarrow_to_region. * src/bytecode.c (exec_byte_code): Add a third argument to Fnarrow_to_region. * etc/NEWS (like): Mention the new parameter of 'narrow-to-region'. * doc/lispref/positions.texi (Narrowing): Document it.
2022-06-24Bytecode opcode comments updateMattias Engdegård1-5/+11
This is a cosmetic change only; there is no change in behaviour. * lisp/emacs-lisp/bytecomp.el: * src/bytecode.c (BYTE_CODES, exec_byte_code): Update and/or remove incorrect, outdated or useless comments. Clarify. Reorder where appropriate. Rename Bsave_current_buffer to Bsave_current_buffer_OBSOLETE and Bsave_current_buffer_1 to Bsave_current_buffer, reflecting the state since 1996.
2022-06-12Use BASE_EQ when comparing with QunboundMattias Engdegård1-2/+2
Qunbound is uninterned and can therefore never be EQ to any symbol with position. * src/buffer.c (Fbuffer_local_value, buffer_lisp_local_variables) (buffer_local_variables_1): * src/bytecode.c (exec_byte_code): * src/comp.c (compile_function, Fcomp__compile_ctxt_to_file): * src/composite.c (composition_gstring_cache_clear_font): * src/data.c (Fboundp, Fsymbol_value, set_internal) (Fdefault_boundp, Fdefault_value, Fmake_variable_buffer_local): * src/emacs-module.c (module_global_reference_p): * src/eval.c (Fdefault_toplevel_value, defvar) (run_hook_with_args): * src/fns.c (hash_put, Fmaphash): * src/font.c (font_put_extra): * src/frame.c (gui_set_frame_parameters) (gui_frame_get_and_record_arg, gui_default_parameter) (gui_figure_window_size): * src/haikufns.c (get_geometry_from_preferences) (haiku_create_frame, haiku_create_tip_frame): * src/haikuterm.c (haiku_draw_text_decoration) (haiku_default_font_parameter): * src/json.c (lisp_to_json_nonscalar_1): * src/keymap.c (access_keymap_1, access_keymap, current_minor_maps): * src/lread.c (readevalloop, define_symbol): * src/minibuf.c (read_minibuf, Ftry_completion): (Fall_completions, Ftest_completion): * src/pgtkfns.c (pgtk_default_font_parameter, Fx_create_frame) (x_create_tip_frame): * src/pgtkselect.c (Fpgtk_own_selection_internal): * src/print.c (print): * src/profiler.c (evict_lower_half, record_backtrace): * src/terminal.c (create_terminal): * src/textprop.c (set_properties): * src/w32fns.c (my_create_window, w32_icon) (w32_default_font_parameter, Fx_create_frame) (w32_create_tip_frame): * src/w32term.c (w32_draw_glyph_string): * src/xdisp.c (handle_single_display_spec) (cursor_row_fully_visible_p, calc_pixel_width_or_height): * src/xfns.c (x_default_scroll_bar_color_parameter, x_icon_verify) (x_icon, x_default_font_parameter, Fx_create_frame) (x_create_tip_frame): * src/xselect.c (x_handle_selection_request): * src/xterm.c (x_draw_glyph_string, x_term_init): Use BASE_EQ instead of EQ when comparing with Qunbound.
2022-05-12; * src/bytecode.c (exec_byte_code): Fix white space.Stefan Kangas1-1/+1
2022-04-19Fix GCC warnings when CHECK_LISP_OBJECT_TYPEStefan Monnier1-1/+1
* src/lisp.h (lisp_h_Qni): New macro. (DEFUN): Use it. * src/alloc.c (syms_of_alloc): Use it. * src/bytecode.c (Fbyte_code): Fix Lisp_Object/int mixup.
2022-03-19valid_sp inline fixPaul Eggert1-1/+1
* src/bytecode.c (valid_sp): static, not INLINE, as INLINE should be used only in headers and between INLINE_HEADER_BEGIN and INLINE_HEADER_END. No need for ‘inline’ here.
2022-03-17Put bytecode stack frame metadata in a structMattias Engdegård1-74/+38
Using a plain C struct instead of type-punning Lisp_Object stack slots makes the bytecode interpreter code more type-safe and potentially faster (from better alias analysis), and the special-purpose accessors are no longer needed. It also reduces the stack requirements when using 64-bit Lisp_Object on 32-bit platforms. * src/bytecode.c (enum stack_frame_index) (sf_get_ptr, sf_set_ptr, sf_get_lisp_ptr, sf_set_lisp_ptr, sf_get_saved_pc, sf_set_saved_pc): Remove. (BC_STACK_SIZE): Now in bytes, not Lisp words. (struct bc_frame): New. (init_bc_thread, mark_bytecode, Finternal_stack_stats, valid_sp) (exec_byte_code): * src/lisp.h (struct handler, get_act_rec, set_act_rec): Adapt to new struct bc_frame.
2022-03-14Prefer CALLNPaul Eggert1-2/+2
* src/bytecode.c (Fbyte_code): * src/composite.c (Fclear_composition_cache): Prefer CALLN to doing it by hand. * src/fns.c (ccall2): Remove. All uses replaced by CALLN.
2022-03-13* src/bytecode.c: Include sysstdio.h, for fprint, stderr.Glenn Morris1-0/+1
; Ref https://hydra.nixos.org/build/169207408
2022-03-13* src/bytecode.c (sf_set_ptr): Cast pointer to type of right size.Mattias Engdegård1-1/+1
2022-03-13Separate bytecode stackMattias Engdegård1-50/+268
Use a dedicated stack for bytecode, instead of using the C stack. Stack frames are managed explicitly and we stay in the same exec_byte_code activation throughout bytecode function calls and returns. In other words, exec_byte_code no longer uses recursion for calling bytecode functions. This results in better performance, and bytecode recursion is no longer limited by the size of the C stack. The bytecode stack is currently of fixed size but overflow is handled gracefully by signalling a Lisp error instead of the hard crash that we get now. In addition, GC marking of the stack is now faster and more precise. Full precision could be attained if desired. * src/alloc.c (ATTRIBUTE_NO_SANITIZE_ADDRESS): Make non-static. * src/bytecode.c (enum stack_frame_index, BC_STACK_SIZE) (sf_get_ptr, sf_set_ptr, sf_get_lisp_ptr, sf_set_lisp_ptr) (sf_get_saved_pc, sf_set_saved_pc, init_bc_thread, free_bc_thread) (mark_bytecode, Finternal_stack_stats, valid_sp): New. (exec_byte_code): Adapt to use the new bytecode stack. (syms_of_bytecode): Add defsubr. * src/eval.c (unwind_to_catch): Restore saved stack frame. (push_handler_nosignal): Save stack frame. * src/lisp.h (struct handler): Add act_rec member. (get_act_rec, set_act_rec): New. * src/thread.c (mark_one_thread): Call mark_bytecode. (finalize_one_thread): Free bytecode thread state. (Fmake_thread, init_threads): Set up bytecode thread state. * src/thread.h (struct bc_thread_state): New. (struct thread_state): Add bytecode thread state.
2022-03-13Simplify exec_byte_code argumentsMattias Engdegård1-16/+14
Pass the function object and encoded arity, not the other components. This speeds up several call paths and is necessary for improvements to come. * src/bytecode.c (Fbyte_code): Make a new byte code object for execution. This is slower but performance isn't critical here. (exec_byte_code): Retrieve components from the passed function. * src/eval.c (fetch_and_exec_byte_code): * src/lisp.h (exec_byte_code): Update signature.