Skip to content

Commit d3c1036

Browse files
committed
Auto merge of #3972 - rust-lang:eager_dyn, r=RalfJung
Avoid some needless monomorphizations All code paths always end up boxing the type, so let's do it eagerly in the `callback!` macro instead
2 parents d183660 + 1412993 commit d3c1036

2 files changed

Lines changed: 7 additions & 10 deletions

File tree

‎src/tools/miri/src/concurrency/init_once.rs‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use std::collections::VecDeque;
22

33
use rustc_index::Idx;
44

5+
usesuper::thread::DynUnblockCallback;
56
usesuper::vector_clock::VClock;
67
usecrate::*;
78

@@ -34,11 +35,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
3435

3536
/// Put the thread into the queue waiting for the initialization.
3637
#[inline]
37-
fninit_once_enqueue_and_block(
38-
&mutself,
39-
id:InitOnceId,
40-
callback:implUnblockCallback<'tcx> + 'tcx,
41-
){
38+
fninit_once_enqueue_and_block(&mutself,id:InitOnceId,callback:DynUnblockCallback<'tcx>){
4239
let this = self.eval_context_mut();
4340
let thread = this.active_thread();
4441
let init_once = &mut this.machine.sync.init_onces[id];

‎src/tools/miri/src/concurrency/thread.rs‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ pub trait UnblockCallback<'tcx>: VisitProvenance {
5050
fntimeout(self:Box<Self>,_ecx:&mutInterpCx<'tcx,MiriMachine<'tcx>>)
5151
-> InterpResult<'tcx>;
5252
}
53-
typeDynUnblockCallback<'tcx> = Box<dynUnblockCallback<'tcx> + 'tcx>;
53+
pubtypeDynUnblockCallback<'tcx> = Box<dynUnblockCallback<'tcx> + 'tcx>;
5454

5555
#[macro_export]
5656
macro_rules! callback {
@@ -101,7 +101,7 @@ macro_rules! callback {
101101
}
102102
}
103103

104-
Callback{ $($name,)* _phantom: std::marker::PhantomData}
104+
Box::new(Callback{ $($name,)* _phantom: std::marker::PhantomData})
105105
}}
106106
}
107107

@@ -715,11 +715,11 @@ impl<'tcx> ThreadManager<'tcx> {
715715
&mutself,
716716
reason:BlockReason,
717717
timeout:Option<Timeout>,
718-
callback:implUnblockCallback<'tcx> + 'tcx,
718+
callback:DynUnblockCallback<'tcx>,
719719
){
720720
let state = &mutself.threads[self.active_thread].state;
721721
assert!(state.is_enabled());
722-
*state = ThreadState::Blocked{ reason, timeout,callback:Box::new(callback)}
722+
*state = ThreadState::Blocked{ reason, timeout, callback }
723723
}
724724

725725
/// Change the active thread to some enabled thread.
@@ -1032,7 +1032,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
10321032
&mutself,
10331033
reason:BlockReason,
10341034
timeout:Option<(TimeoutClock,TimeoutAnchor,Duration)>,
1035-
callback:implUnblockCallback<'tcx> + 'tcx,
1035+
callback:DynUnblockCallback<'tcx>,
10361036
){
10371037
let this = self.eval_context_mut();
10381038
let timeout = timeout.map(|(clock, anchor, duration)| {

0 commit comments

Comments
 (0)