| 1 |
#pragma once |
| 2 |
|
| 3 |
#ifdef PYPY_JIT_CODEMAP |
| 4 |
#include "vmprof.h" |
| 5 |
|
| 6 |
#ifdef VMPROF_WINDOWS |
| 7 |
#include "msiinttypes/stdint.h" |
| 8 |
#else |
| 9 |
#include <stdint.h> |
| 10 |
#endif |
| 11 |
|
| 12 |
void *pypy_find_codemap_at_addr(long addr, long *start_addr); |
| 13 |
long pypy_yield_codemap_at_addr(void *codemap_raw, long addr, |
| 14 |
long *current_pos_addr); |
| 15 |
|
| 16 |
#define MAX_INLINE_DEPTH 384 |
| 17 |
|
| 18 |
long vmprof_write_header_for_jit_addr(intptr_t *result, long n, |
| 19 |
intptr_t addr, int max_depth) |
| 20 |
{ |
| 21 |
void *codemap; |
| 22 |
long current_pos = 0; |
| 23 |
intptr_t ident, local_stack[MAX_INLINE_DEPTH]; |
| 24 |
long m; |
| 25 |
long start_addr = 0; |
| 26 |
|
| 27 |
codemap = pypy_find_codemap_at_addr(addr, &start_addr); |
| 28 |
if (codemap == NULL || n >= max_depth - 2) |
| 29 |
|
| 30 |
return n; |
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
result[n++] = VMPROF_ASSEMBLER_TAG; |
| 35 |
result[n++] = start_addr; |
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
m = 0; |
| 47 |
while (m < MAX_INLINE_DEPTH) { |
| 48 |
ident = pypy_yield_codemap_at_addr(codemap, addr, ¤t_pos); |
| 49 |
if (ident == -1) |
| 50 |
|
| 51 |
break; |
| 52 |
if (ident == 0) |
| 53 |
continue; |
| 54 |
local_stack[m++] = ident; |
| 55 |
} |
| 56 |
while (m > 0 && n < max_depth) { |
| 57 |
result[n++] = VMPROF_JITTED_TAG; |
| 58 |
result[n++] = local_stack[--m]; |
| 59 |
} |
| 60 |
return n; |
| 61 |
} |
| 62 |
#endif |