diff options
| author | Stefan Monnier | 2013-06-03 05:01:53 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2013-06-03 05:01:53 -0400 |
| commit | 2f592f95d2344d4a28eb946848330dca49e0f5ee (patch) | |
| tree | a920b413f4367d49b7f7feeb3fdf63c5e9018dcb /src/profiler.c | |
| parent | e5e4a94293d5a9a157557e53b4fea4e5d280673e (diff) | |
| download | emacs-2f592f95d2344d4a28eb946848330dca49e0f5ee.tar.gz emacs-2f592f95d2344d4a28eb946848330dca49e0f5ee.zip | |
Merge the specpdl and backtrace stacks. Make the structure of the
specpdl entries more obvious via a tagged union of structs.
* src/lisp.h (BITS_PER_PTRDIFF_T): New constant.
(enum specbind_tag): New enum.
(struct specbinding): Make it a tagged union of structs.
Add a case for backtrace records.
(specpdl_symbol, specpdl_old_value, specpdl_where, specpdl_arg)
(specpdl_func, backtrace_function, backtrace_nargs, backtrace_args)
(backtrace_debug_on_exit): New accessors.
(struct backtrace): Remove.
(struct catchtag): Remove backlist field.
* src/data.c (let_shadows_buffer_binding_p, let_shadows_global_binding_p):
Move to eval.c.
(Flocal_variable_p): Speed up the common case where the binding is
already loaded.
* src/eval.c (backtrace_list): Remove.
(set_specpdl_symbol, set_specpdl_old_value): Remove.
(set_backtrace_args, set_backtrace_nargs)
(set_backtrace_debug_on_exit, backtrace_p, backtrace_top)
(backtrace_next): New functions.
(Fdefvaralias, Fdefvar): Adjust to new specpdl format.
(unwind_to_catch, internal_lisp_condition_case)
(internal_condition_case, internal_condition_case_1)
(internal_condition_case_2, internal_condition_case_n): Don't bother
with backtrace_list any more.
(Fsignal): Adjust to new backtrace format.
(grow_specpdl): Move up.
(record_in_backtrace): New function.
(eval_sub, Ffuncall): Use it.
(apply_lambda): Adjust to new backtrace format.
(let_shadows_buffer_binding_p, let_shadows_global_binding_p): Move from
data.c.
(specbind): Adjust to new specpdl format. Simplify.
(record_unwind_protect, unbind_to): Adjust to new specpdl format.
(Fbacktrace_debug, Fbacktrace, Fbacktrace_frame): Adjust to new
backtrace format.
(mark_backtrace): Remove.
(mark_specpdl, get_backtrace, backtrace_top_function): New functions.
* src/xdisp.c (redisplay_internal): Use record_in_backtrace.
* src/alloc.c (Fgarbage_collect): Use record_in_backtrace.
Use mark_specpdl.
* src/profiler.c (record_backtrace): Use get_backtrace.
(handle_profiler_signal): Use backtrace_top_function.
* src/.gdbinit (xbacktrace, hookpost-backtrace): Use new backtrace
accessor functions.
Diffstat (limited to 'src/profiler.c')
| -rw-r--r-- | src/profiler.c | 17 |
1 files changed, 3 insertions, 14 deletions
diff --git a/src/profiler.c b/src/profiler.c index 0a0a4d0bc57..aba81344c68 100644 --- a/src/profiler.c +++ b/src/profiler.c | |||
| @@ -138,10 +138,8 @@ static void evict_lower_half (log_t *log) | |||
| 138 | static void | 138 | static void |
| 139 | record_backtrace (log_t *log, EMACS_INT count) | 139 | record_backtrace (log_t *log, EMACS_INT count) |
| 140 | { | 140 | { |
| 141 | struct backtrace *backlist = backtrace_list; | ||
| 142 | Lisp_Object backtrace; | 141 | Lisp_Object backtrace; |
| 143 | ptrdiff_t index, i = 0; | 142 | ptrdiff_t index; |
| 144 | ptrdiff_t asize; | ||
| 145 | 143 | ||
| 146 | if (!INTEGERP (log->next_free)) | 144 | if (!INTEGERP (log->next_free)) |
| 147 | /* FIXME: transfer the evicted counts to a special entry rather | 145 | /* FIXME: transfer the evicted counts to a special entry rather |
| @@ -151,16 +149,7 @@ record_backtrace (log_t *log, EMACS_INT count) | |||
| 151 | 149 | ||
| 152 | /* Get a "working memory" vector. */ | 150 | /* Get a "working memory" vector. */ |
| 153 | backtrace = HASH_KEY (log, index); | 151 | backtrace = HASH_KEY (log, index); |
| 154 | asize = ASIZE (backtrace); | 152 | get_backtrace (backtrace); |
| 155 | |||
| 156 | /* Copy the backtrace contents into working memory. */ | ||
| 157 | for (; i < asize && backlist; i++, backlist = backlist->next) | ||
| 158 | /* FIXME: For closures we should ignore the environment. */ | ||
| 159 | ASET (backtrace, i, backlist->function); | ||
| 160 | |||
| 161 | /* Make sure that unused space of working memory is filled with nil. */ | ||
| 162 | for (; i < asize; i++) | ||
| 163 | ASET (backtrace, i, Qnil); | ||
| 164 | 153 | ||
| 165 | { /* We basically do a `gethash+puthash' here, except that we have to be | 154 | { /* We basically do a `gethash+puthash' here, except that we have to be |
| 166 | careful to avoid memory allocation since we're in a signal | 155 | careful to avoid memory allocation since we're in a signal |
| @@ -232,7 +221,7 @@ static EMACS_INT current_sampling_interval; | |||
| 232 | static void | 221 | static void |
| 233 | handle_profiler_signal (int signal) | 222 | handle_profiler_signal (int signal) |
| 234 | { | 223 | { |
| 235 | if (backtrace_list && EQ (backtrace_list->function, Qautomatic_gc)) | 224 | if (EQ (backtrace_top_function (), Qautomatic_gc)) |
| 236 | /* Special case the time-count inside GC because the hash-table | 225 | /* Special case the time-count inside GC because the hash-table |
| 237 | code is not prepared to be used while the GC is running. | 226 | code is not prepared to be used while the GC is running. |
| 238 | More specifically it uses ASIZE at many places where it does | 227 | More specifically it uses ASIZE at many places where it does |