mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-12 23:37:38 +02:00
Micro-optimization - turn Cyc_st_add into a macro
This commit is contained in:
parent
dd0fc1408d
commit
549bb59937
2 changed files with 18 additions and 17 deletions
|
@ -543,7 +543,24 @@ object copy2heap(void *data, object obj);
|
|||
* @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);
|
||||
/**@}*/
|
||||
|
||||
|
|
16
runtime.c
16
runtime.c
|
@ -315,22 +315,6 @@ const object quote_void = &Cyc_void_symbol;
|
|||
|
||||
/* 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.
|
||||
* @param data Thread data object
|
||||
|
|
Loading…
Add table
Reference in a new issue