koffi 2.6.3 → 2.6.5
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 +9 -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 +26 -33
- package/doc/benchmarks.xlsx +0 -0
- package/doc/contribute.md +1 -1
- package/doc/packaging.md +4 -2
- package/doc/static/perf_linux_20231028.png +0 -0
- package/doc/static/perf_windows_20231028.png +0 -0
- package/index.js +3 -4
- package/indirect.js +3 -4
- package/package.json +2 -2
- package/src/cnoke/src/builder.js +2 -2
- package/src/core/libcc/libcc.cc +263 -177
- package/src/core/libcc/libcc.hh +31 -19
- package/src/koffi/CMakeLists.txt +9 -9
- package/src/koffi/cmake/raylib.cmake +98 -0
- package/src/koffi/cmake/sqlite.cmake +27 -0
- package/src/koffi/src/ffi.cc +50 -28
- package/src/koffi/src/ffi.hh +3 -2
- package/src/koffi/src/util.cc +8 -1
- package/src/koffi/src/win32.cc +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,15 @@
|
|
|
4
4
|
|
|
5
5
|
### Koffi 2.6
|
|
6
6
|
|
|
7
|
+
#### Koffi 2.6.5 (2023-10-28)
|
|
8
|
+
|
|
9
|
+
- Allow self-referential structs and unions
|
|
10
|
+
- Fix rare Node.js "FATAL ERROR" with some invalid types specifiers
|
|
11
|
+
|
|
12
|
+
#### Koffi 2.6.4 (2023-10-26)
|
|
13
|
+
|
|
14
|
+
- Fix build issue with recent Visual Studio versions
|
|
15
|
+
|
|
7
16
|
#### Koffi 2.6.3 (2023-10-17)
|
|
8
17
|
|
|
9
18
|
- Add indirect loading script to help some bundlers
|
|
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
|
@@ -10,8 +10,8 @@ Here is a quick overview of the execution time of Koffi calls on three benchmark
|
|
|
10
10
|
|
|
11
11
|
<table style="margin: 0 auto;">
|
|
12
12
|
<tr>
|
|
13
|
-
<td><a href="_static/
|
|
14
|
-
<td><a href="_static/
|
|
13
|
+
<td><a href="_static/perf_linux_20231028.png" target="_blank"><img src="_static/perf_linux_20231028.png" alt="Linux x86_64 performance" style="width: 350px;"/></a></td>
|
|
14
|
+
<td><a href="_static/perf_windows_20231028.png" target="_blank"><img src="_static/perf_windows_20231028.png" alt="Windows x86_64 performance" style="width: 350px;"/></a></td>
|
|
15
15
|
</tr>
|
|
16
16
|
</table>
|
|
17
17
|
|
|
@@ -31,9 +31,9 @@ This test is based around repeated calls to a simple standard C function `rand`,
|
|
|
31
31
|
|
|
32
32
|
Benchmark | Iteration time | Relative performance | Overhead
|
|
33
33
|
------------- | -------------- | -------------------- | --------
|
|
34
|
-
rand_napi |
|
|
35
|
-
rand_koffi |
|
|
36
|
-
rand_node_ffi |
|
|
34
|
+
rand_napi | 700 ns | x1.00 | (ref)
|
|
35
|
+
rand_koffi | 1152 ns | x0.61 | +64%
|
|
36
|
+
rand_node_ffi | 32750 ns | x0.02 | +4576%
|
|
37
37
|
|
|
38
38
|
Because rand is a pretty small function, the FFI overhead is clearly visible.
|
|
39
39
|
|
|
@@ -43,9 +43,9 @@ This test is similar to the rand one, but it is based on `atoi`, which takes a s
|
|
|
43
43
|
|
|
44
44
|
Benchmark | Iteration time | Relative performance | Overhead
|
|
45
45
|
------------- | -------------- | -------------------- | --------
|
|
46
|
-
atoi_napi |
|
|
47
|
-
atoi_koffi |
|
|
48
|
-
atoi_node_ffi |
|
|
46
|
+
atoi_napi | 1028 ns | x1.00 | (ref)
|
|
47
|
+
atoi_koffi | 1730 ns | x0.59 | +68%
|
|
48
|
+
atoi_node_ffi | 121670 ns | x0.008 | +11738%
|
|
49
49
|
|
|
50
50
|
Because atoi is a pretty small function, the FFI overhead is clearly visible.
|
|
51
51
|
|
|
@@ -58,10 +58,10 @@ This benchmark uses the CPU-based image drawing functions in Raylib. The calls a
|
|
|
58
58
|
|
|
59
59
|
Benchmark | Iteration time | Relative performance | Overhead
|
|
60
60
|
------------------ | -------------- | -------------------- | --------
|
|
61
|
-
raylib_cc |
|
|
62
|
-
raylib_node_raylib |
|
|
63
|
-
raylib_koffi |
|
|
64
|
-
raylib_node_ffi |
|
|
61
|
+
raylib_cc | 18.5 µs | x1.42 | -30%
|
|
62
|
+
raylib_node_raylib | 26.3 µs | x1.00 | (ref)
|
|
63
|
+
raylib_koffi | 28.0 µs | x0.94 | +6%
|
|
64
|
+
raylib_node_ffi | 87.0 µs | x0.30 | +230%
|
|
65
65
|
|
|
66
66
|
## Windows x86_64
|
|
67
67
|
|
|
@@ -77,9 +77,9 @@ This test is based around repeated calls to a simple standard C function `rand`,
|
|
|
77
77
|
|
|
78
78
|
Benchmark | Iteration time | Relative performance | Overhead
|
|
79
79
|
------------- | -------------- | -------------------- | --------
|
|
80
|
-
rand_napi |
|
|
81
|
-
rand_koffi |
|
|
82
|
-
rand_node_ffi |
|
|
80
|
+
rand_napi | 859 ns | x1.00 | (ref)
|
|
81
|
+
rand_koffi | 1352 ns | x0.64 | +57%
|
|
82
|
+
rand_node_ffi | 35640 ns | x0.02 | +4048%
|
|
83
83
|
|
|
84
84
|
Because rand is a pretty small function, the FFI overhead is clearly visible.
|
|
85
85
|
|
|
@@ -91,9 +91,9 @@ The results below were measured on my x86_64 Windows machine (Intel® Core™ i5
|
|
|
91
91
|
|
|
92
92
|
Benchmark | Iteration time | Relative performance | Overhead
|
|
93
93
|
------------- | -------------- | -------------------- | --------
|
|
94
|
-
atoi_napi |
|
|
95
|
-
atoi_koffi |
|
|
96
|
-
atoi_node_ffi |
|
|
94
|
+
atoi_napi | 1336 ns | x1.00 | (ref)
|
|
95
|
+
atoi_koffi | 2440 ns | x0.55 | +83%
|
|
96
|
+
atoi_node_ffi | 136890 ns | x0.010 | +10144%
|
|
97
97
|
|
|
98
98
|
Because atoi is a pretty small function, the FFI overhead is clearly visible.
|
|
99
99
|
|
|
@@ -106,26 +106,19 @@ This benchmark uses the CPU-based image drawing functions in Raylib. The calls a
|
|
|
106
106
|
|
|
107
107
|
Benchmark | Iteration time | Relative performance | Overhead
|
|
108
108
|
------------------ | -------------- | -------------------- | --------
|
|
109
|
-
raylib_cc |
|
|
110
|
-
raylib_node_raylib |
|
|
111
|
-
raylib_koffi |
|
|
112
|
-
raylib_node_ffi |
|
|
113
|
-
|
|
114
|
-
Please note that in order to get fair numbers for raylib_node_raylib, it was recompiled with clang-cl before running the benchmark with the following commands:
|
|
115
|
-
|
|
116
|
-
```batch
|
|
117
|
-
cd node_modules\raylib
|
|
118
|
-
rmdir /S /Q bin build
|
|
119
|
-
npx cmake-js compile -t ClangCL
|
|
120
|
-
```
|
|
109
|
+
raylib_cc | 18.2 µs | x1.50 | -33%
|
|
110
|
+
raylib_node_raylib | 27.3 µs | x1.00 | (ref)
|
|
111
|
+
raylib_koffi | 29.8 µs | x0.92 | +9%
|
|
112
|
+
raylib_node_ffi | 96.3 µs | x0.28 | +253%
|
|
121
113
|
|
|
122
114
|
## Running benchmarks
|
|
123
115
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
Please note that all benchmark results are made with Clang-built binaries.
|
|
116
|
+
Please note that all benchmark results on this page are made with Clang-built binaries.
|
|
127
117
|
|
|
128
118
|
```sh
|
|
119
|
+
cd koffi
|
|
120
|
+
node ../../cnoke/cnoke.js --prefer-clang
|
|
121
|
+
|
|
129
122
|
cd koffi/benchmark
|
|
130
123
|
node ../../cnoke/cnoke.js --prefer-clang
|
|
131
124
|
```
|
package/doc/benchmarks.xlsx
CHANGED
|
Binary file
|
package/doc/contribute.md
CHANGED
package/doc/packaging.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# Bundlers and Koffi
|
|
2
2
|
|
|
3
|
-
## Bundling
|
|
3
|
+
## Bundling
|
|
4
|
+
|
|
5
|
+
### Native modules
|
|
4
6
|
|
|
5
7
|
*Simplified in Koffi 2.5.9*
|
|
6
8
|
|
|
@@ -36,7 +38,7 @@ resources/
|
|
|
36
38
|
MyApp.exe
|
|
37
39
|
```
|
|
38
40
|
|
|
39
|
-
|
|
41
|
+
### Indirect loader
|
|
40
42
|
|
|
41
43
|
*New in Koffi 2.6.2*
|
|
42
44
|
|
|
Binary file
|
|
Binary file
|
package/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.6.
|
|
382
|
-
stable: "2.6.
|
|
381
|
+
version: "2.6.5",
|
|
382
|
+
stable: "2.6.5",
|
|
383
383
|
description: "Fast and simple C FFI (foreign function interface) for Node.js",
|
|
384
384
|
keywords: [
|
|
385
385
|
"foreign",
|
|
@@ -413,10 +413,9 @@ var require_package = __commonJS({
|
|
|
413
413
|
chalk: "^4.1.2",
|
|
414
414
|
esbuild: "^0.19.2",
|
|
415
415
|
"ffi-napi": "^4.0.3",
|
|
416
|
-
"ffi-rs": "^1.0.12",
|
|
417
416
|
minimatch: "^5.0.1",
|
|
418
417
|
"node-ssh": "^12.0.3",
|
|
419
|
-
raylib: "^0.
|
|
418
|
+
raylib: "^0.14.0",
|
|
420
419
|
"ref-napi": "^3.0.3",
|
|
421
420
|
"ref-struct-di": "^1.1.1",
|
|
422
421
|
tar: "^6.1.11"
|
package/indirect.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.6.
|
|
382
|
-
stable: "2.6.
|
|
381
|
+
version: "2.6.5",
|
|
382
|
+
stable: "2.6.5",
|
|
383
383
|
description: "Fast and simple C FFI (foreign function interface) for Node.js",
|
|
384
384
|
keywords: [
|
|
385
385
|
"foreign",
|
|
@@ -413,10 +413,9 @@ var require_package = __commonJS({
|
|
|
413
413
|
chalk: "^4.1.2",
|
|
414
414
|
esbuild: "^0.19.2",
|
|
415
415
|
"ffi-napi": "^4.0.3",
|
|
416
|
-
"ffi-rs": "^1.0.12",
|
|
417
416
|
minimatch: "^5.0.1",
|
|
418
417
|
"node-ssh": "^12.0.3",
|
|
419
|
-
raylib: "^0.
|
|
418
|
+
raylib: "^0.14.0",
|
|
420
419
|
"ref-napi": "^3.0.3",
|
|
421
420
|
"ref-struct-di": "^1.1.1",
|
|
422
421
|
tar: "^6.1.11"
|
package/package.json
CHANGED
package/src/cnoke/src/builder.js
CHANGED
|
@@ -340,9 +340,9 @@ function Builder(config = {}) {
|
|
|
340
340
|
|
|
341
341
|
function get_cache_directory() {
|
|
342
342
|
if (process.platform == 'win32') {
|
|
343
|
-
let cache_dir = process.env['APPDATA'];
|
|
343
|
+
let cache_dir = process.env['LOCALAPPDATA'] || process.env['APPDATA'];
|
|
344
344
|
if (cache_dir == null)
|
|
345
|
-
throw new Error('Missing APPDATA environment variable');
|
|
345
|
+
throw new Error('Missing LOCALAPPDATA and APPDATA environment variable');
|
|
346
346
|
|
|
347
347
|
cache_dir = path.join(cache_dir, 'cnoke');
|
|
348
348
|
return cache_dir;
|