[Mono-list] Mono doesn't seem to like JSharp code in MSIL form. -> BANG

Chris Ball chris@void.printf.net
Sun, 16 Feb 2003 16:16:54 +0000


>> On 15 Feb 2003 21:20:22, Simon Waite <simon@psionics.demon.co.uk> said:

   >> I've been collecting reviews for my dissertation (which is a
   >> retarget of the Jikes Java compiler to output MSIL)

   > Hows that dissertation going BTW ?

Great, thanks.  It's working on simple classes, and I'm concentrating on
OO model and class library mappings.  I've just finished giving a bunch
of talks on it; it's at the halfway stage, time-wise.  I've been meaning
to post an update for a while - to borrow from the talks, so far I've:

   - Created a complete set of opcode mappings.

   - Written methods for dereferencing Java's constant pool.  Java
     doesn't allow variable-length data in the code segment, so you
     end up with (simplified) bytecode like:

       method_info  name_index 5  descriptor_index 6
       3   ldc 15
       5   invokevirtual 20
       8   return

       ==
       15  CONSTANT_String_info: string_index: 16
       16  CONSTANT_Utf8_info: length: 11 Hello World
       20  CONSTANT_Methodref_info: class_index: 21
       21  CONSTANT_Class_info: name_index 22
       22  CONSTANT_Utf8_info: length: 19 java/io/PrintStream

     In constrast, MSIL inlines all of this:

       IL_0000: ldstr "Hello World"
       IL_0005: call void class [corlib]System.Console::WriteLine(string)
       IL_000a: ret

   - Kept track of local variables, etc.  The bytecode verification
     actually stops me from needing to do a lot of reporting and type
     checking, which is neat.

   - Class mappings.  A basic case'd be:

       System.out.println("a: " + a + " b: " + b);
         .. to ..
       System.Console.Writeline("a: {0}, b: {1}", a, b);

     I've worked out a framework for these kind of transformations, but
     I can't see myself getting too near a full class library on my own;
     perhaps it'll get there when I release where I'm at so far (after
     the dissertation's handed in for marking in May); Jikes is under a
     GPL-like license, so if the IBM guys want to include MSIL as an
     official target (I've not crippled the capability to compile Java
     as well), that'd be a big step forward for OSS .NET, especially
     since it doesn't suffer from the J# limitation of JVM 1.1.4.

   - Test suite.  I've come up with a full regressive test suite for
     each section of the ECMA spec, and a corpus of Java code to be
     automatically compiled and assembled and run through mono to make 
     sure it's giving correct output.  As well as testing against the
     spec, there are some computational tests thrown in (Ackerman's 
     function, Sieve of Erathosthenes, Factorial, Quicksort, etc) -
     it'll be useful to see if any of my changes slow these down.
     I've knocked up a Perl/gtk2 frontend for the test suite, just 
     because having a black screen full of scrolling compiler output 
     isn't the best way to present your successes. ;-)

Right, I've written far too much already.  Apologies for the off-topic
post; in an attempt to make it more on-topic, I'd like to thank everyone
responsible for recent vast improvements to mono's ilasm - they've been
a great help.  :)

Cheers,

- Chris.
-- 
$a="printf.net";  Chris Ball | chris@void.$a | www.$a | finger: chris@$a
|  Q: How many OO Perl programmers does it take to change a light bulb?
|  A: HASH(0x870bf8)                     -- Tim Sweetman, on london-pm.