cmake-js/fastcall

Fast-FFI is coming

Opened this issue · 3 comments

jjrv commented

Looks like V8 will soon have native FFI support (FFI calls will be JIT-compiled with the rest of the code like LuaJIT does). For now the relevant npm package Github repository is empty (lots of people from Google are watching it). Thought you might want to prepare or collaborate with them.

In some cases it may even be faster than NAN-based native modules (in theory, an FFI call to a really simple external C function could be JIT-compiled to just a call opcode with numbers already in registers just pushed to the stack as needed).

jjrv commented

References:

https://github.com/nodejs/api/blob/master/ffi/FFI%20presentation%20%40%20VM%20summit.pdf

JIT generated bindings can be as fast as the current v8 marshalling approach in most scenarios, and may be faster on some scenarios.

https://docs.google.com/document/d/1D7-RBkuJiakADIWXOBVNyb6FNSXdoE3XIEXZ1axq97Q

Next steps:

  • V8 to publish branch with Fast FFI implementation.

More on this:

https://medium.com/@nodejs/ibm-intel-microsoft-mozilla-and-nodesource-join-forces-on-node-js-48e21ffb697d#.6994az45c

The good new is that fastcall's C++ code is a very simple one, and porting it from Nan to NAPI would be fair easy.