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)
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>

1  2 
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

Simple merge
Simple merge
Simple merge
diff --cc tests/niti.skip
@@@ -20,5 -20,6 +20,8 @@@ hamming_numbe
  hailstone
  nitls_args
  nituml_args
 +count_the_coins
 +semordnilap_args1
+ mpi_simple
+ blink
+ input
@@@ -20,5 -20,6 +20,8 @@@ hamming_numbe
  hailstone
  nitls_args
  nituml_args
 +count_the_coins
 +semordnilap_args1
+ mpi_simple
+ blink
+ input
index 0000000,0000000..4ad3dc3
new file mode 100644 (file)
--- /dev/null
--- /dev/null
@@@ -1,0 -1,0 +1,1 @@@
++UNDEFINED