Hello, Hugh!
| You have put ocaml->haxe converter on hold, and decided to directly write a LLVM backend?
My first trick is to generate IR binaries similar to Java .jar/.class via
gennative.ml,
and load them into toolchain (which can 1) execute (jit and non-jit) or 2) transpile them (to C)).
--- UPDATE BEGIN
I had to re-read your questions! :) Misunderstood at begin! Other info is still relevant to read, anyway.
Okay, the basic idea is the "environment coherency".
| My first trick is to generate IR binaries similar to Java .jar/.class via
gennative.mlThis allows to effectively compile any Haxe code to the compiler-indepedent form,
which we can then run in same VM we run our MACROCODE yeah!
So we achieve near-zero overhead of interopability of macro with compiler itself.
I was going to use LuaJIT for this, but it is..slow (to fully emulate Haxe) and abandoned (nobody fully understants how LuaJIT works, lol)..yup. Okay, you can read the rest of my answer :)
Thanks for your interest!
--- UPDATE END
| The idea being that this backend would then #1 run macros faster
I think it is reasonable to provide bindings to JITted VM written in C. I dont think this will slow down codegeneration.
But as a considerable simplification to overall maintenance of VM (only single version of VM, not "VM in C++" and "VM in OCaml", like with Neko).
--- UPDATE BEGIN
I meant if you add the LLVM JIT to the existing OCaml compiler.
--- UPDATE END
| and #2 produce executables in its own right?
The problem is that 1) Apple disallows direct assembles (uses own bitcode that takes only C/C++/ObjC/Swift) and 2) some tech limitations (like Clang has no good linker on windows, linkers themself are too big to distribute with Haxe, etc) moved me to the decision of outputting the C language as a final IR, with special optimizations, and then compile with GCC\Clang\Emscripten\etc.
BUT
User can use JITted VM instead of pre-compiled executable (like Neko).
So we have both VM and C options, no direct executables, I dont see the real-deal of this feature.
| While it is true that llvm can generate "ultimately" fast code, I think haxe performance is going to be more about how you handle Dynamic, interface inheritance, GC and a few other features.
This all... no, I mean, really ARE the problems which aims LLVM. I remember you had used SLJIT, but LLVM proides so much possibilities in runtime optimizations, so *Haxe essentially may become to be a language **without** of Dynamic or Interfaces overhead*. I studied how LuaJIT solves this, and how this is done in LLVM-based JavaScript interpreters. Basically if done right, LLVM can on-the-fly patch pointers in memory, so even v-tables lookups may be avoided.
And I event didnt started to talk about mix of *custom*+builtin optimization passes, which may outperform current analyzer in lowlevel, and I beleave high/medium level stuff.
| It is also quite a big dependency - possibly in the order of the JVM? If you had haxe-in-haxe, the JVM would be the easiest way to get JIT macros.
I see that Haxe is more like C++, than Java-like kind of language.
You can open Haxe Java std, and see how much tricks it requires to properly emulate Haxe atop JVM.
And... This is out of scope of my project: use native tools to generate and run native stuff.
Oh, yeah, Hugh! To not be proofless! You know, I tried to write some high performance code in Haxe utilizing Neko, V8, Mono and HXCPP.
HXCPP was 100 times faster of all of them! And when I added C-specific magic, it became ultimate!
Totally impossible with any of other runtimes.
| If I added JIT to cppia, then I think hxcpp would be the smallest/lowest dependency way to get JIT macros - again assuming haxe-in-haxe.
"Just add JIT" gives you no benefits, I think. You can eventually replace CPPIA with current LuaJIT target, which we develop with Justin and Simon, and you will see that LuaJIT will be much faster then the CPPIA.
I havent tested myslef, and LuaJIT target requires some optimisations for now, but you can test yourself and tell me results! would be great to see them!
If you will investigate how Make Pall implemented interpreter in LuaJIT, you ll be shocked. And even more shocked about JIT. This all requires many years of investiment, but we can just use LLVM, and deal with it.
понедельник, 8 февраля 2016 г. пользователь Hugh написал: