@@ -252,6 +252,8 @@ pub struct MachBuffer<I: VCodeInst> {
252252 call_sites : SmallVec < [ MachCallSite ; 16 ] > ,
253253 /// Any patchable call site locations.
254254 patchable_call_sites : SmallVec < [ MachPatchableCallSite ; 16 ] > ,
255+ /// Any locations which do an MMU-based check for the end of an epoch.
256+ epoch_checks : SmallVec < [ EpochCheckOffset ; 16 ] > ,
255257 /// Any exception-handler records referred to at call sites.
256258 exception_handlers : SmallVec < [ MachExceptionHandler ; 16 ] > ,
257259 /// Any source location mappings referring to this code.
@@ -343,6 +345,7 @@ impl MachBufferFinalized<Stencil> {
343345 traps : self . traps ,
344346 call_sites : self . call_sites ,
345347 patchable_call_sites : self . patchable_call_sites ,
348+ epoch_checks : self . epoch_checks ,
346349 exception_handlers : self . exception_handlers ,
347350 srclocs : self
348351 . srclocs
@@ -380,6 +383,8 @@ pub struct MachBufferFinalized<T: CompilePhase> {
380383 pub ( crate ) call_sites : SmallVec < [ MachCallSite ; 16 ] > ,
381384 /// Any patchable call site locations refering to this code.
382385 pub ( crate ) patchable_call_sites : SmallVec < [ MachPatchableCallSite ; 16 ] > ,
386+ /// Any locations which do an MMU-based check for the end of an epoch.
387+ pub epoch_checks : SmallVec < [ EpochCheckOffset ; 16 ] > ,
383388 /// Any exception-handler records referred to at call sites.
384389 pub ( crate ) exception_handlers : SmallVec < [ FinalizedMachExceptionHandler ; 16 ] > ,
385390 /// Any source location mappings referring to this code.
@@ -480,6 +485,7 @@ impl<I: VCodeInst> MachBuffer<I> {
480485 traps : SmallVec :: new ( ) ,
481486 call_sites : SmallVec :: new ( ) ,
482487 patchable_call_sites : SmallVec :: new ( ) ,
488+ epoch_checks : SmallVec :: new ( ) ,
483489 exception_handlers : SmallVec :: new ( ) ,
484490 srclocs : SmallVec :: new ( ) ,
485491 debug_tags : vec ! [ ] ,
@@ -1581,6 +1587,7 @@ impl<I: VCodeInst> MachBuffer<I> {
15811587 traps : self . traps ,
15821588 call_sites : self . call_sites ,
15831589 patchable_call_sites : self . patchable_call_sites ,
1590+ epoch_checks : self . epoch_checks ,
15841591 exception_handlers : finalized_exception_handlers,
15851592 srclocs,
15861593 debug_tags : self . debug_tags ,
@@ -1696,6 +1703,14 @@ impl<I: VCodeInst> MachBuffer<I> {
16961703 } ) ;
16971704 }
16981705
1706+ /// Record that an MMU-based epoch interruption check occurs at the current
1707+ /// offset. The signal handler uses these annotations to distinguish that a
1708+ /// segfault is actually an epoch interruption in disguise. The
1709+ /// DeadLoadWithContext instruction is assumed to have already been emitted.
1710+ pub fn add_epoch_check ( & mut self ) {
1711+ self . epoch_checks . push ( self . cur_offset ( ) ) ;
1712+ }
1713+
16991714 /// Add an unwind record at the current offset.
17001715 pub fn add_unwind ( & mut self , unwind : UnwindInst ) {
17011716 self . unwind_info . push ( ( self . cur_offset ( ) , unwind) ) ;
@@ -2198,6 +2213,12 @@ pub struct MachPatchableCallSite {
21982213 pub len : u32 ,
21992214}
22002215
2216+ /// The location of an epoch-end check, when using MMU-based epoch interruption.
2217+ ///
2218+ /// Specifically, this points to the instruction after the one that does the
2219+ /// epoch-end check: the one at which to resume execution.
2220+ pub type EpochCheckOffset = CodeOffset ;
2221+
22012222/// A source-location mapping resulting from a compilation.
22022223#[ derive( PartialEq , Debug , Clone ) ]
22032224#[ cfg_attr(
0 commit comments