<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Zor&#039;s Blog &#187; Mono</title>
	<atom:link href="http://xtzgzorex.wordpress.com/category/mono/feed/" rel="self" type="application/rss+xml" />
	<link>http://xtzgzorex.wordpress.com</link>
	<description>Seeing Sharp</description>
	<lastBuildDate>Sun, 27 May 2012 16:09:46 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='xtzgzorex.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Zor&#039;s Blog &#187; Mono</title>
		<link>http://xtzgzorex.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://xtzgzorex.wordpress.com/osd.xml" title="Zor&#039;s Blog" />
	<atom:link rel='hub' href='http://xtzgzorex.wordpress.com/?pushpress=hub'/>
		<item>
		<title>C#/Mono: Playing with Pointers</title>
		<link>http://xtzgzorex.wordpress.com/2012/05/05/cmono-playing-with-pointers/</link>
		<comments>http://xtzgzorex.wordpress.com/2012/05/05/cmono-playing-with-pointers/#comments</comments>
		<pubDate>Sat, 05 May 2012 14:33:22 +0000</pubDate>
		<dc:creator>XTZGZoReX</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[ILAsm]]></category>
		<category><![CDATA[Mono]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://xtzgzorex.wordpress.com/?p=835</guid>
		<description><![CDATA[I haven&#8217;t blogged in a while. Let&#8217;s fix that! So, I&#8217;ve been programming a lot in D lately, which means systems programming, which means pointers! Pointers are amazing. You can do all sorts of crazy and awesome hacks with them. C# and the .NET Framework try to abstract pointers away from us. But fear not, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xtzgzorex.wordpress.com&#038;blog=13381977&#038;post=835&#038;subd=xtzgzorex&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I haven&#8217;t blogged in a while. Let&#8217;s fix that!</p>
<p>So, I&#8217;ve been programming a lot in D lately, which means systems programming, which means pointers! Pointers are amazing. You can do all sorts of crazy and awesome hacks with them. C# and the .NET Framework try to abstract pointers away from us. But fear not, for there are ways around this safety nonsense!</p>
<p>It turns out that on Mono, you can pin an object even if it contains managed data. This makes it safe to modify an object&#8217;s internal layout even in the presence of a moving GC (well, kinda, sorta). You can&#8217;t take the address of the object, however, which means we must resort to some IL hackery.</p>
<p>Thus, the code:</p>
<pre>using System;
using System.Reflection.Emit;
using System.Runtime.InteropServices;

public unsafe delegate void PointerAction(byte* pointer);

public static class ObjectExtensions
{
    private static object _lock = new object();
    private static Func _addrOf;

    private static IntPtr AddressOf(object obj)
    {
        lock (_lock)
        {
            if (_addrOf == null)
            {
                var dm = new DynamicMethod(string.Empty, typeof(IntPtr), new[] { typeof(object) },
                                           typeof(ObjectExtensions), true);

                var il = dm.GetILGenerator();

                il.Emit(OpCodes.Ldarg_0);
                il.Emit(OpCodes.Conv_I);
                il.Emit(OpCodes.Ret);

                _addrOf = (Func)dm.CreateDelegate(typeof(Func));
            }
        }

        return _addrOf(obj);
    }

    public static unsafe byte* ToPointer(this object obj)
    {
        if (obj == null)
            throw new ArgumentNullException("obj");

        GCHandle handle;

        try
        {
            handle = GCHandle.Alloc(obj, GCHandleType.Pinned);

            return (byte*)AddressOf(obj).ToPointer();
        }
        finally
        {
            if (handle.IsAllocated)
                handle.Free();
        }
    }

    public static unsafe void WithPointer(this object obj, PointerAction action)
    {
        if (obj == null)
            throw new ArgumentNullException("obj");

        if (action == null)
            throw new ArgumentNullException("action");

        GCHandle handle;

        try
        {
            handle = GCHandle.Alloc(obj, GCHandleType.Pinned);

            action((byte*)AddressOf(obj).ToPointer());
        }
        finally
        {
            if (handle.IsAllocated)
                handle.Free();
        }
    }
}</pre>
<p>(Kudos to ki9a on #mono for coming up with the dynamic method IL!)</p>
<p>Now, don&#8217;t try to run that on Microsoft .NET. It will blow up.</p>
<p>Now that we can get at the internals of objects, let&#8217;s try it out:</p>
<pre>static class Program
{
    static unsafe void Main()
    {
        var str = "foo!";
        object obj = new { foo = 0, bar = (object)null }; // create an object with an int32 field and a reference field

        void* vtable = null;
        void* sync = null;
        int length = 0;
        void* chars = null;

        str.WithPointer(ptr =&gt;
        {
            vtable = *(void**)ptr;
            sync = *(void**)(ptr + sizeof(void*));
            length = *(int*)(ptr + sizeof(void*) * 2);
            chars = *(void**)(ptr + sizeof(void*) * 2 + sizeof(int));
        });

        obj.WithPointer(ptr =&gt;
        {
            *(void**)ptr = vtable;
            *(void**)(ptr + sizeof(void*)) = sync;
            *(int*)(ptr + sizeof(void*) * 2) = length;
            *(void**)(ptr + sizeof(void*) * 2 + sizeof(int)) = chars;
        });

        Console.WriteLine((string)obj); // prints "foo!"
    }
}</pre>
<p>Oh boy. Some explanation is probably in order.</p>
<p>First of all, let me explain the layout of objects in Mono. Every object has a header consisting of two machine words. The first word points to the object&#8217;s VTable, which describes its type, methods, etc. The second word holds the so-called synchronization block, which is used to implement <a href="http://msdn.microsoft.com/en-us/library/system.threading.monitor.aspx">monitors</a> (<a href="http://msdn.microsoft.com/en-us/library/c5kehkcz(v=vs.100).aspx">C# lock</a>). Now, strings have two extra fields: One 32-bit field which holds the string&#8217;s length, and one machine word field which points to the raw characters backing the string.</p>
<p>Now look at this line:</p>
<pre>object obj = new { foo = 0, bar = (object)null }; // create an object with an int32 field and a reference field</pre>
<p>What we&#8217;re doing here is creating an anonymous object with a physical structure similar to that of a string. Needless to say, whether it actually <em>is</em> similar is completely implementation-defined. The runtime may decide to reorder fields as it sees fit, and may even make the foo field a 64-bit integer on a 64-bit system. But, what&#8217;s important here is that the resulting object has enough space to hold the contents of a string object.</p>
<p>Now we get to the fun stuff:</p>
<pre>str.WithPointer(ptr =&gt;
{
    vtable = *(void**)ptr;
    sync = *(void**)(ptr + sizeof(void*));
    length = *(int*)(ptr + sizeof(void*) * 2);
    chars = *(void**)(ptr + sizeof(void*) * 2 + sizeof(int));
});</pre>
<p>Here, we read out the VTable, synchronization block, length, and character array fields of the &#8220;foo!&#8221; string object. It is (more or less) safe, since the WithPointer method ensures that the object is pinned while we do our stuff.</p>
<p>Next:</p>
<pre>obj.WithPointer(ptr =&gt;
{
    *(void**)ptr = vtable;
    *(void**)(ptr + sizeof(void*)) = sync;
    *(int*)(ptr + sizeof(void*) * 2) = length;
    *(void**)(ptr + sizeof(void*) * 2 + sizeof(int)) = chars;
});</pre>
<p>Here we assign the values we read out from the string object earlier to the object we created with a similar physical layout to that of string objects. Our anonymously-typed object is now effectively a string.</p>
<p>Let&#8217;s prove that:</p>
<pre>Console.WriteLine((string)obj); // prints "foo!"</pre>
<p>Note two things here: First, the cast succeeded. It would normally have resulted in an InvalidCastException. So far so good. Second, the call actually prints what we expect. This means that we got the physical layout of the string object right.</p>
<p>Note that all of this was done on an x86 machine running 64-bit Linux with Mono 2.10.8. I have no idea whether it will work with any other Mono version, architecture, bitness, or operating system.</p>
<p>Will this break the runtime? Possibly! Will the GC explode? Likely! Will it leak memory? Definitely!</p>
<p>Don&#8217;t do this in production code. Like, seriously, don&#8217;t.</p>
<p><strong>Update:</strong> As lupus points out, I actually got the string layout wrong! The characters of a string are embedded directly in the object. This code just turned out to work because of word size on 64-bit x86. I&#8217;ll leave it as an exercise to the reader to adapt the code to arbitrary amounts of embedded characters. ;)</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xtzgzorex.wordpress.com/835/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xtzgzorex.wordpress.com/835/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xtzgzorex.wordpress.com/835/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xtzgzorex.wordpress.com/835/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/xtzgzorex.wordpress.com/835/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/xtzgzorex.wordpress.com/835/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/xtzgzorex.wordpress.com/835/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/xtzgzorex.wordpress.com/835/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xtzgzorex.wordpress.com/835/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xtzgzorex.wordpress.com/835/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xtzgzorex.wordpress.com/835/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xtzgzorex.wordpress.com/835/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xtzgzorex.wordpress.com/835/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xtzgzorex.wordpress.com/835/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xtzgzorex.wordpress.com&#038;blog=13381977&#038;post=835&#038;subd=xtzgzorex&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xtzgzorex.wordpress.com/2012/05/05/cmono-playing-with-pointers/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/42c54d81a5ed511408e947ccd526d858?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">XTZGZoReX</media:title>
		</media:content>
	</item>
		<item>
		<title>GithubSharp with ServiceStack.Text</title>
		<link>http://xtzgzorex.wordpress.com/2012/01/30/githubsharp-with-servicestack-text/</link>
		<comments>http://xtzgzorex.wordpress.com/2012/01/30/githubsharp-with-servicestack-text/#comments</comments>
		<pubDate>Mon, 30 Jan 2012 11:05:05 +0000</pubDate>
		<dc:creator>XTZGZoReX</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Mono]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://xtzgzorex.wordpress.com/?p=815</guid>
		<description><![CDATA[At Xamarin, we&#8217;ve been using GithubSharp to access the GitHub API for some time. We ran into some issues with it, however, because the JSON serializers in .NET are buggy as hell (one had trouble deserializing a simple dictionary; another couldn&#8217;t handle large payloads). Therefore, we forked and branched the project and made it use [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xtzgzorex.wordpress.com&#038;blog=13381977&#038;post=815&#038;subd=xtzgzorex&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>At Xamarin, we&#8217;ve been using GithubSharp to access the GitHub API for some time. We ran into some issues with it, however, because the JSON serializers in .NET are buggy as hell (one had trouble deserializing a simple dictionary; another couldn&#8217;t handle large payloads). Therefore, we <a href="https://github.com/xamarin/GithubSharp/tree/servicestack">forked and branched</a> the project and made it use ServiceStack.Text, which works nicely (and has the added effect of working on Mono).</p>
<p>Note that our branch is for version 2.0 of the GitHub API; the author of GithubSharp, Erik Zaadi, is now working on GithubSharp for GitHub&#8217;s 3.0 API, using ServiceStack.Text.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xtzgzorex.wordpress.com/815/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xtzgzorex.wordpress.com/815/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xtzgzorex.wordpress.com/815/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xtzgzorex.wordpress.com/815/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/xtzgzorex.wordpress.com/815/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/xtzgzorex.wordpress.com/815/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/xtzgzorex.wordpress.com/815/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/xtzgzorex.wordpress.com/815/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xtzgzorex.wordpress.com/815/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xtzgzorex.wordpress.com/815/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xtzgzorex.wordpress.com/815/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xtzgzorex.wordpress.com/815/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xtzgzorex.wordpress.com/815/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xtzgzorex.wordpress.com/815/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xtzgzorex.wordpress.com&#038;blog=13381977&#038;post=815&#038;subd=xtzgzorex&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xtzgzorex.wordpress.com/2012/01/30/githubsharp-with-servicestack-text/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/42c54d81a5ed511408e947ccd526d858?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">XTZGZoReX</media:title>
		</media:content>
	</item>
		<item>
		<title>Life: Status Update</title>
		<link>http://xtzgzorex.wordpress.com/2011/09/12/life-status-update/</link>
		<comments>http://xtzgzorex.wordpress.com/2011/09/12/life-status-update/#comments</comments>
		<pubDate>Mon, 12 Sep 2011 16:59:12 +0000</pubDate>
		<dc:creator>XTZGZoReX</dc:creator>
				<category><![CDATA[Life]]></category>
		<category><![CDATA[MCI]]></category>
		<category><![CDATA[Mono]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://xtzgzorex.wordpress.com/?p=759</guid>
		<description><![CDATA[I really don&#8217;t blog about my life often, but a lot of interesting stuff has been happening lately that I&#8217;d like to share. First, I&#8217;ve just become an intern at Xamarin. I&#8217;ll be working on the documentation build system and integration into the website and the MonoDevelop IDE. I was hired after GSoC was over, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xtzgzorex.wordpress.com&#038;blog=13381977&#038;post=759&#038;subd=xtzgzorex&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I really don&#8217;t blog about my life often, but a lot of interesting stuff has been happening lately that I&#8217;d like to share.</p>
<p>First, I&#8217;ve just become an intern at <a href="http://xamarin.com/">Xamarin</a>. I&#8217;ll be working on the documentation build system and integration into the website and the MonoDevelop IDE. I was hired after GSoC was over, following a recommendation from Miguel. I&#8217;m really looking forward to working with Xamarin; it&#8217;s an awesome team of skilled hackers.</p>
<p>Second, I&#8217;ve been accepted into university, starting February 1 (at <a href="http://www.ucnorth.dk/">the UCN</a>). The Danish name for the course I&#8217;m taking is &#8220;datamatiker&#8221;. They call it computer science in English, but it&#8217;s actually much more practically oriented than that (i.e. actual software development rather than theory). I was accepted based on my ability in the software development field, as I don&#8217;t fulfill the formal requirements (yet). This means I&#8217;ll probably quit high school, as I&#8217;d rather pursue something software-related than natural sciences.</p>
<p>In other (less life-related) news, I&#8217;ve also been putting some time into writing a compiler infrastructure library. I&#8217;ll be posting more about the goals and directions of that later.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xtzgzorex.wordpress.com/759/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xtzgzorex.wordpress.com/759/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xtzgzorex.wordpress.com/759/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xtzgzorex.wordpress.com/759/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/xtzgzorex.wordpress.com/759/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/xtzgzorex.wordpress.com/759/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/xtzgzorex.wordpress.com/759/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/xtzgzorex.wordpress.com/759/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xtzgzorex.wordpress.com/759/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xtzgzorex.wordpress.com/759/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xtzgzorex.wordpress.com/759/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xtzgzorex.wordpress.com/759/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xtzgzorex.wordpress.com/759/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xtzgzorex.wordpress.com/759/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xtzgzorex.wordpress.com&#038;blog=13381977&#038;post=759&#038;subd=xtzgzorex&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xtzgzorex.wordpress.com/2011/09/12/life-status-update/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/42c54d81a5ed511408e947ccd526d858?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">XTZGZoReX</media:title>
		</media:content>
	</item>
		<item>
		<title>GSoC and the State of ILAsm</title>
		<link>http://xtzgzorex.wordpress.com/2011/08/23/gsoc-and-the-state-of-ilasm/</link>
		<comments>http://xtzgzorex.wordpress.com/2011/08/23/gsoc-and-the-state-of-ilasm/#comments</comments>
		<pubDate>Tue, 23 Aug 2011 17:59:53 +0000</pubDate>
		<dc:creator>XTZGZoReX</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[GSoC]]></category>
		<category><![CDATA[ILAsm]]></category>
		<category><![CDATA[Mono]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://xtzgzorex.wordpress.com/?p=735</guid>
		<description><![CDATA[GSoC 2011 is now officially over, and I figure I should write some sort of status post. First of all, the project is not completely done. I had anticipated this early on, and discussed with JB which parts I should focus on for the deadline. I did get a fair bit done for the deadline, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xtzgzorex.wordpress.com&#038;blog=13381977&#038;post=735&#038;subd=xtzgzorex&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>GSoC 2011 is now officially over, and I figure I should write some sort of status post.</p>
<p>First of all, the project is not completely done. I had anticipated this early on, and discussed with JB which parts I should focus on for the deadline. I did get a fair bit done for the deadline, but I wouldn&#8217;t quite say it&#8217;s ready for production use yet. I did, however, pass the final evaluation, as JB agreed to let me finish the project outside of GSoC (which I fully intend to do).</p>
<p>The project actually ended up being more involved than originally planned. The idea was to simply swap the PEAPI back end with Cecil, but I quickly realized that this was not quite as trivial as it seemed back then. I ended up ripping out the old code generation completely, emptying the code of every last parser production, updating the parser to .NET 4.0, and finally, adding the Cecil code generation back end in. You might think that all of this would have taken most of the entire GSoC period, but a lot of time was spent on spec reading too, not to mention figuring out weird quirks and corner cases in the Microsoft implementation of ILAsm. It&#8217;s scary just how much of the ILAsm language is poorly documented or not documented at all.</p>
<p>I&#8217;d like to extend my thanks to everyone in #cecil @ irc.gnome.org for helping me understand ILAsm, CIL, and the CLI in general.</p>
<p>I&#8217;ve also made some progress on the ILDasm front. It&#8217;s still missing a lot of features, but it does disassemble types and methods decently at this point. I&#8217;ll work more on it later; ILAsm comes first.</p>
<p>I recently switched ILAsm to a deferred type resolution model. This was JB&#8217;s idea, as a way to solve <a href="http://xtzgzorex.wordpress.com/2011/07/19/ilasm-the-mono-implementation/">the generic parameter issue I blogged about earlier</a>, and it&#8217;s worked nicely so far. This was probably the last major issue in the new ILAsm, so I expect to be doing more ILDasm work soon (there are only a couple of known ILAsm issues left).</p>
<p>During GSoC I also wrote a command line interface to the Mono soft debugger (SDB). It&#8217;s available <a href="https://github.com/alexrp/sdb-cli">here</a>. I wrote it primarily because using MonoDevelop (which was the only existing interface to SDB at the time) as a debugger for a command line application was not very convenient. This debugger also has a few cool features such as decompilation of code with no source code (through ICSharpCode.Decompiler).</p>
<p>Overall, it&#8217;s been a very fun and educational program for me. I now know a lot of things about the CLI that I didn&#8217;t have the slightest clue about before, and I finally managed to contribute something really significant to Mono. Working with JB and the Mono community has been an awesome experience, as everyone&#8217;s very helpful and easily approachable. I would definitely do this again if I get the chance.</p>
<p>I&#8217;ll probably make a final blog post whenever I get this entire project merged into mainline Mono.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xtzgzorex.wordpress.com/735/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xtzgzorex.wordpress.com/735/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xtzgzorex.wordpress.com/735/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xtzgzorex.wordpress.com/735/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/xtzgzorex.wordpress.com/735/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/xtzgzorex.wordpress.com/735/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/xtzgzorex.wordpress.com/735/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/xtzgzorex.wordpress.com/735/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xtzgzorex.wordpress.com/735/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xtzgzorex.wordpress.com/735/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xtzgzorex.wordpress.com/735/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xtzgzorex.wordpress.com/735/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xtzgzorex.wordpress.com/735/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xtzgzorex.wordpress.com/735/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xtzgzorex.wordpress.com&#038;blog=13381977&#038;post=735&#038;subd=xtzgzorex&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xtzgzorex.wordpress.com/2011/08/23/gsoc-and-the-state-of-ilasm/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/42c54d81a5ed511408e947ccd526d858?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">XTZGZoReX</media:title>
		</media:content>
	</item>
		<item>
		<title>ILAsm: The Mono Implementation</title>
		<link>http://xtzgzorex.wordpress.com/2011/07/19/ilasm-the-mono-implementation/</link>
		<comments>http://xtzgzorex.wordpress.com/2011/07/19/ilasm-the-mono-implementation/#comments</comments>
		<pubDate>Tue, 19 Jul 2011 11:06:37 +0000</pubDate>
		<dc:creator>XTZGZoReX</dc:creator>
				<category><![CDATA[GSoC]]></category>
		<category><![CDATA[ILAsm]]></category>
		<category><![CDATA[Mono]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://xtzgzorex.wordpress.com/?p=704</guid>
		<description><![CDATA[This time, I&#8217;ll write about some issues I faced during development of Mono&#8217;s ILAsm and how I got around them. I&#8217;ve had to make several changes that make Mono&#8217;s ILAsm stricter than MS.NET&#8217;s or outright incompatible. First of all, we have generic parameters. In MS.NET&#8217;s ILAsm, !0 and !!0 are simply emitted as VAR 0 [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xtzgzorex.wordpress.com&#038;blog=13381977&#038;post=704&#038;subd=xtzgzorex&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This time, I&#8217;ll write about some issues I faced during development of Mono&#8217;s ILAsm and how I got around them. I&#8217;ve had to make several changes that make Mono&#8217;s ILAsm stricter than MS.NET&#8217;s or outright incompatible.</p>
<p>First of all, we have generic parameters. In MS.NET&#8217;s ILAsm, !0 and !!0 are simply emitted as VAR 0 and MVAR 0 in the metadata, meaning that you could do something like:</p>
<pre>.method public static !!0 Foo(!!1 bar)
{
    ldarg bar
    ret
}</pre>
<p>Even though !!1 refers to a generic parameter that does not exist, MS.NET&#8217;s ILAsm will gladly emit it, and not even warn you. Due to an API &#8220;limitation&#8221; in Cecil, Mono&#8217;s ILAsm cannot do this. All GenericParameter objects must have an owner (i.e. the type or method definition/reference) and must be contained in that owner&#8217;s GenericParameters collection at the correct index. Therefore, Mono&#8217;s ILAsm would throw an error for the above code, since !!0 is out of bounds. This is a slightly annoying incompatibility, but there&#8217;s not much I can do about it other than patching Cecil. That&#8217;s only going to happen, though, if it won&#8217;t cause API breaks for version 1.0.</p>
<p>Second, properties like .file alignment, .imagebase, and .stackreserve aren&#8217;t fully supported. Cecil currently has no way of setting these on a module. ILAsm will check the values and error if they&#8217;re invalid, though.</p>
<p>Third, several native and variant types are not supported in marshal signatures. These include variant, void, syschar, decimal, date, objectref, nested struct and null, void, int64, uint64, unsigned int64, lpstr, lpwstr, safearray, hresult, carray, userdefined, record, filetime, blob, stream, storage streamed_object, stored_object, blob_object, cf, clsid, as well as pointers/references/vectors of these. The reason is that Cecil doesn&#8217;t expose any way to set these types. Either way, most of these are deprecated nowadays. All other native/variant types are supported.</p>
<p>Fourth, support for .data declarations is very limited (we actually only do a weak attempt at emulating them). Cecil has no way of emitting data constants, and they&#8217;re implementation-defined anyway. Currently, the only thing we do with them is copy them to the InitialValue property of field definitions where appropriate. This is far from correct, but it&#8217;s the best we can do. Either way, you should avoid using these declarations. They don&#8217;t make a whole lot of sense in managed land.</p>
<p>Fifth, we have no support for parsing System.Reflection-notation strings (yet). This means that things like custom marshalers aren&#8217;t supported (the syntax will simply be ignored). A type parsing API will supposedly be exposed in Cecil 1.0.</p>
<p>Sixth, support for declarative security syntax is limited. While we support the full syntax specified by the standard, we don&#8217;t support all of the syntax MS.NET&#8217;s ILAsm does (specifically, the syntax resembling verbal custom attribute initialization).</p>
<p>Seventh, exported types are unfinished because Cecil lacks a way to manipulate the File table directly, and because of the lack of a type parser.</p>
<p>Eighth, we can&#8217;t emit custom attributes on manifest resources and assembly references. This is a Cecil limitation which should be relatively easy to fix.</p>
<p>Lastly, the .vtable/.vtfixup/.vtentry directives are unsupported. Again, these will be implemented once Cecil has support for them.</p>
<p>There are some other incompatibilities, but they&#8217;re very subtle and you&#8217;re unlikely to ever encounter them. And even if you do, ILAsm will warn you.</p>
<p>Generally, the differences between the two implementations will only be encountered in obscure features that most users are highly unlikely to be using, or when attempting to use nonstandard syntax. Rule of thumb: Stay away from these things and you&#8217;re safe.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xtzgzorex.wordpress.com/704/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xtzgzorex.wordpress.com/704/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xtzgzorex.wordpress.com/704/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xtzgzorex.wordpress.com/704/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/xtzgzorex.wordpress.com/704/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/xtzgzorex.wordpress.com/704/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/xtzgzorex.wordpress.com/704/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/xtzgzorex.wordpress.com/704/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xtzgzorex.wordpress.com/704/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xtzgzorex.wordpress.com/704/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xtzgzorex.wordpress.com/704/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xtzgzorex.wordpress.com/704/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xtzgzorex.wordpress.com/704/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xtzgzorex.wordpress.com/704/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xtzgzorex.wordpress.com&#038;blog=13381977&#038;post=704&#038;subd=xtzgzorex&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xtzgzorex.wordpress.com/2011/07/19/ilasm-the-mono-implementation/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/42c54d81a5ed511408e947ccd526d858?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">XTZGZoReX</media:title>
		</media:content>
	</item>
		<item>
		<title>Managed JIT Compilation</title>
		<link>http://xtzgzorex.wordpress.com/2011/06/25/managed-jit-compilation/</link>
		<comments>http://xtzgzorex.wordpress.com/2011/06/25/managed-jit-compilation/#comments</comments>
		<pubDate>Sat, 25 Jun 2011 18:59:36 +0000</pubDate>
		<dc:creator>XTZGZoReX</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[MCI]]></category>
		<category><![CDATA[Mono]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://xtzgzorex.wordpress.com/?p=687</guid>
		<description><![CDATA[So these are some ideas I&#8217;ve thinking about for a good while, and I&#8217;m finally going to do something with them. A good while back, I blogged about how bytecode is evil. This post will explain what I intend to do with the AST idea. The project I&#8217;m working on consists of five major components: [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xtzgzorex.wordpress.com&#038;blog=13381977&#038;post=687&#038;subd=xtzgzorex&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>So these are some ideas I&#8217;ve thinking about for a good while, and I&#8217;m finally going to do something with them.</p>
<p>A good while back, I blogged about <a href="http://xtzgzorex.wordpress.com/2011/02/03/bytecode-is-evil/">how bytecode is evil</a>. This post will explain what I intend to do with the AST idea.</p>
<p>The project I&#8217;m working on consists of five major components:</p>
<ul>
<li>A new executable format consisting of binary-form ASTs</li>
<li>A managed JIT compiler</li>
<li>A new assembly-like intermediate language</li>
<li>An abstract bare-bones type system</li>
<li>An AST/assembly optimization layer</li>
</ul>
<p>The new executable format will be similar to the CIL format, but without all the PE bloat, and with one major difference: Code is stored as binary-serialized ASTs rather than bytecode. This allows easy introspection of compiled code, opening the doors for many interesting scenarios, such as translation from one language to another at runtime. I&#8217;ve chosen to call the format CAST (Compiled Abstract Syntax Trees).</p>
<p>To make the AST format actually interesting, a new JIT compiler needs to be implemented. This JIT compiler will understand the AST and operate on it for things such as optimization. For compatibility reasons, the AST will have a sort of RawCodeNode that contains plain assembly language (something similar to CIL but with registers). This is useful when one wants to emit non-AST code such as CIL/ILAsm, Java bytecode, Erlang BEAM, etc. I&#8217;ve chosen to call this JIT compiler Mono.Jit.</p>
<p>The new assembly-like intermediate language will be similar in nature to CIL. However, unlike CIL, this language will be based on registers and a stack, rather than locals and a stack. While the CIL approach is generally much prettier here, it&#8217;s less abstract and in some cases it is impossible to translate code to CIL (such as x86 machine code). I&#8217;m not sure what to call this yet, so for now, I&#8217;ll refer to it as IAL (Intermediate Assembly Language).</p>
<p>For CAST, I&#8217;ll eventually need to implement a compiler/decompiler, but for now, plans are to create a fluent API to create CAST code from .NET land. For IAL, I&#8217;ll just make a simple assembler/disassembler.</p>
<p>Now, in order for the AST to have any sort of meaning, a type system is needed. The type system in Mono.Jit is extremely simple; it supports only fields and methods on types. The JIT doesn&#8217;t need to know anything else in order to emit code. I do, however, plan to make an interface that allows giving the JIT optimization hints (such as &#8220;this type is completely immutable&#8221;, &#8220;this method makes no modification to members&#8221;, etc.). The JIT&#8217;s type system currently supports generics (types and methods), but I&#8217;m strongly contemplating delegating this to code loaders unless there is a compelling reason for the JIT to be aware of them.</p>
<p>Lastly, an optimization layer needs to be written. This layer will primarily concern itself with the AST input to the JIT, because that&#8217;s the entire point of this project. As mentioned, IAL is just a fallback for when you don&#8217;t have an AST to feed to the JIT. I don&#8217;t have any particular plans for optimization of IAL other than simple stuff like constant folding/propagation.</p>
<p>That&#8217;s it for now. More details will come as I write more code.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xtzgzorex.wordpress.com/687/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xtzgzorex.wordpress.com/687/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xtzgzorex.wordpress.com/687/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xtzgzorex.wordpress.com/687/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/xtzgzorex.wordpress.com/687/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/xtzgzorex.wordpress.com/687/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/xtzgzorex.wordpress.com/687/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/xtzgzorex.wordpress.com/687/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xtzgzorex.wordpress.com/687/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xtzgzorex.wordpress.com/687/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xtzgzorex.wordpress.com/687/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xtzgzorex.wordpress.com/687/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xtzgzorex.wordpress.com/687/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xtzgzorex.wordpress.com/687/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xtzgzorex.wordpress.com&#038;blog=13381977&#038;post=687&#038;subd=xtzgzorex&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xtzgzorex.wordpress.com/2011/06/25/managed-jit-compilation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/42c54d81a5ed511408e947ccd526d858?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">XTZGZoReX</media:title>
		</media:content>
	</item>
		<item>
		<title>ILAsm: The Microsoft Implementation</title>
		<link>http://xtzgzorex.wordpress.com/2011/06/09/ilasm-the-microsoft-implementation/</link>
		<comments>http://xtzgzorex.wordpress.com/2011/06/09/ilasm-the-microsoft-implementation/#comments</comments>
		<pubDate>Thu, 09 Jun 2011 10:09:54 +0000</pubDate>
		<dc:creator>XTZGZoReX</dc:creator>
				<category><![CDATA[GSoC]]></category>
		<category><![CDATA[ILAsm]]></category>
		<category><![CDATA[Mono]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://xtzgzorex.wordpress.com/?p=660</guid>
		<description><![CDATA[So, we&#8217;re now 3 weeks into GSoC, and I figure I should start blogging about my work. This post will be about the ILAsm standard (specified in ECMA 335) and the Microsoft implementation. There are several annoying differences and incompatibilities between the two. As part of figuring them out, I&#8217;ve been reading Expert .NET 2.0 [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xtzgzorex.wordpress.com&#038;blog=13381977&#038;post=660&#038;subd=xtzgzorex&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>So, we&#8217;re now 3 weeks into GSoC, and I figure I should start blogging about my work.</p>
<p>This post will be about the ILAsm standard (specified in ECMA 335) and the Microsoft implementation. There are several annoying differences and incompatibilities between the two. As part of figuring them out, I&#8217;ve been reading <a href="http://www.amazon.com/Expert-NET-Assembler-Serge-Lidin/dp/1590596463">Expert .NET 2.0 IL Assembler</a> and <a href="http://msdn.microsoft.com/en-us/netframework/aa569283">the Microsoft-annotated ECMA 335 standard</a>.</p>
<p>The first difference is that MS.NET&#8217;s ILAsm does not respect the unsigned modifier on integer types. This means that an unsigned int32 will in effect be treated as an int32 (signed). I&#8217;ve chosen to break compatibility with Microsoft and correctly emit an unsigned integer, primarily because I think this is an outright stupid bug. Note that you can still get an unsigned integer by using uint32 with MS.NET. The latter form is preferred, anyway.</p>
<p>Second, MS.NET does not have the platformapi keyword. Instead, you have to use the winapi keyword, which makes your ILAsm source code unportable. In Mono&#8217;s ILAsm, we support both, in order to aid portability.</p>
<p>Third, MS.NET allows #line instead of .line for specifying source line information. This seems to be for compatibility reasons. Mono&#8217;s ILAsm supports both notations.</p>
<p>Fourth, MS.NET has a bunch of directives that just don&#8217;t exist in the standard. Specifically .file alignment, .imagebase, .language, and .namespace. We support all of them, though the first two currently have no actual effect. Note that use of .namespace is considered bad practice.</p>
<p>Fifth, MS.NET&#8217;s ILAsm doesn&#8217;t use .culture for specifying culture information, but rather .locale. This is directly against the standard, and the assembler won&#8217;t even recognize .culture. Mono&#8217;s ILAsm supports both notations.</p>
<p>Sixth, the MS.NET ILAsm doesn&#8217;t require the .hash directive; if it&#8217;s not specified, the hash will automatically be computed.</p>
<p>Seventh, the MS.NET ILAsm allows using &#8220;value class&#8221; in place of &#8220;valuetype&#8221; for indicating value types. This is relatively easy to handle, and Mono&#8217;s ILAsm does so. It is, however, considered bad notation.</p>
<p>Lastly, the MS.NET ILAsm allows specifying things like calling convention, type attributes, method attributes, field attributes, parameter attributes, and so on using flags(int32) notation. I&#8217;m sure this was done for a reason, but it seems like a great way to give developers the opportunity to make their programs unportable or impossible to run at all.</p>
<p>There are a lot of other incompatibilities, but they&#8217;re less annoying and easier to work around/implement.</p>
<p>That&#8217;s it for the this post. Next time: Implementation details of Mono&#8217;s ILAsm.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xtzgzorex.wordpress.com/660/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xtzgzorex.wordpress.com/660/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xtzgzorex.wordpress.com/660/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xtzgzorex.wordpress.com/660/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/xtzgzorex.wordpress.com/660/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/xtzgzorex.wordpress.com/660/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/xtzgzorex.wordpress.com/660/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/xtzgzorex.wordpress.com/660/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xtzgzorex.wordpress.com/660/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xtzgzorex.wordpress.com/660/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xtzgzorex.wordpress.com/660/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xtzgzorex.wordpress.com/660/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xtzgzorex.wordpress.com/660/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xtzgzorex.wordpress.com/660/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xtzgzorex.wordpress.com&#038;blog=13381977&#038;post=660&#038;subd=xtzgzorex&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xtzgzorex.wordpress.com/2011/06/09/ilasm-the-microsoft-implementation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/42c54d81a5ed511408e947ccd526d858?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">XTZGZoReX</media:title>
		</media:content>
	</item>
		<item>
		<title>Mono Summer of Code</title>
		<link>http://xtzgzorex.wordpress.com/2011/04/26/mono-summer-of-code/</link>
		<comments>http://xtzgzorex.wordpress.com/2011/04/26/mono-summer-of-code/#comments</comments>
		<pubDate>Tue, 26 Apr 2011 15:36:45 +0000</pubDate>
		<dc:creator>XTZGZoReX</dc:creator>
				<category><![CDATA[GSoC]]></category>
		<category><![CDATA[Mono]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://xtzgzorex.wordpress.com/?p=641</guid>
		<description><![CDATA[Around a month ago, I turned in a GSoC 2011 proposal to rewrite Mono&#8217;s ILASM (IL assembler) to use Cecil as its code generation back end, as well as write a managed ILDASM (IL disassembler), as Mono&#8217;s current monodis is written in C and relies greatly on the runtime itself. Yesterday, I received word that [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xtzgzorex.wordpress.com&#038;blog=13381977&#038;post=641&#038;subd=xtzgzorex&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Around a month ago, I turned in a <a href="http://code.google.com/soc/">GSoC</a> 2011 <a href="http://www.google-melange.com/gsoc/proposal/review/google/gsoc2011/xtzgzorex/1">proposal</a> to rewrite Mono&#8217;s ILASM (IL assembler) to use Cecil as its code generation back end, as well as write a managed ILDASM (IL disassembler), as Mono&#8217;s current monodis is written in C and relies greatly on the runtime itself. Yesterday, I received word that the proposal has been accepted, and that I&#8217;m going to participate in GSoC!</p>
<p>My friend, <a href="https://github.com/WolfgangSt">Wolfgang Steffens</a>, who&#8217;s the primary developer on SL#, also had <a href="http://www.google-melange.com/gsoc/project/google/gsoc2011/wolfgangst/20001">a GSoC project</a> accepted, which seeks to incorporate SL# in the Axiom game engine. This would be a great way for us to draw more attention to the library, and also makes shader development for Axiom users much easier.</p>
<p>There are a lot of other interesting projects going on with Mono this year &#8211; check them out <a href="http://www.google-melange.com/gsoc/org/google/gsoc2011/mono">here</a>.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xtzgzorex.wordpress.com/641/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xtzgzorex.wordpress.com/641/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xtzgzorex.wordpress.com/641/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xtzgzorex.wordpress.com/641/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/xtzgzorex.wordpress.com/641/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/xtzgzorex.wordpress.com/641/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/xtzgzorex.wordpress.com/641/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/xtzgzorex.wordpress.com/641/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xtzgzorex.wordpress.com/641/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xtzgzorex.wordpress.com/641/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xtzgzorex.wordpress.com/641/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xtzgzorex.wordpress.com/641/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xtzgzorex.wordpress.com/641/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xtzgzorex.wordpress.com/641/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xtzgzorex.wordpress.com&#038;blog=13381977&#038;post=641&#038;subd=xtzgzorex&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xtzgzorex.wordpress.com/2011/04/26/mono-summer-of-code/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/42c54d81a5ed511408e947ccd526d858?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">XTZGZoReX</media:title>
		</media:content>
	</item>
		<item>
		<title>SL# and Mono</title>
		<link>http://xtzgzorex.wordpress.com/2011/04/24/sl-and-mono/</link>
		<comments>http://xtzgzorex.wordpress.com/2011/04/24/sl-and-mono/#comments</comments>
		<pubDate>Sun, 24 Apr 2011 14:26:33 +0000</pubDate>
		<dc:creator>XTZGZoReX</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Mono]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[SL#]]></category>

		<guid isPermaLink="false">http://xtzgzorex.wordpress.com/?p=634</guid>
		<description><![CDATA[It turned out that SL# 1.4 did not run on Mono as we had expected. Due to a bug in Mono&#8217;s CancellationToken that caused a new instance to be canceled by default, ICSharpCode.Decompiler didn&#8217;t actually decompile methods. This issue was seen in both Mono 2.8 and 2.10.1. A bug has been filed, and we worked [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xtzgzorex.wordpress.com&#038;blog=13381977&#038;post=634&#038;subd=xtzgzorex&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>It turned out that SL# 1.4 did not run on Mono as we had expected. Due to a bug in Mono&#8217;s CancellationToken that caused a new instance to be canceled by default, ICSharpCode.Decompiler didn&#8217;t actually decompile methods. This issue was seen in both Mono 2.8 and 2.10.1. <a href="https://bugzilla.novell.com/show_bug.cgi?id=689459">A bug has been filed</a>, and we <a href="https://github.com/IgniteInteractiveStudio/SLSharp/commit/9fe368c895d4c162a94663ec141b3974c4b09cbe#diff-1">worked around the issue</a> for now.</p>
<p>Another bug we encountered (which is only relevant for SL# master) was invalid IL generation, <a href="https://github.com/IgniteInteractiveStudio/SLSharp/commit/9fe368c895d4c162a94663ec141b3974c4b09cbe#diff-0">which has also been fixed</a>. Curiously, Microsoft&#8217;s CLR actually executed the IL correctly, even though the local variable had an incompatible type&#8230; Mono was much more helpful here, in that it threw an InvalidProgramException. As said, the latter issue is only relevant for master, not 1.4.</p>
<p>We might release a 1.4.1 package of SL# in a few days that addresses the first issue. If you don&#8217;t want to wait, grab <a href="https://github.com/IgniteInteractiveStudio/SLSharp/commit/1a9eefaeade8fd80c36ae52bb927e71ad74ffe43">this commit</a> and apply the CancellationToken workaround.</p>
<p><strong>Edit:</strong> Oh, and this seems to be my 100th blog post! Yay!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xtzgzorex.wordpress.com/634/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xtzgzorex.wordpress.com/634/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xtzgzorex.wordpress.com/634/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xtzgzorex.wordpress.com/634/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/xtzgzorex.wordpress.com/634/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/xtzgzorex.wordpress.com/634/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/xtzgzorex.wordpress.com/634/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/xtzgzorex.wordpress.com/634/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xtzgzorex.wordpress.com/634/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xtzgzorex.wordpress.com/634/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xtzgzorex.wordpress.com/634/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xtzgzorex.wordpress.com/634/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xtzgzorex.wordpress.com/634/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xtzgzorex.wordpress.com/634/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xtzgzorex.wordpress.com&#038;blog=13381977&#038;post=634&#038;subd=xtzgzorex&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xtzgzorex.wordpress.com/2011/04/24/sl-and-mono/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/42c54d81a5ed511408e947ccd526d858?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">XTZGZoReX</media:title>
		</media:content>
	</item>
		<item>
		<title>SL# 1.4 Released</title>
		<link>http://xtzgzorex.wordpress.com/2011/04/22/sl-1-4-released/</link>
		<comments>http://xtzgzorex.wordpress.com/2011/04/22/sl-1-4-released/#comments</comments>
		<pubDate>Fri, 22 Apr 2011 16:04:45 +0000</pubDate>
		<dc:creator>XTZGZoReX</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Mono]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[SL#]]></category>

		<guid isPermaLink="false">http://xtzgzorex.wordpress.com/?p=627</guid>
		<description><![CDATA[After less than a month with SL# 1.3, we&#8217;ve decided to release version 1.4. This is probably the release with the most changes that we&#8217;ve done so far: Full support for all GLSL data types (including matrices) Support for in and inout through C#&#8217;s ref and out keywords Switched to ICSharpCode.Decompiler instead of our homegrown [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xtzgzorex.wordpress.com&#038;blog=13381977&#038;post=627&#038;subd=xtzgzorex&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>After <a href="http://xtzgzorex.wordpress.com/2011/03/30/sl-1-3-released-as-open-source/">less than a month with SL# 1.3</a>, we&#8217;ve decided to release version 1.4.</p>
<p>This is probably the release with the most changes that we&#8217;ve done so far:</p>
<ul>
<li>Full support for all GLSL data types (including matrices)</li>
<li>Support for in and inout through C#&#8217;s ref and out keywords</li>
<li>Switched to ICSharpCode.Decompiler instead of our homegrown one</li>
<li>Support for many more language constructs due to switching decompiler engine</li>
<li>Support for hundreds of GLSL functions that we didn&#8217;t have before</li>
<li>Shader.DebugMode now actually works as expected</li>
<li>Better type checking/verification when translating</li>
<li>We now expose a sane standalone API (GlslTransform) for GLSL translation, should you want to use it</li>
<li>We now only ship one assembly, IIS.SLSharp.dll</li>
<li>Lots of cleanups to the public API; we no longer expose any internals</li>
<li>Lots and lots of bug fixes</li>
</ul>
<p>That&#8217;s a fairly impressive list of changes if you compare to our previous ones! We&#8217;ve been incredibly productive with SL# lately, and GitHub certainly has been a booster, with its new intuitive Issues 2.0.</p>
<p>As usual, the Git repository sits <a href="https://github.com/IgniteInteractiveStudio/SLSharp">here</a> (note that master is quite ahead of this release). Downloads can be found <a href="https://github.com/IgniteInteractiveStudio/SLSharp/downloads">here</a>, and <a href="http://www.nuget.org/List/Packages/SLSharp">the updated NuGet package has been published</a>.</p>
<p>If you run into any issues, please report them on <a href="https://github.com/IgniteInteractiveStudio/SLSharp/issues?milestone=&amp;labels=&amp;state=open">the issue tracker</a> as always.</p>
<p>Lastly, the reason we chose to release 1.4 so quickly is because we&#8217;re doing heavy work on making SL# engine-agnostic. This means that 1.4 will be the last release that depends on OpenTK. Future versions (2.0 and on) will support various engines (OpenTK, Axiom, XNA, SlimDX) as well as several languages (GLSL, HLSL, Cg) through bindings. This new architecture should also make it easier to add more native-feeling support for F# (through function quotations). This of course means that we&#8217;ll be doing massive (breaking) changes and refactoring to our API and possibly even our syntax, hence the major version bump.</p>
<p>With that said, enjoy!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xtzgzorex.wordpress.com/627/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xtzgzorex.wordpress.com/627/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xtzgzorex.wordpress.com/627/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xtzgzorex.wordpress.com/627/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/xtzgzorex.wordpress.com/627/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/xtzgzorex.wordpress.com/627/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/xtzgzorex.wordpress.com/627/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/xtzgzorex.wordpress.com/627/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xtzgzorex.wordpress.com/627/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xtzgzorex.wordpress.com/627/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xtzgzorex.wordpress.com/627/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xtzgzorex.wordpress.com/627/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xtzgzorex.wordpress.com/627/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xtzgzorex.wordpress.com/627/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xtzgzorex.wordpress.com&#038;blog=13381977&#038;post=627&#038;subd=xtzgzorex&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xtzgzorex.wordpress.com/2011/04/22/sl-1-4-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/42c54d81a5ed511408e947ccd526d858?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">XTZGZoReX</media:title>
		</media:content>
	</item>
	</channel>
</rss>
