Author: raja
Date: 2007-03-29 09:07:58 -0500 (Thu, 29 Mar 2007)
New Revision: 75141

Modified:
   trunk/mcs/mcs/ChangeLog
   trunk/mcs/mcs/flowanalysis.cs
Log:
Prepare to kill 'Reachability'
* flowanalysis.cs (UsageVector.is_unreachable): New.
(UsageVector): Update to maintain 'is_unreachable' in parallel to
'reachability', and verify they're consistent.


Modified: trunk/mcs/mcs/ChangeLog
===================================================================
--- trunk/mcs/mcs/ChangeLog     2007-03-29 13:42:38 UTC (rev 75140)
+++ trunk/mcs/mcs/ChangeLog     2007-03-29 14:07:58 UTC (rev 75141)
@@ -1,5 +1,10 @@
 2007-03-29  Raja R Harinath  <[EMAIL PROTECTED]>
 
+       Prepare to kill 'Reachability'
+       * flowanalysis.cs (UsageVector.is_unreachable): New.
+       (UsageVector): Update to maintain 'is_unreachable' in parallel to
+       'reachability', and verify they're consistent.
+
        Fix #81121
        * expression.cs (New.EmitStatement): Handle type parameters here too.
 

Modified: trunk/mcs/mcs/flowanalysis.cs
===================================================================
--- trunk/mcs/mcs/flowanalysis.cs       2007-03-29 13:42:38 UTC (rev 75140)
+++ trunk/mcs/mcs/flowanalysis.cs       2007-03-29 14:07:58 UTC (rev 75141)
@@ -212,6 +212,7 @@
                        //
                        MyBitVector locals, parameters;
                        Reachability reachability;
+                       bool is_unreachable;
 
                        static int next_id = 0;
                        int id;
@@ -237,8 +238,12 @@
                                        : new MyBitVector (parent == null ? 
MyBitVector.Empty : parent.parameters, num_params);
 
                                reachability = parent == null ? 
Reachability.Always () : parent.reachability.Clone ();
+                               if (parent != null)
+                                       is_unreachable = parent.is_unreachable;
 
                                id = ++next_id;
+
+                               Check ();
                        }
 
                        public UsageVector (SiblingType type, UsageVector 
parent, Block block, Location loc)
@@ -252,10 +257,13 @@
                                this.Block = block;
 
                                this.reachability = reachability;
+                               this.is_unreachable = 
reachability.IsUnreachable;
                                this.parameters = parameters;
                                this.locals = locals;
 
                                id = ++next_id;
+
+                               Check ();
                        }
 
                        // <summary>
@@ -268,7 +276,10 @@
                                retval.locals = locals.Clone ();
                                retval.parameters = parameters.Clone ();
                                retval.reachability = reachability.Clone ();
+                               retval.is_unreachable = is_unreachable;
 
+                               retval.Check ();
+
                                return retval;
                        }
 
@@ -304,19 +315,29 @@
                                var.SetFieldAssigned (var.IsParameter ? 
parameters : locals, name);
                        }
 
+                       void Check ()
+                       {
+                               if (is_unreachable != 
reachability.IsUnreachable)
+                                       throw new InternalErrorException 
(is_unreachable + " vs. " + reachability.IsUnreachable);
+                       }
+
                        public bool IsUnreachable {
-                               get { return reachability.IsUnreachable; }
+                               get { Check (); return is_unreachable; }
                        }
 
                        public void ResetBarrier ()
                        {
                                reachability.Meet (Reachability.Always ());
+                               is_unreachable = false;
+                               Check ();
                        }
 
                        public void Goto ()
                        {
                                if (!reachability.IsUnreachable)
                                        reachability.SetBarrier ();
+                               is_unreachable = true;
+                               Check ();
                        }
 
                        public static UsageVector MergeSiblings (UsageVector 
sibling_list, Location loc)
@@ -327,6 +348,7 @@
                                MyBitVector locals = null;
                                MyBitVector parameters = null;
                                Reachability reachability = 
sibling_list.reachability.Clone ();
+                               bool is_unreachable = 
sibling_list.is_unreachable;
 
                                if (!sibling_list.IsUnreachable) {
                                        locals &= sibling_list.locals;
@@ -335,6 +357,9 @@
 
                                for (UsageVector child = sibling_list.Next; 
child != null; child = child.Next) {
                                        reachability.Meet (child.reachability);
+                                       is_unreachable &= child.is_unreachable;
+                                       if (is_unreachable != 
reachability.IsUnreachable)
+                                               throw new 
InternalErrorException ("MergeSiblings: " + is_unreachable + " vs. " + 
reachability.IsUnreachable);
 
                                        if (!child.IsUnreachable) {
                                                locals &= child.locals;
@@ -353,6 +378,7 @@
                                Report.Debug (2, "    MERGING CHILD EFFECTS", 
this, child, reachability, Type);
 
                                Reachability new_r = child.reachability;
+                               bool new_isunr = child.is_unreachable;
 
                                //
                                // We've now either reached the point after the 
branching or we will
@@ -373,10 +399,14 @@
                                locals |= child.locals;
                                parameters |= child.parameters;
 
-                               if (overwrite)
+                               if (overwrite) {
                                        reachability = new_r.Clone ();
-                               else
+                                       is_unreachable = new_isunr;
+                               } else {
                                        reachability.Or (new_r);
+                                       is_unreachable |= new_isunr;
+                               }
+                               Check ();
 
                                return child;
                        }
@@ -402,6 +432,8 @@
                                        locals &= vector.locals;
                                        parameters &= vector.parameters;
                                        reachability.Meet (vector.reachability);
+                                       is_unreachable &= vector.is_unreachable;
+                                       Check ();
                                }
 
                                Report.Debug (1, "  MERGING BREAK ORIGINS 
DONE", this);

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to