Camillo Bruni, Luc Fabresse, Stéphane Ducasse, Igor Stasenko
IWST 2013
Language-side Foreign Function Interfaces with NativeBoost IWST - - PowerPoint PPT Presentation
Language-side Foreign Function Interfaces with NativeBoost IWST 2013 Camillo Bruni, Luc Fabresse, Stphane Ducasse, Igor Stasenko Outline 1. Context 2. Existing Solutions 3. NativeBoost 4. Speed Comparison of NativeBoost with other FFIs
Camillo Bruni, Luc Fabresse, Stéphane Ducasse, Igor Stasenko
IWST 2013
IWST ¡2013 ¡@ ¡Annecy
2
IWST ¡2013 ¡@ ¡Annecy
3
LibC
Language Virtual Machine (VM)
Chipmunk
IWST ¡2013 ¡@ ¡Annecy
4
Language Virtual Machine (VM)
LibC
Chipmunk
IWST ¡2013 ¡@ ¡Annecy
Language-side Library VM Extension VM Plugin Foreign Function Interface VM-level Language-level
5
IWST ¡2013 ¡@ ¡Annecy
Language-side Library VM Extension VM Plugin Foreign Function Interface VM-level Language-level
6
IWST ¡2013 ¡@ ¡Annecy
Language-side Library VM Extension VM Plugin Foreign Function Interface VM-level Language-level
7
IWST ¡2013 ¡@ ¡Annecy
Language-side Library VM Extension VM Plugin Foreign Function Interface VM-level Language-level
8
IWST ¡2013 ¡@ ¡Annecy
9
IWST ¡2013 ¡@ ¡Annecy
10
IWST ¡2013 ¡@ ¡Annecy
11
IWST ¡2013 ¡@ ¡Annecy
12
char* getenv(const char*)
IWST ¡2013 ¡@ ¡Annecy
13
char* getenv(const char*)
IWST ¡2013 ¡@ ¡Annecy
14
Regular Smalltalk method with one argument
IWST ¡2013 ¡@ ¡Annecy
15
A pragma indicating that #primitiveNativeCall of #NativeBoost plugin should be executed when this method is executed
IWST ¡2013 ¡@ ¡Annecy
16
IWST ¡2013 ¡@ ¡Annecy
17
types annotation used to generate marshalling code
char* getenv(const char*)
IWST ¡2013 ¡@ ¡Annecy
18
the value to be passed when calling out
IWST ¡2013 ¡@ ¡Annecy
19
the external library address in which the function is looked up
IWST ¡2013 ¡@ ¡Annecy
20
IWST ¡2013 ¡@ ¡Annecy
21
uint clock(void)
0% 50% 100% 150% NativeBoost Alien C-FFI LuaJIT
IWST ¡2013 ¡@ ¡Annecy
22
0% 100% 200% 300% NativeBoost Alien C-FFI LuaJIT
int abs(int)
IWST ¡2013 ¡@ ¡Annecy
23
0% 100% 200% 300% 400% NativeBoost Alien C-FFI LuaJIT
int printf(char*,int,int)
IWST ¡2013 ¡@ ¡Annecy
24
NativeBoost Alien C-FFI LuaJIT
char* getenv( char* )
100% 300% 1000%
IWST ¡2013 ¡@ ¡Annecy
25
NativeBoost Alien C-FFI LuaJIT
char* getenv( char* )
100% 300% 1000%
IWST ¡2013 ¡@ ¡Annecy
26
NativeBoost Alien C-FFI LuaJIT
100% 400% 1000% void cairo_matrix_multiply ( cairo_matrix_t *result, cairo_matrix_t *a, cairo_matrix_t *b)
IWST ¡2013 ¡@ ¡Annecy
27
NativeBoost Alien C-FFI LuaJIT
30% 100% void qsort ( void *base, size_t nel, size_t width, int (*compare)(const void*, const void*))
n
s u p p
t e d
IWST ¡2013 ¡@ ¡Annecy
28
NBExample getenv: ‘PATH’
IWST ¡2013 ¡@ ¡Annecy
29
NBExample getenv: ‘PATH’
IWST ¡2013 ¡@ ¡Annecy
NBExample getenv: ‘PATH’
30
Virtual Machine (VM)
NativeBoost Plugin
IWST ¡2013 ¡@ ¡Annecy
NBExample getenv: ‘PATH’
31
Virtual Machine (VM)
NativeBoost Plugin
Fail if no native code associated with #getenv:
IWST ¡2013 ¡@ ¡Annecy
NBExample getenv: ‘PATH’
32
Virtual Machine (VM)
NativeBoost Plugin
IWST ¡2013 ¡@ ¡Annecy
Virtual Machine (VM)
NativeBoost Plugin
33
activate the native code associated with #getenv:
NBExample getenv: ‘PATH’
IWST ¡2013 ¡@ ¡Annecy
34
require strong VM support
IWST ¡2013 ¡@ ¡Annecy
VM Callback support?
method
35
Camillo Bruni, Luc Fabresse, Stéphane Ducasse, Igor Stasenko
IWST 2013