[Mono-bugs] [Bug 73936][Min] New - gmcs does not optimize for space

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Mon, 21 Mar 2005 12:56:34 -0500 (EST)


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by dsilva@ccs.neu.edu.

http://bugzilla.ximian.com/show_bug.cgi?id=73936

--- shadow/73936	2005-03-21 12:56:34.000000000 -0500
+++ shadow/73936.tmp.22619	2005-03-21 12:56:34.000000000 -0500
@@ -0,0 +1,82 @@
+Bug#: 73936
+Product: Mono: Compilers
+Version: 1.1
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Minor
+Component: C#
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: dsilva@ccs.neu.edu               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: gmcs does not optimize for space
+
+Please fill in this template when reporting a bug, unless you know what you
+are doing.
+Description of Problem:
+
+gmcs is not producing memory-bounded code for the method 'addtr' in this
+program:
+
+public class Program {
+  public static void Main(string[] args) {
+    addtr(5, 6);
+  }
+
+  public static int addtr(int x, int y) {
+    return x == 0 ?
+            y :
+            addtr(x - 1, y + 1);
+  }
+}
+
+
+Steps to reproduce the problem:
+1. Compile with gmcs
+2. See the disassembly with monodis:
+
+    .method public static  hidebysig
+           default int32 addtr (int32 x, int32 y)  cil managed
+    {
+        // Method begins at RVA 0x2124
+        // Code size 24 (0x18)
+        .maxstack 8
+        IL_0000:  ldarg.0
+        IL_0001:  brtrue IL_000c
+
+        IL_0006:  ldarg.1
+        IL_0007:  br IL_0017
+
+        IL_000c:  ldarg.0
+        IL_000d:  ldc.i4.1
+        IL_000e:  sub
+        IL_000f:  ldarg.1
+        IL_0010:  ldc.i4.1
+        IL_0011:  add
+        IL_0012:  call int32 class Program::addtr(int32, int32)
+        IL_0017:  ret
+    } // end of method Program::default int32 addtr (int32 x, int32 y)
+
+3. A tail instruction is missing.
+
+Actual Results:
+
+Stack growth for the loop.
+
+Expected Results:
+
+No growth in loops.
+
+How often does this happen? 
+
+Always.
+
+Additional Information:
+
+This is not required by the ECMA spec but I believe it is allowed.
+(otherwise, why would the instruction exist?)