diff options
| author | Gerd Möllmann | 2024-06-29 23:28:01 +0200 |
|---|---|---|
| committer | Gerd Möllmann | 2024-06-29 23:36:02 +0200 |
| commit | dc3e5cbe5b65278bd977c86f347df748823712a7 (patch) | |
| tree | 0440242bf75cfe13441823f67bc1f3868c69d80d /src | |
| parent | 7f993bf780e34f4b718e43f1fd1f2bd1de4db311 (diff) | |
| download | emacs-dc3e5cbe5b65278bd977c86f347df748823712a7.tar.gz emacs-dc3e5cbe5b65278bd977c86f347df748823712a7.zip | |
build_marker histogram
Diffstat (limited to 'src')
| -rw-r--r-- | src/alloc.c | 18 | ||||
| -rw-r--r-- | src/buffer.c | 14 | ||||
| -rw-r--r-- | src/composite.c | 2 | ||||
| -rw-r--r-- | src/editfns.c | 10 | ||||
| -rw-r--r-- | src/lisp.h | 2 | ||||
| -rw-r--r-- | src/marker.c | 10 | ||||
| -rw-r--r-- | src/window.c | 2 | ||||
| -rw-r--r-- | src/xdisp.c | 2 |
8 files changed, 37 insertions, 23 deletions
diff --git a/src/alloc.c b/src/alloc.c index 09b51ba2a08..5ee1b37e292 100644 --- a/src/alloc.c +++ b/src/alloc.c | |||
| @@ -4167,11 +4167,14 @@ DEFUN ("make-marker", Fmake_marker, Smake_marker, 0, 0, 0, | |||
| 4167 | /* Return a newly allocated marker which points into BUF | 4167 | /* Return a newly allocated marker which points into BUF |
| 4168 | at character position CHARPOS and byte position BYTEPOS. */ | 4168 | at character position CHARPOS and byte position BYTEPOS. */ |
| 4169 | 4169 | ||
| 4170 | static int build_marker_counts[100] = {0}; | ||
| 4171 | |||
| 4170 | Lisp_Object | 4172 | Lisp_Object |
| 4171 | build_marker (struct buffer *buf, ptrdiff_t charpos, ptrdiff_t bytepos) | 4173 | build_marker (struct buffer *buf, ptrdiff_t charpos, ptrdiff_t bytepos, int where) |
| 4172 | { | 4174 | { |
| 4173 | /* No dead buffers here. */ | 4175 | /* No dead buffers here. */ |
| 4174 | eassert (BUFFER_LIVE_P (buf)); | 4176 | eassert (BUFFER_LIVE_P (buf)); |
| 4177 | build_marker_counts[where] += 1; | ||
| 4175 | 4178 | ||
| 4176 | /* Every character is at least one byte. */ | 4179 | /* Every character is at least one byte. */ |
| 4177 | eassert (charpos <= bytepos); | 4180 | eassert (charpos <= bytepos); |
| @@ -4371,6 +4374,16 @@ FUNCTION. FUNCTION will be run once per finalizer object. */) | |||
| 4371 | return make_lisp_ptr (finalizer, Lisp_Vectorlike); | 4374 | return make_lisp_ptr (finalizer, Lisp_Vectorlike); |
| 4372 | } | 4375 | } |
| 4373 | 4376 | ||
| 4377 | DEFUN ("build-marker-counts", Fbuild_marker_counts, Sbuild_marker_counts, 0, 0, | ||
| 4378 | 0, doc: /* */) | ||
| 4379 | (void) | ||
| 4380 | { | ||
| 4381 | Lisp_Object v = Fmake_vector (make_fixnum (30), Qnil); | ||
| 4382 | for (int i = 0; i < 30; ++i) | ||
| 4383 | ASET (v, i, make_int (build_marker_counts[i])); | ||
| 4384 | return v; | ||
| 4385 | } | ||
| 4386 | |||
| 4374 | 4387 | ||
| 4375 | /************************************************************************ | 4388 | /************************************************************************ |
| 4376 | Mark bit access functions | 4389 | Mark bit access functions |
| @@ -8555,7 +8568,8 @@ N should be nonnegative. */); | |||
| 8555 | defsubr (&Sgarbage_collect_maybe); | 8568 | defsubr (&Sgarbage_collect_maybe); |
| 8556 | defsubr (&Smemory_info); | 8569 | defsubr (&Smemory_info); |
| 8557 | defsubr (&Smemory_use_counts); | 8570 | defsubr (&Smemory_use_counts); |
| 8558 | #if defined GNU_LINUX && defined __GLIBC__ && \ | 8571 | defsubr (&Sbuild_marker_counts); |
| 8572 | #if defined GNU_LINUX && defined __GLIBC__ && \ | ||
| 8559 | (__GLIBC__ > 2 || __GLIBC_MINOR__ >= 10) | 8573 | (__GLIBC__ > 2 || __GLIBC_MINOR__ >= 10) |
| 8560 | 8574 | ||
| 8561 | defsubr (&Smalloc_info); | 8575 | defsubr (&Smalloc_info); |
diff --git a/src/buffer.c b/src/buffer.c index 09423e8592a..640cf33ea17 100644 --- a/src/buffer.c +++ b/src/buffer.c | |||
| @@ -736,7 +736,7 @@ clone_per_buffer_values (struct buffer *from, struct buffer *to) | |||
| 736 | { | 736 | { |
| 737 | struct Lisp_Marker *m = XMARKER (obj); | 737 | struct Lisp_Marker *m = XMARKER (obj); |
| 738 | 738 | ||
| 739 | obj = build_marker (to, m->charpos, m->bytepos); | 739 | obj = build_marker (to, m->charpos, m->bytepos, 9); |
| 740 | XMARKER (obj)->insertion_type = m->insertion_type; | 740 | XMARKER (obj)->insertion_type = m->insertion_type; |
| 741 | } | 741 | } |
| 742 | 742 | ||
| @@ -902,15 +902,15 @@ Interactively, CLONE and INHIBIT-BUFFER-HOOKS are nil. */) | |||
| 902 | 902 | ||
| 903 | bset_pt_marker (b->base_buffer, | 903 | bset_pt_marker (b->base_buffer, |
| 904 | build_marker (b->base_buffer, b->base_buffer->pt, | 904 | build_marker (b->base_buffer, b->base_buffer->pt, |
| 905 | b->base_buffer->pt_byte)); | 905 | b->base_buffer->pt_byte, 13)); |
| 906 | 906 | ||
| 907 | bset_begv_marker (b->base_buffer, | 907 | bset_begv_marker (b->base_buffer, |
| 908 | build_marker (b->base_buffer, b->base_buffer->begv, | 908 | build_marker (b->base_buffer, b->base_buffer->begv, |
| 909 | b->base_buffer->begv_byte)); | 909 | b->base_buffer->begv_byte, 14)); |
| 910 | 910 | ||
| 911 | bset_zv_marker (b->base_buffer, | 911 | bset_zv_marker (b->base_buffer, |
| 912 | build_marker (b->base_buffer, b->base_buffer->zv, | 912 | build_marker (b->base_buffer, b->base_buffer->zv, |
| 913 | b->base_buffer->zv_byte)); | 913 | b->base_buffer->zv_byte, 15)); |
| 914 | 914 | ||
| 915 | XMARKER (BVAR (b->base_buffer, zv_marker))->insertion_type = 1; | 915 | XMARKER (BVAR (b->base_buffer, zv_marker))->insertion_type = 1; |
| 916 | } | 916 | } |
| @@ -918,9 +918,9 @@ Interactively, CLONE and INHIBIT-BUFFER-HOOKS are nil. */) | |||
| 918 | if (NILP (clone)) | 918 | if (NILP (clone)) |
| 919 | { | 919 | { |
| 920 | /* Give the indirect buffer markers for its narrowing. */ | 920 | /* Give the indirect buffer markers for its narrowing. */ |
| 921 | bset_pt_marker (b, build_marker (b, b->pt, b->pt_byte)); | 921 | bset_pt_marker (b, build_marker (b, b->pt, b->pt_byte, 17)); |
| 922 | bset_begv_marker (b, build_marker (b, b->begv, b->begv_byte)); | 922 | bset_begv_marker (b, build_marker (b, b->begv, b->begv_byte, 18)); |
| 923 | bset_zv_marker (b, build_marker (b, b->zv, b->zv_byte)); | 923 | bset_zv_marker (b, build_marker (b, b->zv, b->zv_byte, 19)); |
| 924 | XMARKER (BVAR (b, zv_marker))->insertion_type = 1; | 924 | XMARKER (BVAR (b, zv_marker))->insertion_type = 1; |
| 925 | } | 925 | } |
| 926 | else | 926 | else |
diff --git a/src/composite.c b/src/composite.c index ca007f9971d..2256e0254fc 100644 --- a/src/composite.c +++ b/src/composite.c | |||
| @@ -982,7 +982,7 @@ autocmp_chars (Lisp_Object rule, ptrdiff_t charpos, ptrdiff_t bytepos, | |||
| 982 | /* Save point as marker before calling out to lisp. */ | 982 | /* Save point as marker before calling out to lisp. */ |
| 983 | if (NILP (string)) | 983 | if (NILP (string)) |
| 984 | record_unwind_protect (restore_point_unwind, | 984 | record_unwind_protect (restore_point_unwind, |
| 985 | build_marker (current_buffer, pt, pt_byte)); | 985 | build_marker (current_buffer, pt, pt_byte, 8)); |
| 986 | lgstring = safe_calln (Vauto_composition_function, AREF (rule, 2), | 986 | lgstring = safe_calln (Vauto_composition_function, AREF (rule, 2), |
| 987 | pos, make_fixnum (to), font_object, string, | 987 | pos, make_fixnum (to), font_object, string, |
| 988 | direction); | 988 | direction); |
diff --git a/src/editfns.c b/src/editfns.c index 74c7d54086b..0b7c4cff66a 100644 --- a/src/editfns.c +++ b/src/editfns.c | |||
| @@ -199,7 +199,7 @@ DEFUN ("point-marker", Fpoint_marker, Spoint_marker, 0, 0, 0, | |||
| 199 | doc: /* Return value of point, as a marker object. */) | 199 | doc: /* Return value of point, as a marker object. */) |
| 200 | (void) | 200 | (void) |
| 201 | { | 201 | { |
| 202 | return build_marker (current_buffer, PT, PT_BYTE); | 202 | return build_marker (current_buffer, PT, PT_BYTE, 10); |
| 203 | } | 203 | } |
| 204 | 204 | ||
| 205 | DEFUN ("goto-char", Fgoto_char, Sgoto_char, 1, 1, | 205 | DEFUN ("goto-char", Fgoto_char, Sgoto_char, 1, 1, |
| @@ -889,7 +889,7 @@ DEFUN ("point-min-marker", Fpoint_min_marker, Spoint_min_marker, 0, 0, 0, | |||
| 889 | This is the beginning, unless narrowing (a buffer restriction) is in effect. */) | 889 | This is the beginning, unless narrowing (a buffer restriction) is in effect. */) |
| 890 | (void) | 890 | (void) |
| 891 | { | 891 | { |
| 892 | return build_marker (current_buffer, BEGV, BEGV_BYTE); | 892 | return build_marker (current_buffer, BEGV, BEGV_BYTE, 11); |
| 893 | } | 893 | } |
| 894 | 894 | ||
| 895 | DEFUN ("point-max", Fpoint_max, Spoint_max, 0, 0, 0, | 895 | DEFUN ("point-max", Fpoint_max, Spoint_max, 0, 0, 0, |
| @@ -909,7 +909,7 @@ This is (1+ (buffer-size)), unless narrowing (a buffer restriction) | |||
| 909 | is in effect, in which case it is less. */) | 909 | is in effect, in which case it is less. */) |
| 910 | (void) | 910 | (void) |
| 911 | { | 911 | { |
| 912 | return build_marker (current_buffer, ZV, ZV_BYTE); | 912 | return build_marker (current_buffer, ZV, ZV_BYTE, 12); |
| 913 | } | 913 | } |
| 914 | 914 | ||
| 915 | DEFUN ("gap-position", Fgap_position, Sgap_position, 0, 0, 0, | 915 | DEFUN ("gap-position", Fgap_position, Sgap_position, 0, 0, 0, |
| @@ -3009,8 +3009,8 @@ save_restriction_save_1 (void) | |||
| 3009 | { | 3009 | { |
| 3010 | Lisp_Object beg, end; | 3010 | Lisp_Object beg, end; |
| 3011 | 3011 | ||
| 3012 | beg = build_marker (current_buffer, BEGV, BEGV_BYTE); | 3012 | beg = build_marker (current_buffer, BEGV, BEGV_BYTE, 20); |
| 3013 | end = build_marker (current_buffer, ZV, ZV_BYTE); | 3013 | end = build_marker (current_buffer, ZV, ZV_BYTE, 21); |
| 3014 | 3014 | ||
| 3015 | /* END must move forward if text is inserted at its exact location. */ | 3015 | /* END must move forward if text is inserted at its exact location. */ |
| 3016 | XMARKER (end)->insertion_type = 1; | 3016 | XMARKER (end)->insertion_type = 1; |
diff --git a/src/lisp.h b/src/lisp.h index 912b208a213..aaa7b6c4aeb 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -5146,7 +5146,7 @@ extern Lisp_Object set_marker_restricted (Lisp_Object, Lisp_Object, Lisp_Object) | |||
| 5146 | extern Lisp_Object set_marker_both (Lisp_Object, Lisp_Object, ptrdiff_t, ptrdiff_t); | 5146 | extern Lisp_Object set_marker_both (Lisp_Object, Lisp_Object, ptrdiff_t, ptrdiff_t); |
| 5147 | extern Lisp_Object set_marker_restricted_both (Lisp_Object, Lisp_Object, | 5147 | extern Lisp_Object set_marker_restricted_both (Lisp_Object, Lisp_Object, |
| 5148 | ptrdiff_t, ptrdiff_t); | 5148 | ptrdiff_t, ptrdiff_t); |
| 5149 | extern Lisp_Object build_marker (struct buffer *, ptrdiff_t, ptrdiff_t); | 5149 | extern Lisp_Object build_marker (struct buffer *, ptrdiff_t, ptrdiff_t, int); |
| 5150 | extern void syms_of_marker (void); | 5150 | extern void syms_of_marker (void); |
| 5151 | 5151 | ||
| 5152 | /* Defined in fileio.c. */ | 5152 | /* Defined in fileio.c. */ |
diff --git a/src/marker.c b/src/marker.c index 3290917b268..8b22474f2bb 100644 --- a/src/marker.c +++ b/src/marker.c | |||
| @@ -236,7 +236,7 @@ buf_charpos_to_bytepos (struct buffer *b, ptrdiff_t charpos) | |||
| 236 | cache the correspondence by creating a marker here. | 236 | cache the correspondence by creating a marker here. |
| 237 | It will last until the next GC. */ | 237 | It will last until the next GC. */ |
| 238 | if (record) | 238 | if (record) |
| 239 | build_marker (b, best_below, best_below_byte); | 239 | build_marker (b, best_below, best_below_byte, 4); |
| 240 | 240 | ||
| 241 | byte_char_debug_check (b, best_below, best_below_byte); | 241 | byte_char_debug_check (b, best_below, best_below_byte); |
| 242 | 242 | ||
| @@ -261,7 +261,7 @@ buf_charpos_to_bytepos (struct buffer *b, ptrdiff_t charpos) | |||
| 261 | cache the correspondence by creating a marker here. | 261 | cache the correspondence by creating a marker here. |
| 262 | It will last until the next GC. */ | 262 | It will last until the next GC. */ |
| 263 | if (record) | 263 | if (record) |
| 264 | build_marker (b, best_above, best_above_byte); | 264 | build_marker (b, best_above, best_above_byte, 5); |
| 265 | 265 | ||
| 266 | byte_char_debug_check (b, best_above, best_above_byte); | 266 | byte_char_debug_check (b, best_above, best_above_byte); |
| 267 | 267 | ||
| @@ -389,7 +389,7 @@ buf_bytepos_to_charpos (struct buffer *b, ptrdiff_t bytepos) | |||
| 389 | But don't do it if BUF_MARKERS is nil; | 389 | But don't do it if BUF_MARKERS is nil; |
| 390 | that is a signal from Fset_buffer_multibyte. */ | 390 | that is a signal from Fset_buffer_multibyte. */ |
| 391 | if (record && BUF_MARKERS (b)) | 391 | if (record && BUF_MARKERS (b)) |
| 392 | build_marker (b, best_below, best_below_byte); | 392 | build_marker (b, best_below, best_below_byte, 6); |
| 393 | 393 | ||
| 394 | byte_char_debug_check (b, best_below, best_below_byte); | 394 | byte_char_debug_check (b, best_below, best_below_byte); |
| 395 | 395 | ||
| @@ -417,10 +417,10 @@ buf_bytepos_to_charpos (struct buffer *b, ptrdiff_t bytepos) | |||
| 417 | that is a signal from Fset_buffer_multibyte. */ | 417 | that is a signal from Fset_buffer_multibyte. */ |
| 418 | #ifdef HAVE_MPS | 418 | #ifdef HAVE_MPS |
| 419 | if (record && VECTORP (BUF_MARKERS (b))) | 419 | if (record && VECTORP (BUF_MARKERS (b))) |
| 420 | build_marker (b, best_above, best_above_byte); | 420 | build_marker (b, best_above, best_above_byte, 7); |
| 421 | #else | 421 | #else |
| 422 | if (record && BUF_MARKERS (b)) | 422 | if (record && BUF_MARKERS (b)) |
| 423 | build_marker (b, best_above, best_above_byte); | 423 | build_marker (b, best_above, best_above_byte, 7); |
| 424 | #endif | 424 | #endif |
| 425 | byte_char_debug_check (b, best_above, best_above_byte); | 425 | byte_char_debug_check (b, best_above, best_above_byte); |
| 426 | 426 | ||
diff --git a/src/window.c b/src/window.c index 70472749e74..8fd059631ac 100644 --- a/src/window.c +++ b/src/window.c | |||
| @@ -7774,7 +7774,7 @@ save_window_save (Lisp_Object window, struct Lisp_Vector *vector, ptrdiff_t i) | |||
| 7774 | if (EQ (window, selected_window)) | 7774 | if (EQ (window, selected_window)) |
| 7775 | p->pointm = build_marker (XBUFFER (w->contents), | 7775 | p->pointm = build_marker (XBUFFER (w->contents), |
| 7776 | BUF_PT (XBUFFER (w->contents)), | 7776 | BUF_PT (XBUFFER (w->contents)), |
| 7777 | BUF_PT_BYTE (XBUFFER (w->contents))); | 7777 | BUF_PT_BYTE (XBUFFER (w->contents)), 1); |
| 7778 | else | 7778 | else |
| 7779 | p->pointm = Fcopy_marker (w->pointm, Qnil); | 7779 | p->pointm = Fcopy_marker (w->pointm, Qnil); |
| 7780 | p->old_pointm = Fcopy_marker (w->old_pointm, Qnil); | 7780 | p->old_pointm = Fcopy_marker (w->old_pointm, Qnil); |
diff --git a/src/xdisp.c b/src/xdisp.c index 07dd33bbd80..2bfc22fd15f 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -13621,7 +13621,7 @@ format_mode_line_unwind_data (struct frame *target_frame, | |||
| 13621 | unwinding (Bug#32777). */ | 13621 | unwinding (Bug#32777). */ |
| 13622 | ASET (vector, 10, buffer); | 13622 | ASET (vector, 10, buffer); |
| 13623 | current_buffer = b; | 13623 | current_buffer = b; |
| 13624 | ASET (vector, 11, build_marker (current_buffer, PT, PT_BYTE)); | 13624 | ASET (vector, 11, build_marker (current_buffer, PT, PT_BYTE, 2)); |
| 13625 | current_buffer = cb; | 13625 | current_buffer = cb; |
| 13626 | } | 13626 | } |
| 13627 | 13627 | ||