Browse Source

disable code-motion by default for now

I don't completely trust it yet.
Simon Krajewski 9 years ago
parent
commit
a454c80a48
2 changed files with 8 additions and 1 deletions
  1. 7 1
      analyzer.ml
  2. 1 0
      tests/optimization/src/TestJs.hx

+ 7 - 1
analyzer.ml

@@ -134,6 +134,7 @@ module Config = struct
 		analyzer_use : bool;
 		const_propagation : bool;
 		copy_propagation : bool;
+		code_motion : bool;
 		local_dce : bool;
 		dot_debug : bool;
 	}
@@ -143,6 +144,8 @@ module Config = struct
 	let flag_const_propagation = "const_propagation"
 	let flag_no_copy_propagation = "no_copy_propagation"
 	let flag_copy_propagation = "copy_propagation"
+	let flag_code_motion = "code_motion"
+	let flag_no_code_motion = "no_code_motion"
 	let flag_no_local_dce = "no_local_dce"
 	let flag_local_dce = "local_dce"
 	let flag_ignore = "ignore"
@@ -198,6 +201,7 @@ module Config = struct
 			analyzer_use = true;
 			const_propagation = not (Common.raw_defined com "analyzer-no-const-propagation");
 			copy_propagation = not (Common.raw_defined com "analyzer-no-copy-propagation");
+			code_motion = Common.raw_defined com "analyzer-code-motion";
 			local_dce = not (Common.raw_defined com "analyzer-no-local-dce");
 			dot_debug = false;
 		}
@@ -210,6 +214,8 @@ module Config = struct
 					| EConst (Ident s) when s = flag_const_propagation -> { config with const_propagation = true}
 					| EConst (Ident s) when s = flag_no_copy_propagation -> { config with copy_propagation = false}
 					| EConst (Ident s) when s = flag_copy_propagation -> { config with copy_propagation = true}
+					| EConst (Ident s) when s = flag_no_code_motion -> { config with code_motion = false}
+					| EConst (Ident s) when s = flag_code_motion -> { config with code_motion = true}
 					| EConst (Ident s) when s = flag_no_local_dce -> { config with local_dce = false}
 					| EConst (Ident s) when s = flag_local_dce -> { config with local_dce = true}
 					| EConst (Ident s) when s = flag_dot_debug -> {config with dot_debug = true}
@@ -2296,7 +2302,7 @@ module Run = struct
 				with_timer "analyzer-ssa-apply" (fun () -> Ssa.apply ctx);
 				if config.const_propagation then with_timer "analyzer-const-propagation" (fun () -> ConstPropagation.apply ctx);
 				if config.copy_propagation then with_timer "analyzer-copy-propagation" (fun () -> CopyPropagation.apply ctx);
-				(* CodeMotion.apply ctx; *)
+				if config.code_motion then with_timer "analyzer-code-motion" (fun () -> CodeMotion.apply ctx);
 				with_timer "analyzer-local-dce" (fun () -> LocalDce.apply ctx);
 			end;
 			if config.dot_debug then Debug.dot_debug ctx c cf;

+ 1 - 0
tests/optimization/src/TestJs.hx

@@ -22,6 +22,7 @@ private enum EnumFlagTest {
 	EC;
 }
 
+@:analyzer(code_motion)
 class TestJs {
 	//@:js('var x = 10;"" + x;var x1 = 10;"" + x1;var x2 = 10.0;"" + x2;var x3 = "10";x3;var x4 = true;"" + x4;')
 	//static function testStdString() {