Przeglądaj źródła

[compiler] add enter_stage so we can easily track where we are

Simon Krajewski 1 rok temu
rodzic
commit
e7ad8f5eca
3 zmienionych plików z 18 dodań i 14 usunięć
  1. 7 7
      src/compiler/compiler.ml
  2. 4 0
      src/context/common.ml
  3. 7 7
      src/filters/filters.ml

+ 7 - 7
src/compiler/compiler.ml

@@ -275,13 +275,13 @@ let do_type ctx mctx actx display_file_dot_path macro_cache_enabled =
 	let t = Timer.timer ["typing"] in
 	let cs = com.cs in
 	CommonCache.maybe_add_context_sign cs com "before_init_macros";
-	com.stage <- CInitMacrosStart;
+	enter_stage com CInitMacrosStart;
 	ServerMessage.compiler_stage com;
 
 	let mctx = List.fold_left (fun mctx path ->
 		Some (MacroContext.call_init_macro ctx.com mctx path)
 	) mctx (List.rev actx.config_macros) in
-	com.stage <- CInitMacrosDone;
+	enter_stage com CInitMacrosDone;
 	ServerMessage.compiler_stage com;
 	MacroContext.macro_enable_cache := macro_cache_enabled;
 
@@ -301,7 +301,7 @@ let do_type ctx mctx actx display_file_dot_path macro_cache_enabled =
 	end with TypeloadParse.DisplayInMacroBlock ->
 		ignore(DisplayProcessing.load_display_module_in_macro tctx display_file_dot_path true)
 	);
-	com.stage <- CTypingDone;
+	enter_stage com CTypingDone;
 	ServerMessage.compiler_stage com;
 	(* If we are trying to find references, let's syntax-explore everything we know to check for the
 		identifier we are interested in. We then type only those modules that contain the identifier. *)
@@ -315,7 +315,7 @@ let do_type ctx mctx actx display_file_dot_path macro_cache_enabled =
 let finalize_typing ctx tctx =
 	let t = Timer.timer ["finalize"] in
 	let com = ctx.com in
-	com.stage <- CFilteringStart;
+	enter_stage com CFilteringStart;
 	ServerMessage.compiler_stage com;
 	let main, types, modules = run_or_diagnose ctx Finalization.generate tctx in
 	com.main <- main;
@@ -354,7 +354,7 @@ let compile ctx actx callbacks =
 	let t = Timer.timer ["init"] in
 	List.iter (fun f -> f()) (List.rev (actx.pre_compilation));
 	t();
-	com.stage <- CInitialized;
+	enter_stage com CInitialized;
 	ServerMessage.compiler_stage com;
 	if actx.classes = [([],"Std")] && not actx.force_typing then begin
 		if actx.cmds = [] && not actx.did_something then actx.raise_usage();
@@ -367,10 +367,10 @@ let compile ctx actx callbacks =
 		filter ctx tctx;
 		if ctx.has_error then raise Abort;
 		Generate.check_auxiliary_output com actx;
-		com.stage <- CGenerationStart;
+		enter_stage com CGenerationStart;
 		ServerMessage.compiler_stage com;
 		if not actx.no_output then Generate.generate ctx tctx ext actx;
-		com.stage <- CGenerationDone;
+		enter_stage com CGenerationDone;
 		ServerMessage.compiler_stage com;
 	end;
 	Sys.catch_break false;

+ 4 - 0
src/context/common.ml

@@ -432,6 +432,10 @@ type context = {
 	memory_marker : float array;
 }
 
+let enter_stage com stage =
+	(* print_endline (Printf.sprintf "Entering stage %s" (s_compiler_stage stage)); *)
+	com.stage <- stage
+
 exception Abort of Error.error
 
 let ignore_error com =

+ 7 - 7
src/filters/filters.ml

@@ -721,7 +721,7 @@ let destruction tctx detail_times main locals =
 			check_remove_metadata t;
 		) com.types;
 	);
-	com.stage <- CDceStart;
+	enter_stage com CDceStart;
 	with_timer detail_times "dce" None (fun () ->
 		(* DCE *)
 		let dce_mode = try Common.defined_value com Define.Dce with _ -> "no" in
@@ -733,7 +733,7 @@ let destruction tctx detail_times main locals =
 		in
 		Dce.run com main dce_mode;
 	);
-	com.stage <- CDceDone;
+	enter_stage com CDceDone;
 	(* PASS 3: type filters post-DCE *)
 	List.iter
 		(run_expression_filters
@@ -772,7 +772,7 @@ let destruction tctx detail_times main locals =
 		) com.types;
 	);
 	com.callbacks#run com.error_ext com.callbacks#get_after_filters;
-	com.stage <- CFilteringDone
+	enter_stage com CFilteringDone
 
 let update_cache_dependencies com t =
 	let visited_anons = ref [] in
@@ -994,9 +994,9 @@ let run tctx main =
 	with_timer detail_times "type 1" None (fun () ->
 		List.iter (fun f -> List.iter f new_types) filters;
 	);
-	com.stage <- CAnalyzerStart;
+	enter_stage com CAnalyzerStart;
 	if com.platform <> Cross then Analyzer.Run.run_on_types com new_types;
-	com.stage <- CAnalyzerDone;
+	enter_stage com CAnalyzerDone;
 	let locals = RenameVars.init com in
 	let filters = [
 		"sanitize",Optimizer.sanitize com;
@@ -1011,14 +1011,14 @@ let run tctx main =
 	with_timer detail_times "callbacks" None (fun () ->
 		com.callbacks#run com.error_ext com.callbacks#get_before_save;
 	);
-	com.stage <- CSaveStart;
+	enter_stage com CSaveStart;
 	with_timer detail_times "save state" None (fun () ->
 		List.iter (fun mt ->
 			update_cache_dependencies com mt;
 			save_class_state com mt
 		) new_types;
 	);
-	com.stage <- CSaveDone;
+	enter_stage com CSaveDone;
 	with_timer detail_times "callbacks" None (fun () ->
 		com.callbacks#run com.error_ext com.callbacks#get_after_save;
 	);