aboutsummaryrefslogtreecommitdiffstats
path: root/src/alloc.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Merge branch 'master' into scratch/comp-static-dataVibhav Pant2023-06-061-18/+9
|\
| * Prefer C23 ckd_* to Gnulib *_WRAPV macrosPaul Eggert2023-05-171-8/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
| * Pacify GCC 13 -Wanalyzer-out-of-boundsPaul Eggert2023-05-141-9/+0
| | | | | | | | | | | | | | * src/alloc.c (NEAR_STACK_TOP): Hoist from here ... * src/thread.h: ... to here. * src/print.c (print_object): Use NEAR_STACK_TOP instead of raw buffer address. This is more natural, and pacifies GCC 13.
| * Merge branch 'emacs-29'Stefan Monnier2023-05-101-1/+1
| |\
| | * with-display-message: Workaround for bug#63253Stefan Monnier2023-05-091-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Running arbitrary ELisp code from an atimer is still dangerous, at least because the regexp engine is not-reentrant, so let's patch up the case we bumped into. There are probably many other such holes :-( * src/alloc.c (garbage_collection_inhibited): Make it non-static. * src/xdisp.c (garbage_collection_inhibited): Declare it. (set_message, clear_message): Use it as a proxy for "we're in a dangerous context like within `probably_quit`".
* | | Merge branch 'master' into scratch/comp-static-dataVibhav Pant2023-03-081-3/+8
|\ \ \ | |/ /
| * | Unbreak the unexec buildEli Zaretskii2023-03-041-1/+5
| | | | | | | | | | | | | | | * src/alloc.c (BLOCK_ALIGN) [HAVE_UNEXEC]: Reset back to 1024. (Bug#61960)
| * | bug#61489: Increase BLOCK_ALIGN from 1024 to 32768Konstantin Kharlamov2023-03-041-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Originally discovered by Tyler Dodge in his article "Significant Garbage Collection Improvement For Emacs". While testing this change on Archlinux system with Intel i5-7200U CPU, average time of garbage collection gets reduced by ≈25%. Other users report improvements up to 50%. While monitoring PSS of emacs with and without customizations loaded before and after the patch, no statistically significant differences were discovered. So overall, this change is a win. * src/alloc.c (BLOCK_ALIGN): increase from 1024 to 32768.
| * | Merge from origin/emacs-29Stefan Kangas2023-03-021-2/+3
| |\ \ | | |/ | | | | | | | | | | | | | | | | | | | | | | | | 07f3236133b * src/profiler.c (malloc_probe): Make it safe for GC (bug... 1f1d36fa808 * lisp/emacs-lisp/debug-early.el (debug-early-backtrace):... 99df815c153 Revert "Don't disable eldoc when doing edebug" 0a4b1c0102d ; Eglot: improve bug-reference-url-format/bug-reference-u... 40c9fc8e3b3 Eglot: work around Tramp instability bug#61350 4a6db125b9e Fix treesit-indent-region 7ef9a8210c9 Replace C++ comments with C style equivalents
| | * Replace C++ comments with C style equivalentsPo Lu2023-03-011-2/+3
| | | | | | | | | | | | | | | | | | * 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!
* | | Ensure USE_COMP_STATIC_LISP_OBJECTS is always defined.Vibhav Pant2023-02-101-3/+3
| | | | | | | | | | | | | | | * src/comp.h: Define USE_COMP_STATIC_LISP_OBJECTS as 1 or 0, depending on whether static literal compilation is supported or not.
* | | Rename HAVE_STATIC_LISP_OBJECTS, add documentation for it.Vibhav Pant2023-01-311-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | * src/comp.h: Rename HAVE_STATIC_LISP_OBJECTS to USE_COMP_STATIC_LISP_OBJECTS. Add comments explaining the macro's use. * src/comp.c (comp_lisp_const_get_lisp_obj_rval, emit_comp_lisp_obj, emit_data_container_vector, define_init_objs): Add documentation comments.
* | | Merge alloc.h into lisp.h.Vibhav Pant2023-01-281-1/+0
| | | | | | | | | | | | | | | | | | * src/lisp.h: Move declarations from alloc.h. * src/alloc.c: Remove alloc.h include. * src/comp.c: Remove alloc.h include.
* | | Pin native comp units with static objects for now.Vibhav Pant2023-01-191-2/+10
| | | | | | | | | | | | | | | | | | | | | * src/alloc.c (pin_object): New function. * src/comp.c (register_native_comp_unit): If the unit contains static lisp objects, pin it to avoid use-after-free crashes if heap allocated objects in static objects don't get marked.
* | | src/alloc.c: Improve checks in static_comp_object_p.Vibhav Pant2023-01-181-15/+39
| | | | | | | | | | | | | | | | | | src/alloc.c (static_comp_object_p): Improve documentation, return true if the object lies outside the heap, make checks for static objects more efficient.
* | | Merge branch 'master' into scratch/comp-static-dataVibhav Pant2023-01-041-2/+2
|\ \ \ | |/ /
| * | Merge from origin/emacs-29Eli Zaretskii2023-01-011-1/+1
| |\ \ | | |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | cae528457c ; Add 2023 to copyright years. b394359261 Improve documentation of 'isearch-open-overlay-temporary' ab3210e709 Document 'use-package' in the 2 main manuals # Conflicts: # etc/refcards/ru-refcard.tex # lib/explicit_bzero.c # m4/explicit_bzero.m4
| | * ; Add 2023 to copyright years.Eli Zaretskii2023-01-011-1/+1
| | |
| * | Merge from origin/emacs-29Stefan Kangas2022-12-231-1/+1
| |\ \ | | |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 0754173c923 ; Fix docstring 014232d3840 Eglot: eglot--servers-by-xrefed-file doesn't need to be v... bbe35c280c2 Prevent stale servers when using eglot-extend-to-xref 9bf13a3fb9e ; * src/alloc.c (Fmemory_info): Doc fix. baa33a5c054 * etc/tutorials/TUTORIAL.cn: Fix typos. (Bug#60221) 98d7f76b451 Merge branch 'emacs-29' of git.savannah.gnu.org:/srv/git/... a488a6870ac Add alias for removed font-lock function 02e046566e2 Set beginning/end-of-defun-function in treesit-major-mode... 7dea58b88db Add treesit-defun-at-point and fix c-ts-mode-indent-defun 69123d4aa4e ; Fix treesit--defuns-around 05d8310fb5d Use the new keyword ':repeat' in repeatable keymaps.
| | * ; * src/alloc.c (Fmemory_info): Doc fix.Eli Zaretskii2022-12-221-1/+1
| | |
* | | src/alloc.c: Unmark Lisp Vectors when accessing the size field.Vibhav Pant2023-01-041-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | * src/alloc.c (Fmake_closure, visit_vectorlike_root) [HAVE_STATIC_LISP_GLOBALS]: When compiled with support for statically native compiled Lisp literals, unset the mark bit in the Lisp_Vector struct's 'size' field, to avoid using an invalid value as the length if the vector is statically generated during native compilation.
* | | src/alloc.c: Remove unnecessary calls to static_comp_object_p.Vibhav Pant2023-01-041-18/+0
| | | | | | | | | | | | | | | | | | * src/alloc.c (pin_string, process_mark_stack, mark_object) (mark_terminals): Remove calls to check whether obj is a statically native compiled literal.
* | | Avoid additional recursion while marking natively compiled unit.Vibhav Pant2022-12-281-7/+14
| | | | | | | | | | | | | | | * src/alloc.c (mark_native_comp_unit): Push psuedovector fields on the mark stack only, avoiding additional recursion.
* | | Merge branch 'master' into scratch/comp-static-dataVibhav Pant2022-12-201-11/+278
|\ \ \ | |/ /
| * | Add support for additional memory checks using AddressSanitizer.Vibhav Pant2022-12-191-8/+263
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When Emacs is compiled with AddressSanitizer support, enable poisoning/unpoisoning freed/unused Lisp objects and other internal memory management structures. If enabled, this will mark freed bytes that have been put on free lists for future use and initially allocated memory blocks/chunks as "poisoned", triggering an ASan error if they are accessed improperly. Structures are unpoisoned when they have been taken off their respective free lists. Additionally, add optional macros for performing unaligned loads, which when enabled by defining USE_SANITIZER_UNALIGNED_LOAD will use ASan provided functions for loading from unaligned addresses, which may help catch bugs that AddressSanitizer might otherwise miss. * configure.ac: Check for the existence of address and common sanitizer API headers. * src/lisp.h (UNALIGNED_LOAD_SIZE): New macro. If enabled, and the necessary sanitizer API is available, define it to __sanitizer_unaligned_load(64|32) depending on the word size of the architecture. * src/fns.c [HAVE_FAST_UNALIGNED_ACCESS] (Fstring_lessp): Use 'UNALIGNED_LOAD_SIZE' to perform unaligned loads from the two strings. * src/alloc.c (ASAN_POISON_ABLOCK, ASAN_UNPOISON_ABLOCK) (ASAN_POISON_INTERVAL_BLOCK, ASAN_UNPOISON_INTERVAL_BLOCK) (ASAN_POISON_INTERVAL, ASAN_UNPOISON_INTERVAL) (ASAN_PREPARE_DEAD_SDATA, ASAN_PREPARE_LIVE_SDATA) (ASAN_POISON_SBLOCK_DATA, ASAN_POISON_STRING_BLOCK) (ASAN_UNPOISON_STRING_BLOCK, ASAN_POISON_STRING) (ASAN_UNPOISON_STRING, ASAN_POISON_FLOAT_BLOCK) (ASAN_UNPOISON_FLOAT_BLOCK, ASAN_POISON_FLOAT) (ASAN_UNPOISON_FLOAT, ASAN_POISON_CONS_BLOCK) (ASAN_POISON_CONS, ASAN_UNPOISON_CONS) (ASAN_POISON_VECTOR_CONTENTS, ASAN_UNPOISON_VECTOR_CONTENTS) (ASAN_UNPOISON_VECTOR_BLOCK, ASAN_POISON_SYMBOL_BLOCK) (ASAN_UNPOISON_SYMBOL_BLOCK, ASAN_POISON_SYMBOL) (ASAN_UNPOISON_SYMBOL) [ADDRESS_SANITIZER]: New macros. When address sanitization is enabled, define them to poison/unpoison objects. (lisp_align_malloc): Poison newly allocated blocks on `free_ablock', unpoison ablocks taken from it respectively. (lisp_align_free): Poison individual ablocks when they are put on the free list, unpoison them when an entire `ablocks' chunk is being freed. (make_interval): Poison interval blocks on initial allocation, unpoison individual intervals on allocation and removal from `interval_free_list'. (sweep_intervals): Unpoison interval blocks before sweeping, poison dead/unmarked intervals. (allocate_string): Poison string blocks on initial allocation, unpoison Lisp_Strings on removal from the free list. (allocate_string_data): Poison `sblock' data on initial allocation, unpoison individual `sdata' contents on allocation or removal from the free list. Call `ASAN_PREPARE_LIVE_SDATA' on the new `sdata' struct. (sweep_strings): Unpoison string blocks before sweeping them, poisoning dead strings and their sdata afterwards. (compact_small_strings): Call `ASAN_PREPARE_LIVE_DATA' on the `sdata' to where compacted strings to moved to. (pin_string): Call `ASAN_PREPARE_DEAD_SDATA' on `old_sdata'. (make_float): Poison float blocks on allocation, unpoisoning individual Lisp_Floats on allocation or removal from `float_free_list'. (sweep_floats): Unpoison float blocks before sweeping, poison dead/unmarked floats. (free_cons): Poison `ptr'. (Fcons): Poison cons blocks on allocation, unpoisoning individual Lisp_Cons on allocation or removal from `cons_free_list'. (sweep_conses): Poison dead/unmarked conses. (setup_free_list): Poison vectors put on `vector_free_lists'. (allocate_vector_from_block): Unpoison vectors taken from the free list, poison excess vector bytes when vectors allocated from the free list are larger than requested. (sweep_vectors): Unpoison vector blocks before sweeping them. (Fmake_symbol): Poison symbol blocks on initial allocation, unpoisoning individual Lisp_Symbols on allocation or removal from `symbol_free_list'. (sweep_symbols): Unpoison symbol blocks before sweeping, poisoning dead/unmarked symbols. (live_string_holding, live_cons_holding, live_symbol_holding) (live_float_holding): When compiling with address sanitization and GC poisoning enabled, return NULL if the passed address is poisoned, or if the Lisp object it resides in is poisoned, avoiding a use-after-poison trigger if these functions are called on a pointer that might be referring to a now dead/swept object. * etc/DEBUG: Add information about enabling ASan memory poisoning.
| * | Merge from origin/emacs-29Stefan Kangas2022-12-191-1/+2
| |\ \ | | |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | b01d0246d71 * lisp/term/xterm.el (xterm-function-map): Add M-SPC. (B... 303d6ac1423 Fix moving to trash files that overwrite dangling symlink... dc78779c0cd Fix SVG scaling (bug#59802) 10415d9651b ; Add useful hint to which-func documentation c26ab22cf4e ; Improve doc strings of minibuffer-history commands 80f410d281c ; Fix last changes in buffer.c f04680e067b Fix some naming issues involving query buffers in ERC 173e02f4eb4 ; Fix doc string in ERC's module-activation commands 5a9263a8725 Increment erc-debug-irc-protocol-version to 2 89f54e81576 A better fix for bug#60096 1b9ca1e5e64 ; Fix printing Lisp types in .gdbinit 7575c85efd2 Bump Eglot version to 1.10 a0806bc7ea9 Eglot: fix discrepant eglot-guess-contact/eglot-command-h... 8bf4cdcf79b Avoid recursive process filters in lisp/jsonrpc.el (bug#6...
| | * ; Fix printing Lisp types in .gdbinitEli Zaretskii2022-12-161-1/+2
| | | | | | | | | | | | | | | * src/alloc.c (valid_lisp_object_p): Support printing stack-allocated strings and cons cells.
| * | Speed up handling X selection requestsPo Lu2022-12-011-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * etc/NEWS: Announce speedup. * src/alloc.c (garbage_collect): Call mark_xselect. * src/xftfont.c (xftfont_end_for_frame): Fix crash on display IO error. * src/xselect.c (struct selection_data, struct transfer): New structures. (outstading_transfers): New variable. (SELECTED_EVENTS, x_selection_request_lisp_error): Stop checking cs->nofree. (x_catch_errors_unwind): Delete function. (c_size_for_format, x_size_for_format, selection_data_for_offset) (selection_data_size, transfer_selecting_event) (x_continue_selection_transfer, x_remove_selection_transfers) (x_selection_transfer_timeout): New functions. (x_reply_selection_request): When handling selection requests, never wait for property notifications synchronously. Instead, write out the selection data as the client reads it from the event loop. (x_handle_selection_request, x_convert_selection) (x_handle_property_notify, x_get_window_property) (lisp_data_to_selection_data): Don't ever use pointers to Lisp string data! Instead, just store the string object itself. (syms_of_xselect): Initialize outstanding transfer list. (syms_of_xselect_for_pdumper): * src/xterm.c (x_delete_display): Remove outstanding selection transfers. * src/xterm.h: Update prototypes.
| * | Add itree_empty_p for clarity and reduced couplingMatt Armstrong2022-11-301-1/+1
| |/ | | | | | | | | | | | | * src/itree.h (itree_empty_p): New predicate. * src/buffer.h (buffer_has_overlays): * src/pdumper.c (dump_buffer): * src/alloc.c (mark_buffer): Call it. (Bug#59137)
| * Extend memory-info for remote systemsMichael Albinus2022-11-271-1/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * doc/lispref/files.texi (Magic File Names): Add memory-info. * doc/lispref/internals.texi (Garbage Collection): memory-info can also retrieve values from remote systems. * etc/NEWS: Document changes in memory-info. Fix typos. * lisp/files.el (warn-maybe-out-of-memory): Ensure local memory info. * lisp/net/tramp.el (tramp-handle-memory-info): New defun. (tramp-file-name-for-operation) * lisp/net/tramp-adb.el (tramp-adb-file-name-handler-alist): * lisp/net/tramp-archive.el (tramp-archive-file-name-handler-alist): * lisp/net/tramp-crypt.el (tramp-crypt-file-name-handler-alist): * lisp/net/tramp-gvfs.el (tramp-gvfs-file-name-handler-alist): * lisp/net/tramp-rclone.el (tramp-rclone-file-name-handler-alist): * lisp/net/tramp-sh.el (tramp-sh-file-name-handler-alist): * lisp/net/tramp-smb.el (tramp-smb-file-name-handler-alist): * lisp/net/tramp-sshfs.el (tramp-sshfs-file-name-handler-alist) * lisp/net/tramp-sudoedit.el (tramp-sudoedit-file-name-handler-alist): Add 'memory-info'. * lisp/net/tramp-sshfs.el (tramp-sshfs-handle-exec-path): Let-bind `process-file-side-effects'. * src/alloc.c (Fmemory_info): Support remote systems. (Qmemory_info): Declare. * test/lisp/net/tramp-tests.el (tramp-test31-memory-info): New test.
* | Separate marking native comp units into their own function.Vibhav Pant2022-12-201-32/+28
| | | | | | | | | | * src/alloc.c (mark_native_comp_unit): New function. (process_mark_stack): Use it.
* | Add static_comp_object_p for working with statically emmited objectsVibhav Pant2022-12-131-1/+58
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * src/alloc.c [HAVE_STATIC_LISP_GLOBALS] (static_comp_object_p): New function. When statically emitted lisp objects in native compilation are enabled, try to guess whether the provided object can be treated as a Lisp object allocated on the heap. (mark_object) [HAVE_STATIC_LISP_GLOBALS]: Skip marking the object if it has been emitted statically. (valid_lisp_object_p, survives_gc_p): Return true if the obj has been statically emitted. * src/puresize.h (puresize_h_CHECK_IMPURE): [HAVE_STATIC_LISP_GLOBALS]: Return true for statically emitted objects as well, since they are marked as constants during native compilation. * src/lisp.h (static_comp_object_p): Add declaration.
* | src/alloc.c: Don't mark a symbol's name if it's already marked.Vibhav Pant2022-12-081-1/+2
| | | | | | | | | | | | | | * src/alloc.c (process_mark_stack): While marking a Lisp_Symbol, only mark the 'name' string field if it hasn't been already marked, avoiding unnecessarily marking statically generated strings during native compilation.
* | Merge branch 'master' into scratch/comp-static-dataVibhav Pant2022-11-221-6/+21
|\ \ | |/
| * Merge remote-tracking branch 'savannah/master' into feature/tree-sitterYuan Fu2022-11-211-21/+46
| |\
| | * Advise against using too-high GC thresholdsEli Zaretskii2022-11-201-1/+11
| | | | | | | | | | | | | | | | | | | | | * doc/lispref/internals.texi (Garbage Collection): * src/alloc.c (syms_of_alloc) <gc-cons-threshold> <gc-cons-percentage>: Advise against enlarging the GC thresholds more than needed and for prolonged periods of time.
| | * itree.c: Make the iterator reentrant (bug#59183)Stefan Monnier2022-11-171-5/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Get rid of the global iterator object and instead allocate a separate iterator for every loop. This still uses the "duplicate iterator" code, including the old iterator which needs a stack, make ITREE_FOREACH a bit more expensive than we'd like. * src/itree.h (init_itree, forget_itree, itree_iterator_busy_p): Delete declarations. (itree_iterator_start): Add iterator arg and remove `line` and `file` args. (struct itree_iterator): Move from `itree.c`. Remove `line` and `file` fields. (ITREE_FOREACH): Stack allocate an iterator object and pass it to `itree_iterator_start`. * src/itree.c (struct itree_iterator): Move to itree.h. (iter): Delete global variable. (itree_iterator_create, init_itree, forget_itree, itree_iterator_busy_p): Delete functions. (itree_contains): Adjust assertion. (itree_iterator_finish): Deallocate the iterator's stack. (itree_iterator_start): Take the (uninitialized) iterator as argument. Allocate a fresh new stack. Remove `file` and `line` arguments. Don't check `running` any more since the iterator is not expected to be initialized at all. * src/eval.c (signal_or_quit): * src/alloc.c (garbage_collect): Don't check `itree_iterator_busy_p` any more. * src/emacs.c (main): No need to `init_itree` any more. (Fdump_emacs): No need to `forget_itree` any more.
| * | ; Rename ts_* symbols in treesit.cEli Zaretskii2022-10-171-2/+2
| | | | | | | | | | | | | | | * src/treesit.c: Rename all ts_* functions and variables to treesit_*; all references changed. Fix whitespace.
| * | Support MinGW build on MS-WindowsEli Zaretskii2022-10-161-12/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * src/treesit.c [WINDOWSNT]: Add MS-Windows boilerplate for dynamically-loaded optional libraries. (init_treesit_functions) [WINDOWSNT]: New function. (load_tree_sitter_if_necessary): New function. (ts_initialize): Call 'load_tree_sitter_if_necessary'. (ts_delete_parser, ts_delete_query, ts_named_node_p): Wrapper functions for TS calls from outside treesit.c. (Ftreesit_parser_root_node, Ftreesit_parser_set_included_ranges) (Ftreesit_parser_included_ranges, Ftreesit_node_type) (Ftreesit_node_start, Ftreesit_node_end, Ftreesit_node_string) (Ftreesit_node_parent, Ftreesit_node_child, Ftreesit_node_check) (Ftreesit_node_field_name_for_child, Ftreesit_node_child_count) (Ftreesit_node_next_sibling, Ftreesit_node_prev_sibling) (Ftreesit_node_first_child_for_pos) (Ftreesit_node_descendant_for_range, Ftreesit_node_eq) (Ftreesit_query_compile, Ftreesit_query_capture) (Ftreesit_search_subtree, Ftreesit_search_forward) (Ftreesit_induce_sparse_tree): Call 'ts_initialize' before any other TS functions. (Ftreesit_available_p): 'treesit-available-p' implemented in C, so that on WINDOWSNT the library could be loaded dynamically. * src/treesit.h (ts_delete_parser, ts_delete_query) (ts_named_node_p): Add prototypes. * src/print.c (print_vectorlike): * src/alloc.c (cleanup_vector): Call tree-sitter function via wrappers defined in treesit.c, not directly, because WINDOWSNT redefines the TS functions to be called via function pointers. * src/Makefile.in (base_obj): Add treesit.o (TREE_SITTER_OBJ): Remove. * lisp/treesit.el (treesit-available-p): Remove: now implemented in C. * lisp/term/w32-win.el (dynamic-library-alist): Add libtree-sitter DLLs. * configure.ac (TREE_SITTER): Support the MinGW build. (TREE_SITTER_OBJ): Remove.
| * | Merge branch 'master' into feature/tree-sitterYuan Fu2022-10-051-1/+1
| |\ \
| * \ \ Merge remote-tracking branch 'origin/master' into feature/tree-sitterYuan Fu2022-08-291-6/+17
| |\ \ \
| * \ \ \ Merge remote-tracking branch 'savannah/master' into feature/tree-sitterYuan Fu2022-06-141-2/+6
| |\ \ \ \
| * | | | | Add new type treesit-compiled-queryYuan Fu2022-06-141-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | No intergration/interaction with the new type, just adding it. * lisp/emacs-lisp/cl-preloaded.el (cl--typeof-types): Add new type. * src/alloc.c (cleanup_vector): Add gc for the new type. * src/data.c (Ftype_of): Add switch case for the new type. (syms_of_data): Add symbols for the new type. * src/lisp.h (DEFINE_GDB_SYMBOL_BEGIN): Add new type. * src/treesit.c (Ftreesit_compiled_query_p): New function. (syms_of_treesit): Add symbol for the new type. * src/treesit.h (struct Lisp_TS_Query): New struct. (TS_COMPILED_QUERY_P, XTS_COMPILED_QUERY, CHECK_TS_COMPILED_QUERY): New macros. * src/print.c (print_vectorlike): Add printing for the new type.
| * | | | | ; Merge from master.Yuan Fu2022-05-071-289/+402
| |\ \ \ \ \
| * | | | | | Add tree-sitter intergrationYuan Fu2022-05-071-0/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * configure.ac (HAVE_TREE_SITTER, TREE_SITTER_OBJ): New variables. (DYNAMIC_LIB_SUFFIX): new variable, I copied code from MODULES_SUFFIX so the diff looks this way. * doc/lispref/elisp.texi (Top): Add tree-sitter manual. * doc/lispref/modes.texi (Font Lock Mode): mention tree-sitter. (Parser-based Font Lock): New section. (Auto-Indentation): Mention tree-sitter. (Parser-based Indentation): New section. * doc/lispref/parsing.texi (Parsing Program Source): New chapter. * lisp/emacs-lisp/cl-preloaded.el (cl--typeof-types): Add treesit-parser and treesit-node type. * lisp/treesit.el: New file. * src/Makefile.in (TREE_SITTER_LIBS, TREE_SITTER_FLAGS, TREE_SITTER_OBJ): New variables. * src/alloc.c: (cleanup_vector): Add cleanup code for treesit-parser and treesit-node. * src/casefiddle.c (casify_region): Notify tree-sitter parser of buffer change. * src/data.c (Ftype_of): Add treesit-parser and treesit-node type (Qtreesit_parser, Qtreesit_node): New symbol. * src/emacs.c (main): Add symbols in treesit.c. * src/eval.c (define_error): Move the function to here. * src/insdel.c (insert_1_both, insert_from_string_1, insert_from_gap, insert_from_buffer_1, replace_range, del_range_2): Notify tree-sitter parser of buffer change. * src/json.c (define_error): Move this function out. * src/lisp.h (DEFINE_GDB_SYMBOL_BEGIN): Add treesit-parser and treesit-node. * src/lread.c (Vdynamic_library_suffixes): New variable. * src/print.c (print_vectorlike): Add code for printing treesit-parser and treesit-node. * src/treesit.c: New file. * src/treesit.h: New file. * test/src/treesit-tests.el: New file.
* | | | | | | src/alloc.h: Add new header.Vibhav Pant2022-11-191-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add alloc.h, a header containing allocation-related constants that are used by comp.c while emitting static data. * src/alloc.h: New file. * src/alloc.c: Set alloc.h variables only when native compilation is enabled.
* | | | | | | comp: Perma-mark all compiled constants, declare them as const.Vibhav Pant2022-11-171-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * comp.c (emit_lisp_string_constructor_rval, cons_block_emit_constructor, float_block_emit_constructor, emit_comp_lisp_obj): Initialize objects generated with their mark bit(s) set. (comp_lisp_const_get_lisp_obj_rval): Declare constants as const variables. * alloc.c (pin_string): Don't set size_byte when it is already set to -3, avoiding writing to read-only native compiled constants.
* | | | | | | Address styling and indentation inconsistencies.Vibhav Pant2022-11-151-12/+12
| | | | | | |
* | | | | | | Merge branch 'master' into scratch/comp-static-dataVibhav Pant2022-11-141-20/+40
|\ \ \ \ \ \ \ | | |_|_|_|_|/ | |/| | | | |
| * | | | | | Port interval trees to --enable-checking=structsBasil L. Contovounesios2022-11-031-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some names under the interval_* namespace were renamed under the itree_* namespace in commits: 0. f421b58db5 of 2022-10-19 "Prefix all itree.h type names with itree_". 1. 37a1145410 of 2022-10-19 "Rename all exported itree.h functions with the itree_ prefix" Further, some values still referenced in commentary were removed in commits: 2. 258e618364 of 2022-10-17 "Delete the itree_null sentinel node, use NULL everywhere." 3. 2c4a3910b3 of 2022-10-02 "itree: Use a single iterator object" * src/emacs.c (main): Allocate global itree iterator once and for all. * src/alloc.c (mark_overlay): * src/buffer.c (set_overlays_multibyte): * src/itree.c (itree_destroy): Update commentary. (interval_stack_ensure_space, itree_insert_gap): Prefer unsigned-to-unsigned comparisons over signed-to-unsigned. (interval_stack_push_flagged, interval_tree_insert) (interval_tree_contains, itree_iterator_start) (itree_iterator_finish, itree_iterator_next, itree_iterator_narrow): Improve assertions. (itree_init): Rename... (init_itree): ...to this, for consistency with other global init functions. (itree_create): Stop leaking a global iterator allocation on each call. (interval_tree_init): Complete renames of interval_tree -> itree_tree and interval_tree_clear -> itree_clear. (interval_tree_remove_fix): Fix indentation. * src/itree.h: Declare init_itree. (ITREE_FOREACH): Fix typo in commentary. * src/pdumper.c [CHECK_STRUCTS] (dump_interval_node): Use the correct name in the HASH condition and #error message. (dump_overlay, dump_buffer): Update HASH (bug#58975).