private static void ApplyOptimization(CilMethodInterpreter midRepresentation, int i, int j) { var localOps = midRepresentation.MidRepresentation.LocalOperations; var srcMethod = PrecomputeRepeatedUtils.GetMethodData(localOps, i); var destMethod = PrecomputeRepeatedUtils.GetMethodData(localOps, j); if (srcMethod.Result == null) { return; } var computedType = srcMethod.Result.ComputedType(); var newVreg = midRepresentation.CreateCacheVariable(computedType); var assignedTo = srcMethod.Result; var localOperation = PrecomputeRepeatedUtils.CreateAssignLocalOperation(assignedTo, newVreg); localOps.Insert(i + 1, localOperation); srcMethod.Result = newVreg; var destAssignment = PrecomputeRepeatedUtils.CreateAssignLocalOperation(destMethod.Result, newVreg); localOps.RemoveAt(j + 1); localOps.Insert(j + 1, destAssignment); }
static void ApplyOptimization(CilMethodInterpreter interpreter, int i, int j) { var localOps = interpreter.MidRepresentation.LocalOperations; var firstOperator = localOps[i].GetBinaryOperator(); var secondOperator = localOps[j].GetBinaryOperator(); var newVreg = interpreter.CreateCacheVariable(firstOperator.ComputedType()); var assignLocalOperation = PrecomputeRepeatedUtils.CreateAssignLocalOperation(firstOperator.AssignedTo, newVreg); localOps.Insert(i + 1, assignLocalOperation); firstOperator.AssignedTo = newVreg; var destAssignment = PrecomputeRepeatedUtils.CreateAssignLocalOperation(secondOperator.AssignedTo, newVreg); localOps.RemoveAt(j + 1); localOps.Insert(j + 1, destAssignment); }
private static void ApplyOptimization(CilMethodInterpreter midRepresentation, int i, int j) { var localOps = midRepresentation.MidRepresentation.LocalOperations; var firstOperator = localOps[i].Get <GetField>(); var secondOperator = localOps[j].Get <GetField>(); var newVreg = midRepresentation.CreateCacheVariable(firstOperator.AssignedTo.ComputedType()); var assignLocalOperation = PrecomputeRepeatedUtils.CreateAssignLocalOperation(firstOperator.AssignedTo, newVreg); localOps.Insert(i + 1, assignLocalOperation); firstOperator.AssignedTo = newVreg; var destAssignment = PrecomputeRepeatedUtils.CreateAssignLocalOperation(secondOperator.AssignedTo, newVreg); localOps[j + 1] = destAssignment; }