ircmaxell / php-compiler

A compiler. For PHP

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

LLVM?

driusan opened this issue · comments

From the README it seems that this project is based on gccjit. I'm not sure if this is the right place to ask, but I'm curious why that approach was taken instead of mapping the language semantics to LLVM IR and using an LLVM-based JIT. (It seems to me that LLVM IR is more mature and has more documentation available online which make it slightly more approachable.)

That's exactly the direction the project has moved in the past few weeks. I need to update the readme, but the code is 95% ported to LLVM today :)

As far as why u chose libgccjit in the first place, it was mainly due to LLVM being quite daunting and libgccjit having way better docs. But looking at performance and error handling, it is clear that LLVM is the way forward.

In that case, is the project still going: AST -> Opcodes -> LLVM IR or does it go directly AST -> LLVM IR? The main benefit I see of going through the opcode step is that it's easier to do a jit, but with PHP adding its own jit the aot compilation seems to be the main benefit of this project.

Also, is there a list of low-hanging fruit that someone can try tackling to help with this project? (Related to #9, I guess)

So, definitely open for discussion, but I do believe that it should still target a VM first (so include an opcode step). This is primarily due to my suspicion that there's going to be a lot of code that while is possible to compile AOT, will not be efficient. So for those cases, a VM with a JIT compiler would work best I think... And if we can re-use said JIT without the runtime type info to AOT, then that seems the best of both worlds...

As far as low-hanging fruit, some of what you've been doing definitely counts. I do want to add some documentation around stdlib and extensions, so that others can start there.

That makes sense to me.. (it's also easier to test with bin/vm.php, since from what I can tell your php-llvm package has very specific LLVM version requirements and needs either LLVM4 or LLVM9.)

For now it's LLVM4, but it's on my list to target 4, 6, 8 and 9, and auto-select between them at runtime based on what .so files it can find.

I'll open an issue there for that.