13 void on_code_start(
const void* compiled_base,
const void* wasm_code_start) {}
16 void on_code_end(
const void* code_addr,
const void* wasm_addr) {}
31 void on_code_start(
const void* compiled_base,
const void* wasm_code_start) {
37 static_cast<std::uint32_t
>(
reinterpret_cast<const char*
>(code_addr) -
reinterpret_cast<const char*
>(
code_base)),
38 static_cast<std::uint32_t
>(
reinterpret_cast<const char*
>(wasm_addr) -
reinterpret_cast<const char*
>(
wasm_base))
43 static_cast<std::uint32_t
>(
reinterpret_cast<const char*
>(code_addr) -
reinterpret_cast<const char*
>(
code_base)),
44 static_cast<std::uint32_t
>(
reinterpret_cast<const char*
>(wasm_addr) -
reinterpret_cast<const char*
>(
wasm_base))
47 void on_code_end(
const void* code_addr,
const void* wasm_addr) {
54 std::vector<addr_entry>
data;
58 data = std::move(b.data);
59 std::sort(data.begin(), data.end(), [](
const addr_entry& lhs,
const addr_entry& rhs){ return lhs.offset < rhs.offset; });
60 base_address = b.code_base;
61 code_size =
reinterpret_cast<const char*
>(b.code_end) -
reinterpret_cast<const char*
>(base_address);
62 offset_to_addr = data.data();
63 offset_to_addr_len = data.size();
71 void relocate(
const void* new_base) { base_address = new_base; }
75 std::size_t
diff = (
reinterpret_cast<const char*
>(pc) -
reinterpret_cast<const char*
>(base_address));
76 if(
diff >= code_size ||
diff < offset_to_addr[0].offset)
return 0xFFFFFFFFu;
77 std::uint32_t offset =
diff;
80 std::size_t lower = 0, upper = offset_to_addr_len;
81 while(upper - lower > 1) {
82 std::size_t mid = lower + (upper - lower) / 2;
83 if(offset_to_addr[mid].offset <= offset) {
90 return offset_to_addr[lower].wasm_addr;
93 const void* base_address =
nullptr;
94 std::size_t code_size = 0;
96 addr_entry* offset_to_addr =
nullptr;
97 std::size_t offset_to_addr_len = 0;
99 std::vector<addr_entry> data;
profile_instr_map & operator=(const profile_instr_map &)=delete
profile_instr_map()=default
void relocate(const void *new_base)
profile_instr_map(const profile_instr_map &)=delete
std::uint32_t translate(const void *pc) const
void diff(const std::string &a, const std::string &b)
void relocate(const void *)
void on_instr_start(const void *code_addr, const void *wasm_addr)
void on_function_start(const void *code_addr, const void *wasm_addr)
void on_code_start(const void *compiled_base, const void *wasm_code_start)
void on_code_end(const void *code_addr, const void *wasm_addr)
void set(const null_debug_info &)
void on_code_end(const void *code_addr, const void *wasm_addr)
void on_instr_start(const void *code_addr, const void *wasm_addr)
void on_code_start(const void *compiled_base, const void *wasm_code_start)
std::vector< addr_entry > data
void on_function_start(const void *code_addr, const void *wasm_addr)