Skip to content

Commit

Permalink
Merge #549
Browse files Browse the repository at this point in the history
549: Tidy ups r=vext01 a=ltratt



Co-authored-by: Laurence Tratt <laurie@tratt.net>
  • Loading branch information
bors[bot] and ltratt authored Apr 26, 2022
2 parents 8e6634c + e995e2b commit 7d4511b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
6 changes: 3 additions & 3 deletions tests/src/bin/run_trace_compiler_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use yktrace::{IRBlock, IRTrace};
const BBS_ENV: &str = "YKT_TRACE_BBS";

fn parse_bb(bb: &str) -> Result<(CString, usize), Box<dyn Error>> {
let mut elems = bb.split(":");
let mut elems = bb.split(':');
let func = elems.next().ok_or("malformed function name")?;
let bb_idx = elems
.next()
Expand All @@ -23,7 +23,7 @@ fn main() -> Result<(), String> {
// Build the trace that we are going to have compiled.
let mut bbs = vec![IRBlock::unmappable()];
if let Ok(tbbs) = env::var(BBS_ENV) {
for bb in tbbs.split(",") {
for bb in tbbs.split(',') {
if let Ok((func, bb_idx)) = parse_bb(bb) {
bbs.push(IRBlock::new(func, bb_idx));
} else {
Expand All @@ -41,7 +41,7 @@ fn main() -> Result<(), String> {
// Map the `.ll` file into the address space so that we can give a pointer to it to the trace
// compiler. Normally (i.e. outside of testing), the trace compiler wouldn't deal with textual
// bitcode format, but it just so happens that LLVM's module loading APIs accept either format.
let ll_path = env::args().skip(1).next().unwrap();
let ll_path = env::args().nth(1).unwrap();
let ll_file = File::open(ll_path).unwrap();
let mmap = unsafe { memmap2::Mmap::map(&ll_file).unwrap() };

Expand Down
18 changes: 9 additions & 9 deletions ykrt/src/mt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,9 @@ impl MT {
Ordering::Relaxed,
)
.ok();
return TransitionLocation::NoAction;
TransitionLocation::NoAction
} else {
return THREAD_MTTHREAD.with(|mtt| {
THREAD_MTTHREAD.with(|mtt| {
if !mtt.tracing.load(Ordering::Relaxed).is_null() {
// This thread is already tracing another Location, so either another
// thread needs to trace this Location or this thread needs to wait
Expand Down Expand Up @@ -267,7 +267,7 @@ impl MT {
}
}
}
});
})
}
} else {
// There's no point contending with other threads, so in general we don't want to
Expand Down Expand Up @@ -297,9 +297,9 @@ impl MT {
let thread_arc = THREAD_MTTHREAD.with(|mtt| Arc::clone(&mtt.tracing));
if !thread_arc.load(Ordering::Relaxed).is_null() {
// FIXME: https://github.com/ykjit/yk/issues/519
return TransitionLocation::NoAction;
TransitionLocation::NoAction
} else {
return TransitionLocation::Execute(*ctr);
TransitionLocation::Execute(*ctr)
}
}
HotLocationKind::Compiling(arcmtx) => {
Expand All @@ -322,7 +322,7 @@ impl MT {
}
};
loc.unlock();
return r;
r
}
HotLocationKind::Tracing(ref tracing_arc) => {
let thread_arc = THREAD_MTTHREAD.with(|mtt| Arc::clone(&mtt.tracing));
Expand All @@ -338,7 +338,7 @@ impl MT {
let mtx = Arc::new(Mutex::new(None));
hl.kind = HotLocationKind::Compiling(Arc::clone(&mtx));
loc.unlock();
return TransitionLocation::StopTracing(mtx);
TransitionLocation::StopTracing(mtx)
} else {
// This thread isn't tracing anything
if Arc::strong_count(tracing_arc) == 1 {
Expand All @@ -359,12 +359,12 @@ impl MT {
}
}
loc.unlock();
return TransitionLocation::NoAction;
TransitionLocation::NoAction
}
}
HotLocationKind::DontTrace => {
loc.unlock();
return TransitionLocation::NoAction;
TransitionLocation::NoAction
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions yksgi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -326,17 +326,17 @@ impl SGInterp {
if ALWAYS_SKIP_FUNCS.contains(&name) {
// There's no point calling these functions inside the stopgap interpreter so just skip
// them.
return false;
false
} else if SKIP_FOR_NOW_FUNCS.contains(&name) {
// FIXME: These need to run, but since we can't do calls, just skip them for now.
return false;
false
} else if name.starts_with("puts") || name.starts_with("printf") {
// FIXME: Until we can handle function calls, simulate prints to make our tests work.
// Get format string.
let op = self.pc.get_operand(0);
let op2 = op.get_operand(0);
let op3 = LLVMGetInitializer(op2.get());
let mut l = 0 as usize;
let mut l = 0;
let s = LLVMGetAsString(op3, &mut l);
// Get operands
let mut ops = Vec::new();
Expand All @@ -355,10 +355,10 @@ impl SGInterp {
3 => libc::printf(s, ops[0], ops[1], ops[2]),
_ => todo!(),
};
return false;
false
} else if name.starts_with(YK_CONTROL_POINT_FUNC) {
// FIXME: When we see the control point we are done and can just return.
return true;
true
} else {
// FIXME: Properly implement calls.
todo!("{:?}", self.pc.as_str())
Expand Down

0 comments on commit 7d4511b

Please sign in to comment.