[Mono-bugs] [Bug 398358] New: Different behavior between , net and Mono's DynamicMethod

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Sun Jun 8 13:00:43 EDT 2008


https://bugzilla.novell.com/show_bug.cgi?id=398358


           Summary: Different behavior between ,net and Mono's DynamicMethod
           Product: Mono: Runtime
           Version: SVN
          Platform: i586
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: misc
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: jbevain at novell.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---


First, I have no idea if this a Mono «bug», or not.

Let see the following piece of code:

<<<<<<<<<<<<<<<<<<<<<<<
using System;
using System.Reflection;
using System.Reflection.Emit;

namespace Pad {

        class Program {

                static void Main ()
                {
                        var method = new DynamicMethod ("foo", typeof (ulong),
new [] { typeof (ulong), typeof (short) });
                        var ig = method.GetILGenerator ();
                        Emit (ig, OpCodes.Ldarg_0, OpCodes.Ldarg_1,
OpCodes.Conv_I4, OpCodes.Shl, OpCodes.Ret);

                        var del = (Func<ulong, short, ulong>)
method.CreateDelegate (typeof (Func<ulong, short, ulong>));

                        Console.WriteLine (del (0xFFFFFFFF, 0xA01));
                }

                static void Emit (ILGenerator ig, params OpCode [] ops)
                {
                        foreach (var op in ops)
                                ig.Emit (op);
                }
        }
}
<<<<<<<<<<<<<<<<<<<<<<<<<<

net outputs:
18446744065119617024

Mono outputs:
8589934590

Thing is that, for this piece of code, compiled without using dynamic methods:

<<<<<<<<<<<<<<<<<<<<<<<<<<
assembly extern mscorlib {}
assembly 'test2' {}
module test2.exe

class private Test extends [mscorlib]System.Object
{

        .method private static unsigned int64 LeftShift (unsigned int64 a,
int16 b)
        {
                ldarg.0 
                ldarg.1 
                conv.i4
                shl 
                ret 
        }

        .method private static void Main ()
        {
                .entrypoint
                ldc.i4 0xffffffff
                conv.u8 
                ldc.i4 0xA01
                conv.i2
                call unsigned int64 class Test::LeftShift(unsigned int64,
int16)
                call void class [mscorlib]System.Console::WriteLine(unsigned
int64)
                ret 
        }
}
<<<<<<<<<<<<<<<<<<<<<<<<<<

Both Mono and .net outputs:
8589934590

So I'm a little puzzled about what's going on here.


-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.


More information about the mono-bugs mailing list