Skip to content

Commit

Permalink
remove half-baked TlsKey solution
Browse files Browse the repository at this point in the history
  • Loading branch information
max-heller committed Nov 10, 2023
1 parent 80f17ca commit b8e6566
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 21 deletions.
13 changes: 0 additions & 13 deletions src/shims/tls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,25 +105,12 @@ impl<'tcx> TlsData<'tcx> {
thread_id: ThreadId,
new_data: Scalar<Provenance>,
cx: &impl HasDataLayout,
static_roots: &mut Vec<AllocId>,
) -> InterpResult<'tcx> {
match self.keys.get_mut(&key) {
Some(TlsEntry { data, .. }) => {
if new_data.to_target_usize(cx)? != 0 {
trace!("TLS key {} for thread {:?} stored: {:?}", key, thread_id, new_data);
data.insert(thread_id, new_data);
if thread_id.to_u32() == 0 {
if let Some(alloc) = (new_data.to_pointer(cx).ok())
.and_then(|ptr| ptr.provenance.and_then(|prov| prov.get_alloc_id()))
{
trace!(
"TLS key {} for main thread stored as static root: {:?}",
key,
alloc,
);
static_roots.push(alloc);
}
}
} else {
trace!("TLS key {} for thread {:?} removed", key, thread_id);
data.remove(&thread_id);
Expand Down
2 changes: 1 addition & 1 deletion src/shims/unix/foreign_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
let key = this.read_scalar(key)?.to_bits(key.layout.size)?;
let active_thread = this.get_active_thread();
let new_data = this.read_scalar(new_ptr)?;
this.machine.tls.store_tls(key, active_thread, new_data, &*this.tcx, &mut this.machine.static_roots)?;
this.machine.tls.store_tls(key, active_thread, new_data, &*this.tcx)?;

// Return success (`0`).
this.write_null(dest)?;
Expand Down
8 changes: 1 addition & 7 deletions src/shims/windows/foreign_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,13 +230,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
let key = u128::from(this.read_scalar(key)?.to_u32()?);
let active_thread = this.get_active_thread();
let new_data = this.read_scalar(new_ptr)?;
this.machine.tls.store_tls(
key,
active_thread,
new_data,
&*this.tcx,
&mut this.machine.static_roots,
)?;
this.machine.tls.store_tls(key, active_thread, new_data, &*this.tcx)?;

// Return success (`1`).
this.write_scalar(Scalar::from_i32(1), dest)?;
Expand Down

0 comments on commit b8e6566

Please sign in to comment.