@@ -102,35 +102,21 @@ pub mod jit {
102102 use back:: link:: llvm_err;
103103 use driver:: session:: Session ;
104104 use lib:: llvm:: llvm;
105- use lib:: llvm:: { ModuleRef , PassManagerRef , ContextRef } ;
105+ use lib:: llvm:: { ModuleRef , ContextRef } ;
106106 use metadata:: cstore;
107107
108108 use core:: cast;
109- use core:: libc:: c_int;
110109 use core:: ptr;
111110 use core:: str;
112-
113- pub mod rusti {
114- #[ nolink]
115- #[ abi = "rust-intrinsic" ]
116- pub extern "rust-intrinsic" {
117- pub fn morestack_addr ( ) -> * ( ) ;
118- }
119- }
120-
121- pub struct Closure {
122- code : * ( ) ,
123- env : * ( ) ,
124- }
111+ use core:: sys;
112+ use core:: unstable:: intrinsics;
125113
126114 pub fn exec ( sess : Session ,
127- pm : PassManagerRef ,
128115 c : ContextRef ,
129116 m : ModuleRef ,
130- opt : c_int ,
131117 stacks : bool ) {
132118 unsafe {
133- let manager = llvm:: LLVMRustPrepareJIT ( rusti :: morestack_addr ( ) ) ;
119+ let manager = llvm:: LLVMRustPrepareJIT ( intrinsics :: morestack_addr ( ) ) ;
134120
135121 // We need to tell JIT where to resolve all linked
136122 // symbols from. The equivalent of -lstd, -lcore, etc.
@@ -156,7 +142,7 @@ pub mod jit {
156142
157143 // We custom-build a JIT execution engine via some rust wrappers
158144 // first. This wrappers takes ownership of the module passed in.
159- let ee = llvm:: LLVMRustBuildJIT ( manager, pm , m , opt , stacks) ;
145+ let ee = llvm:: LLVMRustBuildJIT ( manager, m , stacks) ;
160146 if ee. is_null ( ) {
161147 llvm:: LLVMContextDispose ( c) ;
162148 llvm_err ( sess, ~"Could not create the JIT ") ;
@@ -179,7 +165,7 @@ pub mod jit {
179165 // closure
180166 let code = llvm:: LLVMGetPointerToGlobal ( ee, fun) ;
181167 assert ! ( !code. is_null( ) ) ;
182- let closure = Closure {
168+ let closure = sys :: Closure {
183169 code : code,
184170 env : ptr:: null ( )
185171 } ;
@@ -282,7 +268,17 @@ pub mod write {
282268 debug ! ( "Running Module Optimization Pass" ) ;
283269 mpm. run ( llmod) ;
284270
285- if is_object_or_assembly_or_exe ( output_type) || opts. jit {
271+ if opts. jit {
272+ // If we are using JIT, go ahead and create and execute the
273+ // engine now. JIT execution takes ownership of the module and
274+ // context, so don't dispose and return.
275+ jit:: exec ( sess, llcx, llmod, true ) ;
276+
277+ if sess. time_llvm_passes ( ) {
278+ llvm:: LLVMRustPrintPassTimings ( ) ;
279+ }
280+ return ;
281+ } else if is_object_or_assembly_or_exe ( output_type) {
286282 let LLVMOptNone = 0 as c_int ; // -O0
287283 let LLVMOptLess = 1 as c_int ; // -O1
288284 let LLVMOptDefault = 2 as c_int ; // -O2, -Os
@@ -295,20 +291,6 @@ pub mod write {
295291 session:: Aggressive => LLVMOptAggressive
296292 } ;
297293
298- if opts. jit {
299- // If we are using JIT, go ahead and create and
300- // execute the engine now.
301- // JIT execution takes ownership of the module,
302- // so don't dispose and return.
303-
304- jit:: exec ( sess, pm. llpm , llcx, llmod, CodeGenOptLevel , true ) ;
305-
306- if sess. time_llvm_passes ( ) {
307- llvm:: LLVMRustPrintPassTimings ( ) ;
308- }
309- return ;
310- }
311-
312294 let FileType ;
313295 if output_type == output_type_object ||
314296 output_type == output_type_exe {
0 commit comments