Author: martin
Date: 2005-04-12 13:51:52 -0400 (Tue, 12 Apr 2005)
New Revision: 42849

Modified:
   trunk/mcs/gmcs/ChangeLog
   trunk/mcs/gmcs/class.cs
   trunk/mcs/gmcs/constant.cs
   trunk/mcs/gmcs/driver.cs
   trunk/mcs/gmcs/ecore.cs
   trunk/mcs/gmcs/literal.cs
   trunk/mcs/gmcs/rootcontext.cs
Log:
**** Merged r40869 from MCS ****


Modified: trunk/mcs/gmcs/ChangeLog
===================================================================
--- trunk/mcs/gmcs/ChangeLog    2005-04-12 17:50:15 UTC (rev 42848)
+++ trunk/mcs/gmcs/ChangeLog    2005-04-12 17:51:52 UTC (rev 42849)
@@ -1,3 +1,18 @@
+2005-02-18  Marek Safar  <[EMAIL PROTECTED]>
+
+       * class.cs (EmitFieldInitializers): Don't emit field initializer
+       for default values when optimilization is on.
+       
+       * constant.cs (Constant.IsDefaultValue): New property.
+       
+       * driver.cs: Add /optimize handling.
+       
+       * constant.cs,
+       * ecore.cs,
+       * literal.cs: Implement new IsDefaultValue property.
+       
+       * rootcontext.cs (Optimize): New field, holds /optimize option.
+
 2005-02-18  Raja R Harinath  <[EMAIL PROTECTED]>
 
        Fix crasher in re-opened #72347.

Modified: trunk/mcs/gmcs/class.cs
===================================================================
--- trunk/mcs/gmcs/class.cs     2005-04-12 17:50:15 UTC (rev 42848)
+++ trunk/mcs/gmcs/class.cs     2005-04-12 17:51:52 UTC (rev 42849)
@@ -866,6 +866,14 @@
                                if (a == null)
                                        return false;
 
+                               if (RootContext.Optimize) {
+                                       Constant c = e as Constant;
+                                       if (c != null) {
+                                               if (c.IsDefaultValue)
+                                                       continue;
+                                       }
+                               }
+
                                a.EmitStatement (ec);
                        }
 

Modified: trunk/mcs/gmcs/constant.cs
===================================================================
--- trunk/mcs/gmcs/constant.cs  2005-04-12 17:50:15 UTC (rev 42848)
+++ trunk/mcs/gmcs/constant.cs  2005-04-12 17:51:52 UTC (rev 42849)
@@ -162,6 +162,10 @@
                        return null;
                }
                
+               public abstract bool IsDefaultValue {
+                       get;
+               }
+
                public abstract bool IsNegative {
                        get;
                }
@@ -205,6 +209,12 @@
                                ec.ig.Emit (OpCodes.Ldc_I4_0);
                }
                
+               public override bool IsDefaultValue {
+                       get {
+                               return !Value;
+                       }
+               }
+
                public override bool IsNegative {
                        get {
                                return false;
@@ -271,6 +281,12 @@
                        return new IntConstant (Value);
                }
                
+               public override bool IsDefaultValue {
+                       get {
+                               return Value == 0;
+                       }
+               }
+
                public override bool IsNegative {
                        get {
                                return false;
@@ -366,6 +382,12 @@
                        return new IntConstant (Value);
                }
                
+               public override bool IsDefaultValue {
+                       get {
+                               return Value == 0;
+                       }
+               }
+
                public override bool IsNegative {
                        get {
                                return false;
@@ -435,6 +457,12 @@
                        return new IntConstant (Value);
                }
                
+               public override bool IsDefaultValue {
+                       get {
+                               return Value == 0;
+                       }
+               }
+
                public override bool IsNegative {
                        get {
                                return Value < 0;
@@ -500,6 +528,12 @@
                {
                        return new IntConstant (Value);
                }
+
+               public override bool IsDefaultValue {
+                       get {
+                               return Value == 0;
+                       }
+               }
                
                public override bool IsZeroInteger {
                        get { return Value == 0; }
@@ -567,6 +601,12 @@
                        return new IntConstant (Value);
                }
                
+               public override bool IsDefaultValue {
+                       get {
+                               return Value == 0;
+                       }
+               }
+
                public override bool IsNegative {
                        get {
                                return false;
@@ -695,6 +735,12 @@
                {
                        return this;
                }
+
+               public override bool IsDefaultValue {
+                       get {
+                               return Value == 0;
+                       }
+               }
                
                public override bool IsNegative {
                        get {
@@ -762,6 +808,12 @@
                        return null;
                }
                
+               public override bool IsDefaultValue {
+                       get {
+                               return Value == 0;
+                       }
+               }
+
                public override bool IsNegative {
                        get {
                                return false;
@@ -843,6 +895,12 @@
                        return null;
                }
                
+               public override bool IsDefaultValue {
+                       get {
+                               return Value == 0;
+                       }
+               }
+
                public override bool IsNegative {
                        get {
                                return Value < 0;
@@ -911,6 +969,12 @@
                        return null;
                }
                
+               public override bool IsDefaultValue {
+                       get {
+                               return Value == 0;
+                       }
+               }
+
                public override bool IsNegative {
                        get {
                                return false;
@@ -972,6 +1036,12 @@
                        return null;
                }
 
+               public override bool IsDefaultValue {
+                       get {
+                               return Value == 0;
+                       }
+               }
+
                public override bool IsNegative {
                        get {
                                return Value < 0;
@@ -1034,6 +1104,12 @@
                        return null;
                }
 
+               public override bool IsDefaultValue {
+                       get {
+                               return Value == 0;
+                       }
+               }
+
                public override bool IsNegative {
                        get {
                                return Value < 0;
@@ -1094,6 +1170,12 @@
                        ig.Emit (OpCodes.Newobj, 
TypeManager.void_decimal_ctor_five_args);
                }
 
+               public override bool IsDefaultValue {
+                       get {
+                               return Value == 0;
+                       }
+               }
+
                public override bool IsNegative {
                        get {
                                return Value < 0;
@@ -1130,6 +1212,12 @@
                                ec.ig.Emit (OpCodes.Ldstr, Value);
                }
 
+               public override bool IsDefaultValue {
+                       get {
+                               return Value == null;
+                       }
+               }
+
                public override bool IsNegative {
                        get {
                                return false;

Modified: trunk/mcs/gmcs/driver.cs
===================================================================
--- trunk/mcs/gmcs/driver.cs    2005-04-12 17:50:15 UTC (rev 42848)
+++ trunk/mcs/gmcs/driver.cs    2005-04-12 17:51:52 UTC (rev 42849)
@@ -220,6 +220,7 @@
                                "   -noconfig[+|-]     Disables implicit 
references to assemblies\n" +
                                "   -nostdlib[+|-]     Does not load core 
libraries\n" +
                                "   -nowarn:W1[,W2]    Disables one or more 
warnings\n" + 
+                               "   -optimize[+|-]     Enables code 
optimalizations" + Environment.NewLine +
                                "   -out:FNAME         Specifies output file\n" 
+
                                "   -pkg:P1[,Pn]       References packages 
P1..Pn\n" + 
                                "   --expect-error X   Expect that error X will 
be encountered\n" +
@@ -950,7 +951,13 @@
 
                        case "/optimize":
                        case "/optimize+":
+                               RootContext.Optimize = true;
+                               return true;
+
                        case "/optimize-":
+                               RootContext.Optimize = false;
+                               return true;
+
                        case "/incremental":
                        case "/incremental+":
                        case "/incremental-":

Modified: trunk/mcs/gmcs/ecore.cs
===================================================================
--- trunk/mcs/gmcs/ecore.cs     2005-04-12 17:50:15 UTC (rev 42848)
+++ trunk/mcs/gmcs/ecore.cs     2005-04-12 17:51:52 UTC (rev 42849)
@@ -1500,6 +1500,12 @@
                        child.Emit (ec);
                }
 
+               public override bool IsDefaultValue {
+                       get {
+                               throw new NotImplementedException ();
+                       }
+               }
+
                public override bool IsNegative {
                        get {
                                return false;
@@ -1636,7 +1642,13 @@
                {
                        return Child.ConvertToInt ();
                }
-               
+
+               public override bool IsDefaultValue {
+                       get {
+                               return Child.IsDefaultValue;
+                       }
+               }
+
                public override bool IsZeroInteger {
                        get { return Child.IsZeroInteger; }
                }

Modified: trunk/mcs/gmcs/literal.cs
===================================================================
--- trunk/mcs/gmcs/literal.cs   2005-04-12 17:50:15 UTC (rev 42848)
+++ trunk/mcs/gmcs/literal.cs   2005-04-12 17:51:52 UTC (rev 42849)
@@ -79,7 +79,13 @@
                {
                        ec.ig.Emit (OpCodes.Ldnull);
                }
-               
+
+               public override bool IsDefaultValue {
+                       get {
+                               return true;
+                       }
+               }
+
                public override bool IsNegative {
                        get {
                                return false;

Modified: trunk/mcs/gmcs/rootcontext.cs
===================================================================
--- trunk/mcs/gmcs/rootcontext.cs       2005-04-12 17:50:15 UTC (rev 42848)
+++ trunk/mcs/gmcs/rootcontext.cs       2005-04-12 17:51:52 UTC (rev 42849)
@@ -71,6 +71,11 @@
 
                public static bool VerifyClsCompliance = true;
 
+               /// <summary>
+               /// Holds /optimize option
+               /// </summary>
+               public static bool Optimize;
+
                public static LanguageVersion Version = LanguageVersion.Default;
 
                //

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

Reply via email to