@@ -17,6 +17,12 @@ pub enum FunctionLookupError {
17
17
FunctionNotFound , // 404!
18
18
}
19
19
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.
20
26
#[ derive( PartialEq , Eq , Debug ) ]
21
27
pub struct ExecutionEngine {
22
28
execution_engine : ExecEngineInner ,
@@ -91,7 +97,7 @@ impl ExecutionEngine {
91
97
///
92
98
/// assert_eq!(result, 128.);
93
99
/// ```
94
- pub fn add_global_mapping ( & mut self , value : & AnyValue , addr : usize ) {
100
+ pub fn add_global_mapping ( & self , value : & AnyValue , addr : usize ) {
95
101
unsafe {
96
102
LLVMAddGlobalMapping ( * self . execution_engine , value. as_value_ref ( ) , addr as * mut _ )
97
103
}
@@ -114,7 +120,7 @@ impl ExecutionEngine {
114
120
///
115
121
/// assert!(ee.add_module(&module).is_err());
116
122
/// ```
117
- pub fn add_module ( & mut self , module : & Module ) -> Result < ( ) , ( ) > {
123
+ pub fn add_module ( & self , module : & Module ) -> Result < ( ) , ( ) > {
118
124
unsafe {
119
125
LLVMAddModule ( * self . execution_engine , module. module . get ( ) )
120
126
}
@@ -128,7 +134,7 @@ impl ExecutionEngine {
128
134
Ok ( ( ) )
129
135
}
130
136
131
- pub fn remove_module ( & mut self , module : & Module ) -> Result < ( ) , String > {
137
+ pub fn remove_module ( & self , module : & Module ) -> Result < ( ) , String > {
132
138
match * module. owned_by_ee . borrow ( ) {
133
139
Some ( ref ee) if * ee. execution_engine != * self . execution_engine => return Err ( "Module is not owned by this Execution Engine" . into ( ) ) ,
134
140
None => return Err ( "Module is not owned by an Execution Engine" . into ( ) ) ,
0 commit comments