koffi 2.5.0 → 2.5.1

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.
Files changed (48) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/build/2.5.1/koffi_darwin_arm64/koffi.node +0 -0
  3. package/build/{2.5.0 → 2.5.1}/koffi_darwin_x64/koffi.node +0 -0
  4. package/build/{2.5.0 → 2.5.1}/koffi_freebsd_arm64/koffi.node +0 -0
  5. package/build/{2.5.0 → 2.5.1}/koffi_freebsd_ia32/koffi.node +0 -0
  6. package/build/{2.5.0 → 2.5.1}/koffi_freebsd_x64/koffi.node +0 -0
  7. package/build/2.5.1/koffi_linux_arm32hf/koffi.node +0 -0
  8. package/build/2.5.1/koffi_linux_arm64/koffi.node +0 -0
  9. package/build/{2.5.0 → 2.5.1}/koffi_linux_ia32/koffi.node +0 -0
  10. package/build/{2.5.0 → 2.5.1}/koffi_linux_riscv64hf64/koffi.node +0 -0
  11. package/build/{2.5.0 → 2.5.1}/koffi_linux_x64/koffi.node +0 -0
  12. package/build/{2.5.0 → 2.5.1}/koffi_openbsd_ia32/koffi.node +0 -0
  13. package/build/{2.5.0 → 2.5.1}/koffi_openbsd_x64/koffi.node +0 -0
  14. package/build/2.5.1/koffi_win32_arm64/koffi.node +0 -0
  15. package/build/{2.5.0 → 2.5.1}/koffi_win32_ia32/koffi.node +0 -0
  16. package/build/{2.5.0 → 2.5.1}/koffi_win32_x64/koffi.node +0 -0
  17. package/package.json +2 -2
  18. package/src/core/libcc/brotli.cc +1 -1
  19. package/src/core/libcc/libcc.cc +53 -65
  20. package/src/core/libcc/libcc.hh +67 -28
  21. package/src/core/libcc/miniz.cc +2 -2
  22. package/src/koffi/CMakeLists.txt +1 -5
  23. package/src/koffi/src/abi_arm32.cc +35 -35
  24. package/src/koffi/src/abi_arm64.cc +34 -34
  25. package/src/koffi/src/abi_riscv64.cc +29 -29
  26. package/src/koffi/src/abi_x64_sysv.cc +29 -28
  27. package/src/koffi/src/abi_x64_win.cc +23 -23
  28. package/src/koffi/src/abi_x86.cc +27 -27
  29. package/src/koffi/src/call.cc +62 -69
  30. package/src/koffi/src/call.hh +2 -2
  31. package/src/koffi/src/ffi.cc +24 -24
  32. package/src/koffi/src/ffi.hh +4 -4
  33. package/src/koffi/src/parser.cc +1 -1
  34. package/src/koffi/src/trampolines/prototypes.inc +1 -1
  35. package/src/koffi/src/util.cc +7 -7
  36. package/src/koffi/src/util.hh +1 -1
  37. package/src/koffi/src/win32.hh +4 -4
  38. package/build/2.5.0/koffi_darwin_arm64/koffi.node +0 -0
  39. package/build/2.5.0/koffi_linux_arm32hf/koffi.node +0 -0
  40. package/build/2.5.0/koffi_linux_arm64/koffi.node +0 -0
  41. package/build/2.5.0/koffi_win32_arm64/koffi.node +0 -0
  42. package/build/2.5.0/koffi_win32_x64/koffi.pdb +0 -0
  43. /package/build/{2.5.0 → 2.5.1}/koffi_win32_arm64/koffi.exp +0 -0
  44. /package/build/{2.5.0 → 2.5.1}/koffi_win32_arm64/koffi.lib +0 -0
  45. /package/build/{2.5.0 → 2.5.1}/koffi_win32_ia32/koffi.exp +0 -0
  46. /package/build/{2.5.0 → 2.5.1}/koffi_win32_ia32/koffi.lib +0 -0
  47. /package/build/{2.5.0 → 2.5.1}/koffi_win32_x64/koffi.exp +0 -0
  48. /package/build/{2.5.0 → 2.5.1}/koffi_win32_x64/koffi.lib +0 -0
@@ -135,7 +135,7 @@ bool CallData::Prepare(const FunctionInfo *func, const Napi::CallbackInfo &info)
135
135
  uint32_t *fast_ptr = nullptr;
136
136
 
137
137
  // Pass return value in register or through memory
138
- if (RG_UNLIKELY(!AllocStack(func->args_size, 16, &args_ptr)))
138
+ if (!AllocStack(func->args_size, 16, &args_ptr)) [[unlikely]]
139
139
  return false;
140
140
  if (func->fast) {
141
141
  fast_ptr = args_ptr;
@@ -148,7 +148,7 @@ bool CallData::Prepare(const FunctionInfo *func, const Napi::CallbackInfo &info)
148
148
 
149
149
  #define PUSH_INTEGER_32(CType) \
150
150
  do { \
151
- if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) { \
151
+ if (!value.IsNumber() && !value.IsBigInt()) [[unlikely]] { \
152
152
  ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected number", GetValueType(instance, value)); \
153
153
  return false; \
154
154
  } \
@@ -158,7 +158,7 @@ bool CallData::Prepare(const FunctionInfo *func, const Napi::CallbackInfo &info)
158
158
  } while (false)
159
159
  #define PUSH_INTEGER_32_SWAP(CType) \
160
160
  do { \
161
- if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) { \
161
+ if (!value.IsNumber() && !value.IsBigInt()) [[unlikely]] { \
162
162
  ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected number", GetValueType(instance, value)); \
163
163
  return false; \
164
164
  } \
@@ -168,7 +168,7 @@ bool CallData::Prepare(const FunctionInfo *func, const Napi::CallbackInfo &info)
168
168
  } while (false)
169
169
  #define PUSH_INTEGER_64(CType) \
170
170
  do { \
171
- if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) { \
171
+ if (!value.IsNumber() && !value.IsBigInt()) [[unlikely]] { \
172
172
  ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected number", GetValueType(instance, value)); \
173
173
  return false; \
174
174
  } \
@@ -180,7 +180,7 @@ bool CallData::Prepare(const FunctionInfo *func, const Napi::CallbackInfo &info)
180
180
  } while (false)
181
181
  #define PUSH_INTEGER_64_SWAP(CType) \
182
182
  do { \
183
- if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) { \
183
+ if (!value.IsNumber() && !value.IsBigInt()) [[unlikely]] { \
184
184
  ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected number", GetValueType(instance, value)); \
185
185
  return false; \
186
186
  } \
@@ -202,7 +202,7 @@ bool CallData::Prepare(const FunctionInfo *func, const Napi::CallbackInfo &info)
202
202
  case PrimitiveKind::Void: { RG_UNREACHABLE(); } break;
203
203
 
204
204
  case PrimitiveKind::Bool: {
205
- if (RG_UNLIKELY(!value.IsBoolean())) {
205
+ if (!value.IsBoolean()) [[unlikely]] {
206
206
  ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected boolean", GetValueType(instance, value));
207
207
  return false;
208
208
  }
@@ -226,28 +226,28 @@ bool CallData::Prepare(const FunctionInfo *func, const Napi::CallbackInfo &info)
226
226
  case PrimitiveKind::UInt64S: { PUSH_INTEGER_64_SWAP(uint64_t); } break;
227
227
  case PrimitiveKind::String: {
228
228
  const char *str;
229
- if (RG_UNLIKELY(!PushString(value, param.directions, &str)))
229
+ if (!PushString(value, param.directions, &str)) [[unlikely]]
230
230
  return false;
231
231
 
232
232
  *(const char **)((param.fast ? fast_ptr : args_ptr)++) = str;
233
233
  } break;
234
234
  case PrimitiveKind::String16: {
235
235
  const char16_t *str16;
236
- if (RG_UNLIKELY(!PushString16(value, param.directions, &str16)))
236
+ if (!PushString16(value, param.directions, &str16)) [[unlikely]]
237
237
  return false;
238
238
 
239
239
  *(const char16_t **)((param.fast ? fast_ptr : args_ptr)++) = str16;
240
240
  } break;
241
241
  case PrimitiveKind::Pointer: {
242
242
  void *ptr;
243
- if (RG_UNLIKELY(!PushPointer(value, param.type, param.directions, &ptr)))
243
+ if (!PushPointer(value, param.type, param.directions, &ptr)) [[unlikely]]
244
244
  return false;
245
245
 
246
246
  *(void **)((param.fast ? fast_ptr : args_ptr)++) = ptr;
247
247
  } break;
248
248
  case PrimitiveKind::Record:
249
249
  case PrimitiveKind::Union: {
250
- if (RG_UNLIKELY(!IsObject(value))) {
250
+ if (!IsObject(value)) [[unlikely]] {
251
251
  ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected object", GetValueType(instance, value));
252
252
  return false;
253
253
  }
@@ -267,7 +267,7 @@ bool CallData::Prepare(const FunctionInfo *func, const Napi::CallbackInfo &info)
267
267
  } break;
268
268
  case PrimitiveKind::Array: { RG_UNREACHABLE(); } break;
269
269
  case PrimitiveKind::Float32: {
270
- if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) {
270
+ if (!value.IsNumber() && !value.IsBigInt()) [[unlikely]] {
271
271
  ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected number", GetValueType(instance, value));
272
272
  return false;
273
273
  }
@@ -276,7 +276,7 @@ bool CallData::Prepare(const FunctionInfo *func, const Napi::CallbackInfo &info)
276
276
  *(float *)((param.fast ? fast_ptr : args_ptr)++) = f;
277
277
  } break;
278
278
  case PrimitiveKind::Float64: {
279
- if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) {
279
+ if (!value.IsNumber() && !value.IsBigInt()) [[unlikely]] {
280
280
  ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected number", GetValueType(instance, value));
281
281
  return false;
282
282
  }
@@ -292,7 +292,7 @@ bool CallData::Prepare(const FunctionInfo *func, const Napi::CallbackInfo &info)
292
292
  Napi::Function func = value.As<Napi::Function>();
293
293
 
294
294
  ptr = ReserveTrampoline(param.type->ref.proto, func);
295
- if (RG_UNLIKELY(!ptr))
295
+ if (!ptr) [[unlikely]]
296
296
  return false;
297
297
  } else if (CheckValueTag(instance, value, param.type->ref.marker)) {
298
298
  ptr = value.As<Napi::External<void>>().Data();
@@ -462,7 +462,7 @@ Napi::Value CallData::Complete(const FunctionInfo *func)
462
462
 
463
463
  void CallData::Relay(Size idx, uint8_t *, uint8_t *caller_sp, bool async, BackRegisters *out_reg)
464
464
  {
465
- if (RG_UNLIKELY(env.IsExceptionPending()))
465
+ if (env.IsExceptionPending()) [[unlikely]]
466
466
  return;
467
467
 
468
468
  #ifdef _WIN32
@@ -510,7 +510,7 @@ void CallData::Relay(Size idx, uint8_t *, uint8_t *caller_sp, bool async, BackRe
510
510
  out_reg->ret_pop = pop;
511
511
  };
512
512
 
513
- if (RG_UNLIKELY(trampoline.generation >= 0 && trampoline.generation != (int32_t)mem->generation)) {
513
+ if (trampoline.generation >= 0 && trampoline.generation != (int32_t)mem->generation) [[unlikely]] {
514
514
  ThrowError<Napi::Error>(env, "Cannot use non-registered callback beyond FFI call");
515
515
  return;
516
516
  }
@@ -704,12 +704,12 @@ void CallData::Relay(Size idx, uint8_t *, uint8_t *caller_sp, bool async, BackRe
704
704
  }
705
705
  Napi::Value value(env, ret);
706
706
 
707
- if (RG_UNLIKELY(env.IsExceptionPending()))
707
+ if (env.IsExceptionPending()) [[unlikely]]
708
708
  return;
709
709
 
710
710
  #define RETURN_INTEGER_32(CType) \
711
711
  do { \
712
- if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) { \
712
+ if (!value.IsNumber() && !value.IsBigInt()) [[unlikely]] { \
713
713
  ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected number", GetValueType(instance, value)); \
714
714
  return; \
715
715
  } \
@@ -719,7 +719,7 @@ void CallData::Relay(Size idx, uint8_t *, uint8_t *caller_sp, bool async, BackRe
719
719
  } while (false)
720
720
  #define RETURN_INTEGER_32_SWAP(CType) \
721
721
  do { \
722
- if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) { \
722
+ if (!value.IsNumber() && !value.IsBigInt()) [[unlikely]] { \
723
723
  ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected number", GetValueType(instance, value)); \
724
724
  return; \
725
725
  } \
@@ -729,7 +729,7 @@ void CallData::Relay(Size idx, uint8_t *, uint8_t *caller_sp, bool async, BackRe
729
729
  } while (false)
730
730
  #define RETURN_INTEGER_64(CType) \
731
731
  do { \
732
- if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) { \
732
+ if (!value.IsNumber() && !value.IsBigInt()) [[unlikely]] { \
733
733
  ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected number", GetValueType(instance, value)); \
734
734
  return; \
735
735
  } \
@@ -741,7 +741,7 @@ void CallData::Relay(Size idx, uint8_t *, uint8_t *caller_sp, bool async, BackRe
741
741
  } while (false)
742
742
  #define RETURN_INTEGER_64_SWAP(CType) \
743
743
  do { \
744
- if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) { \
744
+ if (!value.IsNumber() && !value.IsBigInt()) [[unlikely]] { \
745
745
  ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected number", GetValueType(instance, value)); \
746
746
  return; \
747
747
  } \
@@ -755,7 +755,7 @@ void CallData::Relay(Size idx, uint8_t *, uint8_t *caller_sp, bool async, BackRe
755
755
  switch (type->primitive) {
756
756
  case PrimitiveKind::Void: {} break;
757
757
  case PrimitiveKind::Bool: {
758
- if (RG_UNLIKELY(!value.IsBoolean())) {
758
+ if (!value.IsBoolean()) [[unlikely]] {
759
759
  ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected boolean", GetValueType(instance, value));
760
760
  return;
761
761
  }
@@ -779,14 +779,14 @@ void CallData::Relay(Size idx, uint8_t *, uint8_t *caller_sp, bool async, BackRe
779
779
  case PrimitiveKind::UInt64S: { RETURN_INTEGER_64_SWAP(uint64_t); } break;
780
780
  case PrimitiveKind::String: {
781
781
  const char *str;
782
- if (RG_UNLIKELY(!PushString(value, 1, &str)))
782
+ if (!PushString(value, 1, &str)) [[unlikely]]
783
783
  return;
784
784
 
785
785
  out_reg->eax = (uint32_t)str;
786
786
  } break;
787
787
  case PrimitiveKind::String16: {
788
788
  const char16_t *str16;
789
- if (RG_UNLIKELY(!PushString16(value, 1, &str16)))
789
+ if (!PushString16(value, 1, &str16)) [[unlikely]]
790
790
  return;
791
791
 
792
792
  out_reg->eax = (uint32_t)str16;
@@ -815,7 +815,7 @@ void CallData::Relay(Size idx, uint8_t *, uint8_t *caller_sp, bool async, BackRe
815
815
  } break;
816
816
  case PrimitiveKind::Record:
817
817
  case PrimitiveKind::Union: {
818
- if (RG_UNLIKELY(!IsObject(value))) {
818
+ if (!IsObject(value)) [[unlikely]] {
819
819
  ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected object", GetValueType(instance, value));
820
820
  return;
821
821
  }
@@ -832,7 +832,7 @@ void CallData::Relay(Size idx, uint8_t *, uint8_t *caller_sp, bool async, BackRe
832
832
  } break;
833
833
  case PrimitiveKind::Array: { RG_UNREACHABLE(); } break;
834
834
  case PrimitiveKind::Float32: {
835
- if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) {
835
+ if (!value.IsNumber() && !value.IsBigInt()) [[unlikely]] {
836
836
  ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected number", GetValueType(instance, value));
837
837
  return;
838
838
  }
@@ -841,7 +841,7 @@ void CallData::Relay(Size idx, uint8_t *, uint8_t *caller_sp, bool async, BackRe
841
841
  out_reg->x87_double = false;
842
842
  } break;
843
843
  case PrimitiveKind::Float64: {
844
- if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) {
844
+ if (!value.IsNumber() && !value.IsBigInt()) [[unlikely]] {
845
845
  ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected number", GetValueType(instance, value));
846
846
  return;
847
847
  }
@@ -856,7 +856,7 @@ void CallData::Relay(Size idx, uint8_t *, uint8_t *caller_sp, bool async, BackRe
856
856
  Napi::Function func2 = value.As<Napi::Function>();
857
857
 
858
858
  ptr = ReserveTrampoline(type->ref.proto, func2);
859
- if (RG_UNLIKELY(!ptr))
859
+ if (!ptr) [[unlikely]]
860
860
  return;
861
861
  } else if (CheckValueTag(instance, value, type->ref.marker)) {
862
862
  ptr = value.As<Napi::External<void>>().Data();