@@ -72,32 +72,32 @@ impl UnwindContext {
72
72
}
73
73
74
74
#[ cfg( feature = "jit" ) ]
75
- pub ( crate ) unsafe fn register_jit (
76
- self ,
77
- jit_module : & cranelift_jit:: JITModule ,
78
- ) -> Option < UnwindRegistry > {
75
+ pub ( crate ) unsafe fn register_jit ( self , jit_module : & cranelift_jit:: JITModule ) {
79
76
let mut eh_frame = EhFrame :: from ( super :: emit:: WriterRelocate :: new ( self . endian ) ) ;
80
77
self . frame_table . write_eh_frame ( & mut eh_frame) . unwrap ( ) ;
81
78
82
79
if eh_frame. 0 . writer . slice ( ) . is_empty ( ) {
83
- return None ;
80
+ return ;
84
81
}
85
82
86
83
let mut eh_frame = eh_frame. 0 . relocate_for_jit ( jit_module) ;
87
84
88
85
// GCC expects a terminating "empty" length, so write a 0 length at the end of the table.
89
86
eh_frame. extend ( & [ 0 , 0 , 0 , 0 ] ) ;
90
87
91
- let mut registrations = Vec :: new ( ) ;
88
+ // FIXME support unregistering unwind tables once cranelift-jit supports deallocating
89
+ // individual functions
90
+ #[ allow( unused_variables) ]
91
+ let ( eh_frame, eh_frame_len, _) = Vec :: into_raw_parts ( eh_frame) ;
92
92
93
93
// =======================================================================
94
94
// Everything after this line up to the end of the file is loosly based on
95
95
// https://github.com/bytecodealliance/wasmtime/blob/4471a82b0c540ff48960eca6757ccce5b1b5c3e4/crates/jit/src/unwind/systemv.rs
96
96
#[ cfg( target_os = "macos" ) ]
97
97
{
98
98
// On macOS, `__register_frame` takes a pointer to a single FDE
99
- let start = eh_frame. as_ptr ( ) ;
100
- let end = start. add ( eh_frame . len ( ) ) ;
99
+ let start = eh_frame;
100
+ let end = start. add ( eh_frame_len ) ;
101
101
let mut current = start;
102
102
103
103
// Walk all of the entries in the frame table and register them
@@ -107,7 +107,6 @@ impl UnwindContext {
107
107
// Skip over the CIE
108
108
if current != start {
109
109
__register_frame ( current) ;
110
- registrations. push ( current as usize ) ;
111
110
}
112
111
113
112
// Move to the next table entry (+4 because the length itself is not inclusive)
@@ -117,41 +116,12 @@ impl UnwindContext {
117
116
#[ cfg( not( target_os = "macos" ) ) ]
118
117
{
119
118
// On other platforms, `__register_frame` will walk the FDEs until an entry of length 0
120
- let ptr = eh_frame. as_ptr ( ) ;
121
- __register_frame ( ptr) ;
122
- registrations. push ( ptr as usize ) ;
119
+ __register_frame ( eh_frame) ;
123
120
}
124
-
125
- Some ( UnwindRegistry { _frame_table : eh_frame, registrations } )
126
121
}
127
122
}
128
123
129
- /// Represents a registry of function unwind information for System V ABI.
130
- pub ( crate ) struct UnwindRegistry {
131
- _frame_table : Vec < u8 > ,
132
- registrations : Vec < usize > ,
133
- }
134
-
135
124
extern "C" {
136
125
// libunwind import
137
126
fn __register_frame ( fde : * const u8 ) ;
138
- fn __deregister_frame ( fde : * const u8 ) ;
139
- }
140
-
141
- impl Drop for UnwindRegistry {
142
- fn drop ( & mut self ) {
143
- unsafe {
144
- // libgcc stores the frame entries as a linked list in decreasing sort order
145
- // based on the PC value of the registered entry.
146
- //
147
- // As we store the registrations in increasing order, it would be O(N^2) to
148
- // deregister in that order.
149
- //
150
- // To ensure that we just pop off the first element in the list upon every
151
- // deregistration, walk our list of registrations backwards.
152
- for fde in self . registrations . iter ( ) . rev ( ) {
153
- __deregister_frame ( * fde as * const _ ) ;
154
- }
155
- }
156
- }
157
127
}
0 commit comments