Skip to content
This repository was archived by the owner on Jun 26, 2020. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion lib/simplejit/src/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use libc;
use memory::Memory;
use std::collections::HashMap;
use std::ffi::CString;
use std::io::Write;
use std::ptr;
use target_lexicon::PointerWidth;
#[cfg(windows)]
Expand Down Expand Up @@ -167,7 +168,7 @@ impl<'simple_jit_backend> Backend for SimpleJITBackend {

fn define_function(
&mut self,
_name: &str,
name: &str,
ctx: &cranelift_codegen::Context,
_namespace: &ModuleNamespace<Self>,
code_size: u32,
Expand All @@ -177,6 +178,17 @@ impl<'simple_jit_backend> Backend for SimpleJITBackend {
.code_memory
.allocate(size)
.expect("TODO: handle OOM etc.");

if cfg!(target_os = "linux") && ::std::env::var_os("PERF_BUILDID_DIR").is_some() {
let mut map_file = ::std::fs::OpenOptions::new()
.create(true)
.append(true)
.open(format!("/tmp/perf-{}.map", ::std::process::id()))
.unwrap();

writeln!(map_file, "{:x} {:x} {}", ptr as usize, code_size, name);
}

let mut reloc_sink = SimpleJITRelocSink::new();
// Ignore traps for now. For now, frontends should just avoid generating code
// that traps.
Expand Down