Micro-optimization - turn Cyc_st_add into a macro

This commit is contained in:
Justin Ethier 2019-03-28 12:21:15 -04:00
parent dd0fc1408d
commit 549bb59937
2 changed files with 18 additions and 17 deletions

View file

@ -543,7 +543,24 @@ object copy2heap(void *data, object obj);
* @brief Functions for maintaining call history. * @brief Functions for maintaining call history.
*/ */
/**@{*/ /**@{*/
void Cyc_st_add(void *data, char *frame);
//void Cyc_st_add(void *data, char *frame); migrated from runtime.c
/**
* @brief Register a frame in the stack trace circular buffer.
* @param data Thread data object
* @param frame Name of the frame
*/
#define Cyc_st_add(data, frame) \
{ \
gc_thread_data *thd = (gc_thread_data *) data; \
/* Do not allow recursion to remove older frames */ \
if ((char *)frame != thd->stack_prev_frame) { \
thd->stack_prev_frame = frame; \
thd->stack_traces[thd->stack_trace_idx] = frame; \
thd->stack_trace_idx = (thd->stack_trace_idx + 1) % MAX_STACK_TRACES; \
} \
}
void Cyc_st_print(void *data, FILE * out); void Cyc_st_print(void *data, FILE * out);
/**@}*/ /**@}*/

View file

@ -315,22 +315,6 @@ const object quote_void = &Cyc_void_symbol;
/* Stack Traces */ /* Stack Traces */
/**
* @brief Register a frame in the stack trace circular buffer.
* @param data Thread data object
* @param frame Name of the frame
*/
void Cyc_st_add(void *data, char *frame)
{
gc_thread_data *thd = (gc_thread_data *) data;
// Do not allow recursion to remove older frames
if (frame != thd->stack_prev_frame) {
thd->stack_prev_frame = frame;
thd->stack_traces[thd->stack_trace_idx] = frame;
thd->stack_trace_idx = (thd->stack_trace_idx + 1) % MAX_STACK_TRACES;
}
}
/** /**
* @brief Print the contents of the given thread's stack trace buffer. * @brief Print the contents of the given thread's stack trace buffer.
* @param data Thread data object * @param data Thread data object