@@ -40,57 +40,57 @@ cfg_if::cfg_if! {
4040 /// the frame is later popped.
4141 pub use imp:: get_stack_pointer;
4242
43- /// Resume execution at the given PC, SP, and FP, with the given
44- /// payload values, according to the tail-call ABI's exception
45- /// scheme. Note that this scheme does not restore any other
46- /// registers, so the given state is all that we need.
47- ///
48- /// # Safety
49- ///
50- /// This method requires:
51- ///
52- /// - the `sp` and `fp` to correspond to an active stack frame
53- /// (above the current function), in code using Cranelift's
54- /// `tail` calling convention.
55- ///
56- /// - The `pc` to correspond to a `try_call` handler
57- /// destination, as emitted in Cranelift metadata, or
58- /// otherwise a target that is expecting the tail-call ABI's
59- /// exception ABI.
60- ///
61- /// - The Rust frames between the unwind destination and this
62- /// frame to be unwind-safe: that is, they cannot have `Drop`
63- /// handlers for which safety requires that they run.
64- pub unsafe fn resume_to_exception_handler(
65- pc: usize ,
66- sp: usize ,
67- fp: usize ,
68- payload1: usize ,
69- payload2: usize ,
70- ) -> ! {
71- // Without this ASAN seems to nondeterministically trigger an
72- // internal assertion when running tests with threads. Not entirely
73- // clear what's going on here but it seems related to the fact that
74- // there's Rust code on the stack which is never cleaned up due to
75- // the jump out of `imp::resume_to_exception_handler`.
76- //
77- // This function is documented as something that should be called to
78- // clean up the entire thread's shadow memory and stack which isn't
79- // exactly what we want but this at least seems to resolve ASAN
80- // issues for now. Probably a heavy hammer but better than false
81- // positives I suppose...
82- #[ cfg( asan) ]
83- {
84- unsafe extern "C" {
85- fn __asan_handle_no_return( ) ;
43+ impl crate :: Handler {
44+ /// Resume execution at the given PC, SP, and FP, with the given
45+ /// payload values, according to the tail-call ABI's exception
46+ /// scheme. Note that this scheme does not restore any other
47+ /// registers, so the given state is all that we need.
48+ ///
49+ /// # Safety
50+ ///
51+ /// This method requires:
52+ ///
53+ /// - the `sp` and `fp` to correspond to an active stack frame
54+ /// (above the current function), in code using Cranelift's
55+ /// `tail` calling convention.
56+ ///
57+ /// - The `pc` to correspond to a `try_call` handler
58+ /// destination, as emitted in Cranelift metadata, or
59+ /// otherwise a target that is expecting the tail-call ABI's
60+ /// exception ABI.
61+ ///
62+ /// - The Rust frames between the unwind destination and this
63+ /// frame to be unwind-safe: that is, they cannot have `Drop`
64+ /// handlers for which safety requires that they run.
65+ pub unsafe fn resume(
66+ & self ,
67+ payload1: usize ,
68+ payload2: usize ,
69+ ) -> ! {
70+ // Without this ASAN seems to nondeterministically trigger an
71+ // internal assertion when running tests with threads. Not entirely
72+ // clear what's going on here but it seems related to the fact that
73+ // there's Rust code on the stack which is never cleaned up due to
74+ // the jump out of `imp::resume_to_exception_handler`.
75+ //
76+ // This function is documented as something that should be called to
77+ // clean up the entire thread's shadow memory and stack which isn't
78+ // exactly what we want but this at least seems to resolve ASAN
79+ // issues for now. Probably a heavy hammer but better than false
80+ // positives I suppose...
81+ #[ cfg( asan) ]
82+ {
83+ unsafe extern "C" {
84+ fn __asan_handle_no_return( ) ;
85+ }
86+ unsafe {
87+ __asan_handle_no_return( ) ;
88+ }
8689 }
8790 unsafe {
88- __asan_handle_no_return ( ) ;
91+ imp :: resume_to_exception_handler ( self . pc , self . sp , self . fp , payload1 , payload2 )
8992 }
9093 }
91- unsafe {
92- imp:: resume_to_exception_handler( pc, sp, fp, payload1, payload2)
93- }
9494 }
9595
9696 /// Get the return address in the function at the next-older
@@ -101,21 +101,20 @@ cfg_if::cfg_if! {
101101 /// - Requires that `fp` is a valid frame-pointer value for an
102102 /// active stack frame (above the current function), in code
103103 /// using Cranelift's `tail` calling convention.
104- pub use imp:: get_next_older_pc_from_fp;
105-
104+ use imp:: get_next_older_pc_from_fp;
106105
107106 /// The offset of the saved old-FP value in a frame, from the
108107 /// location pointed to by a given FP.
109- pub const NEXT_OLDER_FP_FROM_FP_OFFSET : usize = imp:: NEXT_OLDER_FP_FROM_FP_OFFSET ;
108+ const NEXT_OLDER_FP_FROM_FP_OFFSET : usize = imp:: NEXT_OLDER_FP_FROM_FP_OFFSET ;
110109
111110 /// The offset of the next older SP value, from the value of a
112111 /// given FP.
113- pub const NEXT_OLDER_SP_FROM_FP_OFFSET : usize = imp:: NEXT_OLDER_SP_FROM_FP_OFFSET ;
112+ const NEXT_OLDER_SP_FROM_FP_OFFSET : usize = imp:: NEXT_OLDER_SP_FROM_FP_OFFSET ;
114113
115114 /// Assert that the given `fp` is aligned as expected by the
116115 /// host platform's implementation of the Cranelift tail-call
117116 /// ABI.
118- pub use imp:: assert_fp_is_aligned;
117+ use imp:: assert_fp_is_aligned;
119118
120119 /// If we have the above host-specific implementations, we can
121120 /// implement `Unwind`.
0 commit comments