ADON: Adaptive Optimization for .NET
ADON is a framework for analysing and optimizing .NET executables. It was developed in 2004-5 by Kwok Cheung Yeung, while he was a postdoctoral researcher at Imperial College London. ADON is freely available under an open-source license. Development was sponsored by Microsoft through the ROTOR award scheme (although there is no actual link with the Rotor shared-source common-language infrastructure). ADON is published by Paul Kelly at Imperial College London.
Source download: here
Download for Browser binary alone (a nice way to get started): here
Features:
This is primarily designed as a library for building reflective, dynamic, self-optimizing programs.
You can also explore its capabilities using an interactive Browser - see below for screenshots
Example specialization:
Suppose we have an existing static method "Power(int x, int n)", that computes xn. This is how you can use ADON to specialise Power for n=3:
This finds the code for Power, supplies "3" as argument #1 (n), and applies the specialising transformation. The resulting MSIL code is
ldc.i4.1
ldarg [(x: System.Int32)]
mul
stloc L_0
ldloc L_0
ldarg [(x: System.Int32)]
mul
stloc L_0
ldloc L_0
ldarg [(x: System.Int32)]
mul
stloc L_0
ldloc L_0
stloc L_2
ldloc L_2
ret
(I got this using "Console.Out.Writeln(method.Instructions)"). The final line above executes the specialised code, producing the result, 23=8.
Where to find this in the distribution: The Power function is in
Examples.cs. The specialization code above is in Launcher.cs.
Example: browsing data-flow analyses:
Suppose we have a Bubblesort program, Bubblesort.exe, with static methods "sort", "min" and "max". The ADON Browser let's us interactively analyse Bubblesort's code:
Now try a simple analysis; control-flow analysis is a good one to start with:
Now if we select the conditional branch "bge" we see it has two successors:
Reaching definitions tell us which instructions produce values that might be used at each point:
This shows that the bge instruction uses two stack locations ($0 and $1), and via these, the instructions is reached by the two definitions "ldarg a" and "ldarg b".
Finally, you might try the "Inlining transformation"; select "sort(A,size)", and the call to "min", and apply the Inlining Transformation: