Tuesday, January 21, 2014

Target 0.0.2: Status 7

A milestone was reached!

With minimal changes of a Tao/Sdl/OpenGL sample, the following program is running (and is running well):


The executable has 21KB (when built with Visual Studio on release).

This achievement may motivate me to release the 0.0.2 release somewhere in March.

Wednesday, January 15, 2014

Target 0.0.2: Status 6

Bugfix update:

Switch instruction is fixed and well optimized if you use it with constants.

The code like this:
            
           var case_val = 3;
            switch (case_val)
            {
                case 1:
                    Console.WriteLine(1);
                    break;
                case 2:
                    Console.WriteLine(2);
                    break;
                case 3:
                    Console.WriteLine(3);
                    break;   
            }

Was not optimized correctly to Console.WriteLine(3); (the rest of code should be removed as dead). Right now the generated C++ code is correct and equivalent with the optimum code.

Escape analysis will allocate also arrays on stack (not the array content but the smart-pointer is not allocated at all). In the past was generated bad code for it.

Thursday, January 9, 2014

Target 0.0.2: Status 5

The progress of the code is: big refactoring.

The invoke-dynamic like comportament is a big component, and maybe it will not need to be implemented at all, but before wanting to implement it or not, the reasoning is simply that the runtime library has some difficult use-cases of matching C++ code to C# (or vice-versa). The code is improved in handling library concerns and I will work to improve it even further.

In short, the code changes are the following:

Before refactor, this were the variables were tracked by CR compiler to map a C++ code to a C# code:
  private readonly Dictionary<string, CppMethodBodyAttribute> _supportedCppMethods = new Dictionary<string, CppMethodBodyAttribute>();

private readonly Dictionary<string, MetaLinker> _supportedCilMethods = new Dictionary<string, MetaLinker>();
private readonly Dictionary<string, MethodBase> _supportedMethods = new Dictionary<string, MethodBase>();
public readonly Dictionary<Type, Type> MappedTypes = new Dictionary<Type, Type>();
public readonly Dictionary<Type, MapTypeAttribute> TypeAttribute = new Dictionary<Type, MapTypeAttribute>();
public readonly Dictionary<Type, Type> ReverseMappedTypes = new Dictionary<Type, Type>();

private readonly Dictionary<Type, List<CppMethodDefinition>> _crMethods =
            new Dictionary<Type, List<CppMethodDefinition>>();
public readonly Dictionary<string, MethodBase> UsedCppMethods = new Dictionary<string, MethodBase>();
public readonly Dictionary<string, MetaLinker> UsedCilMethods = new Dictionary<string, MetaLinker>();
public readonly Dictionary<Type, Type> UsedTypes = new Dictionary<Type, Type>();
After refactor:
         public readonly Dictionary<Type, Type> MappedTypes = new Dictionary<Type, Type>();

Sadly the today's code (soon it will be fixed) it has a bug that does not include all code (a linker bug). This cleanup also is important as it improves the way the escape analysis works and separate to make variables to contain escape data.

More fixes will come, but this is rewrite was important to improve the library level integration of C++ and C#.