EMACS_INT discarded; /* Samples evicted during table overflow. */
};
+static Lisp_Object export_log (struct profiler_log *);
+
static struct profiler_log
make_log (void)
{
\f
/* Sampling profiler. */
+/* Signal handler for sampling profiler. */
+
+static void
+add_sample (struct profiler_log *plog, EMACS_INT count)
+{
+ if (EQ (backtrace_top_function (), QAutomatic_GC)) /* bug#60237 */
+ /* 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
+ not expect the ARRAY_MARK_FLAG to be set. We could try and
+ harden the hash-table code, but it doesn't seem worth the
+ effort. */
+ plog->gc_count = saturated_add (plog->gc_count, count);
+ else
+ record_backtrace (plog, count);
+}
+
#ifdef PROFILER_CPU_SUPPORT
/* The profiler timer and whether it was properly initialized, if
/* The current sampling interval in nanoseconds. */
static EMACS_INT current_sampling_interval;
-/* Signal handler for sampling profiler. */
-
-static void
-add_sample (struct profiler_log *plog, EMACS_INT count)
-{
- if (EQ (backtrace_top_function (), QAutomatic_GC)) /* bug#60237 */
- /* 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
- not expect the ARRAY_MARK_FLAG to be set. We could try and
- harden the hash-table code, but it doesn't seem worth the
- effort. */
- plog->gc_count = saturated_add (plog->gc_count, count);
- else
- record_backtrace (plog, count);
-}
-
-
static void
handle_profiler_signal (int signal)
{
return profiler_cpu_running ? Qt : Qnil;
}
+DEFUN ("profiler-cpu-log", Fprofiler_cpu_log, Sprofiler_cpu_log,
+ 0, 0, 0,
+ doc: /* Return the current cpu profiler log.
+The log is a hash-table mapping backtraces to counters which represent
+the amount of time spent at those points. Every backtrace is a vector
+of functions, where the last few elements may be nil.
+Before returning, a new log is allocated for future samples. */)
+ (void)
+{
+ return (export_log (&cpu));
+}
+#endif /* PROFILER_CPU_SUPPORT */
+
static Lisp_Object
export_log (struct profiler_log *log)
{
Fputhash (CALLN (Fvector, QDiscarded_Samples, Qnil),
make_fixnum (log->discarded),
result);
+#ifdef PROFILER_CPU_SUPPORT
/* Here we're making the log visible to Elisp, so it's not safe any
more for our use afterwards since we can't rely on its special
pre-allocated keys anymore. So we have to allocate a new one. */
if (profiler_cpu_running)
*log = make_log ();
+#endif /* PROFILER_CPU_SUPPORT */
return result;
}
-
-DEFUN ("profiler-cpu-log", Fprofiler_cpu_log, Sprofiler_cpu_log,
- 0, 0, 0,
- doc: /* Return the current cpu profiler log.
-The log is a hash-table mapping backtraces to counters which represent
-the amount of time spent at those points. Every backtrace is a vector
-of functions, where the last few elements may be nil.
-Before returning, a new log is allocated for future samples. */)
- (void)
-{
- return (export_log (&cpu));
-}
-#endif /* PROFILER_CPU_SUPPORT */
\f
/* Memory profiler. */