koffi 2.16.1 → 3.0.0-alpha.2
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 +2 -2
- package/README.md +8 -8
- 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_arm64/koffi.node +0 -0
- package/build/koffi/linux_ia32/koffi.node +0 -0
- package/build/koffi/linux_x64/koffi.node +0 -0
- package/build/koffi/musl_arm64/koffi.node +0 -0
- package/build/koffi/musl_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_ia32/koffi.node +0 -0
- package/build/koffi/win32_x64/koffi.node +0 -0
- package/doc/benchmarks.md +33 -33
- package/doc/benchmarks.xlsx +0 -0
- package/doc/contribute.md +37 -25
- package/doc/index.md +8 -8
- package/doc/variables.md +1 -1
- package/index.d.ts +11 -9
- package/index.js +1 -634
- package/indirect.js +1 -533
- package/lib/native/base/base.cc +63 -85
- package/lib/native/base/base.hh +178 -151
- package/package.json +3 -4
- package/src/build.js +1178 -0
- package/src/koffi/CMakeLists.txt +97 -34
- package/src/koffi/index.js +359 -0
- package/src/koffi/indirect.js +216 -0
- package/src/koffi/src/{abi_arm32.cc → abi/arm32.cc} +279 -275
- package/src/koffi/src/{abi_arm32_asm.S → abi/arm32_asm.S} +2 -5
- package/src/koffi/src/abi/arm64.cc +1511 -0
- package/src/koffi/src/{abi_arm64_asm.S → abi/arm64_asm.S} +44 -23
- package/src/koffi/src/{abi_arm64_asm.asm → abi/arm64_asm.asm} +32 -25
- package/src/koffi/src/{abi_loong64_asm.S → abi/loong64_asm.S} +1 -5
- package/src/koffi/src/{abi_riscv64.cc → abi/riscv64.cc} +279 -273
- package/src/koffi/src/{abi_riscv64_asm.S → abi/riscv64_asm.S} +1 -4
- package/src/koffi/src/abi/x64sysv.cc +1456 -0
- package/src/koffi/src/{abi_x64_sysv_asm.S → abi/x64sysv_asm.S} +30 -33
- package/src/koffi/src/abi/x64win.cc +1121 -0
- package/src/koffi/src/{abi_x64_win_asm.S → abi/x64win_asm.S} +8 -12
- package/src/koffi/src/{abi_x64_win_asm.asm → abi/x64win_asm.asm} +11 -14
- package/src/koffi/src/abi/x86.cc +1233 -0
- package/src/koffi/src/{abi_x86_asm.S → abi/x86_asm.S} +49 -25
- package/src/koffi/src/{abi_x86_asm.asm → abi/x86_asm.asm} +11 -14
- package/src/koffi/src/call.cc +458 -598
- package/src/koffi/src/call.hh +61 -82
- package/src/koffi/src/ffi.cc +595 -309
- package/src/koffi/src/ffi.hh +103 -89
- package/src/koffi/src/parser.cc +0 -4
- package/src/koffi/src/primitives.inc +39 -0
- package/src/koffi/{tools/write_trampolines.js → src/trampolines.js} +1 -1
- package/src/koffi/src/util.cc +503 -446
- package/src/koffi/src/util.hh +269 -57
- package/src/koffi/src/uv.cc +2 -2
- package/src/koffi/src/uv.def +3 -0
- package/src/koffi/src/win32.hh +30 -1
- package/vendor/node-addon-api/napi-inl.h +4 -0
- package/vendor/node-addon-api/napi.h +1 -0
- package/build/koffi/linux_armhf/koffi.node +0 -0
- package/build/koffi/linux_loong64/koffi.node +0 -0
- package/build/koffi/linux_riscv64d/koffi.node +0 -0
- package/build/koffi/win32_arm64/koffi.exp +0 -0
- package/build/koffi/win32_arm64/koffi.lib +0 -0
- package/build/koffi/win32_arm64/koffi.node +0 -0
- package/doc/platforms.md +0 -36
- package/src/cnoke/LICENSE.txt +0 -22
- package/src/cnoke/README.md +0 -99
- package/src/cnoke/assets/FindCNoke.cmake +0 -127
- package/src/cnoke/assets/toolchains.json +0 -126
- package/src/cnoke/assets/win_delay_hook.c +0 -36
- package/src/cnoke/cnoke.js +0 -170
- package/src/cnoke/package.json +0 -24
- package/src/cnoke/src/builder.js +0 -511
- package/src/cnoke/src/index.js +0 -10
- package/src/cnoke/src/tools.js +0 -407
- package/src/koffi/src/abi_arm64.cc +0 -1295
- package/src/koffi/src/abi_x64_sysv.cc +0 -939
- package/src/koffi/src/abi_x64_win.cc +0 -715
- package/src/koffi/src/abi_x86.cc +0 -860
- package/src/koffi/src/init.js +0 -105
- /package/src/koffi/src/{abi_loong64.cc → abi/loong64.cc} +0 -0
|
@@ -1,715 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: MIT
|
|
2
|
-
// SPDX-FileCopyrightText: 2025 Niels Martignène <niels.martignene@protonmail.com>
|
|
3
|
-
|
|
4
|
-
#if defined(_WIN32) && (defined(__x86_64__) || defined(_M_AMD64))
|
|
5
|
-
|
|
6
|
-
#include "lib/native/base/base.hh"
|
|
7
|
-
#include "ffi.hh"
|
|
8
|
-
#include "call.hh"
|
|
9
|
-
#include "util.hh"
|
|
10
|
-
#include "win32.hh"
|
|
11
|
-
|
|
12
|
-
#include <napi.h>
|
|
13
|
-
|
|
14
|
-
namespace K {
|
|
15
|
-
|
|
16
|
-
struct BackRegisters {
|
|
17
|
-
uint64_t rax;
|
|
18
|
-
double xmm0;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
extern "C" uint64_t ForwardCallG(const void *func, uint8_t *sp, uint8_t **out_old_sp);
|
|
22
|
-
extern "C" float ForwardCallF(const void *func, uint8_t *sp, uint8_t **out_old_sp);
|
|
23
|
-
extern "C" double ForwardCallD(const void *func, uint8_t *sp, uint8_t **out_old_sp);
|
|
24
|
-
extern "C" uint64_t ForwardCallXG(const void *func, uint8_t *sp, uint8_t **out_old_sp);
|
|
25
|
-
extern "C" float ForwardCallXF(const void *func, uint8_t *sp, uint8_t **out_old_sp);
|
|
26
|
-
extern "C" double ForwardCallXD(const void *func, uint8_t *sp, uint8_t **out_old_sp);
|
|
27
|
-
|
|
28
|
-
bool AnalyseFunction(Napi::Env, InstanceData *, FunctionInfo *func)
|
|
29
|
-
{
|
|
30
|
-
func->ret.regular = IsRegularSize(func->ret.type->size, 8);
|
|
31
|
-
|
|
32
|
-
for (ParameterInfo ¶m: func->parameters) {
|
|
33
|
-
param.regular = IsRegularSize(param.type->size, 8);
|
|
34
|
-
func->forward_fp |= IsFloat(param.type);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
func->args_size = AlignLen(8 * std::max((Size)4, func->parameters.len + !func->ret.regular), 16);
|
|
38
|
-
|
|
39
|
-
return true;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
bool CallData::Prepare(const FunctionInfo *func, const Napi::CallbackInfo &info)
|
|
43
|
-
{
|
|
44
|
-
uint64_t *args_ptr = nullptr;
|
|
45
|
-
|
|
46
|
-
// Pass return value in register or through memory
|
|
47
|
-
if (!AllocStack(func->args_size, 16, &args_ptr)) [[unlikely]]
|
|
48
|
-
return false;
|
|
49
|
-
if (!func->ret.regular) {
|
|
50
|
-
return_ptr = AllocHeap(func->ret.type->size, 16);
|
|
51
|
-
*(uint8_t **)(args_ptr++) = return_ptr;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
#define PUSH_INTEGER(CType) \
|
|
55
|
-
do { \
|
|
56
|
-
if (!value.IsNumber() && !value.IsBigInt()) [[unlikely]] { \
|
|
57
|
-
ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected number", GetValueType(instance, value)); \
|
|
58
|
-
return false; \
|
|
59
|
-
} \
|
|
60
|
-
\
|
|
61
|
-
CType v = GetNumber<CType>(value); \
|
|
62
|
-
*(args_ptr++) = (uint64_t)v; \
|
|
63
|
-
} while (false)
|
|
64
|
-
#define PUSH_INTEGER_SWAP(CType) \
|
|
65
|
-
do { \
|
|
66
|
-
if (!value.IsNumber() && !value.IsBigInt()) [[unlikely]] { \
|
|
67
|
-
ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected number", GetValueType(instance, value)); \
|
|
68
|
-
return false; \
|
|
69
|
-
} \
|
|
70
|
-
\
|
|
71
|
-
CType v = GetNumber<CType>(value); \
|
|
72
|
-
*(args_ptr++) = (uint64_t)ReverseBytes(v); \
|
|
73
|
-
} while (false)
|
|
74
|
-
|
|
75
|
-
// Push arguments
|
|
76
|
-
for (Size i = 0; i < func->parameters.len; i++) {
|
|
77
|
-
const ParameterInfo ¶m = func->parameters[i];
|
|
78
|
-
K_ASSERT(param.directions >= 1 && param.directions <= 3);
|
|
79
|
-
|
|
80
|
-
Napi::Value value = info[param.offset];
|
|
81
|
-
|
|
82
|
-
switch (param.type->primitive) {
|
|
83
|
-
case PrimitiveKind::Void: { K_UNREACHABLE(); } break;
|
|
84
|
-
|
|
85
|
-
case PrimitiveKind::Bool: {
|
|
86
|
-
if (!value.IsBoolean()) [[unlikely]] {
|
|
87
|
-
ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected boolean", GetValueType(instance, value));
|
|
88
|
-
return false;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
bool b = value.As<Napi::Boolean>();
|
|
92
|
-
|
|
93
|
-
*(bool *)(args_ptr++) = b;
|
|
94
|
-
} break;
|
|
95
|
-
case PrimitiveKind::Int8: { PUSH_INTEGER(int8_t); } break;
|
|
96
|
-
case PrimitiveKind::UInt8: { PUSH_INTEGER(uint8_t); } break;
|
|
97
|
-
case PrimitiveKind::Int16: { PUSH_INTEGER(int16_t); } break;
|
|
98
|
-
case PrimitiveKind::Int16S: { PUSH_INTEGER_SWAP(int16_t); } break;
|
|
99
|
-
case PrimitiveKind::UInt16: { PUSH_INTEGER(uint16_t); } break;
|
|
100
|
-
case PrimitiveKind::UInt16S: { PUSH_INTEGER_SWAP(uint16_t); } break;
|
|
101
|
-
case PrimitiveKind::Int32: { PUSH_INTEGER(int32_t); } break;
|
|
102
|
-
case PrimitiveKind::Int32S: { PUSH_INTEGER_SWAP(int32_t); } break;
|
|
103
|
-
case PrimitiveKind::UInt32: { PUSH_INTEGER(uint32_t); } break;
|
|
104
|
-
case PrimitiveKind::UInt32S: { PUSH_INTEGER_SWAP(uint32_t); } break;
|
|
105
|
-
case PrimitiveKind::Int64: { PUSH_INTEGER(int64_t); } break;
|
|
106
|
-
case PrimitiveKind::Int64S: { PUSH_INTEGER_SWAP(int64_t); } break;
|
|
107
|
-
case PrimitiveKind::UInt64: { PUSH_INTEGER(uint64_t); } break;
|
|
108
|
-
case PrimitiveKind::UInt64S: { PUSH_INTEGER_SWAP(uint64_t); } break;
|
|
109
|
-
case PrimitiveKind::String: {
|
|
110
|
-
const char *str;
|
|
111
|
-
if (!PushString(value, param.directions, &str)) [[unlikely]]
|
|
112
|
-
return false;
|
|
113
|
-
|
|
114
|
-
*(const char **)(args_ptr++) = str;
|
|
115
|
-
} break;
|
|
116
|
-
case PrimitiveKind::String16: {
|
|
117
|
-
const char16_t *str16;
|
|
118
|
-
if (!PushString16(value, param.directions, &str16)) [[unlikely]]
|
|
119
|
-
return false;
|
|
120
|
-
|
|
121
|
-
*(const char16_t **)(args_ptr++) = str16;
|
|
122
|
-
} break;
|
|
123
|
-
case PrimitiveKind::String32: {
|
|
124
|
-
const char32_t *str32;
|
|
125
|
-
if (!PushString32(value, param.directions, &str32)) [[unlikely]]
|
|
126
|
-
return false;
|
|
127
|
-
|
|
128
|
-
*(const char32_t **)(args_ptr++) = str32;
|
|
129
|
-
} break;
|
|
130
|
-
case PrimitiveKind::Pointer: {
|
|
131
|
-
void *ptr;
|
|
132
|
-
if (!PushPointer(value, param.type, param.directions, &ptr)) [[unlikely]]
|
|
133
|
-
return false;
|
|
134
|
-
|
|
135
|
-
*(void **)(args_ptr++) = ptr;
|
|
136
|
-
} break;
|
|
137
|
-
case PrimitiveKind::Record:
|
|
138
|
-
case PrimitiveKind::Union: {
|
|
139
|
-
if (!IsObject(value)) [[unlikely]] {
|
|
140
|
-
ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected object", GetValueType(instance, value));
|
|
141
|
-
return false;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
uint8_t *ptr;
|
|
145
|
-
if (param.regular) {
|
|
146
|
-
ptr = (uint8_t *)(args_ptr++);
|
|
147
|
-
} else {
|
|
148
|
-
ptr = AllocHeap(param.type->size, 16);
|
|
149
|
-
*(uint8_t **)(args_ptr++) = ptr;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
Napi::Object obj = value.As<Napi::Object>();
|
|
153
|
-
if (!PushObject(obj, param.type, ptr))
|
|
154
|
-
return false;
|
|
155
|
-
} break;
|
|
156
|
-
case PrimitiveKind::Array: { K_UNREACHABLE(); } break;
|
|
157
|
-
case PrimitiveKind::Float32: {
|
|
158
|
-
if (!value.IsNumber() && !value.IsBigInt()) [[unlikely]] {
|
|
159
|
-
ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected number", GetValueType(instance, value));
|
|
160
|
-
return false;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
float f = GetNumber<float>(value);
|
|
164
|
-
|
|
165
|
-
memset((uint8_t *)args_ptr + 4, 0, 4);
|
|
166
|
-
*(float *)(args_ptr++) = f;
|
|
167
|
-
} break;
|
|
168
|
-
case PrimitiveKind::Float64: {
|
|
169
|
-
if (!value.IsNumber() && !value.IsBigInt()) [[unlikely]] {
|
|
170
|
-
ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected number", GetValueType(instance, value));
|
|
171
|
-
return false;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
double d = GetNumber<double>(value);
|
|
175
|
-
*(double *)(args_ptr++) = d;
|
|
176
|
-
} break;
|
|
177
|
-
case PrimitiveKind::Callback: {
|
|
178
|
-
void *ptr;
|
|
179
|
-
if (!PushCallback(value, param.type, &ptr)) [[unlikely]]
|
|
180
|
-
return false;
|
|
181
|
-
|
|
182
|
-
*(void **)(args_ptr++) = ptr;
|
|
183
|
-
} break;
|
|
184
|
-
|
|
185
|
-
case PrimitiveKind::Prototype: { K_UNREACHABLE(); } break;
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
#undef PUSH_INTEGER_SWAP
|
|
190
|
-
#undef PUSH_INTEGER
|
|
191
|
-
|
|
192
|
-
new_sp = mem->stack.end();
|
|
193
|
-
|
|
194
|
-
return true;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
void CallData::Execute(const FunctionInfo *func, void *native)
|
|
198
|
-
{
|
|
199
|
-
TEB *teb = GetTEB();
|
|
200
|
-
|
|
201
|
-
// Restore previous stack limits at the end
|
|
202
|
-
K_DEFER_C(exception_list = teb->ExceptionList,
|
|
203
|
-
base = teb->StackBase,
|
|
204
|
-
limit = teb->StackLimit,
|
|
205
|
-
dealloc = teb->DeallocationStack,
|
|
206
|
-
guaranteed = teb->GuaranteedStackBytes,
|
|
207
|
-
stfs = teb->SameTebFlags) {
|
|
208
|
-
teb->ExceptionList = exception_list;
|
|
209
|
-
teb->StackBase = base;
|
|
210
|
-
teb->StackLimit = limit;
|
|
211
|
-
teb->DeallocationStack = dealloc;
|
|
212
|
-
teb->GuaranteedStackBytes = guaranteed;
|
|
213
|
-
teb->SameTebFlags = stfs;
|
|
214
|
-
|
|
215
|
-
instance->last_error = teb->LastErrorValue;
|
|
216
|
-
};
|
|
217
|
-
|
|
218
|
-
// Adjust stack limits so SEH works correctly
|
|
219
|
-
teb->ExceptionList = (void *)-1; // EXCEPTION_CHAIN_END
|
|
220
|
-
teb->StackBase = mem->stack0.end();
|
|
221
|
-
teb->StackLimit = mem->stack0.ptr;
|
|
222
|
-
teb->DeallocationStack = mem->stack0.ptr;
|
|
223
|
-
teb->GuaranteedStackBytes = 0;
|
|
224
|
-
teb->SameTebFlags &= ~0x200;
|
|
225
|
-
|
|
226
|
-
teb->LastErrorValue = instance->last_error;
|
|
227
|
-
|
|
228
|
-
#define PERFORM_CALL(Suffix) \
|
|
229
|
-
([&]() { \
|
|
230
|
-
auto ret = (func->forward_fp ? ForwardCallX ## Suffix(native, new_sp, &old_sp) \
|
|
231
|
-
: ForwardCall ## Suffix(native, new_sp, &old_sp)); \
|
|
232
|
-
return ret; \
|
|
233
|
-
})()
|
|
234
|
-
|
|
235
|
-
switch (func->ret.type->primitive) {
|
|
236
|
-
case PrimitiveKind::Void:
|
|
237
|
-
case PrimitiveKind::Bool:
|
|
238
|
-
case PrimitiveKind::Int8:
|
|
239
|
-
case PrimitiveKind::UInt8:
|
|
240
|
-
case PrimitiveKind::Int16:
|
|
241
|
-
case PrimitiveKind::Int16S:
|
|
242
|
-
case PrimitiveKind::UInt16:
|
|
243
|
-
case PrimitiveKind::UInt16S:
|
|
244
|
-
case PrimitiveKind::Int32:
|
|
245
|
-
case PrimitiveKind::Int32S:
|
|
246
|
-
case PrimitiveKind::UInt32:
|
|
247
|
-
case PrimitiveKind::UInt32S:
|
|
248
|
-
case PrimitiveKind::Int64:
|
|
249
|
-
case PrimitiveKind::Int64S:
|
|
250
|
-
case PrimitiveKind::UInt64:
|
|
251
|
-
case PrimitiveKind::UInt64S:
|
|
252
|
-
case PrimitiveKind::String:
|
|
253
|
-
case PrimitiveKind::String16:
|
|
254
|
-
case PrimitiveKind::String32:
|
|
255
|
-
case PrimitiveKind::Pointer:
|
|
256
|
-
case PrimitiveKind::Record:
|
|
257
|
-
case PrimitiveKind::Union:
|
|
258
|
-
case PrimitiveKind::Callback: { result.u64 = PERFORM_CALL(G); } break;
|
|
259
|
-
case PrimitiveKind::Array: { K_UNREACHABLE(); } break;
|
|
260
|
-
case PrimitiveKind::Float32: { result.f = PERFORM_CALL(F); } break;
|
|
261
|
-
case PrimitiveKind::Float64: { result.d = PERFORM_CALL(D); } break;
|
|
262
|
-
|
|
263
|
-
case PrimitiveKind::Prototype: { K_UNREACHABLE(); } break;
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
#undef PERFORM_CALL
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
Napi::Value CallData::Complete(const FunctionInfo *func)
|
|
270
|
-
{
|
|
271
|
-
K_DEFER {
|
|
272
|
-
PopOutArguments();
|
|
273
|
-
|
|
274
|
-
if (func->ret.type->dispose) {
|
|
275
|
-
func->ret.type->dispose(env, func->ret.type, result.ptr);
|
|
276
|
-
}
|
|
277
|
-
};
|
|
278
|
-
|
|
279
|
-
switch (func->ret.type->primitive) {
|
|
280
|
-
case PrimitiveKind::Void: return env.Undefined();
|
|
281
|
-
case PrimitiveKind::Bool: return Napi::Boolean::New(env, result.u8 & 0x1);
|
|
282
|
-
case PrimitiveKind::Int8: return Napi::Number::New(env, (double)result.i8);
|
|
283
|
-
case PrimitiveKind::UInt8: return Napi::Number::New(env, (double)result.u8);
|
|
284
|
-
case PrimitiveKind::Int16: return Napi::Number::New(env, (double)result.i16);
|
|
285
|
-
case PrimitiveKind::Int16S: return Napi::Number::New(env, (double)ReverseBytes(result.i16));
|
|
286
|
-
case PrimitiveKind::UInt16: return Napi::Number::New(env, (double)result.u16);
|
|
287
|
-
case PrimitiveKind::UInt16S: return Napi::Number::New(env, (double)ReverseBytes(result.u16));
|
|
288
|
-
case PrimitiveKind::Int32: return Napi::Number::New(env, (double)result.i32);
|
|
289
|
-
case PrimitiveKind::Int32S: return Napi::Number::New(env, (double)ReverseBytes(result.i32));
|
|
290
|
-
case PrimitiveKind::UInt32: return Napi::Number::New(env, (double)result.u32);
|
|
291
|
-
case PrimitiveKind::UInt32S: return Napi::Number::New(env, (double)ReverseBytes(result.u32));
|
|
292
|
-
case PrimitiveKind::Int64: return NewBigInt(env, result.i64);
|
|
293
|
-
case PrimitiveKind::Int64S: return NewBigInt(env, ReverseBytes(result.i64));
|
|
294
|
-
case PrimitiveKind::UInt64: return NewBigInt(env, result.u64);
|
|
295
|
-
case PrimitiveKind::UInt64S: return NewBigInt(env, ReverseBytes(result.u64));
|
|
296
|
-
case PrimitiveKind::String: return result.ptr ? Napi::String::New(env, (const char *)result.ptr) : env.Null();
|
|
297
|
-
case PrimitiveKind::String16: return result.ptr ? Napi::String::New(env, (const char16_t *)result.ptr) : env.Null();
|
|
298
|
-
case PrimitiveKind::String32: return result.ptr ? MakeStringFromUTF32(env, (const char32_t *)result.ptr) : env.Null();
|
|
299
|
-
case PrimitiveKind::Pointer:
|
|
300
|
-
case PrimitiveKind::Callback: {
|
|
301
|
-
if (result.ptr) {
|
|
302
|
-
Napi::External<void> external = Napi::External<void>::New(env, result.ptr);
|
|
303
|
-
SetValueTag(external, func->ret.type->ref.marker);
|
|
304
|
-
|
|
305
|
-
return external;
|
|
306
|
-
} else {
|
|
307
|
-
return env.Null();
|
|
308
|
-
}
|
|
309
|
-
} break;
|
|
310
|
-
case PrimitiveKind::Record:
|
|
311
|
-
case PrimitiveKind::Union: {
|
|
312
|
-
const uint8_t *ptr = return_ptr ? (const uint8_t *)return_ptr
|
|
313
|
-
: (const uint8_t *)&result.buf;
|
|
314
|
-
|
|
315
|
-
Napi::Object obj = DecodeObject(env, ptr, func->ret.type);
|
|
316
|
-
return obj;
|
|
317
|
-
} break;
|
|
318
|
-
case PrimitiveKind::Array: { K_UNREACHABLE(); } break;
|
|
319
|
-
case PrimitiveKind::Float32: return Napi::Number::New(env, (double)result.f);
|
|
320
|
-
case PrimitiveKind::Float64: return Napi::Number::New(env, result.d);
|
|
321
|
-
|
|
322
|
-
case PrimitiveKind::Prototype: { K_UNREACHABLE(); } break;
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
K_UNREACHABLE();
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
void CallData::Relay(Size idx, uint8_t *sp)
|
|
329
|
-
{
|
|
330
|
-
const TrampolineInfo &trampoline = shared.trampolines[idx];
|
|
331
|
-
|
|
332
|
-
uint8_t *own_sp = sp;
|
|
333
|
-
uint8_t *caller_sp = sp + 128;
|
|
334
|
-
BackRegisters *out_reg = (BackRegisters *)(sp + 64);
|
|
335
|
-
|
|
336
|
-
const FunctionInfo *proto = trampoline.proto;
|
|
337
|
-
Napi::Function func = trampoline.func.Value();
|
|
338
|
-
|
|
339
|
-
uint64_t *gpr_ptr = (uint64_t *)own_sp;
|
|
340
|
-
uint64_t *xmm_ptr = gpr_ptr + 4;
|
|
341
|
-
uint64_t *args_ptr = (uint64_t *)caller_sp;
|
|
342
|
-
|
|
343
|
-
uint8_t *return_ptr = !proto->ret.regular ? (uint8_t *)gpr_ptr[0] : nullptr;
|
|
344
|
-
|
|
345
|
-
K_DEFER_N(err_guard) { memset(out_reg, 0, K_SIZE(*out_reg)); };
|
|
346
|
-
|
|
347
|
-
LocalArray<napi_value, MaxParameters + 1> arguments;
|
|
348
|
-
|
|
349
|
-
arguments.Append(!trampoline.recv.IsEmpty() ? trampoline.recv.Value() : env.Undefined());
|
|
350
|
-
|
|
351
|
-
// Convert to JS arguments
|
|
352
|
-
for (Size i = 0, j = !!return_ptr; i < proto->parameters.len; i++, j++) {
|
|
353
|
-
const ParameterInfo ¶m = proto->parameters[i];
|
|
354
|
-
K_ASSERT(param.directions >= 1 && param.directions <= 3);
|
|
355
|
-
|
|
356
|
-
switch (param.type->primitive) {
|
|
357
|
-
case PrimitiveKind::Void: { K_UNREACHABLE(); } break;
|
|
358
|
-
|
|
359
|
-
case PrimitiveKind::Bool: {
|
|
360
|
-
bool b = *(bool *)(j < 4 ? gpr_ptr + j : args_ptr);
|
|
361
|
-
args_ptr += (j >= 4);
|
|
362
|
-
|
|
363
|
-
Napi::Value arg = Napi::Boolean::New(env, b);
|
|
364
|
-
arguments.Append(arg);
|
|
365
|
-
} break;
|
|
366
|
-
case PrimitiveKind::Int8: {
|
|
367
|
-
double d = (double)*(int8_t *)(j < 4 ? gpr_ptr + j : args_ptr);
|
|
368
|
-
args_ptr += (j >= 4);
|
|
369
|
-
|
|
370
|
-
Napi::Value arg = Napi::Number::New(env, d);
|
|
371
|
-
arguments.Append(arg);
|
|
372
|
-
} break;
|
|
373
|
-
case PrimitiveKind::UInt8: {
|
|
374
|
-
double d = (double)*(uint8_t *)(j < 4 ? gpr_ptr + j : args_ptr);
|
|
375
|
-
args_ptr += (j >= 4);
|
|
376
|
-
|
|
377
|
-
Napi::Value arg = Napi::Number::New(env, d);
|
|
378
|
-
arguments.Append(arg);
|
|
379
|
-
} break;
|
|
380
|
-
case PrimitiveKind::Int16: {
|
|
381
|
-
double d = (double)*(int16_t *)(j < 4 ? gpr_ptr + j : args_ptr);
|
|
382
|
-
args_ptr += (j >= 4);
|
|
383
|
-
|
|
384
|
-
Napi::Value arg = Napi::Number::New(env, d);
|
|
385
|
-
arguments.Append(arg);
|
|
386
|
-
} break;
|
|
387
|
-
case PrimitiveKind::Int16S: {
|
|
388
|
-
int16_t v = *(int16_t *)(j < 4 ? gpr_ptr + j : args_ptr);
|
|
389
|
-
double d = (double)ReverseBytes(v);
|
|
390
|
-
args_ptr += (j >= 4);
|
|
391
|
-
|
|
392
|
-
Napi::Value arg = Napi::Number::New(env, d);
|
|
393
|
-
arguments.Append(arg);
|
|
394
|
-
} break;
|
|
395
|
-
case PrimitiveKind::UInt16: {
|
|
396
|
-
double d = (double)*(uint16_t *)(j < 4 ? gpr_ptr + j : args_ptr);
|
|
397
|
-
args_ptr += (j >= 4);
|
|
398
|
-
|
|
399
|
-
Napi::Value arg = Napi::Number::New(env, d);
|
|
400
|
-
arguments.Append(arg);
|
|
401
|
-
} break;
|
|
402
|
-
case PrimitiveKind::UInt16S: {
|
|
403
|
-
uint16_t v = *(uint16_t *)(j < 4 ? gpr_ptr + j : args_ptr);
|
|
404
|
-
double d = (double)ReverseBytes(v);
|
|
405
|
-
args_ptr += (j >= 4);
|
|
406
|
-
|
|
407
|
-
Napi::Value arg = Napi::Number::New(env, d);
|
|
408
|
-
arguments.Append(arg);
|
|
409
|
-
} break;
|
|
410
|
-
case PrimitiveKind::Int32: {
|
|
411
|
-
double d = (double)*(int32_t *)(j < 4 ? gpr_ptr + j : args_ptr);
|
|
412
|
-
args_ptr += (j >= 4);
|
|
413
|
-
|
|
414
|
-
Napi::Value arg = Napi::Number::New(env, d);
|
|
415
|
-
arguments.Append(arg);
|
|
416
|
-
} break;
|
|
417
|
-
case PrimitiveKind::Int32S: {
|
|
418
|
-
int32_t v = *(int32_t *)(j < 4 ? gpr_ptr + j : args_ptr);
|
|
419
|
-
double d = (double)ReverseBytes(v);
|
|
420
|
-
args_ptr += (j >= 4);
|
|
421
|
-
|
|
422
|
-
Napi::Value arg = Napi::Number::New(env, d);
|
|
423
|
-
arguments.Append(arg);
|
|
424
|
-
} break;
|
|
425
|
-
case PrimitiveKind::UInt32: {
|
|
426
|
-
double d = (double)*(uint32_t *)(j < 4 ? gpr_ptr + j : args_ptr);
|
|
427
|
-
args_ptr += (j >= 4);
|
|
428
|
-
|
|
429
|
-
Napi::Value arg = Napi::Number::New(env, d);
|
|
430
|
-
arguments.Append(arg);
|
|
431
|
-
} break;
|
|
432
|
-
case PrimitiveKind::UInt32S: {
|
|
433
|
-
uint32_t v = *(uint32_t *)(j < 4 ? gpr_ptr + j : args_ptr);
|
|
434
|
-
double d = (double)ReverseBytes(v);
|
|
435
|
-
args_ptr += (j >= 4);
|
|
436
|
-
|
|
437
|
-
Napi::Value arg = Napi::Number::New(env, d);
|
|
438
|
-
arguments.Append(arg);
|
|
439
|
-
} break;
|
|
440
|
-
case PrimitiveKind::Int64: {
|
|
441
|
-
int64_t v = *(int64_t *)(j < 4 ? gpr_ptr + j : args_ptr);
|
|
442
|
-
args_ptr += (j >= 4);
|
|
443
|
-
|
|
444
|
-
Napi::Value arg = NewBigInt(env, v);
|
|
445
|
-
arguments.Append(arg);
|
|
446
|
-
} break;
|
|
447
|
-
case PrimitiveKind::Int64S: {
|
|
448
|
-
int64_t v = *(int64_t *)(j < 4 ? gpr_ptr + j : args_ptr);
|
|
449
|
-
args_ptr += (j >= 4);
|
|
450
|
-
|
|
451
|
-
Napi::Value arg = NewBigInt(env, ReverseBytes(v));
|
|
452
|
-
arguments.Append(arg);
|
|
453
|
-
} break;
|
|
454
|
-
case PrimitiveKind::UInt64: {
|
|
455
|
-
uint64_t v = *(uint64_t *)(j < 4 ? gpr_ptr + j : args_ptr);
|
|
456
|
-
args_ptr += (j >= 4);
|
|
457
|
-
|
|
458
|
-
Napi::Value arg = NewBigInt(env, v);
|
|
459
|
-
arguments.Append(arg);
|
|
460
|
-
} break;
|
|
461
|
-
case PrimitiveKind::UInt64S: {
|
|
462
|
-
uint64_t v = *(uint64_t *)(j < 4 ? gpr_ptr + j : args_ptr);
|
|
463
|
-
args_ptr += (j >= 4);
|
|
464
|
-
|
|
465
|
-
Napi::Value arg = NewBigInt(env, ReverseBytes(v));
|
|
466
|
-
arguments.Append(arg);
|
|
467
|
-
} break;
|
|
468
|
-
case PrimitiveKind::String: {
|
|
469
|
-
const char *str = *(const char **)(j < 4 ? gpr_ptr + j : args_ptr);
|
|
470
|
-
args_ptr += (j >= 4);
|
|
471
|
-
|
|
472
|
-
Napi::Value arg = str ? Napi::String::New(env, str) : env.Null();
|
|
473
|
-
arguments.Append(arg);
|
|
474
|
-
|
|
475
|
-
if (param.type->dispose) {
|
|
476
|
-
param.type->dispose(env, param.type, str);
|
|
477
|
-
}
|
|
478
|
-
} break;
|
|
479
|
-
case PrimitiveKind::String16: {
|
|
480
|
-
const char16_t *str16 = *(const char16_t **)(j < 4 ? gpr_ptr + j : args_ptr);
|
|
481
|
-
args_ptr += (j >= 4);
|
|
482
|
-
|
|
483
|
-
Napi::Value arg = str16 ? Napi::String::New(env, str16) : env.Null();
|
|
484
|
-
arguments.Append(arg);
|
|
485
|
-
|
|
486
|
-
if (param.type->dispose) {
|
|
487
|
-
param.type->dispose(env, param.type, str16);
|
|
488
|
-
}
|
|
489
|
-
} break;
|
|
490
|
-
case PrimitiveKind::String32: {
|
|
491
|
-
const char32_t *str32 = *(const char32_t **)(j < 4 ? gpr_ptr + j : args_ptr);
|
|
492
|
-
args_ptr += (j >= 4);
|
|
493
|
-
|
|
494
|
-
Napi::Value arg = str32 ? MakeStringFromUTF32(env, str32) : env.Null();
|
|
495
|
-
arguments.Append(arg);
|
|
496
|
-
} break;
|
|
497
|
-
case PrimitiveKind::Pointer:
|
|
498
|
-
case PrimitiveKind::Callback: {
|
|
499
|
-
void *ptr2 = *(void **)(j < 4 ? gpr_ptr + j : args_ptr);
|
|
500
|
-
args_ptr += (j >= 4);
|
|
501
|
-
|
|
502
|
-
if (ptr2) {
|
|
503
|
-
Napi::External<void> external = Napi::External<void>::New(env, ptr2);
|
|
504
|
-
SetValueTag(external, param.type->ref.marker);
|
|
505
|
-
|
|
506
|
-
arguments.Append(external);
|
|
507
|
-
} else {
|
|
508
|
-
arguments.Append(env.Null());
|
|
509
|
-
}
|
|
510
|
-
|
|
511
|
-
if (param.type->dispose) {
|
|
512
|
-
param.type->dispose(env, param.type, ptr2);
|
|
513
|
-
}
|
|
514
|
-
} break;
|
|
515
|
-
case PrimitiveKind::Record:
|
|
516
|
-
case PrimitiveKind::Union: {
|
|
517
|
-
uint8_t *ptr;
|
|
518
|
-
if (param.regular) {
|
|
519
|
-
ptr = (uint8_t *)(j < 4 ? gpr_ptr + j : args_ptr);
|
|
520
|
-
} else {
|
|
521
|
-
ptr = *(uint8_t **)(j < 4 ? gpr_ptr + j : args_ptr);
|
|
522
|
-
}
|
|
523
|
-
args_ptr += (j >= 4);
|
|
524
|
-
|
|
525
|
-
Napi::Object obj2 = DecodeObject(env, ptr, param.type);
|
|
526
|
-
arguments.Append(obj2);
|
|
527
|
-
} break;
|
|
528
|
-
case PrimitiveKind::Array: { K_UNREACHABLE(); } break;
|
|
529
|
-
case PrimitiveKind::Float32: {
|
|
530
|
-
float f = *(float *)(j < 4 ? xmm_ptr + j : args_ptr);
|
|
531
|
-
args_ptr += (j >= 4);
|
|
532
|
-
|
|
533
|
-
Napi::Value arg = Napi::Number::New(env, (double)f);
|
|
534
|
-
arguments.Append(arg);
|
|
535
|
-
} break;
|
|
536
|
-
case PrimitiveKind::Float64: {
|
|
537
|
-
double d = *(double *)(j < 4 ? xmm_ptr + j : args_ptr);
|
|
538
|
-
args_ptr += (j >= 4);
|
|
539
|
-
|
|
540
|
-
Napi::Value arg = Napi::Number::New(env, d);
|
|
541
|
-
arguments.Append(arg);
|
|
542
|
-
} break;
|
|
543
|
-
|
|
544
|
-
case PrimitiveKind::Prototype: { K_UNREACHABLE(); } break;
|
|
545
|
-
}
|
|
546
|
-
}
|
|
547
|
-
|
|
548
|
-
const TypeInfo *type = proto->ret.type;
|
|
549
|
-
|
|
550
|
-
// Make the call!
|
|
551
|
-
Napi::Value value = func.Call(arguments[0], arguments.len - 1, arguments.data + 1);
|
|
552
|
-
|
|
553
|
-
if (env.IsExceptionPending()) [[unlikely]]
|
|
554
|
-
return;
|
|
555
|
-
|
|
556
|
-
#define RETURN_INTEGER(CType) \
|
|
557
|
-
do { \
|
|
558
|
-
if (!value.IsNumber() && !value.IsBigInt()) [[unlikely]] { \
|
|
559
|
-
ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected number", GetValueType(instance, value)); \
|
|
560
|
-
return; \
|
|
561
|
-
} \
|
|
562
|
-
\
|
|
563
|
-
CType v = GetNumber<CType>(value); \
|
|
564
|
-
out_reg->rax = (uint64_t)v; \
|
|
565
|
-
} while (false)
|
|
566
|
-
#define RETURN_INTEGER_SWAP(CType) \
|
|
567
|
-
do { \
|
|
568
|
-
if (!value.IsNumber() && !value.IsBigInt()) [[unlikely]] { \
|
|
569
|
-
ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected number", GetValueType(instance, value)); \
|
|
570
|
-
return; \
|
|
571
|
-
} \
|
|
572
|
-
\
|
|
573
|
-
CType v = GetNumber<CType>(value); \
|
|
574
|
-
out_reg->rax = (uint64_t)ReverseBytes(v); \
|
|
575
|
-
} while (false)
|
|
576
|
-
|
|
577
|
-
switch (type->primitive) {
|
|
578
|
-
case PrimitiveKind::Void: {} break;
|
|
579
|
-
case PrimitiveKind::Bool: {
|
|
580
|
-
if (!value.IsBoolean()) [[unlikely]] {
|
|
581
|
-
ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected boolean", GetValueType(instance, value));
|
|
582
|
-
return;
|
|
583
|
-
}
|
|
584
|
-
|
|
585
|
-
bool b = value.As<Napi::Boolean>();
|
|
586
|
-
out_reg->rax = (uint64_t)b;
|
|
587
|
-
} break;
|
|
588
|
-
case PrimitiveKind::Int8: { RETURN_INTEGER(int8_t); } break;
|
|
589
|
-
case PrimitiveKind::UInt8: { RETURN_INTEGER(uint8_t); } break;
|
|
590
|
-
case PrimitiveKind::Int16: { RETURN_INTEGER(int16_t); } break;
|
|
591
|
-
case PrimitiveKind::Int16S: { RETURN_INTEGER_SWAP(int16_t); } break;
|
|
592
|
-
case PrimitiveKind::UInt16: { RETURN_INTEGER(uint16_t); } break;
|
|
593
|
-
case PrimitiveKind::UInt16S: { RETURN_INTEGER_SWAP(uint16_t); } break;
|
|
594
|
-
case PrimitiveKind::Int32: { RETURN_INTEGER(int32_t); } break;
|
|
595
|
-
case PrimitiveKind::Int32S: { RETURN_INTEGER_SWAP(int32_t); } break;
|
|
596
|
-
case PrimitiveKind::UInt32: { RETURN_INTEGER(uint32_t); } break;
|
|
597
|
-
case PrimitiveKind::UInt32S: { RETURN_INTEGER_SWAP(uint32_t); } break;
|
|
598
|
-
case PrimitiveKind::Int64: { RETURN_INTEGER(int64_t); } break;
|
|
599
|
-
case PrimitiveKind::Int64S: { RETURN_INTEGER_SWAP(int64_t); } break;
|
|
600
|
-
case PrimitiveKind::UInt64: { RETURN_INTEGER(uint64_t); } break;
|
|
601
|
-
case PrimitiveKind::UInt64S: { RETURN_INTEGER_SWAP(uint64_t); } break;
|
|
602
|
-
case PrimitiveKind::String: {
|
|
603
|
-
const char *str;
|
|
604
|
-
if (!PushString(value, 1, &str)) [[unlikely]]
|
|
605
|
-
return;
|
|
606
|
-
|
|
607
|
-
out_reg->rax = (uint64_t)str;
|
|
608
|
-
} break;
|
|
609
|
-
case PrimitiveKind::String16: {
|
|
610
|
-
const char16_t *str16;
|
|
611
|
-
if (!PushString16(value, 1, &str16)) [[unlikely]]
|
|
612
|
-
return;
|
|
613
|
-
|
|
614
|
-
out_reg->rax = (uint64_t)str16;
|
|
615
|
-
} break;
|
|
616
|
-
case PrimitiveKind::String32: {
|
|
617
|
-
const char32_t *str32;
|
|
618
|
-
if (!PushString32(value, 1, &str32)) [[unlikely]]
|
|
619
|
-
return;
|
|
620
|
-
|
|
621
|
-
out_reg->rax = (uint64_t)str32;
|
|
622
|
-
} break;
|
|
623
|
-
case PrimitiveKind::Pointer: {
|
|
624
|
-
uint8_t *ptr;
|
|
625
|
-
|
|
626
|
-
if (CheckValueTag(value, type->ref.marker)) {
|
|
627
|
-
ptr = value.As<Napi::External<uint8_t>>().Data();
|
|
628
|
-
} else if (IsObject(value) && (type->ref.type->primitive == PrimitiveKind::Record ||
|
|
629
|
-
type->ref.type->primitive == PrimitiveKind::Union)) {
|
|
630
|
-
Napi::Object obj = value.As<Napi::Object>();
|
|
631
|
-
|
|
632
|
-
ptr = AllocHeap(type->ref.type->size, 16);
|
|
633
|
-
|
|
634
|
-
if (!PushObject(obj, type->ref.type, ptr))
|
|
635
|
-
return;
|
|
636
|
-
} else if (IsNullOrUndefined(value)) {
|
|
637
|
-
ptr = nullptr;
|
|
638
|
-
} else {
|
|
639
|
-
ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected %2", GetValueType(instance, value), type->name);
|
|
640
|
-
return;
|
|
641
|
-
}
|
|
642
|
-
|
|
643
|
-
out_reg->rax = (uint64_t)ptr;
|
|
644
|
-
} break;
|
|
645
|
-
case PrimitiveKind::Record:
|
|
646
|
-
case PrimitiveKind::Union: {
|
|
647
|
-
if (!IsObject(value)) [[unlikely]] {
|
|
648
|
-
ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected object", GetValueType(instance, value));
|
|
649
|
-
return;
|
|
650
|
-
}
|
|
651
|
-
|
|
652
|
-
Napi::Object obj = value.As<Napi::Object>();
|
|
653
|
-
|
|
654
|
-
if (return_ptr) {
|
|
655
|
-
if (!PushObject(obj, type, return_ptr))
|
|
656
|
-
return;
|
|
657
|
-
out_reg->rax = (uint64_t)return_ptr;
|
|
658
|
-
} else {
|
|
659
|
-
PushObject(obj, type, (uint8_t *)&out_reg->rax);
|
|
660
|
-
}
|
|
661
|
-
} break;
|
|
662
|
-
case PrimitiveKind::Array: { K_UNREACHABLE(); } break;
|
|
663
|
-
case PrimitiveKind::Float32: {
|
|
664
|
-
if (!value.IsNumber() && !value.IsBigInt()) [[unlikely]] {
|
|
665
|
-
ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected number", GetValueType(instance, value));
|
|
666
|
-
return;
|
|
667
|
-
}
|
|
668
|
-
|
|
669
|
-
float f = GetNumber<float>(value);
|
|
670
|
-
|
|
671
|
-
memset((uint8_t *)&out_reg->xmm0 + 4, 0, 4);
|
|
672
|
-
memcpy(&out_reg->xmm0, &f, 4);
|
|
673
|
-
} break;
|
|
674
|
-
case PrimitiveKind::Float64: {
|
|
675
|
-
if (!value.IsNumber() && !value.IsBigInt()) [[unlikely]] {
|
|
676
|
-
ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected number", GetValueType(instance, value));
|
|
677
|
-
return;
|
|
678
|
-
}
|
|
679
|
-
|
|
680
|
-
double d = GetNumber<double>(value);
|
|
681
|
-
out_reg->xmm0 = d;
|
|
682
|
-
} break;
|
|
683
|
-
case PrimitiveKind::Callback: {
|
|
684
|
-
void *ptr;
|
|
685
|
-
|
|
686
|
-
if (value.IsFunction()) {
|
|
687
|
-
Napi::Function func2 = value.As<Napi::Function>();
|
|
688
|
-
|
|
689
|
-
ptr = ReserveTrampoline(type->ref.proto, func2);
|
|
690
|
-
if (!ptr) [[unlikely]]
|
|
691
|
-
return;
|
|
692
|
-
} else if (CheckValueTag(value, type->ref.marker)) {
|
|
693
|
-
ptr = value.As<Napi::External<void>>().Data();
|
|
694
|
-
} else if (IsNullOrUndefined(value)) {
|
|
695
|
-
ptr = nullptr;
|
|
696
|
-
} else {
|
|
697
|
-
ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected %2", GetValueType(instance, value), type->name);
|
|
698
|
-
return;
|
|
699
|
-
}
|
|
700
|
-
|
|
701
|
-
out_reg->rax = (uint64_t)ptr;
|
|
702
|
-
} break;
|
|
703
|
-
|
|
704
|
-
case PrimitiveKind::Prototype: { K_UNREACHABLE(); } break;
|
|
705
|
-
}
|
|
706
|
-
|
|
707
|
-
#undef RETURN_INTEGER_SWAP
|
|
708
|
-
#undef RETURN_INTEGER
|
|
709
|
-
|
|
710
|
-
err_guard.Disable();
|
|
711
|
-
}
|
|
712
|
-
|
|
713
|
-
}
|
|
714
|
-
|
|
715
|
-
#endif
|