1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-03-27 09:11:48 -07:00
Commit graph

51674 commits

Author SHA1 Message Date
Eli Zaretskii
005f908680 ; Improve doc strings of some igc functions
* src/igc.c (Figc__arena_step):
* lisp/emacs-lisp/igc.el (igc--current-idle-time, igc--on-idle):
Doc fixes.
2025-12-06 15:15:50 +02:00
Helmut Eller
4d4694e498 * src/igc.c (process_one_message): Use "GC end:" instead of "GC:"
A comment in mps/code/traceanc.c says:

 * (Note: this should properly be called "trace end", but it's much
 * too late to change it now!)
2025-12-05 08:49:28 +01:00
Helmut Eller
372eff48c4 * src/igc.h (igc_pin, igc_unpin): Remove redundant declarations. 2025-12-05 08:46:58 +01:00
Gerd Möllmann
f4571d757d ; Revert a change ein src/.lldbinit 2025-12-04 14:00:48 +01:00
Eli Zaretskii
098b9b74db ; Fix comments and whitespace of a recent changeset
* src/pdumper.c (dump_do_dump_relocation):
* src/comp.h:
* src/comp.c (obj_to_reloc, emit_static_object)
(declare_imported_data_relocs, check_abi_version, setup_constants)
(load_comp_unit):  Fix comments and whitespace.
2025-12-04 13:56:20 +02:00
Kien Nguyen
771542f612 Unbreak the MS-Windows build broken by last changes
* src/comp.c (gcc_jit_context_zero) [WINDOWSNT]: Define and define
the prototype of its function pointer.
(init_gccjit_functions) [WINDOWSNT]: Load 'gcc_jit_context_zero
from the DLL.
2025-12-04 13:42:42 +02:00
Gerd Möllmann
714c641df8 Alternative implementation of constants in .eln files.
See the comment at the start of comp.h about this.

* src/comp.c (ABI_VERSION): Make it an integer, and increment.
(ABI_VERSION_SYM): New.
(hash_native_abi): Use it.
(emit_abi_version, check_abi_version): New functions.
(Fcomp__compile_ctxt_to_file0): Emit ABI_VERSION_SYM.
(load_comp_unit): Check ABI version.

* src/comp.c (comp_t): Add n_data_relocs and
n_data_relocs_ephemeral.
(obj_to_reloc): Use them, and handle case of using pointers to
constants.
(emit_static_object): Add FIXMEs.
(declare_imported_data_relocs): Handle case of pointers to
constants vectors differently.
(declare_imported_data): Set comp's number of constants.
(setup_constants): New function.
(load_comp_unit): Don't create roots, pin instead. Don't rely on
tricks to protect ephemeral vector.
(Fnative_elisp_load): Init pins.

* src/comp.h (USE_POINTER_TO_CONSTANT_VECTOR): New. If defined,
don't use vectors.
(Lisp_Native_Comp_Unit): Define data_relocs and data_eph_relocs
depending on USE_POINTER_TO_CONSTANT_VECTOR. Add pin ids

* src/igc.c (unpin): Add an eassert.
(root_create_exact_ptr, igc_root_create_exact_ptr):
Return root list node.
(maybe_destroy_rootI: Removed.
(igc_pin, igc_unpin): New functions.
(igc_root_destroy_comp_unit): Removed.
(igc_init_pin, igc_unpin_comp_unit): New function.

* src/igc.h: Declare new functions, remove old ones.
2025-12-03 16:44:01 +01:00
Helmut Eller
efbfd82060 Allocate bignum limbs in the AMC pool
Keep the mpz_t field in the Lisp_Bignum struct and the indirection so
that we don't need to change the bignum_val function.  However, the
value._mp_d fields always points right after the mpz_t.

This patch also changes the peak memory usage for the pidigits benchmark
with MPS:

    |        | max rss   | elapsed time |
    |--------+-----------+--------------|
    | before | 702316 KB | 16.99 s      |
    | after  | 81128 KB  | 17.15 s      |

* src/bignum.h (struct Lisp_Bignum): Add room for the limb array.
* src/bignum.c (make_bignum_from_mpz): New.
(make_bignum_bits, make_bignum_str): Use it.
* src/igc.h (fix_bignum): New, needed to adjust the _mp_d field.
(fix_vector): Call it.
(finalize_bignum): Deleted.
(finalize_vector, maybe_finalize): No more finalization for bignums.
* src/pdumper.c (dump_bignum, dump_do_dump_relocation, dump_cold_bignum):
Adapt to new bignums.
2025-12-01 20:26:32 +01:00
Helmut Eller
6410312c00 Tally GMP allocations
Without this, bignum allocations in the pidigits don't properly trigger
GC.  This patch changes the peak memory usage for the pidigits benchmark
by a factor of 6.  The benchmark also begins to spend much more time in
GC, as it should be:

|        | max rss   | elapsed time |
|--------+-----------+--------------|
| before | 392472 KB | 6.7 s        |
| after  | 58512 KB  | 32.93 s      |

* src/bignum.h (init_gmp_memory_functions): Declare new function.
* src/alloc.c (init_gmp_memory_functions): Implement it.
(xmalloc_for_gmp): New helper.
(xrealloc_for_gmp, xfree_for_gmp): Moved here from bignum.c.
* src/bignum.c (init_bignum): Call init_gmp_memory_functions.
2025-12-01 15:58:11 +01:00
Helmut Eller
29c2adca16 Abort if EMACS_IGC_ARENA_SIZE can't be parsed
* src/igc.c (parse_error): New helper.
(read_gens, read_arena_size): Use it.
2025-11-29 20:52:56 +01:00
Helmut Eller
1e31845486 * src/igc.c (process_one_message): Format timestamps as floats. 2025-11-29 20:52:56 +01:00
Eli Zaretskii
870e008c31 ; * src/igc.c (Figc__collect): Doc fix. 2025-11-29 11:39:22 +02:00
Helmut Eller
2463d86ec7 Read the MPS_KEY_ARENA_SIZE parameter from environment
The initial arena size can be set with EMACS_IGC_ARENA_SIZE=<bytes>.

* src/igc.c (read_arena_size): New function.
(make_arena): Use it.
2025-11-28 20:17:39 +01:00
Helmut Eller
863840d69d Make it easier to start an incremental collection
* src/igc.h (igc_collect): Add incremental argument.
* src/igc.c (igc_collect): Depending on the argument, either call
mps_arena_collect or mps_arena_start_collect.
(Figc__collect): Add optional argument.
2025-11-28 20:14:18 +01:00
Helmut Eller
2340de8917 Process mps_message_type_gc messages
This makes the output look like:
[81338818] GC start: Generation 0 of a chain has reached capacity: start
 a minor collection.
[81344807] GC: condemned: 16802688 live: 417424 not_condemned: 58871808

The "[81338818]" part is the time when the message was posted.

* src/igc.c (enable_messages): Include mps_message_type_gc.
(process_one_message): Handler mps_message_type_gc and include the
timestamp.
2025-11-28 10:54:47 +01:00
Helmut Eller
e9711a2b2b Remove the oldgen_ap field from struct igc_thread
This allocation point is only needed for the dump.  It's simpler to
create and destroy this allocation point in igc_alloc_dump than to do it
for each thread.

* src/igc.c (struct igc_thread): Remove oldgen_ap.
(create_thread_aps): Delete code for oldgen_ap.
(igc_on_pdump_loaded): Create and destroy the allocation point here.
2025-11-26 17:47:57 +01:00
Helmut Eller
eee0010938 Revert "Add "flat" representation for bignums"
This reverts commit ddba4198ab.
2025-11-26 09:34:00 +01:00
Helmut Eller
ddba4198ab Add "flat" representation for bignums
If FLAT_BIGNUMS is defined, Lisp_Bignums are a vector of GMP limbs
instead of a mpz_t (i.e. pointer to limb array).

The primary difficulty was the changed return type of the bignum_val
function.  The idiom "*bignum_val (foo)" was used all over the place.
For the flat representation, it seems impossible to define bignum_val
such that it returns a pointer.  I changed the return type to a struct,
but that made it necessary to change the idiom to "bignum_val (foo).z".

* src/bignum.h (FLAT_BIGNUMS): Define if HAVE_MPS.
(struct Lisp_Bignums): Define alternative representation.
(struct bignum_val): New helper struct.
(bignum_val): Change return type and define different version for flat
bignums.
(bignum_integer): Define a separate version for flat bignums.
(BIGNUM_VAL): New macro.
(init_gmp_memory_functions): New.  Define the prototype here for a
function that is implemented in alloc.c.
(mpz_set_integer): Update for changed xbignum_val.
* src/bignum.c (init_bignum): Call init_gmp_memory_functions.
(make_bignum_from_mpz): New helper.
(make_bignum_bits, make_bignum_str): Adapted for flat bignums.
(bignum_to_double, bignum_to_uintmax, bignum_bufsize, bignum_to_c_string)
(get_random_bignum): Adapt to changed bignum_val.
* src/alloc.c (xmalloc_for_gmp): New.
(xrealloc_for_gmp, xfree_for_gmp): Moved here from bignum.c.  Call
tally_consing.
(init_gmp_memory_functions): New.
(cleanup_vector): Adapt to flat bignums.
* src/data.c (Fnatnump, arithcompare, Fminus, integer_remainder)
(Flogcount, Fash, expt_integer, Fadd1, Fsub1, Flognot): Adapt to changed
bignum_val.
* src/emacs-module.c (module_extract_big_integer): Adapt to changed
bignum_val.
* src/floatfns.c (Fabs, Flogb): Adapt to changed bignum_val.
* src/fns.c (Frandom, Ftake, Fntake, Fnthcdr, Fmemql, Feql)
(internal_equal_1, value_cmp, sxhash_bignum): Adapt to changed
bignum_val.
* src/igc.c (finalize_bignum, finalize_vector, maybe_finalize): Adapt to
flat bignums.
* src/pdumper.c (dump_bignum): Define separate version for flat bignums.
(dump_cold_bignum, dump_do_dump_relocation): Adapt to changed
bignum_val.
* src/timefns.c (ztrillion, ticks_hz_to_timespec, ticks_hz_hz_ticks)
(lispint_arith): Adapt to changed bignum_val.
2025-11-25 20:21:28 +01:00
Helmut Eller
e6ae5433df Merge branch 'master' into feature/igc 2025-11-25 20:19:43 +01:00
Pip Cet
515ec7bb2c Avoid fixing the same reference twice in 'fix_window'
These references are already fixed by 'fix_vectorlike'.  Fixing them a
second time is possibly unsafe because the forwarded pointers may have
a different summary.

* src/igc.c (fix_window): Remove explicit 'IGC_FIX12_OBJ' calls.
2025-11-25 02:17:31 +00:00
Sean Whitton
188ad4f909 ; * src/keyboard.c (read_key_sequence): Style tweaks. 2025-11-24 10:57:54 +00:00
Po Lu
860996afb0 ; * src/gtkutil.c (xg_update_dark_mode_for_all_displays): Typo. 2025-11-24 10:19:56 +08:00
Po Lu
7550791287 Support `toolkit-theme-set-functions' on Android and execute hooks safely
* java/org/gnu/emacs/EmacsNative.java (setEmacsParams): New arg
UIMODE.
(sendConfigurationChanged): New args DETAIL and UI_MODE.

* java/org/gnu/emacs/EmacsNoninteractive.java (main1): Provide
an undefined UI mode.

* java/org/gnu/emacs/EmacsService.java (EmacsService): New field
uiMode.
(onCreate): Initialize this field at start-up and provide the
same to setEmacsParams.
(onConfigurationChanged): If the UI mode has been altered,
generate a configuration changed event to match.

* src/android.c (android_ui_mode): New variable.
(setEmacsParams): New argument UI_MODE.  Initialize the same
from this variable.

* src/androidgui.h (enum android_configuration_changed): New
enum.
(struct android_configuration_changed_event): New field
`DETAIL'.  Convert fields providing specifics into a union of
display density information and a UI mode integer.

* src/androidterm.c (handle_one_android_event): Handle both
manners of configuration change events.
(android_term_init): Initialize Vtoolkit_theme from UI mode
provided at start-up.

* src/frame.c (syms_of_frame): Always define Vtoolkit_theme.
Define Qtoolkit_theme_set_functions.

* src/gtkutil.c (xg_update_dark_mode_for_all_displays):

* src/w32term.c (w32_read_socket): Generate special toolkit
theme events, rather than executing hooks directly within the
read_socket callback.

* src/keyboard.c (kbd_buffer_get_event)
<TOOLKIT_THEME_CHANGED_EVENT>: Run Qtoolkit_theme_set_functions
and set Vtoolkit_theme from event->ie.arg.

* src/termhooks.h (enum event_kind): New event
TOOLKIT_THEME_CHANGED_EVENT.
2025-11-24 10:16:49 +08:00
Ahmed Khanzada
bc0f662573 Add `toolkit-theme' and 'toolkit-theme-set-functions'
* etc/NEWS: Document `toolkit-theme' and
'toolkit-theme-set-functions'
* lisp/frame.el: Add 'toolkit-theme-set-functions'
* src/frame.c: Add `toolkit-theme' Elisp variable
* src/gtkutil.c: (xg_update_dark_mode_for_all_displays): Set
`toolkit-theme' and call 'toolkit-theme-set-functions'
* src/w32fns.c: (w32_applytheme): Send WM_EMACS_SET_TOOLKIT_THEME
message to Lisp thread.
* src/w32term.h: Declare WM_EMACS_SET_TOOLKIT_THEME
* src/w32term.c: (w32_read_socket): Receive
WM_EMACS_SET_TOOLKIT_THEME message and set `toolkit-theme' and call
'toolkit-theme-set-functions'
2025-11-22 12:57:53 +02:00
Martin Rudalics
b728f50e1f Fix thinko in 'window_set_parent_and_normal_sizes'
* src/window.c (window_set_parent_and_normal_sizes): When
assigning normal sizes in a combination, take the direction from
its parent's 'horizontal' slot and not from that of the first
window in the combination.
2025-11-22 10:12:37 +01:00
Paul Eggert
c230dfdc26 A few more functions are not pure
Assuming ATTRIBUTE_PURE means that the function must return,
a few more functions that should not be declared with ATTRIBUTE_PURE.
The GCC manual (and even the C23 standard, with [[reproducible]])
is not clear about this, and it’s better to be safe.
* src/bignum.h (mpz_get_d_rounded):
* src/lisp.h (bignum_to_double):
No longer pure, as it does not return if memory is exhausted.
* src/fns.c (Fproper_list_p): No longer pure, as it does not
return if the user quits.
* src/gnutls.c (Fgnutls_errorp): No longer pure, as it does not
return if it runs into an eassert failure in XSYMBOL_WITH_POS via EQ.
* src/lisp.h (bignum_to_intmax, bignum_to_uintmax, bignum_bufsize):
No longer pure, as it does not return if it runs into an
eassert failure in XBIGNUM via xbignum_val.
2025-11-20 12:04:01 -08:00
Paul Eggert
cada1c3192 Fix more mis-declarations of non-const functions
Problem reported by Helmut Eller in:
https://lists.gnu.org/r/emacs-devel/2025-11/msg00809.html
* src/data.c (Fsymbol_with_pos_p, Fnatnump):
* src/fns.c (Fproper_list_p):
* src/gnutls.c (Fgnutls_errorp):
Now pure, not const.
2025-11-20 09:11:59 -08:00
Paul Eggert
20fd47e741 Fix mis-declarations of non-const functions
Problem for mpz_get_d_rounded reported by Helmut Eller in:
https://lists.gnu.org/r/emacs-devel/2025-11/msg00795.html
* lib-src/make-docfile.c (DEFUN_pure): New constant.
(write_globals, scan_c_stream): Support "attributes: pure".
* src/bignum.h (mpz_get_d_rounded):
* src/data.c (Fsymbolp, Fmodule_function_p, Fintegerp, Fnumberp):
* src/lisp.h (bignum_to_double, bignum_to_intmax)
(bignum_to_uintmax, bignum_bufsize):
Now pure, not const, since they depend on current state.
For example, Fsymbolp now inspects symbols_with_pos_enabled,
and the bignum functions inspect bignum contents in memory.
* src/data.c (Feq):
* src/xfaces.c (Fface_attribute_relative_p):
No longer const, since they might abort when debugging.
* src/pdumper.h (pdumper_object_p, pdumper_cold_object_p)
(pdumper_find_object_type, pdumper_object_p_precise):
These are not const functions.  But there is no need to declare
them to be pure, either, as they’re inline so the compiler can
figure it out.
2025-11-19 16:21:24 -08:00
Martin Rudalics
788b39740a Fix 'make_lispy_position' for left margin clicks (Bug#79846)
* src/keyboard.c (make_lispy_position): When calculating a
position in the left margin skip any scroll bar on the left of
the associated window (Bug#79846).
2025-11-19 09:31:28 +01:00
Eli Zaretskii
0026445dd6 Fix MinGW build broken by integration of 'stdio-consolesafe'
* src/conf_post.h: Avoid redirecting '*printf' functions if
'OMIT_CONSOLESAFE' is defined to 1.
* nt/cmdproxy.c:
* nt/ddeclient.c: Define 'OMIT_CONSOLESAFE' to 1 to avoid
redirecting '*printf functions' to stdio-consolesafe replacements.
* nt/Makefile.in (LIBS_ADDPM): Add -lgnu to link 'addpm' against
Gnulib.  (Bug#79855)
2025-11-18 16:19:20 +02:00
Helmut Eller
cf185d2c9e Allocate the dump in the oldest generation
* src.igc (struct igc_thread.oldgen_ap): New allocation point.
(struct igc.gen_count): New field.
(create_oldgen_ap): New helper.
(create_thread_aps): Use it.
(make_arena): Initialize gen_count.
(igc_on_pdump_loaded): Use the oldgen_ap.
2025-11-17 20:58:21 +01:00
Eli Zaretskii
364b5306c0 Fix last change in keyboard.c
* src/keyboard.c (adjust_point_for_property): Handle 'display'
property on the same text as 'invisible' property the same as the
overlay with a 'display' property.  (Bug#79787)
2025-11-16 17:17:37 +02:00
Eli Zaretskii
3888979ee1 Fix cursor motion across invisible text with an overlay
* src/keyboard.c (adjust_point_for_property): Handle the case
where invisible text has an overlay over it with a replacing
'display' property, which leaves some "trace" of the invisible
text on display.  (Bug#79787)
2025-11-16 16:38:37 +02:00
Eli Zaretskii
2ab07033ea Workaround for MSVCRT stdio on MS-Windows for CJK locales
MSVCRT implementation of stdio functions which output
characters one by one fails for CJK double-byte encodings.
Gnulib provides replacement functions which work around
those bugs.  This change makes Emacs and lib-src programs
use the replacements when Emacs is linked against MSVCRT.
* src/conf_post.h (fwrite, fprintf, printf, vfprintf, vprintf)
[WINDOWSNT]: Redirect to Gnulib replacements when Emacs is linked
against MSVCRT (as opposed to UCRT).  Suggested by Bruno Haible
<bruno@clisp.org>.
2025-11-16 09:36:03 +02:00
Eli Zaretskii
28f0658d8f Fix processing sub-process exit when keyboard input is pending
* src/process.c (wait_reading_process_output): Process status
changes of sub-processes when called with read_kbd zero and some
"keyboard input" is available, but no output from any sub-process.
(Bug#79777)
2025-11-15 19:48:08 +02:00
Eli Zaretskii
fd5e3b123e Avoid extra newline in user-error logged in *Messages*
* src/xdisp.c (reset_message_log_need_newline): New function.
* src/lisp.h: Add prototype of 'reset_message_log_need_newline'.
* src/print.c (print_error_message): Call
'reset_message_log_need_newline' to prevent message3 from
outputting a newline after "user-error:".  (Bug#79840)
2025-11-15 19:29:20 +02:00
Sean Whitton
5e819f76dc read_key_sequence: Additional check for fix_current_buffer
* src/keyboard.c (read_key_sequence): If we were interrupted
while initializing the terminal, also check for a change of
current buffer (bug#79513).
2025-11-13 17:17:34 +00:00
Helmut Eller
917138da6d Merge branch 'master' into feature/igc 2025-11-12 17:48:40 +01:00
Helmut Eller
1d88346973 Set dump_public.start to some place outside of the GC heap
The idea is to reduce the probability for stray pointers on the stack.
pdumper_object_p uses dump_public.start and pdumper_object_p is called
quite frequently, e.g. by xfree.

* src/pdumper.c (pdumper_load): Set dump_public.start to ~0.
2025-11-12 13:26:02 +01:00
Helmut Eller
c4380c68b7 Remove IGC_OBJ_DUMPED_CHARSET_TABLE from igc_obj_type
Use IGC_OBJ_DUMPED_BYTES instead.

* src/igc.h (enum igc_obj_type): Remove IGC_OBJ_DUMPED_CHARSET_TABLE.
* src/igc.c (obj_type_names, gc_init_header, dflt_scan_obj, thread_ap)
(builtin_obj_type_and_hash, igc_dump_finish_obj, igc_on_pdump_loaded):
Adjust accordingly.
(fix_charset_table): Deleted.
* src/pdumper.c (dump_charset_table): Use IGC_OBJ_DUMPED_BYTES.
2025-11-12 13:18:08 +01:00
Helmut Eller
b0cba7b36e Remove gc_header from struct charset
* src/charset.h (struct charset): Remove gc_header.
* src/pdumper.c (dump_charset_table): No header to initialize.
* src/igc.c: Update struct hashes.
2025-11-12 11:15:46 +01:00
Helmut Eller
be4014aa80 Avoid crashes when displaying menu help-echo strings
Use GC handles for help-echo strings instead of raw pointers.

* src/w32menu.c (add_menu_item): Store GC handles.
(w32_menu_display_help): Dereference the string.
(w32_free_submenu_strings): Free GC handles.
2025-11-12 08:01:28 +01:00
Po Lu
45a82437a3 Merge from savannah/emacs-30
ca4af1768d Fix crash on Android 2.2
2025-11-12 01:14:37 +08:00
Po Lu
ca4af1768d Fix crash on Android 2.2
* src/android-asset.h (AAssetManager_open): Initialize desc and
asset to NULL, lest `desc' be accessed uninitialized if C_NAME
does not exist in the directory tree.
2025-11-12 01:13:46 +08:00
Helmut Eller
0da729a2fc Fix MS Windows build
* src/w32menu.c (add_menu_item): Adapt to gc-handles enough to
avoid compilation error.  More work is needed to fix the problem.
2025-11-10 13:11:18 +01:00
Helmut Eller
10f0529fc3 Fix help popups for Athena menus
* lwlib/lwlib-widget.h (struct _widget_value): Use a gc_handle for the
help field.
* lwlib/lwlib.c (free_widget_value_tree, copy_widget_value_tree)
(merge_widget_value): Adapt to gc_handles.
* src/gc-handles.h (gc_handle_for_gc_handle, gc_handle_assign): New
helpers.
* src/gc-handles.c (gc_handle_for_gc_handle, gc_handle_assign):
Implementation.
* src/menu.c (make_widget_value, free_menubar_widget_value_tree): Adapt
to gc_handles.
* src/xmenu.c (menu_highlight_callback): Adapt to gc_handles.
* src/gtkutil.c (make_menu_item, xg_create_one_menuitem)
(xg_update_menu_item): Adapted to changed widget_value.
2025-11-10 13:03:27 +01:00
Helmut Eller
413a8fe572 Fix non-MPS build
* src/alloc.c (make_misc_ptr, make_user_ptr): Add #ifdefs.
2025-11-10 12:43:35 +01:00
Helmut Eller
3fbf4dc9ac Don't call record_unwind_protect_ptr with a GCed pointer
* src/xmenu.c (create_and_show_popup_menu): Use record_unwind_protect
instead of record_unwind_protect_ptr.
(leave_toolkit_menu): Use a Lisp_Object instead of a untagged pointer.
2025-11-10 12:35:21 +01:00
Helmut Eller
f536751c7a Fix indentation of recent commits
* src/fns.c (strong_copy_hash_table):
* src/xterm.c (x_cache_xi_devices, xi_disable_devices): clang-format's
output does not comform to Emacs coding conventions.
2025-11-10 12:33:18 +01:00
Gerd Möllmann
87b7b29718 Revert "Alternative implementation of constants in .eln files"
This reverts commit a93ee02873
because it is missing some important other changes.
2025-11-10 12:16:04 +01:00