http://bugzilla.novell.com/show_bug.cgi?id=524595


           Summary: JIT produces very slow code if you use a temporary
                    variable outside a try/catch block
    Classification: Mono
           Product: Mono: Runtime
           Version: unspecified
          Platform: x86
        OS/Version: Linux
            Status: NEW
          Severity: Enhancement
          Priority: P5 - None
         Component: JIT
        AssignedTo: [email protected]
        ReportedBy: [email protected]
         QAContact: [email protected]
          Found By: ---


Created an attachment (id=307179)
 --> (http://bugzilla.novell.com/attachment.cgi?id=307179)
C# program to reproduce the behaviour

User-Agent:       Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.10)
Gecko/2009071311 Gentoo Firefox/3.0.10

Consider these two methods:

    public static int Fast()
    {
        int i = 0;
        int step = 3;
        while (i < N) {
            try {
                i = checked(i + step);
            }
            catch (OverflowException) {
                return -1;
            }
        }
        return i;
    }

    public static int Slow()
    {
        int i = 0;
        int step = 3;
        int tmp = 0;
        while (i < N) {
            try {
                tmp = checked(i + step);
            }
            catch (OverflowException) {
                return -1;
            }
            i = tmp;
        }
        return i;
    }

The only difference between the twos is the presence of the "tmp" variable in
the "Slow" method.  However, this seems to be enough to make the resulting code
2x slower.

Reproducible: Always

Steps to Reproduce:
1. gmcs tempvar.cs  # (see attachment)
2. mono tempvar.cs

Actual Results:  
viper tmp $ mono tempvar.exe 
Fast: 00:00:01.1878510
Slow: 00:00:02.0227760


Expected Results:  
viper tmp $ mono tempvar.exe 
Fast: 00:00:01.1878510
Slow: 00:00:01.1878510

(well, maybe not exactly the same time, but still :-))

viper tmp $ mono -V
Mono JIT compiler version 2.4.2 (tarball Thu Jul 23 14:13:20 CEST 2009)
Copyright (C) 2002-2008 Novell, Inc and Contributors. www.mono-project.com
        TLS:           __thread
        GC:            Included Boehm (with typed GC)
        SIGSEGV:       altstack
        Notifications: epoll
        Architecture:  x86
        Disabled:      none

-- 
Configure bugmail: http://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
_______________________________________________
mono-bugs maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-bugs

Reply via email to