@@ -13,10 +13,10 @@ use rustc_middle::mir::mono::MonoItem;
1313use rustc_session:: Session ;
1414use rustc_span:: sym;
1515
16+ use crate :: CodegenCx ;
1617use crate :: debuginfo:: TypeDebugContext ;
1718use crate :: prelude:: * ;
1819use crate :: unwind_module:: UnwindModule ;
19- use crate :: { CodegenCx , CodegenMode } ;
2020
2121struct JitState {
2222 jit_module : UnwindModule < JITModule > ,
@@ -79,7 +79,7 @@ fn create_jit_module(tcx: TyCtxt<'_>, hotswap: bool) -> (UnwindModule<JITModule>
7979 ( jit_module, cx)
8080}
8181
82- pub ( crate ) fn run_jit ( tcx : TyCtxt < ' _ > , codegen_mode : CodegenMode , jit_args : Vec < String > ) -> ! {
82+ pub ( crate ) fn run_jit ( tcx : TyCtxt < ' _ > , jit_lazy : bool , jit_args : Vec < String > ) -> ! {
8383 if !tcx. sess . opts . output_types . should_codegen ( ) {
8484 tcx. dcx ( ) . fatal ( "JIT mode doesn't work with `cargo check`" ) ;
8585 }
@@ -88,8 +88,7 @@ pub(crate) fn run_jit(tcx: TyCtxt<'_>, codegen_mode: CodegenMode, jit_args: Vec<
8888 tcx. dcx ( ) . fatal ( "can't jit non-executable crate" ) ;
8989 }
9090
91- let ( mut jit_module, mut cx) =
92- create_jit_module ( tcx, matches ! ( codegen_mode, CodegenMode :: JitLazy ) ) ;
91+ let ( mut jit_module, mut cx) = create_jit_module ( tcx, jit_lazy) ;
9392 let mut cached_context = Context :: new ( ) ;
9493
9594 let cgus = tcx. collect_and_partition_mono_items ( ( ) ) . codegen_units ;
@@ -105,9 +104,10 @@ pub(crate) fn run_jit(tcx: TyCtxt<'_>, codegen_mode: CodegenMode, jit_args: Vec<
105104 super :: predefine_mono_items ( tcx, & mut jit_module, & mono_items) ;
106105 for ( mono_item, _) in mono_items {
107106 match mono_item {
108- MonoItem :: Fn ( inst) => match codegen_mode {
109- CodegenMode :: Aot => unreachable ! ( ) ,
110- CodegenMode :: Jit => {
107+ MonoItem :: Fn ( inst) => {
108+ if jit_lazy {
109+ codegen_shim ( tcx, & mut cached_context, & mut jit_module, inst)
110+ } else {
111111 codegen_and_compile_fn (
112112 tcx,
113113 & mut cx,
@@ -116,10 +116,7 @@ pub(crate) fn run_jit(tcx: TyCtxt<'_>, codegen_mode: CodegenMode, jit_args: Vec<
116116 inst,
117117 ) ;
118118 }
119- CodegenMode :: JitLazy => {
120- codegen_shim ( tcx, & mut cached_context, & mut jit_module, inst)
121- }
122- } ,
119+ }
123120 MonoItem :: Static ( def_id) => {
124121 crate :: constant:: codegen_static ( tcx, & mut jit_module, def_id) ;
125122 }
0 commit comments