Beispiel #1
0
        private int FindDependentInstruction(string returnReg, MethodAnalyzer meth, int index_await)
        {
            int j = 0;

            string invocArg0 = meth.FindInvokedArgument(returnReg);

            string invocMeth0 = meth.FindInvokedMethod(returnReg);

            foreach (Tuple <Accesses, string, IOperation> ele in meth.conflictUnit)
            {
                if (j > index_await)
                {
                    if (ele.Item1 == Accesses.Read && ele.Item2 == returnReg)
                    {
                        return(j);
                    }
                    else if ((ele.Item1 == Accesses.Read || ele.Item1 == Accesses.Write) && ele.Item2 == invocArg0)
                    {
                        return(j);
                    }
                    else if (ele.Item1 == Accesses.Invocation && ele.Item2 != returnReg)
                    {
                        string invocArg1  = meth.FindInvokedArgument(ele.Item2);
                        string invocMeth2 = meth.FindInvokedMethod(ele.Item2);
                        if (progMethods.IndexOf(invocMeth0) == -1 && progMethods.IndexOf(invocMeth2) == -1)
                        {
                            if (invocArg1 == invocArg0 || invocArg1 == returnReg)
                            {
                                return(j);
                            }
                        }
                    }
                }
                j = j + 1;
            }
            return(j);
        }
Beispiel #2
0
        private int IsThereDataRace(MethodAnalyzer meth1, List <Tuple <Accesses, string, IOperation> > conflictUnit1,
                                    MethodAnalyzer meth2, List <Tuple <Accesses, string, IOperation> > conflictUnit2)
        {
            int    j = 0;
            string meth2Name;
            int    sysm2Index = -1;

            if (conflictUnit2.Count == 1 && conflictUnit2[0].Item1 == Accesses.Invocation)
            {
                meth2Name = meth2.FindInvokedMethod(conflictUnit2[0].Item2);
                if (systemMethod.IndexOf(meth2Name) != -1)
                {
                    sysm2Index = systemMethod.IndexOf(meth2Name);
                }
            }

            foreach (var ele in conflictUnit1)
            {
                if (ele.Item1 == Accesses.Invocation)
                {
                    string         methName = meth1.FindInvokedMethod(ele.Item2);
                    MethodAnalyzer newMeth  = FindMethod(methName);
                    if (newMeth != null)
                    {
                        var confUnit = newMeth.conflictUnit;
                        var k        = IsThereDataRace(newMeth, confUnit, meth2, conflictUnit2);
                        if (k != -1)
                        {
                            return(j);
                        }
                    }
                    else if (progMethods.IndexOf(methName) == -1 && sysm2Index != -1)
                    {
                        if (systemMethodConflicts[sysm2Index].IndexOf(methName) != -1)
                        {
                            string invocArg0 = meth2.FindInvokedArgument(conflictUnit2[0].Item2);

                            string invocArg1 = meth1.FindInvokedArgument(ele.Item2);

                            if (invocArg0 == invocArg1 && invocArg0 != null)
                            {
                                return(j);
                            }
                        }
                    }
                    else if (progMethods.IndexOf(methName) == -1 && sysm2Index == -1)
                    {
                        string invocArg1 = meth1.FindInvokedArgument(ele.Item2);

                        foreach (var ele2 in conflictUnit2)
                        {
                            if (ele2.Item1 == Accesses.Invocation)
                            {
                                string         methName2 = meth2.FindInvokedMethod(ele2.Item2);
                                MethodAnalyzer newMeth2  = FindMethod(methName2);
                                if (newMeth2 != null)
                                {
                                    var confUnit2 = newMeth2.conflictUnit;
                                    var confUnit1 = new List <Tuple <Accesses, string, IOperation> >();
                                    confUnit1.Add(ele);
                                    var k = IsThereDataRace(meth1, confUnit1, newMeth2, confUnit2);
                                    if (k != -1)
                                    {
                                        return(j);
                                    }
                                }
                                else if (systemMethod.IndexOf(methName2) != -1)
                                {
                                    string invocArg0 = meth2.FindInvokedArgument(ele2.Item2);

                                    if (invocArg0 == invocArg1 && systemMethodConflicts[systemMethod.IndexOf(methName2)].IndexOf(methName) != -1)
                                    {
                                        return(j);
                                    }
                                }
                            }
                            else if (ele2.Item1 == Accesses.Write && ele2.Item2 == invocArg1)
                            {
                                return(j);
                            }
                            else if (ele2.Item1 == Accesses.Read && ele2.Item2 == invocArg1)
                            {
                                return(j);
                            }
                        }
                    }
                }
                else if (ele.Item1 == Accesses.Read)
                {
                    if (sysm2Index == -1)
                    {
                        foreach (var ele2 in conflictUnit2)
                        {
                            if (ele2.Item1 == Accesses.Invocation)
                            {
                                string         methName2 = meth2.FindInvokedMethod(ele2.Item2);
                                MethodAnalyzer newMeth2  = FindMethod(methName2);
                                if (newMeth2 != null)
                                {
                                    var confUnit2 = newMeth2.conflictUnit;
                                    var confUnit1 = new List <Tuple <Accesses, string, IOperation> >();
                                    confUnit1.Add(ele);
                                    var k = IsThereDataRace(meth1, confUnit1, newMeth2, confUnit2);
                                    if (k != -1)
                                    {
                                        return(j);
                                    }
                                }
                                // should this be any system method or only the ones with asynchronous counter parts
                                else if (progMethods.IndexOf(methName2) == -1)
                                {
                                    string invocArg0 = meth2.FindInvokedArgument(ele2.Item2);

                                    if (invocArg0 == ele.Item2)
                                    {
                                        return(j);
                                    }
                                }
                            }
                            else if (ele2.Item1 == Accesses.Write && ele2.Item2 == ele.Item2)
                            {
                                return(j);
                            }
                        }
                    }
                }
                else if (ele.Item1 == Accesses.Write)
                {
                    if (sysm2Index == -1)
                    {
                        foreach (var ele2 in conflictUnit2)
                        {
                            if (ele2.Item1 == Accesses.Invocation)
                            {
                                string         methName2 = meth2.FindInvokedMethod(ele2.Item2);
                                MethodAnalyzer newMeth2  = FindMethod(methName2);
                                if (newMeth2 != null)
                                {
                                    var confUnit2 = newMeth2.conflictUnit;
                                    var confUnit1 = new List <Tuple <Accesses, string, IOperation> >();
                                    confUnit1.Add(ele);
                                    var k = IsThereDataRace(meth1, confUnit1, newMeth2, confUnit2);
                                    if (k != -1)
                                    {
                                        return(j);
                                    }
                                }
                                else if (progMethods.IndexOf(methName2) == -1)
                                {
                                    string invocArg0 = meth2.FindInvokedArgument(ele2.Item2);

                                    if (invocArg0 == ele.Item2)
                                    {
                                        return(j);
                                    }
                                }
                            }
                            else if (ele2.Item1 == Accesses.Write && ele2.Item2 == ele.Item2)
                            {
                                return(j);
                            }
                            else if (ele2.Item1 == Accesses.Read && ele2.Item2 == ele.Item2)
                            {
                                return(j);
                            }
                        }
                    }
                }
                j = j + 1;
            }

            return(-1);
        }