summaryrefslogtreecommitdiff
path: root/src/profiler.c
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2013-06-03 05:01:53 -0400
committerStefan Monnier <monnier@iro.umontreal.ca>2013-06-03 05:01:53 -0400
commit2f592f95d2344d4a28eb946848330dca49e0f5ee (patch)
treea920b413f4367d49b7f7feeb3fdf63c5e9018dcb /src/profiler.c
parente5e4a94293d5a9a157557e53b4fea4e5d280673e (diff)
downloademacs-2f592f95d2344d4a28eb946848330dca49e0f5ee.tar.gz
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.c17
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)
static void
record_backtrace (log_t *log, EMACS_INT count)
{
- struct backtrace *backlist = backtrace_list;
Lisp_Object backtrace;
- ptrdiff_t index, i = 0;
- ptrdiff_t asize;
+ ptrdiff_t index;
if (!INTEGERP (log->next_free))
/* FIXME: transfer the evicted counts to a special entry rather
@@ -151,16 +149,7 @@ record_backtrace (log_t *log, EMACS_INT count)
/* Get a "working memory" vector. */
backtrace = HASH_KEY (log, index);
- asize = ASIZE (backtrace);
-
- /* Copy the backtrace contents into working memory. */
- for (; i < asize && backlist; i++, backlist = backlist->next)
- /* FIXME: For closures we should ignore the environment. */
- ASET (backtrace, i, backlist->function);
-
- /* Make sure that unused space of working memory is filled with nil. */
- for (; i < asize; i++)
- ASET (backtrace, i, Qnil);
+ get_backtrace (backtrace);
{ /* We basically do a `gethash+puthash' here, except that we have to be
careful to avoid memory allocation since we're in a signal
@@ -232,7 +221,7 @@ static EMACS_INT current_sampling_interval;
static void
handle_profiler_signal (int signal)
{
- if (backtrace_list && EQ (backtrace_list->function, Qautomatic_gc))
+ if (EQ (backtrace_top_function (), Qautomatic_gc))
/* Special case the time-count inside GC because the hash-table
code is not prepared to be used while the GC is running.
More specifically it uses ASIZE at many places where it does