Skip to content

Commit 63d840c

Browse files
Removed &mut self and mentioned ExecutionEngine is cheap to copy
1 parent 8d3a3b5 commit 63d840c

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/execution_engine.rs

+9-3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ pub enum FunctionLookupError {
1717
FunctionNotFound, // 404!
1818
}
1919

20+
/// A reference-counted wrapper around LLVM's execution engine.
21+
///
22+
/// Cloning this object is essentially just a case of copying a couple pointers
23+
/// and incrementing one or two atomics, so this should be quite cheap to create
24+
/// copies. The underlying LLVM object will be automatically deallocated when
25+
/// there are no more references to it.
2026
#[derive(PartialEq, Eq, Debug)]
2127
pub struct ExecutionEngine {
2228
execution_engine: ExecEngineInner,
@@ -91,7 +97,7 @@ impl ExecutionEngine {
9197
///
9298
/// assert_eq!(result, 128.);
9399
/// ```
94-
pub fn add_global_mapping(&mut self, value: &AnyValue, addr: usize) {
100+
pub fn add_global_mapping(&self, value: &AnyValue, addr: usize) {
95101
unsafe {
96102
LLVMAddGlobalMapping(*self.execution_engine, value.as_value_ref(), addr as *mut _)
97103
}
@@ -114,7 +120,7 @@ impl ExecutionEngine {
114120
///
115121
/// assert!(ee.add_module(&module).is_err());
116122
/// ```
117-
pub fn add_module(&mut self, module: &Module) -> Result<(), ()> {
123+
pub fn add_module(&self, module: &Module) -> Result<(), ()> {
118124
unsafe {
119125
LLVMAddModule(*self.execution_engine, module.module.get())
120126
}
@@ -128,7 +134,7 @@ impl ExecutionEngine {
128134
Ok(())
129135
}
130136

131-
pub fn remove_module(&mut self, module: &Module) -> Result<(), String> {
137+
pub fn remove_module(&self, module: &Module) -> Result<(), String> {
132138
match *module.owned_by_ee.borrow() {
133139
Some(ref ee) if *ee.execution_engine != *self.execution_engine => return Err("Module is not owned by this Execution Engine".into()),
134140
None => return Err("Module is not owned by an Execution Engine".into()),

0 commit comments

Comments
 (0)