Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion ykllvm
18 changes: 18 additions & 0 deletions ykrt/src/mt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1345,6 +1345,24 @@ impl MTThread {
true
}

/// Records `val` as a value to be promoted. Returns `true` if either: no trace is being
/// recorded; or recording the promotion succeeded.
///
/// If `false` is returned, the current trace is unable to record the promotion successfully
/// and further calls are probably pointless, though they will not cause the tracer to enter
/// undefined behaviour territory.
///
/// # Panics
///
/// If the stack is empty. There should always be at least one element on the stack, so a panic
/// here means that something has gone wrong elsewhere.
pub(crate) fn promote_i8(&mut self, val: i8) -> bool {
if let MTThreadState::Tracing { promotions, .. } = self.peek_mut_tstate() {
promotions.push(val.cast_unsigned());
}
true
}

/// Records `val` as a value to be promoted. Returns `true` if either: no trace is being
/// recorded; or recording the promotion succeeded.
///
Expand Down
12 changes: 12 additions & 0 deletions ykrt/src/promote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,15 @@ pub extern "C" fn __yk_idempotent_promote_i32(val: i32) -> i32 {
}
val
}

/// Records an 8-bit return value of an idempotent function during trace recording.
#[unsafe(no_mangle)]
pub extern "C" fn __yk_idempotent_promote_i8(val: i8) -> i8 {
if MTThread::is_tracing() {
MTThread::with_borrow_mut(|mtt| {
// We ignore the return value as we can't really cancel tracing from this function.
mtt.promote_i8(val);
});
}
val
}