New. NET interpreter – Mono has arrived


Mono has improved its instant compiler and static compiler through a new way of running code.

In 2001, when the Mono project officially began, the Mono development team wrote an interpreter for the. NET instruction set to boot a self-hosted. NET development environment on Linux.

It was thought that the interpreter was just a temporary tool that could be used when building a Just-in-Time (JIT) compiler. The mint and mono remain in synchronization until the JIT engine can be ported to all supported platforms.

When generics are introduced, the engineering cost of retaining both interpreters and JIT engines becomes too high to be worthwhile, so the interpreter is removed.

The full static compilation of. NET code will be introduced later. This is also the introduction of a technology that prohibits the generation of dynamic code by the target platform. IOS is the main driver of this, opening the door for Mono to run on games like PlayStation and Xbox.

The main disadvantage of full static compilation is that every time the code is updated, a brand new executable must be created. This is a slow process, not suitable for the interactive development of practice.

For example, some game developers like to adjust their game code without triggering a complete recompile. Static compilation makes this situation impractical, so they embed scripting language in game code to quickly iterate and adjust.

The lack of dynamic capabilities in. NET also hinders the use of. NET as a teaching or prototype development tool in some environments. Some tools, such as Xamarin Workbooks or simple scripts, cannot use the. NET language and have to resort to other solutions on the platform.

Frank Krueger needed such an environment on iOS when he built the Continuous IDE, so he wrote his own. NET interpreter with F # so that he could have a complete. NET development environment on the iPad.

In order to solve these problems and support some internal Microsoft products, Mono interpreter was welcomed back.

New Mono interpreter

Now Mono’s old interpreter is back, and its support for. NET has been upgraded, along with generics, to run. NET, which is now officially available in 2017. Mono will then add support for hybrid mode execution.

Mono now runs on Web Assembly in one way (the other is static compilation using LLVM).

Interpreter is now an important part of Mono, which has passed most of the tests of a large number of test suites. Now you can use it when building Mono from source code, as follows:

$ mono --interpreter yourassembly.exe

Hybrid mode execution

Despite the maturity of independent interpreters, the Mono development team is currently developing a configuration that can mix interpreted code with statically compiled or instantly compiled code, called hybrid mode execution.

For platforms like iOS, PlayStation and Xbox, hybrid mode execution means that you can pre-compile core libraries or core applications and still support dynamic loading and execution of code. While having the advantage of using LLVM to optimize all core libraries, it still has the flexibility to run some dynamic code.

This will allow game developers to prototype, experiment, and adjust game code on their systems in. NET without having to recompile the application.

This will open the door to the design of scriptable applications on devices using. NET language.

Future work

The Mono development team is expanding the interpreter’s capabilities to handle various interesting scenarios. Here are some current projects:

  • Improving static compilation of Mono

Mono’s full AOT compiled version does not have System. Reflection. Emit, which has several uses.

The System. Linq. Expressions API has been widely used in many advanced scenarios, such as entity frameworks or users parsing expressions into expression trees using C # compilers. You may have seen code in the following scenarios:

Expression sum = a + b;
var adder = sum.Compile ( );
adder ( );

In a complete AOT scenario, both the way to design an Entity Framework and the above work are integrated into the interpreter through the Expression class above. Although this expression interpreter has limitations, it is also a very large interpreter.

By enabling the System. Reflection. Emit interpreter, you can remove a lot of code.

This also enables scripting languages built for. NET to work in static compiled environments such as IronPython, IronRuby and IronScheme.

To do this, the Mono development team is completing mixed mode execution. This means that the interpreted code complements the existing statically compiled. NET code.

  • Better isolation

Previously, the hot loading problem for developers when deploying apps was not solved. The Mono development team is completing support for AppDomain to enable this solution.

  • Mixed mode options are being studied

The Mono development team found that programs interpreted by interpreters run faster than JIT engines.

So we intend to study hybrid execution patterns, or layered compilation. Interpreters can be allowed to execute performance-insensitive code, such as static constructors or other initialized code that can only run once, in order to reduce memory usage, code usage and execution time.

Another solution is to run the code in interpretive mode, if it exceeds a certain threshold, then switch to the JIT compilation implementation of the method, or use attributes to annotate the problems encountered and the methods that are not worth optimizing.

Mono Download Address:…

Link to the original text:…

Reproduced from: Vineyard Control

About Grape City

Founded in 1980, Vineyard is the world’s largest control provider. It is the world’s leading provider of customized tools, business reports and business intelligence solutions for enterprises, serving more than 75% of Fortune 500 companies worldwide. Vineyard established R&D center in China in 1988. In the process of global product R&D, Vineyard continuously adapts to the local needs of the Chinese market, and provides excellent software tools and consulting services for software enterprises and industry informatization.

Recommended Today

JS generate guid method

JS generate guid method Globally unique identification(GUID) is an algorithm generatedBinaryCount Reg128 bitsNumber ofidentifier , GUID is mainly used in networks or systems with multiple nodes and computers. Ideally, any computational geometry computer cluster will not generate two identical guids, and the total number of guids is2^128In theory, it is difficult to make two […]