Browse Source

[analyzer] fix fusion flag handling and enable for C#

Simon Krajewski 9 years ago
parent
commit
cbee676933

+ 1 - 1
src/optimization/analyzer.ml

@@ -1150,7 +1150,7 @@ module Run = struct
 		DynArray.iter (fun vi ->
 		DynArray.iter (fun vi ->
 			vi.vi_var.v_extra <- vi.vi_extra;
 			vi.vi_var.v_extra <- vi.vi_extra;
 		) actx.graph.g_var_infos;
 		) actx.graph.g_var_infos;
-		let e = with_timer actx "analyzer-fusion" (fun () -> Fusion.apply actx.com actx.config e) in
+		let e = if actx.config.fusion then with_timer actx "analyzer-fusion" (fun () -> Fusion.apply actx.com actx.config e) else e in
 		if actx.com.debug then add_debug_expr actx "after fusion" e;
 		if actx.com.debug then add_debug_expr actx "after fusion" e;
 		let e = with_timer actx "analyzer-cleanup" (fun () -> Cleanup.apply actx.com e) in
 		let e = with_timer actx "analyzer-cleanup" (fun () -> Cleanup.apply actx.com e) in
 		if actx.com.debug then add_debug_expr actx "after cleanup" e;
 		if actx.com.debug then add_debug_expr actx "after cleanup" e;

+ 2 - 2
src/optimization/analyzerConfig.ml

@@ -88,11 +88,11 @@ let get_base_config com =
 		copy_propagation = not (Common.raw_defined com "analyzer-no-copy-propagation");
 		copy_propagation = not (Common.raw_defined com "analyzer-no-copy-propagation");
 		code_motion = Common.raw_defined com "analyzer-code-motion";
 		code_motion = Common.raw_defined com "analyzer-code-motion";
 		local_dce = not (Common.raw_defined com "analyzer-no-local-dce");
 		local_dce = not (Common.raw_defined com "analyzer-no-local-dce");
-		fusion = not (Common.raw_defined com "analyzer-no-fusion") && (match com.platform with Flash | Java | Cs -> false | _ -> true);
+		fusion = not (Common.raw_defined com "analyzer-no-fusion");
 		purity_inference = not (Common.raw_defined com "analyzer-no-purity-inference");
 		purity_inference = not (Common.raw_defined com "analyzer-no-purity-inference");
 		debug_kind = DebugNone;
 		debug_kind = DebugNone;
 		detail_times = Common.raw_defined com "analyzer-times";
 		detail_times = Common.raw_defined com "analyzer-times";
-		user_var_fusion = Common.raw_defined com "analyzer-user-var-fusion" || (not com.debug && not (Common.raw_defined com "analyzer-no-user-var-fusion"));
+		user_var_fusion = (match com.platform with Flash | Java -> false | _ -> true) && (Common.raw_defined com "analyzer-user-var-fusion" || (not com.debug && not (Common.raw_defined com "analyzer-no-user-var-fusion")));
 		fusion_debug = false;
 		fusion_debug = false;
 	}
 	}
 
 

+ 5 - 0
src/optimization/analyzerTexpr.ml

@@ -697,6 +697,9 @@ module Fusion = struct
 							in
 							in
 							if not !found then raise Exit;
 							if not !found then raise Exit;
 							{e with eexpr = TSwitch(e1,cases,edef)}
 							{e with eexpr = TSwitch(e1,cases,edef)}
+						| TCall({eexpr = TLocal v},_) when is_really_unbound v ->
+							e
+						(* locals *)
 						| TLocal v2 when v1 == v2 && not !blocked ->
 						| TLocal v2 when v1 == v2 && not !blocked ->
 							found := true;
 							found := true;
 							if type_change_ok com v1.v_type e1.etype then e1 else mk (TCast(e1,None)) v1.v_type e.epos
 							if type_change_ok com v1.v_type e1.etype then e1 else mk (TCast(e1,None)) v1.v_type e.epos
@@ -885,6 +888,8 @@ module Cleanup = struct
 				let e2 = loop e2 in
 				let e2 = loop e2 in
 				let e3 = loop e3 in
 				let e3 = loop e3 in
 				if_or_op e e1 e2 e3;
 				if_or_op e e1 e2 e3;
+			| TUnop((Increment | Decrement),_,({eexpr = TConst _} as e1)) ->
+				loop e1
 			| TCall({eexpr = TLocal v},_) when is_really_unbound v ->
 			| TCall({eexpr = TLocal v},_) when is_really_unbound v ->
 				e
 				e
 			| TBlock el ->
 			| TBlock el ->

+ 1 - 1
tests/optimization/src/Test.hx

@@ -13,7 +13,7 @@ class InlineCtor {
 }
 }
 
 
 @:analyzer(no_local_dce)
 @:analyzer(no_local_dce)
-@:analyzer(no_fusion)
+@:analyzer(no_user_var_fusion)
 class Test {
 class Test {
 	@:js('')
 	@:js('')
 	static function testNoOpRemoval() {
 	static function testNoOpRemoval() {

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

@@ -23,7 +23,7 @@ private enum EnumFlagTest {
 }
 }
 
 
 @:analyzer(code_motion)
 @:analyzer(code_motion)
-@:analyzer(no_fusion)
+@:analyzer(no_user_var_fusion)
 class TestJs {
 class TestJs {
 	//@:js('var x = 10;"" + x;var x1 = 10;"" + x1;var x2 = 10.0;"" + x2;var x3 = "10";x3;var x4 = true;"" + x4;')
 	//@: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() {
 	//static function testStdString() {

+ 1 - 1
tests/optimization/src/TestLocalDce.hx

@@ -13,7 +13,7 @@ private abstract MyEnum(String) to String {
 	var A = "a";
 	var A = "a";
 }
 }
 
 
-@:analyzer(no_fusion)
+@:analyzer(no_user_var_fusion)
 class TestLocalDce {
 class TestLocalDce {
 	@:js('console.log(3);')
 	@:js('console.log(3);')
 	static function testNoOpRemoval() {
 	static function testNoOpRemoval() {