mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-29 22:40:34 +02:00
Add support for perf map creation
* libguile/jit.c (create_perf_map_once, create_perf_map, perf_map): New locals. (compute_mcode): Add an entry to perf_map for emitted JIT code.
This commit is contained in:
parent
8b3cad6183
commit
5c950503a6
1 changed files with 25 additions and 0 deletions
|
@ -5623,6 +5623,21 @@ initialize_jit (void)
|
|||
(scm_jit_return_to_interpreter_trampoline);
|
||||
}
|
||||
|
||||
static scm_i_pthread_once_t create_perf_map_once = SCM_I_PTHREAD_ONCE_INIT;
|
||||
static FILE *perf_map = NULL;
|
||||
static void
|
||||
create_perf_map (void)
|
||||
{
|
||||
unsigned long pid = getpid ();
|
||||
char *file_name;
|
||||
if (asprintf (&file_name, "/tmp/perf-%lu.map", pid) < 0)
|
||||
return;
|
||||
perf_map = fopen (file_name, "w");
|
||||
if (perf_map)
|
||||
DEBUG ("created %s\n", file_name);
|
||||
free (file_name);
|
||||
}
|
||||
|
||||
static uint8_t *
|
||||
compute_mcode (scm_thread *thread, uint32_t *entry_ip,
|
||||
struct scm_jit_function_data *data)
|
||||
|
@ -5673,6 +5688,16 @@ compute_mcode (scm_thread *thread, uint32_t *entry_ip,
|
|||
{
|
||||
entry_mcode = j->labels[inline_label_offset (j->entry - j->start)];
|
||||
data->mcode = mcode;
|
||||
|
||||
if (jit_log_level >= LOG_LEVEL_INFO) {
|
||||
scm_i_pthread_once (&create_perf_map_once, create_perf_map);
|
||||
if (perf_map) {
|
||||
uint8_t *end = j->code_arena->base + j->code_arena->used;
|
||||
fprintf (perf_map, "%lx %zx %p,+%zu\n", (long)mcode, end - mcode,
|
||||
j->start, j->end - j->start);
|
||||
fflush (perf_map);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue