koffi 1.3.2 → 1.3.3
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/CMakeLists.txt +26 -2
- package/ChangeLog.md +28 -14
- package/build/qemu/1.3.3/koffi_darwin_arm64.tar.gz +0 -0
- package/build/qemu/1.3.3/koffi_darwin_x64.tar.gz +0 -0
- package/build/qemu/1.3.3/koffi_freebsd_arm64.tar.gz +0 -0
- package/build/qemu/1.3.3/koffi_freebsd_ia32.tar.gz +0 -0
- package/build/qemu/1.3.3/koffi_freebsd_x64.tar.gz +0 -0
- package/build/qemu/1.3.3/koffi_linux_arm32hf.tar.gz +0 -0
- package/build/qemu/1.3.3/koffi_linux_arm64.tar.gz +0 -0
- package/build/qemu/1.3.3/koffi_linux_ia32.tar.gz +0 -0
- package/build/qemu/1.3.3/koffi_linux_riscv64hf64.tar.gz +0 -0
- package/build/qemu/1.3.3/koffi_linux_x64.tar.gz +0 -0
- package/build/qemu/1.3.3/koffi_openbsd_ia32.tar.gz +0 -0
- package/build/qemu/1.3.3/koffi_openbsd_x64.tar.gz +0 -0
- package/build/qemu/1.3.3/koffi_win32_arm64.tar.gz +0 -0
- package/build/qemu/1.3.3/koffi_win32_ia32.tar.gz +0 -0
- package/build/qemu/1.3.3/koffi_win32_x64.tar.gz +0 -0
- package/doc/_static/perf_linux_20220623.png +0 -0
- package/doc/_static/perf_linux_20220623_2.png +0 -0
- package/doc/_static/perf_windows_20220623.png +0 -0
- package/doc/_static/perf_windows_20220623_2.png +0 -0
- package/doc/benchmarks.md +40 -36
- package/doc/benchmarks.xlsx +0 -0
- package/doc/changes.md +2 -0
- package/doc/conf.py +10 -3
- package/doc/contribute.md +16 -0
- package/doc/dist/doctrees/benchmarks.doctree +0 -0
- package/doc/dist/doctrees/changes.doctree +0 -0
- package/doc/dist/doctrees/contribute.doctree +0 -0
- package/doc/dist/doctrees/environment.pickle +0 -0
- package/doc/dist/doctrees/functions.doctree +0 -0
- package/doc/dist/doctrees/index.doctree +0 -0
- package/doc/dist/doctrees/platforms.doctree +0 -0
- package/doc/dist/html/_sources/benchmarks.md.txt +40 -36
- package/doc/dist/html/_sources/changes.md.txt +2 -0
- package/doc/dist/html/_sources/contribute.md.txt +16 -0
- package/doc/dist/html/_sources/functions.md.txt +2 -0
- package/doc/dist/html/_sources/index.rst.txt +2 -1
- package/doc/dist/html/_sources/platforms.md.txt +2 -0
- package/doc/dist/html/_static/perf_linux_20220623.png +0 -0
- package/doc/dist/html/_static/perf_linux_20220623_2.png +0 -0
- package/doc/dist/html/_static/perf_windows_20220623.png +0 -0
- package/doc/dist/html/_static/perf_windows_20220623_2.png +0 -0
- package/doc/dist/html/benchmarks.html +52 -20
- package/doc/dist/html/changes.html +369 -0
- package/doc/dist/html/contribute.html +24 -2
- package/doc/dist/html/functions.html +2 -0
- package/doc/dist/html/genindex.html +1 -0
- package/doc/dist/html/index.html +13 -1
- package/doc/dist/html/memory.html +1 -0
- package/doc/dist/html/objects.inv +0 -0
- package/doc/dist/html/platforms.html +2 -0
- package/doc/dist/html/search.html +1 -0
- package/doc/dist/html/searchindex.js +1 -1
- package/doc/dist/html/start.html +1 -0
- package/doc/dist/html/types.html +1 -0
- package/doc/functions.md +2 -0
- package/doc/index.rst +2 -1
- package/doc/platforms.md +2 -0
- package/package.json +1 -1
- package/qemu/qemu.js +1 -0
- package/src/abi_arm32.cc +9 -9
- package/src/abi_arm64.cc +9 -9
- package/src/abi_riscv64.cc +9 -9
- package/src/abi_x64_sysv.cc +9 -9
- package/src/abi_x64_win.cc +9 -9
- package/src/abi_x86.cc +9 -9
- package/src/call.cc +6 -6
- package/src/call.hh +6 -0
- package/src/ffi.cc +2 -0
- package/src/parser.cc +1 -1
- package/src/util.hh +21 -1
- package/test/misc.c +20 -0
- package/test/sync.js +13 -3
- package/vendor/libcc/libcc.hh +1 -1
- package/build/qemu/1.3.2/koffi_darwin_arm64.tar.gz +0 -0
- package/build/qemu/1.3.2/koffi_darwin_x64.tar.gz +0 -0
- package/build/qemu/1.3.2/koffi_freebsd_arm64.tar.gz +0 -0
- package/build/qemu/1.3.2/koffi_freebsd_ia32.tar.gz +0 -0
- package/build/qemu/1.3.2/koffi_freebsd_x64.tar.gz +0 -0
- package/build/qemu/1.3.2/koffi_linux_arm32hf.tar.gz +0 -0
- package/build/qemu/1.3.2/koffi_linux_arm64.tar.gz +0 -0
- package/build/qemu/1.3.2/koffi_linux_ia32.tar.gz +0 -0
- package/build/qemu/1.3.2/koffi_linux_riscv64hf64.tar.gz +0 -0
- package/build/qemu/1.3.2/koffi_linux_x64.tar.gz +0 -0
- package/build/qemu/1.3.2/koffi_openbsd_ia32.tar.gz +0 -0
- package/build/qemu/1.3.2/koffi_openbsd_x64.tar.gz +0 -0
- package/build/qemu/1.3.2/koffi_win32_arm64.tar.gz +0 -0
- package/build/qemu/1.3.2/koffi_win32_ia32.tar.gz +0 -0
- package/build/qemu/1.3.2/koffi_win32_x64.tar.gz +0 -0
package/src/call.cc
CHANGED
|
@@ -801,11 +801,11 @@ void CallData::PopObject(Napi::Object obj, const uint8_t *origin, const TypeInfo
|
|
|
801
801
|
} break;
|
|
802
802
|
case PrimitiveKind::Int64: {
|
|
803
803
|
int64_t v = *(int64_t *)src;
|
|
804
|
-
obj.Set(member.name,
|
|
804
|
+
obj.Set(member.name, NewBigInt(env, v));
|
|
805
805
|
} break;
|
|
806
806
|
case PrimitiveKind::UInt64: {
|
|
807
807
|
uint64_t v = *(uint64_t *)src;
|
|
808
|
-
obj.Set(member.name,
|
|
808
|
+
obj.Set(member.name, NewBigInt(env, v));
|
|
809
809
|
} break;
|
|
810
810
|
case PrimitiveKind::String: {
|
|
811
811
|
const char *str = *(const char **)src;
|
|
@@ -914,13 +914,13 @@ void CallData::PopNormalArray(Napi::Array array, const uint8_t *origin, const Ty
|
|
|
914
914
|
case PrimitiveKind::Int64: {
|
|
915
915
|
POP_ARRAY({
|
|
916
916
|
int64_t v = *(int64_t *)src;
|
|
917
|
-
array.Set(i,
|
|
917
|
+
array.Set(i, NewBigInt(env, v));
|
|
918
918
|
});
|
|
919
919
|
} break;
|
|
920
920
|
case PrimitiveKind::UInt64: {
|
|
921
921
|
POP_ARRAY({
|
|
922
922
|
uint64_t v = *(uint64_t *)src;
|
|
923
|
-
array.Set(i,
|
|
923
|
+
array.Set(i, NewBigInt(env, v));
|
|
924
924
|
});
|
|
925
925
|
} break;
|
|
926
926
|
case PrimitiveKind::String: {
|
|
@@ -1078,13 +1078,13 @@ Napi::Value CallData::PopArray(const uint8_t *origin, const TypeInfo *type, int1
|
|
|
1078
1078
|
case PrimitiveKind::Int64: {
|
|
1079
1079
|
POP_ARRAY({
|
|
1080
1080
|
int64_t v = *(int64_t *)src;
|
|
1081
|
-
array.Set(i,
|
|
1081
|
+
array.Set(i, NewBigInt(env, v));
|
|
1082
1082
|
});
|
|
1083
1083
|
} break;
|
|
1084
1084
|
case PrimitiveKind::UInt64: {
|
|
1085
1085
|
POP_ARRAY({
|
|
1086
1086
|
uint64_t v = *(uint64_t *)src;
|
|
1087
|
-
array.Set(i,
|
|
1087
|
+
array.Set(i, NewBigInt(env, v));
|
|
1088
1088
|
});
|
|
1089
1089
|
} break;
|
|
1090
1090
|
case PrimitiveKind::String: {
|
package/src/call.hh
CHANGED
package/src/ffi.cc
CHANGED
|
@@ -636,6 +636,8 @@ static InstanceMemory *AllocateMemory(InstanceData *instance, Size stack_size, S
|
|
|
636
636
|
#endif
|
|
637
637
|
RG_CRITICAL(mem->heap.ptr, "Failed to allocate %1 of memory", mem->heap.len);
|
|
638
638
|
|
|
639
|
+
mem->depth = 0;
|
|
640
|
+
|
|
639
641
|
if (instance->memories.len <= instance->resident_async_pools) {
|
|
640
642
|
instance->memories.Append(mem);
|
|
641
643
|
} else {
|
package/src/parser.cc
CHANGED
|
@@ -44,7 +44,7 @@ bool PrototypeParser::Parse(const char *str, FunctionInfo *out_func)
|
|
|
44
44
|
out_func->name = ParseIdentifier();
|
|
45
45
|
|
|
46
46
|
Consume("(");
|
|
47
|
-
if (offset < tokens.len && tokens[offset] != ")") {
|
|
47
|
+
if (offset < tokens.len && tokens[offset] != ")" && !Match("void")) {
|
|
48
48
|
for (;;) {
|
|
49
49
|
ParameterInfo param = {};
|
|
50
50
|
|
package/src/util.hh
CHANGED
|
@@ -89,7 +89,7 @@ static inline bool IsObject(Napi::Value value)
|
|
|
89
89
|
int GetTypedArrayType(const TypeInfo *type);
|
|
90
90
|
|
|
91
91
|
template <typename T>
|
|
92
|
-
T CopyNumber(
|
|
92
|
+
T CopyNumber(Napi::Value value)
|
|
93
93
|
{
|
|
94
94
|
RG_ASSERT(value.IsNumber() || value.IsBigInt());
|
|
95
95
|
|
|
@@ -105,6 +105,26 @@ T CopyNumber(const Napi::Value &value)
|
|
|
105
105
|
RG_UNREACHABLE();
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
+
static inline Napi::Value NewBigInt(Napi::Env env, int64_t value)
|
|
109
|
+
{
|
|
110
|
+
if (value <= 9007199254740992ll && value >= -9007199254740992ll) {
|
|
111
|
+
double d = (double)value;
|
|
112
|
+
return Napi::Number::New(env, d);
|
|
113
|
+
} else {
|
|
114
|
+
return Napi::BigInt::New(env, value);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
static inline Napi::Value NewBigInt(Napi::Env env, uint64_t value)
|
|
119
|
+
{
|
|
120
|
+
if (value <= 9007199254740992ull) {
|
|
121
|
+
double d = (double)value;
|
|
122
|
+
return Napi::Number::New(env, d);
|
|
123
|
+
} else {
|
|
124
|
+
return Napi::BigInt::New(env, value);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
108
128
|
int AnalyseFlat(const TypeInfo *type, FunctionRef<void(const TypeInfo *type, int offset, int count)> func);
|
|
109
129
|
|
|
110
130
|
int IsHFA(const TypeInfo *type, int min, int max);
|
package/test/misc.c
CHANGED
|
@@ -129,6 +129,26 @@ typedef struct IntContainer {
|
|
|
129
129
|
int len;
|
|
130
130
|
} IntContainer;
|
|
131
131
|
|
|
132
|
+
EXPORT int8_t GetMinusOne1(void)
|
|
133
|
+
{
|
|
134
|
+
return -1;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
EXPORT int16_t GetMinusOne2(void)
|
|
138
|
+
{
|
|
139
|
+
return -1;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
EXPORT int32_t GetMinusOne4(void)
|
|
143
|
+
{
|
|
144
|
+
return -1;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
EXPORT int64_t GetMinusOne8(void)
|
|
148
|
+
{
|
|
149
|
+
return -1;
|
|
150
|
+
}
|
|
151
|
+
|
|
132
152
|
EXPORT void FillPack1(int a, Pack1 *p)
|
|
133
153
|
{
|
|
134
154
|
p->a = a;
|
package/test/sync.js
CHANGED
|
@@ -122,6 +122,10 @@ async function test() {
|
|
|
122
122
|
let lib_filename = path.dirname(__filename) + '/build/misc' + koffi.extension;
|
|
123
123
|
let lib = koffi.load(lib_filename);
|
|
124
124
|
|
|
125
|
+
const GetMinusOne1 = lib.func('int8_t GetMinusOne1(void)');
|
|
126
|
+
const GetMinusOne2 = lib.func('int16_t GetMinusOne2(void)');
|
|
127
|
+
const GetMinusOne4 = lib.func('int32_t GetMinusOne4(void)');
|
|
128
|
+
const GetMinusOne8 = lib.func('int64_t GetMinusOne8(void)');
|
|
125
129
|
const FillPack1 = lib.func('FillPack1', 'void', ['int', koffi.out(koffi.pointer(Pack1))]);
|
|
126
130
|
const RetPack1 = lib.func('RetPack1', Pack1, ['int']);
|
|
127
131
|
const AddPack1 = lib.fastcall('AddPack1', 'void', ['int', koffi.inout(koffi.pointer(Pack1))]);
|
|
@@ -172,6 +176,12 @@ async function test() {
|
|
|
172
176
|
const FillRange = lib.func('void FillRange(int init, int step, _Out_ int *out, int len)');
|
|
173
177
|
const MultiplyIntegers = lib.func('void MultiplyIntegers(int multiplier, _Inout_ int *values, int len)');
|
|
174
178
|
|
|
179
|
+
// Simple signed value returns
|
|
180
|
+
assert.equal(GetMinusOne1(), -1);
|
|
181
|
+
assert.equal(GetMinusOne2(), -1);
|
|
182
|
+
assert.equal(GetMinusOne4(), -1);
|
|
183
|
+
assert.equal(GetMinusOne8(), -1);
|
|
184
|
+
|
|
175
185
|
// Simple tests with Pack1
|
|
176
186
|
{
|
|
177
187
|
let p = {};
|
|
@@ -250,9 +260,9 @@ async function test() {
|
|
|
250
260
|
|
|
251
261
|
// Many parameters
|
|
252
262
|
{
|
|
253
|
-
assert.equal(ConcatenateToInt1(5, 6, 1, 2, 3, 9, 4, 4, 0, 6, 8, 7),
|
|
254
|
-
assert.equal(ConcatenateToInt4(5, 6, 1, 2, 3, 9, 4, 4, 0, 6, 8, 7),
|
|
255
|
-
assert.equal(ConcatenateToInt8(5, 6, 1, 2, 3, 9, 4, 4, 0, 6, 8, 7),
|
|
263
|
+
assert.equal(ConcatenateToInt1(5, 6, 1, 2, 3, 9, 4, 4, 0, 6, 8, 7), 561239440687);
|
|
264
|
+
assert.equal(ConcatenateToInt4(5, 6, 1, 2, 3, 9, 4, 4, 0, 6, 8, 7), 561239440687);
|
|
265
|
+
assert.equal(ConcatenateToInt8(5, 6, 1, 2, 3, 9, 4, 4, 0, 6, 8, 7), 561239440687);
|
|
256
266
|
assert.equal(ConcatenateToStr1(5, 6, 1, 2, 3, 9, 4, 4, {i: 0, j: 6, k: 8}, 7), '561239440687');
|
|
257
267
|
assert.equal(ConcatenateToStr4(5, 6, 1, 2, 3, 9, 4, 4, {i: 0, j: 6, k: 8}, 7), '561239440687');
|
|
258
268
|
assert.equal(ConcatenateToStr8(5, 6, 1, 2, 3, 9, 4, 4, {i: 0, j: 6, k: 8}, 7), '561239440687');
|
package/vendor/libcc/libcc.hh
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
|