In mcs and gmcs:
authorRaja R Harinath <harinath@hurrynot.org>
Tue, 8 Aug 2006 12:19:35 +0000 (12:19 -0000)
committerRaja R Harinath <harinath@hurrynot.org>
Tue, 8 Aug 2006 12:19:35 +0000 (12:19 -0000)
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.

svn path=/trunk/mcs/; revision=63475

mcs/errors/known-issues-gmcs
mcs/errors/known-issues-mcs
mcs/gmcs/ChangeLog
mcs/gmcs/assign.cs
mcs/gmcs/codegen.cs
mcs/mcs/ChangeLog
mcs/mcs/assign.cs
mcs/mcs/codegen.cs
mcs/tests/ChangeLog
mcs/tests/test-527.cs [new file with mode: 0644]

index 89268d2c8f96be6d4eece6787e487f4dde6ce722..f5c634d4addcfd5b7039bcbe84719deb808b48c6 100644 (file)
 #                        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
index 3aa78e7dfc0ff7580e5b6f99611eb469629aa408..18e10503895a6f00a4824f9a06de19ba35e46dd5 100644 (file)
 #                        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
index 2d509c1df459048d38685be53c03dfd4cc2691fa..3b22ba0e040d9a7b9dd1d519f7349eb3cc048581 100644 (file)
@@ -1,3 +1,11 @@
+2006-08-08  Raja R Harinath  <rharinath@novell.com>
+
+       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  <marek.safar@seznam.cz>
 
        * expresssion.cs (IndexerAccess.DoResolve): Fixed to report correct error
index dabe1c75d39e01ae4589ed17ebf5baefcec49d9c..8a2d8390d0718755791b9f47b5a96d72b3aad591 100644 (file)
@@ -211,6 +211,9 @@ namespace Mono.CSharp {
                {
                        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)
index 9cdfa7b1c61c2edfdedc6fd3a1b086dd0304cc5f..05b90abacb3c9cb6182567f7364ca36a1a605075 100644 (file)
@@ -894,58 +894,44 @@ namespace Mono.CSharp {
                /// </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>
index f02a10c9bff73a59c54f38d6d6201816311730a5..603eb4f0dd8f70f74d8acee5fba56e53303cd565 100644 (file)
@@ -1,3 +1,11 @@
+2006-08-08  Raja R Harinath  <rharinath@novell.com>
+
+       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  <marek.safar@seznam.cz>
 
        * expresssion.cs (IndexerAccess.DoResolve): Fixed to report correct error
index dabe1c75d39e01ae4589ed17ebf5baefcec49d9c..8a2d8390d0718755791b9f47b5a96d72b3aad591 100644 (file)
@@ -211,6 +211,9 @@ namespace Mono.CSharp {
                {
                        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)
index c5e3a1ec09fb5f081075d5ec9e697e5fed7c6518..c173d1c5971b3a2c444d78d7a48226a71fae8df8 100644 (file)
@@ -868,58 +868,44 @@ namespace Mono.CSharp {
                /// </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>
index f19a9b01982af4069e0212f197a19e8babac7d37..e5e1b947e5a92f40d7b098d0a95a41c0a86c2fce 100644 (file)
@@ -1,3 +1,7 @@
+2006-08-08  Raja R Harinath  <rharinath@novell.com>
+
+       * test-527.cs: New test from #79026.
+
 2006-08-02  Raja R Harinath  <rharinath@novell.com>
 
        * gtest-282.cs: New test from #77963.
diff --git a/mcs/tests/test-527.cs b/mcs/tests/test-527.cs
new file mode 100644 (file)
index 0000000..50232d9
--- /dev/null
@@ -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;
+  }
+}
+