aboutsummaryrefslogtreecommitdiffstats
path: root/src/alloc.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Faster, more compact, and readable closure creationMattias Engdegård2021-02-211-0/+33
| | | | | | | | | | | | | | | | | | | Simplify closure creation by calling a single function at run time instead of putting it together from small pieces. This is faster (by about a factor 2), takes less space on disk and in memory, and makes internal functions somewhat readable in disassembly listings again. This is done by creating a prototype function at compile-time whose closure variables are placeholder values V0, V1... which can be seen in the disassembly. The prototype is then cloned at run time using the new make-closure function that replaces the placeholders with the actual closure variables. * lisp/emacs-lisp/bytecomp.el (byte-compile-make-closure): Generate call to make-closure from a prototype function. * src/alloc.c (Fmake_closure): New function. (syms_of_alloc): Defsubr it. * src/data.c (syms_of_data): Defsym byte-code-function-p.
* Don't let `maybe_quit` prevent resetting `consing_until_gc` (bug#43389)Stefan Monnier2021-01-201-2/+4
| | | | | * src/alloc.c (garbage_collect): Postpone `unblock_input` a bit. * src/window.c (window_parameter): Avoid `maybe_quit`.
* Update copyright year to 2021Paul Eggert2021-01-011-1/+1
| | | | Run "TZ=UTC0 admin/update-copyright".
* Adjust to recent Gnulib changesPaul Eggert2020-12-251-1/+5
| | | | | | | | | | | | | | | | | | | | | | The latest Gnulib merge brought in free-posix, which causes 'free' to preserve errno. This lets us simplify some Emacs code that calls 'free'. * admin/merge-gnulib (GNULIB_MODULES): Add free-posix. This module is pulled in by canonicalize-lgpl anyway, so we might as well rely on it. * lib-src/emacsclient.c (get_current_dir_name): Sync better with src/sysdep.c. * lib-src/etags.c (process_file_name, etags_mktmp): * lib-src/update-game-score.c (unlock_file): * src/fileio.c (file_accessible_directory_p): * src/sysdep.c (get_current_dir_name_or_unreachable): Simplify by assuming that 'free' preserves errno. * src/alloc.c (malloc_unblock_input): Preserve errno, so that xfree preserves errno. * src/sysdep.c (get_current_dir_name_or_unreachable): Simplify by using strdup instead of malloc+memcpy. No need for realloc (and the old code leaked memory anyway on failure); just use free+malloc.
* Fix use of obsolete 'emergency' warning levelStefan Kangas2020-12-231-1/+1
| | | | | * src/alloc.c (display_malloc_warning): Use new style ':emergency' warning level instead of obsolete 'emergency'.
* * src/alloc.c (Fgarbage_collect_maybe): New functionSpencer Baugh2020-12-041-0/+25
|
* garbage-collect doc string clarificationLars Ingebrigtsen2020-11-291-1/+8
| | | | | * src/alloc.c (Fgarbage_collect): Mention that calling this function is not guaranteed to collect all the garbage (bug#34404).
* Fix incorrect handling of module runtime and environment pointers.Philipp Stephani2020-11-271-4/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We used to store module runtime and environment pointers in the static lists Vmodule_runtimes and Vmodule_environments. However, this is incorrect because these objects have to be kept per-thread. With this naive approach, interleaving module function calls in separate threads leads to environments being removed in the wrong order, which in turn can cause local module values to be incorrectly garbage-collected. The fix isn't completely trivial: specbinding the lists wouldn't work either, because then the garbage collector wouldn't find the environments in other threads than the current ones, again leading to objects being garbage-collected incorrectly. While introducing custom pseudovector types would fix this, it's simpler to put the runtime and environment pointers into the specbinding list as new specbinding kinds. This works since we need to unwind them anyway, and we only ever treat the lists as a stack. The thread switching machinery ensures that the specbinding lists are thread-local, and that all elements of the specbinding lists in all threads are marked during garbage collection. Module assertions now have to walk the specbinding list for the current thread, which is more correct since they now only find environments for the current thread. As a result, we can now remove the faulty Vmodule_runtimes and Vmodule_environments variables entirely. Also add a unit test that exemplifies the problem. It interleaves two module calls in two threads so that the first call ends while the second one is still active. Without this change, this test triggers an assertion failure. * src/lisp.h (enum specbind_tag): Add new tags for module runtimes and environments. * src/eval.c (record_unwind_protect_module): New function to record a module object in the specpdl list. (do_one_unbind): Unwind module objects. (backtrace_eval_unrewind, default_toplevel_binding, lexbound_p) (Fbacktrace__locals): Deal with new specbinding types. (mark_specpdl): Mark module environments as needed. * src/alloc.c (garbage_collect): Remove call to 'mark-modules'. Garbage collection of module values is now handled as part of marking the specpdl of each thread. * src/emacs-module.c (Fmodule_load, funcall_module): Use specpdl to record module runtimes and environments. (module_assert_runtime, module_assert_env, value_to_lisp): Walk through specpdl list instead of list variables. (mark_module_environment): Rename from 'mark_modules'. Don't attempt to walk though current thread's environments only, since that would miss other threads. (initialize_environment, finalize_environment): Don't change Vmodule_environments variable; environments are now in the specpdl list. (finalize_environment_unwind, finalize_runtime_unwind): Make 'extern' since do_one_unbind now calls them. (finalize_runtime_unwind): Don't change Vmodule_runtimes variable; runtimes are now in the specpdl list. (syms_of_module): Remove Vmodule_runtimes and Vmodule_environments. * test/data/emacs-module/mod-test.c (Fmod_test_funcall): New test function. (emacs_module_init): Bind it. * test/src/emacs-module-tests.el (emacs-module-tests--variable): New helper type to guard access to state in a thread-safe way. (emacs-module-tests--wait-for-variable) (emacs-module-tests--change-variable): New helper functions. (emacs-module-tests/interleaved-threads): New unit test.
* New debugging command 'malloc-info'Eli Zaretskii2020-11-101-0/+17
| | | | | * src/alloc.c (Fmalloc_info) [GNU_LINUX]: New command. (syms_of_alloc): Defsubr it. (Bug#43389)
* Use the full name of the null byte/character, not its abbreviationAndreas Schwab2020-10-051-1/+1
| | | | | | | | | | | | | | | | | | | | | * lisp/subr.el (inhibit-nul-byte-detection): Make it an obsolete alias. * src/coding.c (setup_coding_system): Use original name. (detect_coding): Rename nul_byte_found => null_byte_found. (detect_coding_system): Use original name. Rename nul_byte_found => null_byte_found. (Fdefine_coding_system_internal): Use original name. (syms_of_coding): Rename inhibit-nul-byte-detection to inhibit-null-byte-detection. * src/w16select.c (get_clipboard_data): Rename nul_char to null_char. * src/json.c (check_string_without_embedded_nulls): Rename from check_string_without_embedded_nuls. (Fjson_parse_string): Adjust accordingly. * src/coding.h (enum define_coding_undecided_arg_index) (enum coding_attr_index): Rename ...nul_byte... to ...null_byte.... * lisp/info.el (info-insert-file-contents, Info-insert-dir): * lisp/international/mule.el (define-coding-system): * lisp/vc/vc-git.el (vc-git--call): * doc/lispref/nonascii.texi (Lisp and Coding Systems): Use original name.
* Reinstall recent GC-related changesPaul Eggert2020-09-051-129/+118
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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-118/+129
| | | | | | | | | | | | | | | | | | * 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.
* * src/alloc.c (live_symbol_holding): Pacify gcc -Wlogical-op.Paul Eggert2020-08-311-2/+2
|
* Use mark_objects elsewhere tooPaul Eggert2020-08-311-7/+3
| | | | | | | | * 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-91/+14
| | | | | | | | | | | * 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.
* Avoid some false matches in mark_maybe_pointerPaul Eggert2020-08-311-14/+70
| | | | | | | | | | | | | | | This lets Emacs avoid marking some garbage as if it were in use. On one test platform (RHEL 7.8, Intel Xeon Silver 4116) it sped up ‘cd lisp; make compile-always’ by a bit over 1%. * src/alloc.c (live_string_holding, live_cons_holding) (live_symbol_holding, live_large_vector_holding) (live_small_vector_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_vector_pointer): New function.
* Omit no-longer-needed stack mark_maybe_objectPaul Eggert2020-08-311-5/+0
| | | | | | * src/alloc.c (mark_memory): Do not bother using mark_maybe_object on the stack, since mark_maybe_pointer now marks everything that mark_maybe_object would.
* Fix GC bug with Lisp floats and --with-wide-intPaul Eggert2020-08-311-12/+31
| | | | | | | | | | On --with-wide-int platforms where Lisp_Object can be put into non-adjacent registers, mark_maybe_pointer failed to mark a float whose only reference was as a tagged pointer. * src/alloc.c (live_float_holding): New function, a generalization of the old live_float_p. (live_float_p): Use it. (mark_maybe_pointer): Use live_float_holding, not live_float_p.
* Drop support for -fcheck-pointer-boundsPaul Eggert2020-08-041-20/+11
| | | | | | | | | | | GCC has removed the -fcheck-pointer bounds option, and the Linux kernel has also removed support for Intel MPX, so there’s no point to keeping this debugging option within Emacs. * src/bytecode.c (BYTE_CODE_THREADED): * src/lisp.h (DEFINE_LISP_SYMBOL, XSYMBOL, make_lisp_symbol): Assume __CHKP__ is not defined. * src/ptr-bounds.h: Remove. All uses of ptr_bounds_clip, ptr_bounds_copy, ptr_bounds_init, ptr_bounds_set removed.
* Simplify pointer computation in mark_maybe_objectPaul Eggert2020-08-031-17/+7
| | | | | | | | * src/alloc.c (mark_maybe_object): Use simpler way to avoid -fsanitize=undefined false alarms, by converting the word tag to intptr_t first. Omit now-unnecessary runtime overflow check. (mark_memory): Work even if UINTPTR_MAX <= INT_MAX (!).
* * src/alloc.c (mark_maybe_object): Avoid signed integer overflowPhilipp Stephani2020-08-021-1/+2
|
* Fix last change in alloc.c.Eli Zaretskii2020-08-021-0/+2
| | | | | * src/alloc.c (mark_maybe_object) [WIDE_EMACS_INT]: Avoid compiler warning about 'overflow' being unused.
* * src/alloc.c (mark_memory): Avoid signed integer overflowPhilipp Stephani2020-08-021-1/+1
|
* * src/alloc.c (mark_maybe_object): Make overflow check conditional.Philipp Stephani2020-08-011-0/+6
|
* Improve offset calculation in wide int buildsPhilipp Stephani2020-08-011-2/+4
| | | | | * src/alloc.c (mark_maybe_object): Make sure that OFFSET isn’t widened during subtraction.
* * src/alloc.c (resize_string_data): Adjust string bytes (Bug#42540)Philipp Stephani2020-08-011-0/+3
|
* Suppress sanitizer errors about pointer arithmetic in a few placesPhilipp Stephani2020-08-011-2/+3
| | | | | | | | | | We perform weird pointer arithmetic due to the layout of Lisp_Objects holding symbols. ASan/UBSan warns about that (Bug#42530). Suppress the warnings by performing the arithmetic on integer types and casting back to pointers. * src/alloc.c (mark_maybe_object, mark_memory): Temporarily cast pointer to 'intptr_t'.
* Port to Oracle Studio 12.6 (sparc)Paul Eggert2020-07-301-27/+4
| | | | | | | | * src/alloc.c (__builtin_unwind_init) [!HAVE___BUILTIN_UNWIND_INIT]: Move from here ... * src/lisp.h: ... to here, since flush_stack_call_func uses it. * src/pdumper.c (dump_off_from_lisp): Avoid ‘return n;;’ to pacify Oracle Studio.
* Streamline live_*_holdingPaul Eggert2020-06-041-124/+148
| | | | | | | | | | | | | | | | | | | (live_string_holding, live_cons_holding, live_symbol_holding) (live_float_p, live_vector_holding): Assert that m->type is correct, instead of testing this at runtime. All callers changed. (live_large_vector_holding, live_small_vector_holding): Now two functions instead of the old live_vector_holding. All callers changed. (live_large_vector_p, live_small_vector_p): Now two functions instead of the old live_vector_p. All callers changed. (mark_maybe_object): Ignore Lisp_Type_Unused0 quickly too, since that cannot possibly be an object. (CHECK_LIVE, CHECK_ALLOCATED_AND_LIVE): New arg MEM_TYPE. All callers changed. (CHECK_ALLOCATED_AND_LIVE_SYMBOL): Simplify by combining GC_CHECK_MARKED_OBJECTS code.
* Make live_*_p more accuratePaul Eggert2020-06-041-40/+60
| | | | | | | | | | | | * src/alloc.c (live_string_holding, live_cons_holding) (live_symbol_holding, live_vector_holding): Return a C pointer, not a Lisp_Object. All callers changed. This helps the compiler a bit. (live_string_p, live_cons_p, live_symbol_p, live_vector_p): Require that P point directly at the object, rather than somewhere within the object. This fixes some false positives with valid_lisp_object_p (used only in debugging). (mark_maybe_object): Rely on the new accuracy.
* Don’t default to Valgrind unless ENABLE_CHECKINGPaul Eggert2020-06-031-2/+3
| | | | | | | | | | | * src/alloc.c (USE_VALGRIND): If not defined, don’t default it to 1 unless ENABLE_CHECKING. The Valgrind hooks bloat the garbage collector a bit in production, and there’s no need for them these days if one has a Valgrind suppressions file (which one needs anyway). (mark_maybe_pointer): Use ‘#if USE_VALGRIND’ instead of ‘#ifdef USE_VALGRIND’ for consistency with other uses of USE_VALGRIND. This is in case someone builds with ‘-DENABLE_CHECKING -DUSE_VALGRIND=0’ in CFLAGS.
* Simplify and regularize some offset tests in alloc.cPaul Eggert2020-06-011-5/+4
| | | | | * src/alloc.c (live_string_holding, live_cons_holding) (live_symbol_holding, live_float_p): Simplify and regularize.
* Merge from origin/emacs-27Paul Eggert2020-06-011-33/+10
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 44c0e074f7 * doc/emacs/buffers.texi (Icomplete): Mention icomplete-mi... 68b6dad1d8 Be more aggressive in marking objects during GC 36f508f589 ; * src/xdisp.c (find_last_unchanged_at_beg_row): Fix a typo. cc340da1fe Fix bug #41618 "(byte-compile 'foo) errors when foo is a m... 41232e6797 Avoid crashes due to bidi cache being reset during redisplay f72bb4ce36 * lisp/tab-bar.el (switch-to-buffer-other-tab): Normalize ... d3e0023aaa ; * etc/TODO: Fix formatting. (Bug#41497) a8ad94cd2f Fix mingw.org's MinGW GCC 9 warning about 'execve' # Conflicts: # lisp/tab-bar.el # nt/inc/ms-w32.h # src/alloc.c
| * Be more aggressive in marking objects during GCPaul Eggert2020-05-311-16/+10
| | | | | | | | | | | | | | Simplified version of a patch from Pip Cet (Bug#41321#299). * src/alloc.c (maybe_lisp_pointer): Remove. All uses removed. (mark_memory): Also look at the pointer offset by ‘lispsym’, for symbols.
* | Tweak GC performance if !USE_LSB_TAGPaul Eggert2020-05-261-2/+19
| | | | | | | | | | | | Performance issue reported by Eli Zaretskii (Bug#41321#149). * src/alloc.c (GC_OBJECT_ALIGNMENT_MINIMUM): New constant. (maybe_lisp_pointer): Use it instead of GCALIGNMENT.
* | Move union emacs_align_type to alloc.cPaul Eggert2020-05-251-0/+40
| | | | | | | | | | | | * src/alloc.c (union emacs_align_type): Move to here ... * src/lisp.h: ... from here, and uncomment out some of the types that alloc.c can see but lisp.h cannot.
* | Further fix for aborts due to GC losing pseudovectorsPaul Eggert2020-05-251-18/+16
| | | | | | | | | | | | | | | | | | * src/alloc.c (MALLOC_ALIGNMENT_BOUND): Remove. (LISP_ALIGNMENT): Go back to yesterday’s version, except use union emacs_align_type instead of max_align_t. (MALLOC_IS_LISP_ALIGNED): Go back to yesterday’s version. (maybe_lisp_pointer): Check against GCALIGNMENT, not LISP_ALIGNMENT. * src/lisp.h (union emacs_align_type): Bring back.
* | Refix aborts due to GC losing pseudovectorsPaul Eggert2020-05-251-19/+13
| | | | | | | | | | | | | | | | | | | | | | This is simpler, and fixes a bug in the previous fix. * src/alloc.c (MALLOC_ALIGNMENT_BOUND): Simplify by using max_align_t, since the buggy implementations won’t break this simpler implementation. (LISP_ALIGNMENT): Simplify by just using GCALIGNMENT, since the fancier implementation wasn’t correct anyway, and fixing it isn’t worth the trouble on practical platforms. * src/lisp.h (union emacs_align_type): Remove.
* | Fix aborts due to GC losing pseudovectorsPaul Eggert2020-05-251-26/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem reported by Eli Zaretskii (Bug#41321). * src/alloc.c (MALLOC_ALIGNMENT_BOUND): New constant. (LISP_ALIGNMENT): Lower it to avoid crashes on MinGW and similarly buggy platforms where malloc returns pointers not aligned to alignof (max_align_t). But keep it higher on platforms where this is known to work, as it helps GC performance. (MALLOC_IS_LISP_ALIGNED): Define in terms of the other two. * src/alloc.c (stacktop_sentry): * src/thread.c (run_thread): Don’t overalign or oversize stack sentries; they need to be aligned only for pointers and Lisp_Object, not for arbitrary pseudovector contents. * src/lisp.h (union emacs_align_type): New type, used for LISP_ALIGNMENT.
* | ; src/alloc.c: Add a GC reg spill mechanism and Bug#41357 related commentary.Andrea Corallo2020-05-201-3/+17
| |
* | Hoist some byte-code checking out of evalPaul Eggert2020-05-191-23/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 Garbage Collector for missing calle-saved regs content (Bug#41357)Andrea Corallo2020-05-171-3/+1
| | | | | | | | | | | | | | | | | | * src/alloc.c (SET_STACK_TOP_ADDRESS): Do not call __builtin_unwind_init. (flush_stack_call_func1): Rename from 'flush_stack_call_func'. (flush_stack_call_func): New function to spill all registers before calling 'flush_stack_call_func1'. This to make sure the top of the stack identified includes those registers.
* | Remove `all_buffers` and the associated `next` field of buffersStefan Monnier2020-03-311-82/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * src/alloc.c (enum mem_type): Remove MEM_TYPE_BUFFER. (allocate_buffer): Allocate like any other pseudovector. Don't register on `all_buffers` any more. (live_buffer_holding, live_buffer_p): Delete functions. (mark_maybe_object, valid_lisp_object_p): Don't pay attention to MEM_TYPE_BUFFER any more. (garbage_collect): Only compact the live buffers. (mark_buffer): Mark the undo_list of dead buffers here. (mark_object): Buffers are normal pseudovectors now. (sweep_buffers): Don't do the actual sweep here, just cleanup the markers and only for live buffers. * src/buffer.c (all_buffers): Remove variable. (Fkill_buffer): Don't check indirect dead buffers. Set the undo_list before we remove ourselves from the list of live buffers. (Fbuffer_swap_text, Fset_buffer_multibyte): Don't check indirect dead buffers. (init_buffer_once): Don't set `all_buffers`. (init_buffer): Don't map new memory for dead buffers. * src/buffer.h (struct buffer): Remove `next` field. (FOR_EACH_BUFFER): Remove macro. * src/pdumper.c (dump_buffer): Don't dump the `next` field.
* | Reverse the meaning of 2nd arg to 'live_buffer_holding'Eli Zaretskii2020-03-151-7/+9
| | | | | | | | | | | | | | | | | | * src/alloc.c (live_buffer_holding): Rename ALL_BUFFERS ti IGNORE_KILLED, and reverse the condition for returning killed buffers. (live_buffer_p): Add commentary. (live_buffer_p, mark_maybe_object, mark_maybe_pointer): Reverse the 2nd argument to live_buffer_holding. (Bug#39962)
* | Make sure we mark reachable killed buffers during GCPip Cet2020-03-151-8/+10
| | | | | | | | | | | | | | * src/alloc.c (live_buffer_holding): Add ALL_BUFFERS argument for returning killed buffers. (mark_maybe_object, mark_maybe_pointer): Use the additional argument. (Bug#39962)
* | Fix crash when sending Gnus message (Bug#39207)Paul Eggert2020-01-221-1/+3
| | | | | | | | | | | | * src/alloc.c (resize_string_data): The string must be multibyte. When not bothering to reallocate, do bother to change the byte count. * test/src/alloc-tests.el (aset-nbytes-change) New test.
* | Don’t assume sizeof (size_t) == 4 in allocatorsPaul Eggert2020-01-181-11/+30
| | | | | | | | | | | | | | | | | | | | | | This removes some old 32-bit assumptions in Emacs allocator tuning, and improves performance of ‘make compile-always’ by about 7% on a couple of 64-bit GNU/Linux platforms I tried it on. It should not affect performance on 32-bit platforms. * src/alloc.c (MALLOC_SIZE_NEAR): New macro. (MALLOC_ALIGNMENT): New constant. (INTERVAL_BLOCK_SIZE, SBLOCK_SIZE, STRING_BLOCK_SIZE): Use the new macro. Make these enum constants since they need not be macros.
* | Improve performance when a string's byte count changesPaul Eggert2020-01-181-17/+46
| | | | | | | | | | | | | | | | | | | | | | * src/alloc.c (allocate_string_data): Now static. Remove code for when Faset calls this function when S already has data assigned, as that can no longer happen. (resize_string_data): New function, which avoids relocation in more cases than the old code did, by not bothering to relocate when the size changes falls within the alignment slop. * src/data.c (Faset): Use resize_string_data. Change a while to a do-while since it must iterate at least once.
* | Fix bug in recent allocate_string_data patchPaul Eggert2020-01-041-17/+18
| | | | | | | | | | | | | | | | Reported by Glenn Morris in: https://lists.gnu.org/r/emacs-devel/2020-01/msg00098.html * src/alloc.c (allocate_string_data): If the string is small and there is not enough room in the current block, clear the string if CLEARIT.
* | Let the OS clear new large strings of NULPaul Eggert2020-01-031-29/+58
| | | | | | | | | | | | | | | | | | | | | | | | | | On my platform, this sped up (make-string 4000000000 0) from 2.5 to 0.015 seconds (not that people should want to do this much :-). * src/alloc.c (allocate_string_data): New arg CLEARIT. Callers changed. (Fmake_string): Prefer calloc to malloc+memset when allocating a large string of NUL bytes. (make_clear_string): New function. (make_uninit_string): Use it. (make_clear_multibyte_string): New function. (make_uninit_multibyte_string): Use it.