Merge: Light FFI for the interpreter
authorJean Privat <jean@pryen.org>
Wed, 17 Jun 2015 20:14:38 +0000 (16:14 -0400)
committerJean Privat <jean@pryen.org>
Wed, 17 Jun 2015 20:14:38 +0000 (16:14 -0400)
commit5cf88d269fd52410da10510d09db2229416d29c2
tree081243b2223db50cf07b36a1b968b4e261f79446
parent05653379cb6b81baabc6028594dae6bfdb4a23cb
parentb9eb3de926e8464a1f9d0328598361a038153edc
Merge: Light FFI for the interpreter

Intro an FFI for the interpreter. This is a first draft/proof of concept to support the light FFI and few more features, more work is needed to implement the full FFI and support for other languages.

When the interpreter has to execute an extern method, it compiles all the extern code of the modules into an external native shared library (.so). Then the interpreter load dynamically the module, and invoke the C implementation function. The handle to the library is cached so a module isn't compiled twice per execution.

The current version is limited to the light FFI with a few more features. So there is extern methods, native type support and extern classes but it does not support callbacks.

The interpreter can now run 7 out of the 24 tests for the FFI with C.

This version was kept "simple" by design, it lacks some not-so-hard to implement features as well as portability concerns:
* Choosing the compiler (hard coded gcc) and the compile folder.
* Recompile the extern library only when the source is updated.
* Clear the compile folder.
* Support shared library format on OS X.
* Ensure call compatibility between the interpreter and extern libraries

The remaining features of the FFI, the callbacks and the other languages, require a decent amount of work but less than this PR.

Note that not a single line of code was added to the FFI folder, it uses the exact same backend as the compiler without modifications.

The design was inspired by other interpreters and VM-based languages. The JNI expect the user to manually compile the extern code into a native shared library before executing the Java code. This FFI automates the same process.

---

Please ignore the first 6 commits from #1441 and #1442.

Pull-Request: #1443
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>
Reviewed-by: Ait younes Mehdi Adel <overpex@gmail.com>
Reviewed-by: Jean Privat <jean@pryen.org>
lib/standard/math.nit
src/interpreter/naive_interpreter.nit
src/nitni/nitni_base.nit
tests/niti.skip
tests/nitvm.skip
tests/sav/niti/fixme/nitdoc_args4.res