koffi 2.5.16 → 2.5.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/build/koffi/darwin_arm64/koffi.node +0 -0
- package/build/koffi/darwin_x64/koffi.node +0 -0
- package/build/koffi/freebsd_arm64/koffi.node +0 -0
- package/build/koffi/freebsd_ia32/koffi.node +0 -0
- package/build/koffi/freebsd_x64/koffi.node +0 -0
- package/build/koffi/linux_arm32hf/koffi.node +0 -0
- package/build/koffi/linux_arm64/koffi.node +0 -0
- package/build/koffi/linux_ia32/koffi.node +0 -0
- package/build/koffi/linux_riscv64hf64/koffi.node +0 -0
- package/build/koffi/linux_x64/koffi.node +0 -0
- package/build/koffi/openbsd_ia32/koffi.node +0 -0
- package/build/koffi/openbsd_x64/koffi.node +0 -0
- package/build/koffi/win32_arm64/koffi.node +0 -0
- package/build/koffi/win32_ia32/koffi.node +0 -0
- package/build/koffi/win32_x64/koffi.node +0 -0
- package/doc/benchmarks.md +9 -9
- package/doc/start.md +1 -1
- package/package.json +2 -2
- package/src/cnoke/assets/win_delay_hook.c +12 -29
- package/src/index.js +2 -2
- package/src/koffi/examples/electron-builder/package.json +1 -1
- package/src/koffi/examples/electron-forge/package.json +1 -1
- package/src/koffi/examples/node-esbuild/package.json +1 -1
- package/src/koffi/examples/nwjs/src/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/doc/benchmarks.md
CHANGED
|
@@ -23,10 +23,10 @@ The results presented below were measured on my x86_64 Linux machine (Intel® Co
|
|
|
23
23
|
|
|
24
24
|
### rand results
|
|
25
25
|
|
|
26
|
-
This test is based around repeated calls to a simple standard C function
|
|
26
|
+
This test is based around repeated calls to a simple standard C function `rand`, and has three implementations:
|
|
27
27
|
|
|
28
|
-
- the first one is the reference, it calls
|
|
29
|
-
- the second one calls
|
|
28
|
+
- the first one is the reference, it calls rand through an N-API module, and is close to the theoretical limit of a perfect (no overhead) Node.js > C FFI implementation (pre-compiled static glue code)
|
|
29
|
+
- the second one calls rand through Koffi
|
|
30
30
|
- the third one uses the official Node.js FFI implementation, node-ffi-napi
|
|
31
31
|
|
|
32
32
|
Benchmark | Iteration time | Relative performance | Overhead
|
|
@@ -39,7 +39,7 @@ Because rand is a pretty small function, the FFI overhead is clearly visible.
|
|
|
39
39
|
|
|
40
40
|
### atoi results
|
|
41
41
|
|
|
42
|
-
This test is similar to the rand one, but it is based on atoi
|
|
42
|
+
This test is similar to the rand one, but it is based on `atoi`, which takes a string parameter. Javascript (V8) to C string conversion is relatively slow and heavy.
|
|
43
43
|
|
|
44
44
|
Benchmark | Iteration time | Relative performance | Overhead
|
|
45
45
|
------------- | -------------- | -------------------- | --------
|
|
@@ -51,7 +51,7 @@ Because atoi is a pretty small function, the FFI overhead is clearly visible.
|
|
|
51
51
|
|
|
52
52
|
### Raylib results
|
|
53
53
|
|
|
54
|
-
This benchmark uses the CPU-based image drawing functions in Raylib. The calls are much heavier than in
|
|
54
|
+
This benchmark uses the CPU-based image drawing functions in Raylib. The calls are much heavier than in previous benchmarks, thus the FFI overhead is reduced. In this implementation, Koffi is compared to:
|
|
55
55
|
|
|
56
56
|
- Baseline: Full C++ version of the code (no JS)
|
|
57
57
|
- [node-raylib](https://github.com/RobLoach/node-raylib): This is a native wrapper implemented with N-API
|
|
@@ -69,10 +69,10 @@ The results presented below were measured on my x86_64 Windows machine (Intel®
|
|
|
69
69
|
|
|
70
70
|
### rand results
|
|
71
71
|
|
|
72
|
-
This test is based around repeated calls to a simple standard C function
|
|
72
|
+
This test is based around repeated calls to a simple standard C function `rand`, and has three implementations:
|
|
73
73
|
|
|
74
|
-
- the first one is the reference, it calls
|
|
75
|
-
- the second one calls
|
|
74
|
+
- the first one is the reference, it calls rand through an N-API module, and is close to the theoretical limit of a perfect (no overhead) Node.js > C FFI implementation (pre-compiled static glue code)
|
|
75
|
+
- the second one calls rand through Koffi
|
|
76
76
|
- the third one uses the official Node.js FFI implementation, node-ffi-napi
|
|
77
77
|
|
|
78
78
|
Benchmark | Iteration time | Relative performance | Overhead
|
|
@@ -85,7 +85,7 @@ Because rand is a pretty small function, the FFI overhead is clearly visible.
|
|
|
85
85
|
|
|
86
86
|
### atoi results
|
|
87
87
|
|
|
88
|
-
This test is similar to the rand one, but it is based on atoi
|
|
88
|
+
This test is similar to the rand one, but it is based on `atoi`, which takes a string parameter. Javascript (V8) to C string conversion is relatively slow and heavy.
|
|
89
89
|
|
|
90
90
|
The results below were measured on my x86_64 Windows machine (Intel® Core™ i5-4460):
|
|
91
91
|
|
package/doc/start.md
CHANGED
|
@@ -20,7 +20,7 @@ import koffi from 'koffi';
|
|
|
20
20
|
|
|
21
21
|
## Simple examples
|
|
22
22
|
|
|
23
|
-
Below you can find
|
|
23
|
+
Below you can find two examples:
|
|
24
24
|
|
|
25
25
|
* The first one runs on Linux. The functions are declared with the C-like prototype language.
|
|
26
26
|
* The second one runs on Windows, and uses the node-ffi like syntax to declare functions.
|
package/package.json
CHANGED
|
@@ -29,41 +29,24 @@
|
|
|
29
29
|
#include <windows.h>
|
|
30
30
|
#include <delayimp.h>
|
|
31
31
|
|
|
32
|
-
static HMODULE node_dll;
|
|
33
|
-
static HMODULE nw_dll;
|
|
34
|
-
|
|
35
32
|
static FARPROC WINAPI self_exe_hook(unsigned int event, DelayLoadInfo *info)
|
|
36
33
|
{
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
if (
|
|
48
|
-
return
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
if (nw_dll) {
|
|
52
|
-
FARPROC ret = GetProcAddress(nw_dll, info->dlp.szProcName);
|
|
53
|
-
if (ret)
|
|
54
|
-
return ret;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
if (event == dliNotePreLoadLibrary && _stricmp(info->szDll, "node.exe") != 0) {
|
|
59
|
-
if (!node_dll) {
|
|
60
|
-
node_dll = GetModuleHandleA(NULL);
|
|
34
|
+
static const wchar_t *const NodeLibraries[] = {
|
|
35
|
+
L"node.dll",
|
|
36
|
+
NULL
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
if (event == dliNotePreLoadLibrary && !stricmp(info->szDll, "node.exe")) {
|
|
40
|
+
for (int i = 0; i < sizeof(NodeLibraries) / sizeof(*NodeLibraries); i++) {
|
|
41
|
+
const wchar_t *name = NodeLibraries[i];
|
|
42
|
+
HMODULE h = GetModuleHandleW(name);
|
|
43
|
+
|
|
44
|
+
if (h)
|
|
45
|
+
return (FARPROC)h;
|
|
61
46
|
}
|
|
62
|
-
return (FARPROC)node_dll;
|
|
63
47
|
}
|
|
64
48
|
|
|
65
49
|
return NULL;
|
|
66
50
|
}
|
|
67
51
|
|
|
68
52
|
const PfnDliHook __pfnDliNotifyHook2 = self_exe_hook;
|
|
69
|
-
const PfnDliHook __pfnDliFailureHook2 = self_exe_hook;
|
package/src/index.js
CHANGED
|
@@ -378,8 +378,8 @@ var require_package = __commonJS({
|
|
|
378
378
|
"build/dist/src/koffi/package.json"(exports2, module2) {
|
|
379
379
|
module2.exports = {
|
|
380
380
|
name: "koffi",
|
|
381
|
-
version: "2.5.
|
|
382
|
-
stable: "2.5.
|
|
381
|
+
version: "2.5.17",
|
|
382
|
+
stable: "2.5.17",
|
|
383
383
|
description: "Fast and simple C FFI (foreign function interface) for Node.js",
|
|
384
384
|
keywords: [
|
|
385
385
|
"foreign",
|