Extending Rotor with Structural Reflection to support Dynamic Languages

Dynamic languages are becoming increasingly popular for development different kinds of applications. However, one of the main disadvantages of dynamic languages is their low performance when compared with "static" languages. The necessity of performing runtime type checking to support the dynamic features dynamic languages causes a performance penalty. This project explores a way to improve runtime performance of dynamic languages, taking advantage of the optimizations that a production virtual machine implements.

Project Aim

There has been considerable research aimed at improving the performance of virtual machines. Techniques like Just In Time (JIT) compilation or runtime adaptive optimization have made virtual machines appropriate to implement efficient applications. Commercial languages like Java or C# are good examples. In this project we apply to dynamic languages the same techniques that have made virtual machines a valid alternative to develop commercial software.

We have extended an efficient virtual machine to evaluate whether JIT compilation is a suitable technique to improve dynamic languages runtime performance. This extension supports the runtime structural reflection primitives of dynamic languages. Legacy non-reflective class based code is also supported.

We have taken the Microsoft Shared Source Common Language Infrastructure (SSCLI) (aka Rotor ), a Shared Source (source code is available to perform modifications) implementation of the CLI standard. This machine shares a very large amount of code with the commercial CLR implementation. Due to the nature of our extensions to the machine, we have named it Reflective Rotor or ЯRotor .

Project Benefits

  1. Runtime Performance. Reflective Rotor is a platform that improves runtime performance of reflective primitives of dynamic languages. When non reflective code is executed, our system runs faster because of its original design, highly optimized towards static code. When reflective code is executed, we will take advantage of the optimization techniques implemented within the original machine (JIT compilation) to improve the efficiency of reflective primitives.

  2. Language-Neutrality. Direct low-level virtual machine support of dynamic features over a highly-optimized virtual machine avoids the creation of complex and costly intermediate software layers to simulate them. It also offers different language interoperation.

  3. Semantics Extension. The object model extension makes both static and dynamic languages adaptable, providing support for both of them. This facilitates interaction between both kinds of languages.

  4. Backward compatibility. Since we extend the computational model of the virtual machine, legacy works exactly as originally intended.

  5. Small Runtime penalty on the original virtual machine performance with static languages. Our dynamic extensions will not impose large performance penalties to legacy (non reflective) programs. According to our benchmarks, if we compare our system with the original SSCLI implementation, we introduced an average runtime performance cost of only 12.10%. Our memory utilization related benchmarks shows us that the memory usage is only 4.27% more.

  6. No new IL instructions. The intermediate language is not changed. No new instructions are added, nor syntactically modified. Full compliance with the CLI standard. We only extended the semantics (not the syntax) of some IL instructions.

  7. Higher reflection level of existing languages. We enable reflective features to the existing languages and programs. Support for the reflection primitives is also provided in the base class library. Therefore, every language could access them, enabling every existing language to be reflective at runtime.