Hi guys, first of all let me say "hello" to everyone. Its the firt message for me in this list and I'm pretty happy that I'll be able to finally start working with LLVM. I've a question for you all if you can help me: a few years ago I've implemented a simple VM for a language we're using in my company. The VM JIT compiles a simple bytecode and executes it. It works quite well, better then some well know VMs. My idea now is to try to migrate the VM to LLVM to see if I can gain something in terms of speed and extensibility. I'm totally new to LLVM, but as far as I understood thare might be two ways to add LLVM to my project: - generate IR from my complier; - build a VM that converts at runtime my bytecode to IR and executes it; I largely prefer the second option because it would be great if I can continue to use to old programs without having to recompile them. Which approach do you suggest ? are there any alternatives ? Gabriele
On Apr 4, 2009, at 1:20 AM, Gabriele Farina wrote:> Which approach do you suggest ? are there any alternatives ?My take, do the second one first, gain some experience and have some fun. You can use this to double check the performance and suitability. But mid-term, I'd say, do both. This allows you to compare the performance of each solution against the other, compile time, compile time memory pressure, run time and run time memory usage. You're then in a better position to decide which path suits what usage styles you have. Long term, you can then see if it makes sense to trim a solution out.
On Saturday 04 April 2009 09:20:21 Gabriele Farina wrote:> - generate IR from my complier; > - build a VM that converts at runtime my bytecode to IR and executes it; > > I largely prefer the second option because it would be great if I can > continue to use to old programs without having to recompile them. > > Which approach do you suggest ? are there any alternatives ?I've done something similar with HLVM, albeit for a new VM that uses a new representation. I found the combination of OCaml and LLVM to work extremely well. OCaml makes it very easy to manipulate programs and its LLVM bindings make it very easy to JIT compile and execute native code. My entire VM (including GC) is only 1kLOC. -- Dr Jon Harrop, Flying Frog Consultancy Ltd. http://www.ffconsultancy.com/?e
Hi Jon, I've read your articles about HLVM, and that was one of the reasons that convinced me to try out LLVM. Actually my VM has been implemented in C++, but as long as it is not extremely complex, I might port it to OCaml that sounds more compact for this kind of programs. Did you find any significant performance loss when using OCaml over C++ ? Runtime performance is quite important in my situation. Gabriele Il giorno 04/apr/09, alle ore 19:46, Jon Harrop ha scritto:> On Saturday 04 April 2009 09:20:21 Gabriele Farina wrote: >> - generate IR from my complier; >> - build a VM that converts at runtime my bytecode to IR and >> executes it; >> >> I largely prefer the second option because it would be great if I can >> continue to use to old programs without having to recompile them. >> >> Which approach do you suggest ? are there any alternatives ? > > I've done something similar with HLVM, albeit for a new VM that uses > a new > representation. I found the combination of OCaml and LLVM to work > extremely > well. OCaml makes it very easy to manipulate programs and its LLVM > bindings > make it very easy to JIT compile and execute native code. My entire VM > (including GC) is only 1kLOC. > > -- > Dr Jon Harrop, Flying Frog Consultancy Ltd. > http://www.ffconsultancy.com/?e > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Hi Mike, thanks for the suggestion. Do you know if there are any articles around that explains how to use LLVM to build a VM that should work like mine ? I've read something around (mostly source code) but a good article/doc will be perfect Gabriele Il giorno 04/apr/09, alle ore 19:23, Mike Stump ha scritto:> On Apr 4, 2009, at 1:20 AM, Gabriele Farina wrote: >> Which approach do you suggest ? are there any alternatives ? > > My take, do the second one first, gain some experience and have some > fun. You can use this to double check the performance and > suitability. But mid-term, I'd say, do both. This allows you to > compare the performance of each solution against the other, compile > time, compile time memory pressure, run time and run time memory > usage. You're then in a better position to decide which path suits > what usage styles you have. Long term, you can then see if it makes > sense to trim a solution out. > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev