4 ms·
LLVM can just put the compiled code at some place in your ram and then you can just execute it
by jcelerier 6y ago
LLVM can just put the compiled code at some place in your ram and then you can just execute it
- Const-me 6y agoProcessors need addresses of things. Look at the following code https://godbolt.org/z/PYEqKn https://godbolt.org/z/PYEqKn note the function uses another symbol, “func.counter”. Shared libraries include relocation tables https://en.wikipedia.org/wiki/Relocation_%28computing%29 https://en.wikipedia.org/wiki/Relocation_%28computing%29 with all code locations which needs patching. That’s how the OSes can load them into arbitrary locations in memory and the code will still work.
- jcelerier 6y ago... yes ? https://github.com/weliveindetail/JitFromScratch https://github.com/weliveindetail/JitFromScratch
- Const-me 6y agoInteresting, I didn’t know llvm is that flexible. Still, LLVM is a huge dependency to redistribute. And probably has many points of failure. For instance, I expect you gonna need to watch for INCLUDE and PATH environment variables when using that thing. In .NET everything is in the standard library. The generated code is even platform-independent, for no additional overhead. Here’s couple non-trivial examples: https://github.com/Const-me/ComLightInterop/blob/master/ComLight/Emit/Proxy.standard.cs https://github.com/Const-me/ComLightInterop/blob/master/ComL... https://github.com/Const-me/ComLightInterop/blob/master/ComLight/Emit/Proxy.custom.cs https://github.com/Const-me/ComLightInterop/blob/master/ComL...
- SubjectToChange 6y ago> Still, LLVM is a huge dependency to redistribute. But .NET isn't?
- Const-me 6y ago> But .NET isn't? Indeed. .NET runtime takes about 30 MB, or 50 MB if you're on Windows and need desktop components. Links there: https://dotnet.microsoft.com/download/dotnet/5.0 https://dotnet.microsoft.com/download/dotnet/5.0 clang+llvm package takes 300-400 MB, that's almost an order of magnitude difference: https://github.com/llvm/llvm-project/releases/tag/llvmorg-11.0.1 https://github.com/llvm/llvm-project/releases/tag/llvmorg-11...
- jcelerier 6y ago> clang+llvm package takes 300-400 MB, that's almost an order of magnitude difference I ship a statically compiled llvm + clang with my software and it does not add 300-400 mb to the binary at all, only something like 20-30 mb.
- Const-me 6y agoIf you’re willing to compile, ship and support custom builds of .NET runtime, gonna be less than 20-30 MB. coreclr.dll (the runtime) is 4.9 MB, clrjit.dll (JIT compiler) is 1.3 MB. The rest is mostly standard libraries, the largest piece of that is System.Private.CoreLib.dll at 9 MB. The numbers are for Win64 version of .NET 5.0.2. Another thing, for .NET apps the runtime is required anyway, the overhead for runtime code generation is zero. For C++ apps, llvm + clang (or an equivalent) is only needed on developer’s computers, not something you’d normally ship.
- jcelerier 6y ago> For C++ apps, llvm + clang (or an equivalent) is only needed on developer’s computers, not something you’d normally ship. unless you want to JIT-compile C++ code at runtime which is the original point.
- namibj 6y agoI'll give Terra[0] as an example for something relatively high-level that uses LLVM as a JIT. It can also be used as an AoT compiler with fancy macro stuff in place of the C preprocessor. [0]: http://terralang.org/ http://terralang.org/