Mercurial > hg > xemacs-beta
annotate src/profile.h @ 5803:b79e1e02bf01
Preserve extent information in the command builder code.
src/ChangeLog addition:
2014-07-14 Aidan Kehoe <kehoea@parhasard.net>
* event-stream.c:
* event-stream.c (mark_command_builder):
* event-stream.c (finalize_command_builder): Removed.
* event-stream.c (allocate_command_builder):
* event-stream.c (free_command_builder): Removed. Use
free_normal_lisp_object() instead.
* event-stream.c (echo_key_event):
* event-stream.c (regenerate_echo_keys_from_this_command_keys):
Detach all extents here.
* event-stream.c (maybe_echo_keys):
* event-stream.c (reset_key_echo):
* event-stream.c (execute_help_form):
* event-stream.c (Fnext_event):
* event-stream.c (command_builder_find_leaf_no_jit_binding):
* event-stream.c (command_builder_find_leaf):
* event-stream.c (lookup_command_event):
* events.h (struct command_builder):
Move the command builder's echo_buf to being a Lisp string rather
than a malloced Ibyte array. This allows passing through extent
information, which was previously dropped. It also simplifies the
allocation and release code for the command builder.
Rename echo_buf_index to echo_buf_fill_pointer, better reflecting
its function.
Don't rely on zero-termination (something not particularly
compatible with Lisp-level code) when showing a substring of
echo_buf that differs from that designated by
echo_buf_fill_pointer, keep a separate counter instead and use
that.
* minibuf.c:
* minibuf.c (echo_area_append):
Use the new START and END keyword arguments to #'append-message,
rather than consing a new string for basically every #'next-event
prompt displayed.
test/ChangeLog addition:
2014-07-14 Aidan Kehoe <kehoea@parhasard.net>
* automated/extent-tests.el:
Check that extent information is passed through to the echo area
correctly with #'next-event's PROMPT argument.
lisp/ChangeLog addition:
2014-07-14 Aidan Kehoe <kehoea@parhasard.net>
* simple.el (raw-append-message):
Use #'write-sequence in this, take its START and END keyword
arguments, so our callers don't have to cons as much.
* simple.el (append-message):
Pass through START and END here.
| author | Aidan Kehoe <kehoea@parhasard.net> |
|---|---|
| date | Mon, 14 Jul 2014 13:42:42 +0100 |
| parents | 308d34e9f07d |
| children |
| rev | line source |
|---|---|
| 1292 | 1 /* Profiling. |
| 3025 | 2 Copyright (C) 2003, 2005 Ben Wing. |
| 1292 | 3 |
| 4 This file is part of XEmacs. | |
| 5 | |
|
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
4162
diff
changeset
|
6 XEmacs is free software: you can redistribute it and/or modify it |
| 1292 | 7 under the terms of the GNU General Public License as published by the |
|
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
4162
diff
changeset
|
8 Free Software Foundation, either version 3 of the License, or (at your |
|
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
4162
diff
changeset
|
9 option) any later version. |
| 1292 | 10 |
| 11 XEmacs is distributed in the hope that it will be useful, but WITHOUT | |
| 12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
| 13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
| 14 for more details. | |
| 15 | |
| 16 You should have received a copy of the GNU General Public License | |
|
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
4162
diff
changeset
|
17 along with XEmacs. If not, see <http://www.gnu.org/licenses/>. */ |
| 1292 | 18 |
| 19 /* Synched up with: Not in FSF. */ | |
| 20 | |
| 21 /* Authorship: | |
| 22 | |
| 23 Ben Wing: Feb 2003. | |
| 24 */ | |
| 25 | |
| 26 #include "backtrace.h" | |
| 27 | |
| 28 void mark_profiling_info (void); | |
| 29 void profile_record_unwind (struct backtrace *); | |
| 30 void profile_record_about_to_call (struct backtrace *); | |
| 31 void profile_record_just_called (struct backtrace *); | |
| 32 void profile_record_consing (EMACS_INT size); | |
| 33 void profile_record_unconsing (EMACS_INT size); | |
| 34 extern int profiling_active; | |
| 35 | |
| 36 /* We call about_to_call() and just_called() depending on the current | |
| 37 *dynamic* value of profiling_active (which could change as a result of | |
| 38 calling the function) but if we push a backtrace, we must pop it later, | |
| 39 so we need to remember the status of this. */ | |
| 40 #define PROFILE_DECLARE() \ | |
| 41 int do_backtrace = profiling_active || backtrace_with_internal_sections; \ | |
| 42 struct backtrace backtrace | |
| 43 | |
| 44 /* As just mentioned, we rely on the dynamic value of profiling_active. | |
| 45 This ensures correct behavior (e.g. we never modify the profiling info | |
| 46 when profiling is not active) because we seed and reap all functions | |
| 47 currently on the stack when starting and stopping. See | |
| 4162 | 48 `start-profiling'. |
| 49 | |
| 50 We check do_backtrace to make sure that the backtrace structure is | |
| 51 initialised. If it isn't, we can enter a function with profiling turned | |
| 52 off, and exit it with it turned on, with the consequence that an | |
| 53 unitialised backtrace structure is passed to | |
| 54 profile_record_just_called. Since do_backtrace is function-local (apart | |
| 55 from in the garbage collector) this avoids that. */ | |
| 1292 | 56 #define PROFILE_ENTER_FUNCTION() \ |
| 57 do \ | |
| 58 { \ | |
| 4162 | 59 if (profiling_active && do_backtrace) \ |
| 1292 | 60 profile_record_about_to_call (&backtrace); \ |
| 61 } \ | |
| 62 while (0) | |
| 63 | |
| 64 #define PROFILE_EXIT_FUNCTION() \ | |
| 65 do \ | |
| 66 { \ | |
| 4162 | 67 if (profiling_active && do_backtrace) \ |
| 1292 | 68 profile_record_just_called (&backtrace); \ |
| 69 } \ | |
| 70 while (0) | |
| 71 | |
| 72 /* We are entering a section that we would like to record profile information | |
| 73 about. We put this information into the backtrace list, just like | |
| 74 normal functions do. That is one easy way to make sure that we always | |
| 75 record info on the innermost section or function, whether section or | |
| 76 function. (To do this, we always need some sort of collusion between | |
| 77 profile and eval; this is one way.) */ | |
| 78 | |
| 3025 | 79 /* Or, we could call xzero() to zero the whole thing, and avoid four |
| 80 of the statements below; or we could create a global backtrace object, | |
| 81 uninitialized (i.e. it will be initialized to all 0), and do structure | |
| 82 copy to initialize. It's not clear it will make much difference here, | |
| 83 but someone who really cared about counting cycles could implement it. */ | |
| 1292 | 84 #define PROFILE_RECORD_ENTERING_SECTION(var) \ |
| 85 do \ | |
| 86 { \ | |
| 87 if (do_backtrace) \ | |
| 88 { \ | |
| 89 backtrace.function = &var; \ | |
| 90 backtrace.args = NULL; \ | |
| 91 backtrace.nargs = UNEVALLED; \ | |
| 92 backtrace.evalargs = 0; \ | |
| 93 backtrace.pdlcount = specpdl_depth (); \ | |
| 94 backtrace.debug_on_exit = 0; \ | |
| 95 backtrace.function_being_called = 0; \ | |
| 96 PUSH_BACKTRACE (backtrace); \ | |
| 97 } \ | |
| 98 PROFILE_ENTER_FUNCTION (); \ | |
| 99 } while (0) | |
| 100 | |
| 101 #define PROFILE_RECORD_EXITING_SECTION(var) \ | |
| 102 do \ | |
| 103 { \ | |
| 104 PROFILE_EXIT_FUNCTION (); \ | |
| 105 if (do_backtrace) \ | |
| 106 POP_BACKTRACE (backtrace); \ | |
| 107 } while (0) | |
| 2514 | 108 |
| 109 #define RETURN_EXIT_PROFILING(tag, type, expr) \ | |
| 110 do \ | |
| 111 { \ | |
| 112 type _ret_exitpr_ = (expr); \ | |
| 113 PROFILE_RECORD_EXITING_SECTION (tag); \ | |
| 114 RETURN_SANS_WARNINGS _ret_exitpr_; \ | |
| 115 } while (0) | |
| 116 | |
| 117 #define RETURN_LISP_EXIT_PROFILING(tag, expr) \ | |
| 118 RETURN_EXIT_PROFILING (tag, Lisp_Object, expr) | |
| 119 | |
| 120 #define RETURN_UNGCPRO_EXIT_PROFILING(tag, expr) \ | |
| 3282 | 121 do \ |
| 2514 | 122 { \ |
| 123 Lisp_Object ret_ungc_val = (expr); \ | |
| 124 UNGCPRO; \ | |
| 125 PROFILE_RECORD_EXITING_SECTION (tag); \ | |
| 126 RETURN_SANS_WARNINGS ret_ungc_val; \ | |
| 127 } while (0) | |
| 128 | |
| 129 #ifdef DEBUG_XEMACS | |
| 130 extern Lisp_Object QSin_temp_spot_1; | |
| 131 extern Lisp_Object QSin_temp_spot_2; | |
| 132 extern Lisp_Object QSin_temp_spot_3; | |
| 133 extern Lisp_Object QSin_temp_spot_4; | |
| 134 extern Lisp_Object QSin_temp_spot_5; | |
| 135 #endif /* DEBUG_XEMACS */ |
