Skip to content

Commit 28e988a

Browse files
committed
Confirmed its something to do with memory leaking
1 parent 27f3116 commit 28e988a

File tree

2 files changed

+31
-13
lines changed

2 files changed

+31
-13
lines changed

common/src/pointer.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,5 +176,23 @@ impl SafeLLVMPointer {
176176
}
177177
}
178178

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+
179196
unsafe impl Send for SafeLLVMPointer {}
180197
unsafe impl Sync for SafeLLVMPointer {}
198+

jit/src/core.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -192,18 +192,18 @@ impl ExecutionEngine {
192192

193193
impl Drop for ExecutionEngine {
194194
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+
// }
208208
}
209209
}

0 commit comments

Comments
 (0)