@@ -102,35 +102,21 @@ pub mod jit {
102
102
use back:: link:: llvm_err;
103
103
use driver:: session:: Session ;
104
104
use lib:: llvm:: llvm;
105
- use lib:: llvm:: { ModuleRef , PassManagerRef , ContextRef } ;
105
+ use lib:: llvm:: { ModuleRef , ContextRef } ;
106
106
use metadata:: cstore;
107
107
108
108
use core:: cast;
109
- use core:: libc:: c_int;
110
109
use core:: ptr;
111
110
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;
125
113
126
114
pub fn exec ( sess : Session ,
127
- pm : PassManagerRef ,
128
115
c : ContextRef ,
129
116
m : ModuleRef ,
130
- opt : c_int ,
131
117
stacks : bool ) {
132
118
unsafe {
133
- let manager = llvm:: LLVMRustPrepareJIT ( rusti :: morestack_addr ( ) ) ;
119
+ let manager = llvm:: LLVMRustPrepareJIT ( intrinsics :: morestack_addr ( ) ) ;
134
120
135
121
// We need to tell JIT where to resolve all linked
136
122
// symbols from. The equivalent of -lstd, -lcore, etc.
@@ -156,7 +142,7 @@ pub mod jit {
156
142
157
143
// We custom-build a JIT execution engine via some rust wrappers
158
144
// 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) ;
160
146
if ee. is_null ( ) {
161
147
llvm:: LLVMContextDispose ( c) ;
162
148
llvm_err ( sess, ~"Could not create the JIT ") ;
@@ -179,7 +165,7 @@ pub mod jit {
179
165
// closure
180
166
let code = llvm:: LLVMGetPointerToGlobal ( ee, fun) ;
181
167
assert ! ( !code. is_null( ) ) ;
182
- let closure = Closure {
168
+ let closure = sys :: Closure {
183
169
code : code,
184
170
env : ptr:: null ( )
185
171
} ;
@@ -282,7 +268,17 @@ pub mod write {
282
268
debug ! ( "Running Module Optimization Pass" ) ;
283
269
mpm. run ( llmod) ;
284
270
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) {
286
282
let LLVMOptNone = 0 as c_int ; // -O0
287
283
let LLVMOptLess = 1 as c_int ; // -O1
288
284
let LLVMOptDefault = 2 as c_int ; // -O2, -Os
@@ -295,20 +291,6 @@ pub mod write {
295
291
session:: Aggressive => LLVMOptAggressive
296
292
} ;
297
293
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
-
312
294
let FileType ;
313
295
if output_type == output_type_object ||
314
296
output_type == output_type_exe {
0 commit comments