Giter VIP home page Giter VIP logo

camllvm's Introduction

CamllVM : An LLVM backed runtime for OCaml

CamllVM allows you to run OCaml bytecode with the regular OCaml runtime, and an LLVM backend.

It is quite faster than the regular OCaml interpreter, but a lot slower than ocamlopt, OCaml's native code compiler.

The idea is to reuse ocaml's runtime and builtins, but to plug in an LLVM backed native code generator.

A word of caution

THIS IS ALPHA SOFTWARE A lot of things don't yet work. If you would be so kind, send me test cases with complete instructions on how to reproduce the case.

Building the project

What you need

  • A recent version of clang and LLVM (post 3.0 for LLVM). The one on debian unstable is working fine, but you can build it too if your distro doesn't provide recent enough packages.
  • gcc (for building the OCaml runtime). OCaml will build with clang if you feel brave enough to edit its makefiles.
  • libboost-program-options

How does the build works

CamllVM depends on a very slightly modified version of the OCaml runtime, so the first thing that will be done is to get OCaml's sources, patch them, and build this modified version of the runtime. Then CamllVM will be built. CamllVM is coded in C++, because it is LLVM's language, and more convenient in my opinion regarding use of data structures and such than pure C. It could have been done in OCaml, but it wasn't.

How to use it

CamllVM works in the same way ocamlrun does : It takes a bytecode file in, and compiles and runs the program. There is no option yet for AOT compilation, but it shouldn't be too hard to bake in.

So the workflow is something like :

ocamlc myprogram.ml
camllvm a.out

Testing

Run "python tests/runtests.py" to run all regression tests

About it

This project is a proof of concept, and a way to explore some ideas regarding compilation of OCaml bytecode. The version on the main trunk is one of such approaches, and the one that works the best, but also the simplest and slowest.

Here is the performance you can expect from it :

camllvm benchmarks

CamllVM is named "Z3" here, because it was the original name for this project.

If you like that

Mail me if you are interrested in the project : raph.amiard at gmail dot com

Follow me on twitter for updates : @notfonk

camllvm's People

Contributors

cgeoffroy avatar raph-amiard avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

han-li ohmi

camllvm's Issues

remove ocaml source code

Without considering copyright issue, we are not supposed to "hack" the ocaml source files. So they should be outside of our git repo, in a separate directory, with a clear dependency.
Some $VARIABLE could be setup before compiling to point to the corresponding directory.

Moreover, git is actually tracking some files that are generated during the ./configure step.

Use of C++11 features

Do we allow the use of C++11 features ?

This would certainly simplify some things in the code, at the expense of relying on experimental compiler features. I used some of them in my code.

My proposition is that we use the subset of features available in clang : Clang C++11 status

Since clang is already a dependency of the project (if we plan on integrating VMKit), it seems like a fair compromise.

What do you think ?

Using the Ocaml runtime

One solution would be to use the Ocaml runtime for everything it provides, including :

  • Marshaling of data, and reading of ocaml bitcode files
  • Garbage collector
  • Internal functions

The pros of this approach would be :

  • No need to reimplement marshaling and all of stdlib functions that are implemented in C

The cons:

  • Need to understand the codebase of Ocaml, which is in a different language (one more dependency)
  • One advantage of making a ZAM->LLVM compiler is that we're not dependent on the evolution of the ocaml language and codebase. This advantage disappears if we use the Ocaml runtime

Project dead? How about the GC?

Hi!

Did you ever get the OCaml GC to work with LLVM? I'm working on such a project now and I'm having some difficulties with this. Do you know any project that successfully integrated LLVM with the OCaml GC?

Regards
Olle

c++0x and vmkit

All vmkit source code does not use c++0x standard unlike Z3. I don't think we can manage to keep both as is and fix it automagically in the Makefile (Please prove me wrong!).

2 choices: we modify all of our headers or all of vmkit headers (yeah sure) to comply with only one standard.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.