Mercurial > hg > xemacs-beta
annotate src/profile.h @ 5562:855b667dea13
Drop cl-macro-environment in favour of byte-compile-macro-environment.
lisp/ChangeLog addition:
2011-09-04 Aidan Kehoe <kehoea@parhasard.net>
* bytecomp-runtime.el:
* bytecomp-runtime.el (byte-compile-macro-environment): Moved from
bytecomp.el.
* bytecomp.el:
* bytecomp.el (byte-compile-initial-macro-environment):
Add implementations for #'load-time-value, #'labels here, now
cl-macs respects byte-compile-macro-environment.
* bytecomp.el (byte-compile-function-environment):
* bytecomp.el (byte-compile-macro-environment): Removed.
* bytecomp.el (symbol-value):
* bytecomp.el (byte-compile-symbol-value): Removed.
* cl-extra.el (cl-macroexpand-all):
* cl-macs.el:
* cl-macs.el (bind-block):
* cl-macs.el (cl-macro-environment): Removed.
* cl-macs.el (cl-transform-lambda):
* cl-macs.el (load-time-value):
* cl-macs.el (block):
* cl-macs.el (flet):
* cl-macs.el (labels):
* cl-macs.el (macrolet):
* cl-macs.el (symbol-macrolet):
* cl-macs.el (lexical-let):
* cl-macs.el (apply):
* cl-macs.el (nthcdr):
* cl-macs.el (getf):
* cl-macs.el (substring):
* cl-macs.el (values):
* cl-macs.el (get-setf-method):
* cl-macs.el (cl-setf-do-modify):
* cl.el:
* cl.el (cl-macro-environment): Removed.
* cl.el (cl-macroexpand):
* obsolete.el (cl-macro-environment): Moved here.
Drop cl-macro-environment, in favour of
byte-compile-macro-environment; make the latter available in
bytecomp-runtime.el. This makes byte-compile-macro-environment far
less useless, since previously code that used cl-macs would ignore
it when calling #'cl-macroexpand-all.
Add byte-compiler-specific implementations for #'load-time-value,
#'labels. The latter is very nice indeed; it avoids the run-time
consing of the current implementation, is fully lexical and avoids
the run-time shadowing of symbol function slots that flet uses. It
would now be reasonable to move most core uses of flet to use
labels instead. Non-core code can't rely on print-circle for
mutually recursive functions, though, so it's less of an evident
win.
author | Aidan Kehoe <kehoea@parhasard.net> |
---|---|
date | Sun, 04 Sep 2011 20:37:55 +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 */ |