Author: raja
Date: 2006-08-08 08:19:35 -0400 (Tue, 08 Aug 2006)
New Revision: 63475

Added:
   trunk/mcs/tests/test-527.cs
Modified:
   trunk/mcs/errors/known-issues-gmcs
   trunk/mcs/errors/known-issues-mcs
   trunk/mcs/gmcs/ChangeLog
   trunk/mcs/gmcs/assign.cs
   trunk/mcs/gmcs/codegen.cs
   trunk/mcs/mcs/ChangeLog
   trunk/mcs/mcs/assign.cs
   trunk/mcs/mcs/codegen.cs
   trunk/mcs/tests/
   trunk/mcs/tests/ChangeLog
Log:
In mcs and gmcs:
        Fix #79026
        * codegen.cs (EmitContext.GetTemporaryLocal): Simplify.  Use Stack
        instead of ArrayList.  If the hashtable has a LocalBuilder, don't
        leave it in after returning it.
        (EmitContext.FreeTemporaryLocal): Simplify.  Update to changes.

In tests:
        * test-527.cs: New test from #79026.


Modified: trunk/mcs/errors/known-issues-gmcs
===================================================================
--- trunk/mcs/errors/known-issues-gmcs  2006-08-08 11:31:05 UTC (rev 63474)
+++ trunk/mcs/errors/known-issues-gmcs  2006-08-08 12:19:35 UTC (rev 63475)
@@ -12,10 +12,9 @@
 #                        as NO ERROR and CS5001 is automatically ignored.
 
 cs0118-8.cs NO ERROR
-cs0154-3.cs
 cs0162-7.cs NO ERROR
 cs0229-2.cs
-cs0229.cs NO ERROR
+cs0229.cs
 cs0467-2.cs
 cs0467-3.cs
 cs0467.cs NO ERROR

Modified: trunk/mcs/errors/known-issues-mcs
===================================================================
--- trunk/mcs/errors/known-issues-mcs   2006-08-08 11:31:05 UTC (rev 63474)
+++ trunk/mcs/errors/known-issues-mcs   2006-08-08 12:19:35 UTC (rev 63475)
@@ -12,10 +12,9 @@
 #                        as NO ERROR and CS5001 is automatically ignored.
 
 cs0118-8.cs NO ERROR
-cs0154-3.cs
 cs0162-7.cs NO ERROR
 cs0229-2.cs
-cs0229.cs NO ERROR
+cs0229.cs
 cs0467-2.cs
 cs0467-3.cs
 cs0467.cs NO ERROR

Modified: trunk/mcs/gmcs/ChangeLog
===================================================================
--- trunk/mcs/gmcs/ChangeLog    2006-08-08 11:31:05 UTC (rev 63474)
+++ trunk/mcs/gmcs/ChangeLog    2006-08-08 12:19:35 UTC (rev 63475)
@@ -1,3 +1,11 @@
+2006-08-08  Raja R Harinath  <[EMAIL PROTECTED]>
+
+       Fix #79026
+       * codegen.cs (EmitContext.GetTemporaryLocal): Simplify.  Use Stack
+       instead of ArrayList.  If the hashtable has a LocalBuilder, don't
+       leave it in after returning it.
+       (EmitContext.FreeTemporaryLocal): Simplify.  Update to changes.
+
 2006-08-06  Marek Safar  <[EMAIL PROTECTED]>
 
        * expresssion.cs (IndexerAccess.DoResolve): Fixed to report correct 
error

Modified: trunk/mcs/gmcs/assign.cs
===================================================================
--- trunk/mcs/gmcs/assign.cs    2006-08-08 11:31:05 UTC (rev 63474)
+++ trunk/mcs/gmcs/assign.cs    2006-08-08 12:19:35 UTC (rev 63475)
@@ -211,6 +211,9 @@
                {
                        ILGenerator ig = ec.ig;
 
+                       if (builder == null)
+                               throw new InternalErrorException ("Emit without 
Store, or after Release");
+
                        ig.Emit (OpCodes.Ldloc, builder);
                        // we need to copy from the pointer
                        if (is_address)

Modified: trunk/mcs/gmcs/codegen.cs
===================================================================
--- trunk/mcs/gmcs/codegen.cs   2006-08-08 11:31:05 UTC (rev 63474)
+++ trunk/mcs/gmcs/codegen.cs   2006-08-08 12:19:35 UTC (rev 63475)
@@ -894,58 +894,44 @@
                /// </summary>
                public LocalBuilder GetTemporaryLocal (Type t)
                {
-                       LocalBuilder location = null;
-                       
-                       if (temporary_storage != null){
+                       if (temporary_storage != null) {
                                object o = temporary_storage [t];
-                               if (o != null){
-                                       if (o is ArrayList){
-                                               ArrayList al = (ArrayList) o;
-                                               
-                                               for (int i = 0; i < al.Count; 
i++){
-                                                       if (al [i] != null){
-                                                               location = 
(LocalBuilder) al [i];
-                                                               al [i] = null;
-                                                               break;
-                                                       }
-                                               }
-                                       } else
-                                               location = (LocalBuilder) o;
-                                       if (location != null)
-                                               return location;
+                               if (o != null) {
+                                       if (o is Stack) {
+                                               Stack s = (Stack) o;
+                                               o = s.Count == 0 ? null : s.Pop 
();
+                                       } else {
+                                               temporary_storage.Remove (t);
+                                       }
                                }
+                               if (o != null)
+                                       return (LocalBuilder) o;
                        }
-                       
                        return ig.DeclareLocal (t);
                }
 
                public void FreeTemporaryLocal (LocalBuilder b, Type t)
                {
-                       if (temporary_storage == null){
+                       Stack s;
+
+                       if (temporary_storage == null) {
                                temporary_storage = new Hashtable ();
                                temporary_storage [t] = b;
                                return;
                        }
                        object o = temporary_storage [t];
-                       if (o == null){
+                       if (o == null) {
                                temporary_storage [t] = b;
                                return;
                        }
-                       if (o is ArrayList){
-                               ArrayList al = (ArrayList) o;
-                               for (int i = 0; i < al.Count; i++){
-                                       if (al [i] == null){
-                                               al [i] = b;
-                                               return;
-                                       }
-                               }
-                               al.Add (b);
-                               return;
+                       if (o is Stack) {
+                               s = (Stack) o;
+                       } else {
+                               s = new Stack ();
+                               s.Push (o);
+                               temporary_storage [t] = s;
                        }
-                       ArrayList replacement = new ArrayList ();
-                       replacement.Add (o);
-                       temporary_storage.Remove (t);
-                       temporary_storage [t] = replacement;
+                       s.Push (b);
                }
 
                /// <summary>

Modified: trunk/mcs/mcs/ChangeLog
===================================================================
--- trunk/mcs/mcs/ChangeLog     2006-08-08 11:31:05 UTC (rev 63474)
+++ trunk/mcs/mcs/ChangeLog     2006-08-08 12:19:35 UTC (rev 63475)
@@ -1,3 +1,11 @@
+2006-08-08  Raja R Harinath  <[EMAIL PROTECTED]>
+
+       Fix #79026
+       * codegen.cs (EmitContext.GetTemporaryLocal): Simplify.  Use Stack
+       instead of ArrayList.  If the hashtable has a LocalBuilder, don't
+       leave it in after returning it.
+       (EmitContext.FreeTemporaryLocal): Simplify.  Update to changes.
+
 2006-08-06  Marek Safar  <[EMAIL PROTECTED]>
 
        * expresssion.cs (IndexerAccess.DoResolve): Fixed to report correct 
error

Modified: trunk/mcs/mcs/assign.cs
===================================================================
--- trunk/mcs/mcs/assign.cs     2006-08-08 11:31:05 UTC (rev 63474)
+++ trunk/mcs/mcs/assign.cs     2006-08-08 12:19:35 UTC (rev 63475)
@@ -211,6 +211,9 @@
                {
                        ILGenerator ig = ec.ig;
 
+                       if (builder == null)
+                               throw new InternalErrorException ("Emit without 
Store, or after Release");
+
                        ig.Emit (OpCodes.Ldloc, builder);
                        // we need to copy from the pointer
                        if (is_address)

Modified: trunk/mcs/mcs/codegen.cs
===================================================================
--- trunk/mcs/mcs/codegen.cs    2006-08-08 11:31:05 UTC (rev 63474)
+++ trunk/mcs/mcs/codegen.cs    2006-08-08 12:19:35 UTC (rev 63475)
@@ -868,58 +868,44 @@
                /// </summary>
                public LocalBuilder GetTemporaryLocal (Type t)
                {
-                       LocalBuilder location = null;
-                       
-                       if (temporary_storage != null){
+                       if (temporary_storage != null) {
                                object o = temporary_storage [t];
-                               if (o != null){
-                                       if (o is ArrayList){
-                                               ArrayList al = (ArrayList) o;
-                                               
-                                               for (int i = 0; i < al.Count; 
i++){
-                                                       if (al [i] != null){
-                                                               location = 
(LocalBuilder) al [i];
-                                                               al [i] = null;
-                                                               break;
-                                                       }
-                                               }
-                                       } else
-                                               location = (LocalBuilder) o;
-                                       if (location != null)
-                                               return location;
+                               if (o != null) {
+                                       if (o is Stack) {
+                                               Stack s = (Stack) o;
+                                               o = s.Count == 0 ? null : s.Pop 
();
+                                       } else {
+                                               temporary_storage.Remove (t);
+                                       }
                                }
+                               if (o != null)
+                                       return (LocalBuilder) o;
                        }
-                       
                        return ig.DeclareLocal (t);
                }
 
                public void FreeTemporaryLocal (LocalBuilder b, Type t)
                {
-                       if (temporary_storage == null){
+                       Stack s;
+
+                       if (temporary_storage == null) {
                                temporary_storage = new Hashtable ();
                                temporary_storage [t] = b;
                                return;
                        }
                        object o = temporary_storage [t];
-                       if (o == null){
+                       if (o == null) {
                                temporary_storage [t] = b;
                                return;
                        }
-                       if (o is ArrayList){
-                               ArrayList al = (ArrayList) o;
-                               for (int i = 0; i < al.Count; i++){
-                                       if (al [i] == null){
-                                               al [i] = b;
-                                               return;
-                                       }
-                               }
-                               al.Add (b);
-                               return;
+                       if (o is Stack) {
+                               s = (Stack) o;
+                       } else {
+                               s = new Stack ();
+                               s.Push (o);
+                               temporary_storage [t] = s;
                        }
-                       ArrayList replacement = new ArrayList ();
-                       replacement.Add (o);
-                       temporary_storage.Remove (t);
-                       temporary_storage [t] = replacement;
+                       s.Push (b);
                }
 
                /// <summary>

Modified: trunk/mcs/tests/ChangeLog
===================================================================
--- trunk/mcs/tests/ChangeLog   2006-08-08 11:31:05 UTC (rev 63474)
+++ trunk/mcs/tests/ChangeLog   2006-08-08 12:19:35 UTC (rev 63475)
@@ -1,3 +1,7 @@
+2006-08-08  Raja R Harinath  <[EMAIL PROTECTED]>
+
+       * test-527.cs: New test from #79026.
+
 2006-08-02  Raja R Harinath  <[EMAIL PROTECTED]>
 
        * gtest-282.cs: New test from #77963.

Added: trunk/mcs/tests/test-527.cs
===================================================================
--- trunk/mcs/tests/test-527.cs 2006-08-08 11:31:05 UTC (rev 63474)
+++ trunk/mcs/tests/test-527.cs 2006-08-08 12:19:35 UTC (rev 63475)
@@ -0,0 +1,29 @@
+using System;
+
+class Repro
+{
+  private int[] stack = new int[1];
+  private int cc;
+  public int fc;
+  private int sp;
+
+  static int Main()
+  {
+    Repro r = new Repro();
+    r.foo();
+    Console.WriteLine(r.stack[0]);
+    return r.stack[0] == 42 ? 0 : 1;
+  }
+
+  public void foo()
+  {
+    fc = cc = bar();
+    fc = stack[sp++] = cc;
+  }
+
+  private int bar()
+  {
+    return 42;
+  }
+}
+


Property changes on: trunk/mcs/tests/test-527.cs
___________________________________________________________________
Name: svn:eol-style
   + native

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

Reply via email to