Browse Source

refine interference checker for C++ and PHP

Simon Krajewski 9 years ago
parent
commit
60847ec397
2 changed files with 7 additions and 9 deletions
  1. 5 2
      analyzer.ml
  2. 2 7
      optimizer.ml

+ 5 - 2
analyzer.ml

@@ -96,7 +96,7 @@ let rec can_be_used_as_value com e =
 		| TBlock [e] -> loop e
 		| TBlock _ | TSwitch _ | TTry _ -> raise Exit
 		| TCall({eexpr = TConst (TString "phi")},_) -> raise Exit
-		| TCall _ | TNew _ when (match com.platform with Cpp | Php -> true | _ -> false) -> raise Exit
+		(* | TCall _ | TNew _ when (match com.platform with Cpp | Php -> true | _ -> false) -> raise Exit *)
 		| TReturn _ | TThrow _ | TBreak | TContinue -> raise Exit
 		| TFunction _ -> ()
 		| _ -> Type.iter loop e
@@ -419,7 +419,10 @@ module TexprFilter = struct
 						check e1 e2;
 						check e2 e1;
 					with Exit ->
-						affected := true;
+						begin match com.platform with
+							| Cpp | Php -> raise Exit (* They don't define evaluation order, so let's exit *)
+							| _ -> affected := true;
+						end
 				in
 				let rec replace e =
 					let e = match e.eexpr with

+ 2 - 7
optimizer.ml

@@ -592,13 +592,8 @@ let rec type_inline ctx cf f ethis params tret config p ?(self_calling_closure=f
 			acc
 		end else begin
 			(* mark the replacement local for the analyzer *)
-			begin match ctx.com.platform with
-				| Cpp | Php ->
-					()
-				| _ ->
-					if i.i_read <= 1 && not i.i_write then
-						i.i_subst.v_meta <- (Meta.CompilerGenerated,[],p) :: i.i_subst.v_meta;
-			end;
+			if i.i_read <= 1 && not i.i_write then
+				i.i_subst.v_meta <- (Meta.CompilerGenerated,[],p) :: i.i_subst.v_meta;
 			(i.i_subst,Some e) :: acc
 		end
 	) [] inlined_vars in