File tree Expand file tree Collapse file tree 2 files changed +31
-13
lines changed Expand file tree Collapse file tree 2 files changed +31
-13
lines changed Original file line number Diff line number Diff line change @@ -176,5 +176,23 @@ impl SafeLLVMPointer {
176
176
}
177
177
}
178
178
179
+ impl Drop for SafeLLVMPointer {
180
+ fn drop ( & mut self ) {
181
+ self . write ( self . kind , |llvm_ref| {
182
+ match llvm_ref {
183
+ // LLVMRef::Context(ptr) => unsafe { core::LLVMContextDispose(*ptr) },
184
+ // LLVMRef::Module(ptr) => unsafe { core::LLVMDisposeModule(*ptr) },
185
+ LLVMRef :: Builder ( ptr) => unsafe { core:: LLVMDisposeBuilder ( * ptr) } ,
186
+ LLVMRef :: ExecutionEngine ( ptr) => unsafe { execution_engine:: LLVMDisposeExecutionEngine ( * ptr) } ,
187
+ LLVMRef :: Value ( _) |
188
+ LLVMRef :: BasicBlock ( _) |
189
+ LLVMRef :: Type ( _) => { } ,
190
+ _ => { }
191
+ }
192
+ } ) ;
193
+ }
194
+ }
195
+
179
196
unsafe impl Send for SafeLLVMPointer { }
180
197
unsafe impl Sync for SafeLLVMPointer { }
198
+
Original file line number Diff line number Diff line change @@ -192,18 +192,18 @@ impl ExecutionEngine {
192
192
193
193
impl Drop for ExecutionEngine {
194
194
fn drop ( & mut self ) {
195
- if let Ok ( engine_lock) = self . engine . write ( ) {
196
- engine_lock. write ( LLVMRefType :: ExecutionEngine , |engine_ref| {
197
- if let LLVMRef :: ExecutionEngine ( engine_ptr) = engine_ref {
198
- unsafe {
199
- execution_engine:: LLVMDisposeExecutionEngine ( * engine_ptr) ;
200
- }
201
- }
202
- } ) ;
203
- }
204
-
205
- if let Some ( logger) = & self . logger {
206
- logging:: core:: log_info ( logger, "Execution engine disposed." ) ;
207
- }
195
+ // if let Ok(engine_lock) = self.engine.write() {
196
+ // engine_lock.write(LLVMRefType::ExecutionEngine, |engine_ref| {
197
+ // if let LLVMRef::ExecutionEngine(engine_ptr) = engine_ref {
198
+ // unsafe {
199
+ // execution_engine::LLVMDisposeExecutionEngine(*engine_ptr);
200
+ // }
201
+ // }
202
+ // });
203
+ // }
204
+
205
+ // if let Some(logger) = &self.logger {
206
+ // logging::core::log_info(logger, "Execution engine disposed.");
207
+ // }
208
208
}
209
209
}
You can’t perform that action at this time.
0 commit comments