Hacker News new | past | comments | ask | show | jobs | submit login
LLILC – LLVM-Based Compiler for .NET CoreCLR (github.com/dotnet)
220 points by mjsabby on April 13, 2015 | hide | past | favorite | 43 comments



Mailing list post: http://lists.cs.uiuc.edu/pipermail/llvmdev/2015-April/084459...

And also check out LLVMSharp -- http://www.llvmsharp.org which gives LLVM access to .NET

Disclaimer: I'm involved in both projects.


I'm not a .NET user (yet) and have found the readme to be somewhat cryptic:

> LLILC is an LLVM based MSIL Compiler - we pronounce it 'lilac' - with a goal of producing a set of cross-platform .NET code generation tools. Today LLILC is being developed against dotnet/CoreCLR for use as a JIT, but an ahead of time (AOT) compiler is planned for the future.

The mailing list post is a bit clearer to my mind, and I'm now rewording the above in "layman's language" as follows, but I may still be wrong (please correct me):

"Today, LLILC is a modified version of CoreCLR (= .NET Core, which is the part of .NET which was open sourced by Microsoft in November 2014) where the code generation backend is replaced with LLVM (but still working as a JIT). We're also planning to implement an ahead of time compiler for MSIL (= CIL, which is what the .NET bytecode is a form of), also using LLVM, but then perhaps forgoing the use of (most of?) CoreCLR. The aim is also to make it possible to use the wide array of tools available in the LLVM ecosystem, such as code analyzers."


Just because I was confused and others might be as well:

LLVMSharp provides C# bindings to LLVM's C interface. It does not allow LLVM projects to use dotnet code.


This is somewhat similar to IL2CPP from Unity[1] with AOT is currently what is used on iOS and WebGL builds. It is still buggy and has been in development for a few years or over a year, but it does essentially the same thing, take IL and port it to C++ per platform with AOT compiling. They largely did this to go around Mono licensing from Xamarin and the export is now C++ so there can be no platform limitations or it is minimal that C++ tech would be blocked by Apple for any reason for instance like they did with JIT and Flash etc.

Maybe when this has AOT it can also be useable in the same way Unity IL2CPP and Xamarin Mono are used.

[1] http://blogs.unity3d.com/2014/05/20/the-future-of-scripting-...


I hope it gives the IL2CPP guys some incentive to go faster. I've been waiting so long for Unity to support a more modern .NET, and to get faster


I wonder how this will affect Mono/Xamarian, given that LLILC has commited to providing an AoT compiler. It would nice to see a CLR frontend for LLVM that cooperates more closely with LLVM upstream. Mono's fork of LLVM is about a 3.4k line diff (mostly EH additions, few -/+ modifications) but they don't seem to actively try to upstream much.

Edit: I gave up trying to build a Linux-x86_64 to Android-ARM cross-compiled Mono a year ago. The configure script didn't even think of handling bitness differences between host and target... The commerical Xamarian toolchain for AoT iOS compilation seems more mature than what is released in Mono.


LLILC is absolutely interested in upstreaming and in fact, at least one big change (prelim COFF support for MCJIT) is already upstreamed (http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-...) in addition to a few smaller ones.

Diffing upstream with http://github.com/Microsoft/llvm will let you track what Microsoft is currently doing in its repo.


I'm elated to hear that. I'm eager to browse the repo tomorrow. Thanks for the feedback! =)


It seems the pace of .Net improvement is moving much faster then the JVM land.

What are the chances of Enterprise switching to .Net instead of Java?


> What are the chances of Enterprise switching to .Net instead of Java?

Plenty of enterprise shops are Microsoft full-stack shops (Windows Server/.NET/SQL Server/IIS). I get the impression -- though I haven't seen systematic data -- that .NET has been making gains against JVM as an Enterprise platform.


It mostly depends on perspective. I work .Net enterprise and NEVER hear of Java - giving me the obvious false impression that it is Java that is unused. The only thing under the Sun that we really hear of is Oracle: that's one or two customers.

Both Java and .Net are viable, relevant and widespread technologies. It all depends on which segment of the market you happen to be catering to.


It just seems that Google, Twitter, Facebook or many other big Data companies will have some / many pieces of tech dependent on JVM. But I never heard anyone them using .Net


Big data isn't even analogous to enterprise. I don't even think if Google, Twitter and Facebook should be considered to be classically enterprise. However, what you say about big data is certainly true - that's not something .Net is competent at: keep in mind that doesn't make it wholly incompetent. The corollary is true: .Net does things some things really well that Java is dreadful at (e.g. last time I played with Java the UI situation was a complete joke).

That doesn't make either language/runtime bad or better than the other. Their strengths aren't static, either. They are merely different tools suited for different tasks. Both have some extremely large names using them.


The C# language has improved considerably over the years when compared to Java. It will take some time before everything is ported over, opened sourced and running on Linux however, once that happens, I wouldn't be surprised if companies start experimenting with it. It's going to take along time before anyone would really switch I think considering so much JVM is built up but as long as the performance is at least similar (better would be awesome) I don't see why people wouldn't at least toy with the idea of migrating.


Too early to say anything. IMO, it was only a few years ago that .Net felt completely dead and developers were not sure what Microsoft was going to do. This is why .Net didn't take over the Enterprise market in my opinion.

Now, that it is going to be open-source and MS is pushing it harder than it has before, it might have a good chance being used for "new projects" but I've seen MS do this before only to fall off the wagon and stop focusing on these type of stuff.

In addition, the "enterprise" market move much slower than anybody and they care about backward compatibility. It would be several years before .NET would be considered for new projects. It is in that timeframe that Microsoft needs to seriously focus on this and explain why .NET should be used instead of Java.


.NET improving faster than the JVM would be a very hard thing to measure or even estimate. There are very exciting and impressive things happening in JVM land, for example Graal and Truffle.


Except, in both of the examples you cite, .Net has had those features since day 1 ( more than 13 years now ).

I think it's pretty disingenuous to say those things are hard to measure or even estimate. Java and C# are close enough that you actually CAN measure them in a pretty useful way.

Java has been behind the curve for YEARS as compared to .Net with perhaps the exception of the cross platform aspects and the more permissive licensing.


Not sure we're talking about the same thing. To my knowledge no other ecosystem has anything close to Graal and Truffle at this point, much less "since day 1" of .NET.

The closest thing I can think of is PyPy, which like Graal+Truffle lets you write a dynamic language in a high-level way, but still get specialized JIT compilation "for free". (In PyPy you write an interpreter, in Graal+Truffle it's more declarative.)

Both PyPy and Graal+Truffle achieve state of the art performance. I'm not aware of any dynamic language on .NET coming even close to that.


As I understand it, Graal+Truffle is basically the DLR. This has been around since 2008 from Microsoft.

Both IronPython and IronRuby have used this for years.

The "Day 1" comment was specifically pointed at the read-between the lines for Graal, which is basically to create a real IL for Java instead of using the InvokeDynamic semantic that is currently envogue for Scala, Clojure, etc. .NET has had the multi-language one VM paradigm since day one.


No, Graal+Truffle, and PyPy for that matter, are light-years ahead of the DLR. That's why IronPython etc. are nowhere near the state of the art of dynamic language performance, while both the JVM and PyPy have multiple dynamic languages on them that meet that criterion.

The fundamental issue is that dynamic languages need JITs that are very aware of their internals. It's not enough to just emit some code interspersed with PICs and to add fast dynamic dispatch. You also need to speculatively compile and deoptimize in a way that is specific to each dynamic language. Without that, IronPython and other dynamic languages on .NET are often not a little slower but 10x slower than the same languages on the JVM or PyPy.


Graal is a JIT compiler done in Java, it has nothing to do with DLR.

Graal together with SubstractVM offer AOT compilation and is also being used by AMD for the GPGPU support targeted for Java 9, latest Java 10.

Truffle is more of a AST manipulation framework for nodes that can be fed into Graal for compilation.

Then there are those meta-circular JVMs like JikesRVM which are done in Java.


But SubstrateVM, Graal, Truffle, isn't ready for another few years. ( I haven't heard much since 2013.... )


Graal is being used by Project Sumatra (GPGPU) and JRuby.

Sumatra is planned for integration latest by Java 10.

There were a few Java ONE 2014 and JVM Language Summit Presentations.

JRuby: The Hard Parts, Reduction on GPUs, GPU/JVM Cooperation

http://www.oracle.com/technetwork/java/javase/community/jlss...

Ruby on Top of Graal

https://old.parleys.com/share_channel.html#play/543f88bee4b0...

Sumatra OpenJDK Project Update: Parallelize Yourself with the Stream API

https://old.parleys.com/share_channel.html#play/543fa782e4b0...


Clojure doesn't use InvokeDynamic and, AFAIK, has no plans to do so.


SPUR from Microsoft Research demonstrated slightly worse than V8 performance for JavaScript on .NET. Too bad SPUR didn't seem to go anywhere...


The precise GC support in LLVM mentioned by Microsoft is work that is being done by an employee of Azul Systems, a JVM vendor. Stuff is happening, perhaps just not as loudly.

https://github.com/dotnet/llilc/blob/master/Documentation/ll...


Not much. Unless someone rewrites all those systems where there is a JVM available.

The world of enterprise systems isn't only Mac, GNU/Linux and Windows.

Additionally the pace of .NET doesn't matter, because the enterprise is dog slow to upgrade.

We are still doing .NET 4.0, Windows Forms and targeting XP. Some of the project code was written for .NET 3.5.

On the Java side, most corporations are now slowly moving from Java 6 to Java 7 and they hardly care about any alternative JVM languages.


> Additionally the pace of .NET doesn't matter, because the enterprise is dog slow to upgrade.

In some cases they will never upgrade. I'm talking about places still running WebLogic 8 and JVM 1.4.2. Huge business critical production systems. They'll probably still run on that exact stack for the next 5 years at the very minimum. Everything new gets written in whatever the new stack is, that old stack just stays there, forever.

The strange world of mega corp enterprise IT.


It depends on what you count as JVM land, I'd say.

If you live in JVM land and value modern development you are probably already on Groovy, Gradle and Grails - where Grails imo. is ahead of the MVC4/5/6 stack...


The JVM ecosystem is far bigger than Groovy, Gradle and Grails. Think Scala and Clojure for languages, Spring and Play for frameworks, and Maven for builds. Groovy has 2 big use cases in industry:

* scripting to manipulate Java classes, for testing and 50-line scripts in Gradle, though Gradle's been opening up its API so any JVM language can use it. When Java 8 becomes more widespread, a future version of Gradle might standardize on Java lambdas and ignore use of Groovy closures in its DSL

* the MOP used by Grails, though Grails is following its namesake Rails into obscurity

Although Groovy 2 bundled a statically-typed compiler to compete with Java, virtually no-one uses it. There's far better choices for developers who want to replace Java on the JVM, such as Scala. Groovy really should've stuck to its dynamic roots and niche by adding scripting support for Scala-compiled classes instead of going into head on competition with it and Java.


I'm surprised it's hosted by the .NET Foundation. I feel the .NET Foundation operates somewhat independently from Microsoft, but there is a large alignment with what Microsoft wants. Using LLVM feels like a departure from some of the things they're working on now.

Some blog posts I have read on the MSDN Developer Tools Blogs suggested Microsoft was already working on their own AOT compiler, this statement seems to suggest LLILC has not been developed for this purpose yet. So it's an independent project?

> Today LLILC is being developed against dotnet/CoreCLR for use as a JIT, but an ahead of time (AOT) compiler is planned for the future

Which doesn't make much sense to me, unless Microsoft is planning on ditching their existing AOT work for LLVM. (Fine by me, LLVM is quite nice.)


Having multiple code generators is not mutually exclusive, and this effort does not mean MSFT is ditching any existing AOT (or for that matter JIT) compiler projects.

One of LLILC's major objective is give the community an MSIL frontend for LLVM.

This allows a JIT or an AOT compiler to take any C# program written for the .NET Core class libraries to run on any platform that CoreCLR can be ported to and that LLVM will target.


This seems like it would be an interesting alternative to il2cpp from the Unity folks as a path towards compiling C# code to run on asm.js in the browser.


very interesting :)


> Having multiple code generators is not mutually exclusive, and this effort does not mean MSFT is ditching any existing AOT (or for that matter JIT) compiler projects.

Of course not. But why spread your effort across two projects that duplicate functionality when you could focus on one?


Have a look at the FAQ: https://github.com/dotnet/llilc/wiki/LLILC-FAQ

Q: How does LLILC relate to the .NET Native work? A: .NET Native provides a broad tool-chain, targeting Windows. The LLILC AOT could be used as the compiler component of .NET Native to target other platforms.

Since LLVM can run on Windows, you could also use it as your AOT compiler for multiple platforms (including Windows) once LLILC gets there.


I'm surprised it's hosted by the .NET Foundation. I feel the .NET Foundation operates somewhat independently from Microsoft, but there is a large alignment with what Microsoft wants. Using LLVM feels like a departure from some of the things they're working on now.

Anything regarding coreclr seems to be handled with a goal of being through and through cross-platform.

Because of this tools like cmake, LLVM etc are used instead of Microsoft in-house tools. Because of this, formerly closed-source tools like MSBuild are now being made open-source.

It's a departure from how Microsoft traditionally have done things in the past, but it's perfectly aligned with where the .NET Foundation is currently going.


I've never been surprised at Microsoft attempting to solve the same or similar problem through different channels. They like to have competing projects and see which one evolves and wins... Perhaps that explains it.. Rather than say "No" to something might be the winner.


How does the GC integration work? I've heard various (bad things) about LLVM's support for integrating a GC ..


This wiki page details what LLILC will be doing to get GC Support as required by the CoreCLR:

https://github.com/dotnet/llilc/blob/master/Documentation/ll...

Andy Ayers from the LLILC team will be presenting this exact topic at the EuroLLVM developer meeting: http://llvm.org/devmtg/2015-04

I imagine the LLVM folks will put the meeting videos up on their website like they have in the past, and it would be an interesting video to watch if you're looking for GC specific details in LLILC.


llvm used to (removed with release 2.8?) include a .net msil backend -- Maybe they could add it back and go full circle -- use LLILC to load your MSIL and compile it back to... MSIL.

https://github.com/llvm-mirror/llvm/tree/svn-tags/RELEASE_27...


When will I be able to get my MVC websites running in node?


On a side note there is already the Edge project that allows NodeJS and .Net to run in the same process. So you can run Asp.Net MVC websites with NodeJS side by side. And it runs on all platforms using Mono Runtime

https://github.com/tjanczuk/edge




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: