Pārlūkot izejas kodu

do not use `gen_local` to generate temp variables in the analyzer because it's extremely slow

Simon Krajewski 10 gadi atpakaļ
vecāks
revīzija
933778e137
2 mainītis faili ar 9 papildinājumiem un 10 dzēšanām
  1. 6 9
      analyzer.ml
  2. 3 1
      filters.ml

+ 6 - 9
analyzer.ml

@@ -89,7 +89,7 @@ let rec awkward_get_enum_index com e = match e.eexpr with
 	nodes without worrying about their placement.
 *)
 module Simplifier = struct
-	let mk_block_context com gen_temp =
+	let mk_block_context com =
 		let block_el = ref [] in
 		let push e = block_el := e :: !block_el in
 		let assign ev e =
@@ -138,7 +138,7 @@ module Simplifier = struct
 			loop e
 		in
 		let declare_temp t eo p =
-			let v = gen_temp t in
+			let v = alloc_var "tmp" t in
 			v.v_meta <- [Meta.CompilerGenerated,[],p];
 			let e_v = mk (TLocal v) t p in
 			let declare e_init =
@@ -192,8 +192,8 @@ module Simplifier = struct
 		in
 		block,declare_temp,fun () -> !block_el
 
-	let apply com gen_temp e =
-		let block,declare_temp,close_block = mk_block_context com gen_temp in
+	let apply com e =
+		let block,declare_temp,close_block = mk_block_context com in
 		let skip_binding ?(allow_tlocal=false) e =
 			let rec loop e =
 				match e.eexpr with
@@ -1141,7 +1141,7 @@ module EffectChecker = struct
 		in
 		let e = if is_var_expression then
 			(* var initialization expressions are like assignments, so let's cheat a bit here *)
-			snd (Simplifier.apply com (alloc_var "tmp") (Codegen.binop OpAssign (mk (TConst TNull) t_dynamic e.epos) e e.etype e.epos))
+			snd (Simplifier.apply com (Codegen.binop OpAssign (mk (TConst TNull) t_dynamic e.epos) e e.etype e.epos))
 		else e
 		in
 		let rec loop e = match e.eexpr with
@@ -1377,9 +1377,6 @@ module Run = struct
 	open Config
 
 	let run_on_expr com config is_var_expression e =
-		let rec gen_local t =
-			alloc_var "tmp" t
-		in
 		let do_simplify = (not (Common.defined com Define.NoSimplify) ) && match com.platform with
 			| Cpp when Common.defined com Define.Cppia -> false
 			| Cpp | Flash8 | Python -> true
@@ -1393,7 +1390,7 @@ module Run = struct
 		in
 		try
 			let has_unbound,e = if do_simplify || config.analyzer_use then
-				with_timer "analyzer-simplify-apply" (fun () -> Simplifier.apply com gen_local e)
+				with_timer "analyzer-simplify-apply" (fun () -> Simplifier.apply com e)
 			else
 				false,e
 			in

+ 3 - 1
filters.ml

@@ -1056,7 +1056,9 @@ let run com tctx main =
 				else
 					fun e ->
 						let save = save_locals tctx in
-						let e = try snd (Analyzer.Simplifier.apply com (Typecore.gen_local tctx) e) with Exit -> e in
+						let timer = timer "analyzer-simplify-apply" in
+						let e = try snd (Analyzer.Simplifier.apply com e) with Exit -> e in
+						timer();
 						save();
 					e );
 			if com.foptimize then (fun e -> Optimizer.reduce_expression tctx (Optimizer.inline_constructors tctx e)) else Optimizer.sanitize com;