koffi 2.1.0-beta.2 → 2.1.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.
- package/ChangeLog.md +11 -4
- package/build/qemu/2.1.1/koffi_darwin_arm64.tar.gz +0 -0
- package/build/qemu/2.1.1/koffi_darwin_x64.tar.gz +0 -0
- package/build/qemu/2.1.1/koffi_freebsd_arm64.tar.gz +0 -0
- package/build/qemu/2.1.1/koffi_freebsd_ia32.tar.gz +0 -0
- package/build/qemu/2.1.1/koffi_freebsd_x64.tar.gz +0 -0
- package/build/qemu/2.1.1/koffi_linux_arm32hf.tar.gz +0 -0
- package/build/qemu/2.1.1/koffi_linux_arm64.tar.gz +0 -0
- package/build/qemu/2.1.1/koffi_linux_ia32.tar.gz +0 -0
- package/build/qemu/2.1.1/koffi_linux_riscv64hf64.tar.gz +0 -0
- package/build/qemu/2.1.1/koffi_linux_x64.tar.gz +0 -0
- package/build/qemu/2.1.1/koffi_openbsd_ia32.tar.gz +0 -0
- package/build/qemu/2.1.1/koffi_openbsd_x64.tar.gz +0 -0
- package/build/qemu/2.1.1/koffi_win32_arm64.tar.gz +0 -0
- package/build/qemu/2.1.1/koffi_win32_ia32.tar.gz +0 -0
- package/build/qemu/2.1.1/koffi_win32_x64.tar.gz +0 -0
- package/doc/Makefile +1 -1
- package/doc/benchmarks.md +14 -14
- package/doc/benchmarks.xlsx +0 -0
- package/doc/conf.py +5 -0
- package/doc/index.rst +2 -2
- package/doc/make.bat +1 -1
- package/doc/static/perf_linux_20220812.png +0 -0
- package/doc/static/perf_windows_20220812.png +0 -0
- package/doc/templates/badges.html +1 -1
- package/doc/types.md +12 -12
- package/package.json +2 -1
- package/qemu/registry/machines.json +2 -2
- package/qemu/registry/sha256sum.txt +2 -2
- package/src/abi_arm32.cc +158 -248
- package/src/abi_arm64.cc +129 -170
- package/src/abi_riscv64.cc +92 -140
- package/src/abi_x64_sysv.cc +92 -140
- package/src/abi_x64_win.cc +92 -140
- package/src/abi_x86.cc +144 -212
- package/src/call.cc +117 -143
- package/src/call.hh +4 -4
- package/src/ffi.cc +16 -4
- package/src/util.hh +0 -20
- package/test/callbacks.js +3 -3
- package/test/misc.c +45 -2
- package/test/sync.js +83 -2
- package/vendor/libcc/libcc.cc +97 -77
- package/vendor/libcc/libcc.hh +362 -259
- package/vendor/raylib/projects/VS2019-Android/raylib_android/raylib_android.NativeActivity/raylib_android.NativeActivity.vcxproj +226 -0
- package/vendor/raylib/projects/VS2019-Android/raylib_android/raylib_android.NativeActivity/raylib_android.NativeActivity.vcxproj.filters +10 -0
- package/vendor/raylib/projects/VS2019-Android/raylib_android/raylib_android.NativeActivity/raylib_android.NativeActivity.vcxproj.user +4 -0
- package/vendor/raylib/projects/VS2019-Android/raylib_android.sln +75 -0
- package/vendor/raylib/projects/VS2022/examples/audio_module_playing.vcxproj +390 -0
- package/vendor/raylib/projects/VS2022/examples/audio_multichannel_sound.vcxproj +390 -0
- package/vendor/raylib/projects/VS2022/examples/audio_music_stream.vcxproj +390 -0
- package/vendor/raylib/projects/VS2022/examples/audio_raw_stream.vcxproj +390 -0
- package/vendor/raylib/projects/VS2022/examples/audio_sound_loading.vcxproj +390 -0
- package/vendor/raylib/projects/VS2022/examples/audio_stream_effects.vcxproj +390 -0
- package/vendor/raylib/projects/VS2022/examples/core_2d_camera.vcxproj +390 -0
- package/vendor/raylib/projects/VS2022/examples/core_2d_camera_mouse_zoom.vcxproj +390 -0
- package/vendor/raylib/projects/VS2022/examples/core_2d_camera_platformer.vcxproj +390 -0
- package/vendor/raylib/projects/VS2022/examples/core_3d_camera_first_person.vcxproj +390 -0
- package/vendor/raylib/projects/VS2022/examples/core_3d_camera_free.vcxproj +390 -0
- package/vendor/raylib/projects/VS2022/examples/core_3d_camera_mode.vcxproj +390 -0
- package/vendor/raylib/projects/VS2022/examples/core_3d_picking.vcxproj +390 -0
- package/vendor/raylib/projects/VS2022/examples/core_basic_screen_manager.vcxproj +390 -0
- package/vendor/raylib/projects/VS2022/examples/core_basic_window.vcxproj +390 -0
- package/vendor/raylib/projects/VS2022/examples/core_custom_frame_control.vcxproj +390 -0
- package/vendor/raylib/projects/VS2022/examples/core_custom_logging.vcxproj +390 -0
- package/vendor/raylib/projects/VS2022/examples/core_drop_files.vcxproj +390 -0
- package/vendor/raylib/projects/VS2022/examples/core_input_gamepad.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/core_input_gestures.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/core_input_keys.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/core_input_mouse.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/core_input_mouse_wheel.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/core_input_multitouch.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/core_loading_thread.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/core_random_values.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/core_scissor_test.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/core_split_screen.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/core_storage_values.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/core_vr_simulator.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/core_window_flags.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/core_window_letterbox.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/core_window_should_close.vcxproj +390 -0
- package/vendor/raylib/projects/VS2022/examples/core_world_screen.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/easings_testbed.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/embedded_files_loading.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/models_animation.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/models_billboard.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/models_box_collisions.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/models_cubicmap.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/models_first_person_maze.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/models_geometric_shapes.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/models_heightmap.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/models_loading.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/models_loading_gltf.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/models_loading_vox.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/models_mesh_generation.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/models_mesh_picking.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/models_orthographic_projection.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/models_rlgl_solar_system.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/models_skybox.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/models_waving_cubes.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/models_yaw_pitch_roll.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/rlgl_compute_shaders.vcxproj +391 -0
- package/vendor/raylib/projects/VS2022/examples/rlgl_standalone.vcxproj +391 -0
- package/vendor/raylib/projects/VS2022/examples/shaders_basic_lighting.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/shaders_custom_uniform.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/shaders_eratosthenes.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/shaders_fog.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/shaders_hot_reloading.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/shaders_julia_set.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/shaders_mesh_instancing.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/shaders_model_shader.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/shaders_multi_sample2d.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/shaders_palette_switch.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/shaders_postprocessing.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/shaders_raymarching.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/shaders_shapes_textures.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/shaders_simple_mask.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/shaders_spotlight.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/shaders_texture_drawing.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/shaders_texture_waves.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/shapes_basic_shapes.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/shapes_bouncing_ball.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/shapes_collision_area.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/shapes_colors_palette.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/shapes_draw_circle_sector.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/shapes_draw_rectangle_rounded.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/shapes_draw_ring.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/shapes_easings_ball_anim.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/shapes_easings_box_anim.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/shapes_easings_rectangle_array.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/shapes_following_eyes.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/shapes_lines_bezier.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/shapes_logo_raylib.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/shapes_logo_raylib_anim.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/shapes_rectangle_scaling.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/text_codepoints_loading.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/text_draw_3d.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/text_font_filters.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/text_font_loading.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/text_font_sdf.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/text_font_spritefont.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/text_format_text.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/text_input_box.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/text_raylib_fonts.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/text_rectangle_bounds.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/text_unicode.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/text_writing_anim.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/textures_background_scrolling.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/textures_blend_modes.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/textures_bunnymark.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/textures_draw_tiled.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/textures_fog_of_war.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/textures_gif_player.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/textures_image_drawing.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/textures_image_generation.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/textures_image_loading.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/textures_image_processing.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/textures_image_text.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/textures_logo_raylib.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/textures_mouse_painting.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/textures_npatch_drawing.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/textures_particles_blending.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/textures_polygon.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/textures_raw_data.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/textures_sprite_anim.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/textures_sprite_button.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/textures_sprite_explosion.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/textures_srcrec_dstrec.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/textures_to_image.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/raylib/raylib.vcxproj +340 -0
- package/vendor/raylib/projects/VS2022/raylib.sln +2347 -0
- package/build/qemu/2.1.0-beta.2/koffi_darwin_arm64.tar.gz +0 -0
- package/build/qemu/2.1.0-beta.2/koffi_darwin_x64.tar.gz +0 -0
- package/build/qemu/2.1.0-beta.2/koffi_freebsd_arm64.tar.gz +0 -0
- package/build/qemu/2.1.0-beta.2/koffi_freebsd_ia32.tar.gz +0 -0
- package/build/qemu/2.1.0-beta.2/koffi_freebsd_x64.tar.gz +0 -0
- package/build/qemu/2.1.0-beta.2/koffi_linux_arm32hf.tar.gz +0 -0
- package/build/qemu/2.1.0-beta.2/koffi_linux_arm64.tar.gz +0 -0
- package/build/qemu/2.1.0-beta.2/koffi_linux_ia32.tar.gz +0 -0
- package/build/qemu/2.1.0-beta.2/koffi_linux_riscv64hf64.tar.gz +0 -0
- package/build/qemu/2.1.0-beta.2/koffi_linux_x64.tar.gz +0 -0
- package/build/qemu/2.1.0-beta.2/koffi_openbsd_ia32.tar.gz +0 -0
- package/build/qemu/2.1.0-beta.2/koffi_openbsd_x64.tar.gz +0 -0
- package/build/qemu/2.1.0-beta.2/koffi_win32_arm64.tar.gz +0 -0
- package/build/qemu/2.1.0-beta.2/koffi_win32_ia32.tar.gz +0 -0
- package/build/qemu/2.1.0-beta.2/koffi_win32_x64.tar.gz +0 -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/memory.doctree +0 -0
- package/doc/dist/doctrees/platforms.doctree +0 -0
- package/doc/dist/doctrees/start.doctree +0 -0
- package/doc/dist/doctrees/types.doctree +0 -0
- package/doc/dist/html/_static/perf_linux_20220627.png +0 -0
- package/doc/dist/html/_static/perf_linux_20220628.png +0 -0
- package/doc/dist/html/_static/perf_windows_20220627.png +0 -0
- package/doc/dist/html/_static/perf_windows_20220628.png +0 -0
package/src/abi_arm64.cc
CHANGED
|
@@ -265,6 +265,64 @@ bool CallData::Prepare(const Napi::CallbackInfo &info)
|
|
|
265
265
|
gpr_ptr[8] = (uint64_t)return_ptr;
|
|
266
266
|
}
|
|
267
267
|
|
|
268
|
+
#ifdef __APPLE__
|
|
269
|
+
#define PUSH_INTEGER(CType) \
|
|
270
|
+
do { \
|
|
271
|
+
if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) { \
|
|
272
|
+
ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected number", GetValueType(instance, value)); \
|
|
273
|
+
return false; \
|
|
274
|
+
} \
|
|
275
|
+
\
|
|
276
|
+
CType v = CopyNumber<CType>(value); \
|
|
277
|
+
\
|
|
278
|
+
if (RG_LIKELY(param.gpr_count)) { \
|
|
279
|
+
*(gpr_ptr++) = (uint64_t)v; \
|
|
280
|
+
} else { \
|
|
281
|
+
args_ptr = AlignUp(args_ptr, param.type->align); \
|
|
282
|
+
*args_ptr = (uint64_t)v; \
|
|
283
|
+
args_ptr = (uint64_t *)((uint8_t *)args_ptr + param.type->size); \
|
|
284
|
+
} \
|
|
285
|
+
} while (false)
|
|
286
|
+
#define PUSH_INTEGER_SWAP(CType) \
|
|
287
|
+
do { \
|
|
288
|
+
if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) { \
|
|
289
|
+
ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected number", GetValueType(instance, value)); \
|
|
290
|
+
return false; \
|
|
291
|
+
} \
|
|
292
|
+
\
|
|
293
|
+
CType v = CopyNumber<CType>(value); \
|
|
294
|
+
\
|
|
295
|
+
if (RG_LIKELY(param.gpr_count)) { \
|
|
296
|
+
*(gpr_ptr++) = (uint64_t)ReverseBytes(v); \
|
|
297
|
+
} else { \
|
|
298
|
+
args_ptr = AlignUp(args_ptr, param.type->align); \
|
|
299
|
+
*args_ptr = (uint64_t)ReverseBytes(v); \
|
|
300
|
+
args_ptr = (uint64_t *)((uint8_t *)args_ptr + param.type->size); \
|
|
301
|
+
} \
|
|
302
|
+
} while (false)
|
|
303
|
+
#else
|
|
304
|
+
#define PUSH_INTEGER(CType) \
|
|
305
|
+
do { \
|
|
306
|
+
if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) { \
|
|
307
|
+
ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected number", GetValueType(instance, value)); \
|
|
308
|
+
return false; \
|
|
309
|
+
} \
|
|
310
|
+
\
|
|
311
|
+
CType v = CopyNumber<CType>(value); \
|
|
312
|
+
*((param.gpr_count ? gpr_ptr : args_ptr)++) = (uint64_t)v; \
|
|
313
|
+
} while (false)
|
|
314
|
+
#define PUSH_INTEGER_SWAP(CType) \
|
|
315
|
+
do { \
|
|
316
|
+
if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) { \
|
|
317
|
+
ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected number", GetValueType(instance, value)); \
|
|
318
|
+
return false; \
|
|
319
|
+
} \
|
|
320
|
+
\
|
|
321
|
+
CType v = CopyNumber<CType>(value); \
|
|
322
|
+
*((param.gpr_count ? gpr_ptr : args_ptr)++) = (uint64_t)ReverseBytes(v); \
|
|
323
|
+
} while (false)
|
|
324
|
+
#endif
|
|
325
|
+
|
|
268
326
|
// Push arguments
|
|
269
327
|
for (Size i = 0; i < func->parameters.len; i++) {
|
|
270
328
|
const ParameterInfo ¶m = func->parameters[i];
|
|
@@ -277,7 +335,7 @@ bool CallData::Prepare(const Napi::CallbackInfo &info)
|
|
|
277
335
|
|
|
278
336
|
case PrimitiveKind::Bool: {
|
|
279
337
|
if (RG_UNLIKELY(!value.IsBoolean())) {
|
|
280
|
-
ThrowError<Napi::TypeError>(env, "Unexpected %1 value
|
|
338
|
+
ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected boolean", GetValueType(instance, value));
|
|
281
339
|
return false;
|
|
282
340
|
}
|
|
283
341
|
|
|
@@ -294,94 +352,24 @@ bool CallData::Prepare(const Napi::CallbackInfo &info)
|
|
|
294
352
|
*((param.gpr_count ? gpr_ptr : args_ptr)++) = (uint64_t)b;
|
|
295
353
|
#endif
|
|
296
354
|
} break;
|
|
297
|
-
case PrimitiveKind::Int8:
|
|
298
|
-
case PrimitiveKind::UInt8:
|
|
299
|
-
case PrimitiveKind::Int16:
|
|
300
|
-
case PrimitiveKind::
|
|
301
|
-
case PrimitiveKind::
|
|
302
|
-
case PrimitiveKind::
|
|
303
|
-
case PrimitiveKind::
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
#ifdef __APPLE__
|
|
312
|
-
if (RG_LIKELY(param.gpr_count)) {
|
|
313
|
-
*(int64_t *)(gpr_ptr++) = v;
|
|
314
|
-
} else {
|
|
315
|
-
args_ptr = AlignUp(args_ptr, param.type->align);
|
|
316
|
-
*(int64_t *)args_ptr = v;
|
|
317
|
-
args_ptr = (uint64_t *)((uint8_t *)args_ptr + param.type->size);
|
|
318
|
-
}
|
|
319
|
-
#else
|
|
320
|
-
*(int64_t *)((param.gpr_count ? gpr_ptr : args_ptr)++) = v;
|
|
321
|
-
#endif
|
|
322
|
-
} break;
|
|
323
|
-
case PrimitiveKind::Int16S:
|
|
324
|
-
case PrimitiveKind::UInt16S:
|
|
325
|
-
case PrimitiveKind::Int32S:
|
|
326
|
-
case PrimitiveKind::UInt32S:
|
|
327
|
-
case PrimitiveKind::Int64S: {
|
|
328
|
-
if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) {
|
|
329
|
-
ThrowError<Napi::TypeError>(env, "Unexpected %1 value for argument %2, expected number", GetValueType(instance, value), param.offset + 1);
|
|
330
|
-
return false;
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
int64_t v = ReverseBytes(CopyNumber<int64_t>(value));
|
|
334
|
-
|
|
335
|
-
#ifdef __APPLE__
|
|
336
|
-
if (RG_LIKELY(param.gpr_count)) {
|
|
337
|
-
*(int64_t *)(gpr_ptr++) = v;
|
|
338
|
-
} else {
|
|
339
|
-
args_ptr = AlignUp(args_ptr, param.type->align);
|
|
340
|
-
*(int64_t *)args_ptr = v;
|
|
341
|
-
args_ptr = (uint64_t *)((uint8_t *)args_ptr + param.type->size);
|
|
342
|
-
}
|
|
343
|
-
#else
|
|
344
|
-
*(int64_t *)((param.gpr_count ? gpr_ptr : args_ptr)++) = v;
|
|
345
|
-
#endif
|
|
346
|
-
} break;
|
|
347
|
-
case PrimitiveKind::UInt64: {
|
|
348
|
-
if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) {
|
|
349
|
-
ThrowError<Napi::TypeError>(env, "Unexpected %1 value for argument %2, expected number", GetValueType(instance, value), param.offset + 1);
|
|
350
|
-
return false;
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
uint64_t v = CopyNumber<uint64_t>(value);
|
|
354
|
-
|
|
355
|
-
#ifdef __APPLE__
|
|
356
|
-
args_ptr = param.gpr_count ? args_ptr : AlignUp(args_ptr, 8);
|
|
357
|
-
#endif
|
|
358
|
-
*((param.gpr_count ? gpr_ptr : args_ptr)++) = v;
|
|
359
|
-
} break;
|
|
360
|
-
case PrimitiveKind::UInt64S: {
|
|
361
|
-
if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) {
|
|
362
|
-
ThrowError<Napi::TypeError>(env, "Unexpected %1 value for argument %2, expected number", GetValueType(instance, value), param.offset + 1);
|
|
363
|
-
return false;
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
uint64_t v = ReverseBytes(CopyNumber<uint64_t>(value));
|
|
367
|
-
|
|
368
|
-
#ifdef __APPLE__
|
|
369
|
-
args_ptr = param.gpr_count ? args_ptr : AlignUp(args_ptr, 8);
|
|
370
|
-
#endif
|
|
371
|
-
*((param.gpr_count ? gpr_ptr : args_ptr)++) = v;
|
|
372
|
-
} break;
|
|
355
|
+
case PrimitiveKind::Int8: { PUSH_INTEGER(int8_t); } break;
|
|
356
|
+
case PrimitiveKind::UInt8: { PUSH_INTEGER(uint8_t); } break;
|
|
357
|
+
case PrimitiveKind::Int16: { PUSH_INTEGER(int16_t); } break;
|
|
358
|
+
case PrimitiveKind::Int16S: { PUSH_INTEGER_SWAP(int16_t); } break;
|
|
359
|
+
case PrimitiveKind::UInt16: { PUSH_INTEGER(uint16_t); } break;
|
|
360
|
+
case PrimitiveKind::UInt16S: { PUSH_INTEGER_SWAP(uint16_t); } break;
|
|
361
|
+
case PrimitiveKind::Int32: { PUSH_INTEGER(int32_t); } break;
|
|
362
|
+
case PrimitiveKind::Int32S: { PUSH_INTEGER_SWAP(int32_t); } break;
|
|
363
|
+
case PrimitiveKind::UInt32: { PUSH_INTEGER(uint32_t); } break;
|
|
364
|
+
case PrimitiveKind::UInt32S: { PUSH_INTEGER_SWAP(uint32_t); } break;
|
|
365
|
+
case PrimitiveKind::Int64: { PUSH_INTEGER(int64_t); } break;
|
|
366
|
+
case PrimitiveKind::Int64S: { PUSH_INTEGER_SWAP(int64_t); } break;
|
|
367
|
+
case PrimitiveKind::UInt64: { PUSH_INTEGER(uint64_t); } break;
|
|
368
|
+
case PrimitiveKind::UInt64S: { PUSH_INTEGER_SWAP(uint64_t); } break;
|
|
373
369
|
case PrimitiveKind::String: {
|
|
374
370
|
const char *str;
|
|
375
|
-
if (
|
|
376
|
-
str = PushString(value);
|
|
377
|
-
if (RG_UNLIKELY(!str))
|
|
378
|
-
return false;
|
|
379
|
-
} else if (IsNullOrUndefined(value)) {
|
|
380
|
-
str = nullptr;
|
|
381
|
-
} else {
|
|
382
|
-
ThrowError<Napi::TypeError>(env, "Unexpected %1 value for argument %2, expected string", GetValueType(instance, value), param.offset + 1);
|
|
371
|
+
if (RG_UNLIKELY(!PushString(value, &str)))
|
|
383
372
|
return false;
|
|
384
|
-
}
|
|
385
373
|
|
|
386
374
|
#ifdef __APPLE__
|
|
387
375
|
args_ptr = param.gpr_count ? args_ptr : AlignUp(args_ptr, 8);
|
|
@@ -390,16 +378,8 @@ bool CallData::Prepare(const Napi::CallbackInfo &info)
|
|
|
390
378
|
} break;
|
|
391
379
|
case PrimitiveKind::String16: {
|
|
392
380
|
const char16_t *str16;
|
|
393
|
-
if (
|
|
394
|
-
str16 = PushString16(value);
|
|
395
|
-
if (RG_UNLIKELY(!str16))
|
|
396
|
-
return false;
|
|
397
|
-
} else if (IsNullOrUndefined(value)) {
|
|
398
|
-
str16 = nullptr;
|
|
399
|
-
} else {
|
|
400
|
-
ThrowError<Napi::TypeError>(env, "Unexpected %1 value for argument %2, expected string", GetValueType(instance, value), param.offset + 1);
|
|
381
|
+
if (RG_UNLIKELY(!PushString16(value, &str16)))
|
|
401
382
|
return false;
|
|
402
|
-
}
|
|
403
383
|
|
|
404
384
|
#ifdef __APPLE__
|
|
405
385
|
args_ptr = param.gpr_count ? args_ptr : AlignUp(args_ptr, 8);
|
|
@@ -408,7 +388,7 @@ bool CallData::Prepare(const Napi::CallbackInfo &info)
|
|
|
408
388
|
} break;
|
|
409
389
|
case PrimitiveKind::Pointer: {
|
|
410
390
|
void *ptr;
|
|
411
|
-
if (RG_UNLIKELY(!PushPointer(value, param, &ptr)))
|
|
391
|
+
if (RG_UNLIKELY(!PushPointer(value, param.type, param.directions, &ptr)))
|
|
412
392
|
return false;
|
|
413
393
|
|
|
414
394
|
#ifdef __APPLE__
|
|
@@ -418,7 +398,7 @@ bool CallData::Prepare(const Napi::CallbackInfo &info)
|
|
|
418
398
|
} break;
|
|
419
399
|
case PrimitiveKind::Record: {
|
|
420
400
|
if (RG_UNLIKELY(!IsObject(value))) {
|
|
421
|
-
ThrowError<Napi::TypeError>(env, "Unexpected %1 value
|
|
401
|
+
ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected object", GetValueType(instance, value));
|
|
422
402
|
return false;
|
|
423
403
|
}
|
|
424
404
|
|
|
@@ -465,7 +445,7 @@ bool CallData::Prepare(const Napi::CallbackInfo &info)
|
|
|
465
445
|
case PrimitiveKind::Array: { RG_UNREACHABLE(); } break;
|
|
466
446
|
case PrimitiveKind::Float32: {
|
|
467
447
|
if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) {
|
|
468
|
-
ThrowError<Napi::TypeError>(env, "Unexpected %1 value
|
|
448
|
+
ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected number", GetValueType(instance, value));
|
|
469
449
|
return false;
|
|
470
450
|
}
|
|
471
451
|
|
|
@@ -492,7 +472,7 @@ bool CallData::Prepare(const Napi::CallbackInfo &info)
|
|
|
492
472
|
} break;
|
|
493
473
|
case PrimitiveKind::Float64: {
|
|
494
474
|
if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) {
|
|
495
|
-
ThrowError<Napi::TypeError>(env, "Unexpected %1 value
|
|
475
|
+
ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected number", GetValueType(instance, value));
|
|
496
476
|
return false;
|
|
497
477
|
}
|
|
498
478
|
|
|
@@ -525,7 +505,7 @@ bool CallData::Prepare(const Napi::CallbackInfo &info)
|
|
|
525
505
|
} else if (IsNullOrUndefined(value)) {
|
|
526
506
|
ptr = nullptr;
|
|
527
507
|
} else {
|
|
528
|
-
ThrowError<Napi::TypeError>(env, "Unexpected %1 value
|
|
508
|
+
ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected %2", GetValueType(instance, value), param.type->name);
|
|
529
509
|
return false;
|
|
530
510
|
}
|
|
531
511
|
|
|
@@ -539,6 +519,9 @@ bool CallData::Prepare(const Napi::CallbackInfo &info)
|
|
|
539
519
|
}
|
|
540
520
|
}
|
|
541
521
|
|
|
522
|
+
#undef PUSH_INTEGER_SWAP
|
|
523
|
+
#undef PUSH_INTEGER
|
|
524
|
+
|
|
542
525
|
new_sp = mem->stack.end();
|
|
543
526
|
|
|
544
527
|
return true;
|
|
@@ -1075,91 +1058,64 @@ void CallData::Relay(Size idx, uint8_t *own_sp, uint8_t *caller_sp, BackRegister
|
|
|
1075
1058
|
if (RG_UNLIKELY(env.IsExceptionPending()))
|
|
1076
1059
|
return;
|
|
1077
1060
|
|
|
1061
|
+
#define RETURN_INTEGER(CType) \
|
|
1062
|
+
do { \
|
|
1063
|
+
if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) { \
|
|
1064
|
+
ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected number", GetValueType(instance, value)); \
|
|
1065
|
+
return; \
|
|
1066
|
+
} \
|
|
1067
|
+
\
|
|
1068
|
+
CType v = CopyNumber<CType>(value); \
|
|
1069
|
+
out_reg->x0 = (uint64_t)v; \
|
|
1070
|
+
} while (false)
|
|
1071
|
+
#define RETURN_INTEGER_SWAP(CType) \
|
|
1072
|
+
do { \
|
|
1073
|
+
if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) { \
|
|
1074
|
+
ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected number", GetValueType(instance, value)); \
|
|
1075
|
+
return; \
|
|
1076
|
+
} \
|
|
1077
|
+
\
|
|
1078
|
+
CType v = CopyNumber<CType>(value); \
|
|
1079
|
+
out_reg->x0 = (uint64_t)ReverseBytes(v); \
|
|
1080
|
+
} while (false)
|
|
1081
|
+
|
|
1078
1082
|
// Convert the result
|
|
1079
1083
|
switch (type->primitive) {
|
|
1080
1084
|
case PrimitiveKind::Void: {} break;
|
|
1081
1085
|
case PrimitiveKind::Bool: {
|
|
1082
1086
|
if (RG_UNLIKELY(!value.IsBoolean())) {
|
|
1083
|
-
ThrowError<Napi::TypeError>(env, "Unexpected %1 value
|
|
1087
|
+
ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected boolean", GetValueType(instance, value));
|
|
1084
1088
|
return;
|
|
1085
1089
|
}
|
|
1086
1090
|
|
|
1087
1091
|
bool b = value.As<Napi::Boolean>();
|
|
1088
1092
|
out_reg->x0 = (uint64_t)b;
|
|
1089
1093
|
} break;
|
|
1090
|
-
case PrimitiveKind::Int8:
|
|
1091
|
-
case PrimitiveKind::UInt8:
|
|
1092
|
-
case PrimitiveKind::Int16:
|
|
1093
|
-
case PrimitiveKind::
|
|
1094
|
-
case PrimitiveKind::
|
|
1095
|
-
case PrimitiveKind::
|
|
1096
|
-
case PrimitiveKind::
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
} break;
|
|
1105
|
-
case PrimitiveKind::Int16S:
|
|
1106
|
-
case PrimitiveKind::UInt16S:
|
|
1107
|
-
case PrimitiveKind::Int32S:
|
|
1108
|
-
case PrimitiveKind::UInt32S:
|
|
1109
|
-
case PrimitiveKind::Int64S: {
|
|
1110
|
-
if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) {
|
|
1111
|
-
ThrowError<Napi::TypeError>(env, "Unexpected %1 value for return value, expected number", GetValueType(instance, value));
|
|
1112
|
-
return;
|
|
1113
|
-
}
|
|
1114
|
-
|
|
1115
|
-
int64_t v = CopyNumber<int64_t>(value);
|
|
1116
|
-
out_reg->x0 = (uint64_t)ReverseBytes(v);
|
|
1117
|
-
} break;
|
|
1118
|
-
case PrimitiveKind::UInt64: {
|
|
1119
|
-
if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) {
|
|
1120
|
-
ThrowError<Napi::TypeError>(env, "Unexpected %1 value for return value, expected number", GetValueType(instance, value));
|
|
1121
|
-
return;
|
|
1122
|
-
}
|
|
1123
|
-
|
|
1124
|
-
uint64_t v = CopyNumber<uint64_t>(value);
|
|
1125
|
-
out_reg->x0 = v;
|
|
1126
|
-
} break;
|
|
1127
|
-
case PrimitiveKind::UInt64S: {
|
|
1128
|
-
if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) {
|
|
1129
|
-
ThrowError<Napi::TypeError>(env, "Unexpected %1 value for return value, expected number", GetValueType(instance, value));
|
|
1130
|
-
return;
|
|
1131
|
-
}
|
|
1132
|
-
|
|
1133
|
-
uint64_t v = CopyNumber<uint64_t>(value);
|
|
1134
|
-
out_reg->x0 = ReverseBytes(v);
|
|
1135
|
-
} break;
|
|
1094
|
+
case PrimitiveKind::Int8: { RETURN_INTEGER(int8_t); } break;
|
|
1095
|
+
case PrimitiveKind::UInt8: { RETURN_INTEGER(uint8_t); } break;
|
|
1096
|
+
case PrimitiveKind::Int16: { RETURN_INTEGER(int16_t); } break;
|
|
1097
|
+
case PrimitiveKind::Int16S: { RETURN_INTEGER_SWAP(int16_t); } break;
|
|
1098
|
+
case PrimitiveKind::UInt16: { RETURN_INTEGER(uint16_t); } break;
|
|
1099
|
+
case PrimitiveKind::UInt16S: { RETURN_INTEGER_SWAP(uint16_t); } break;
|
|
1100
|
+
case PrimitiveKind::Int32: { RETURN_INTEGER(int32_t); } break;
|
|
1101
|
+
case PrimitiveKind::Int32S: { RETURN_INTEGER_SWAP(int32_t); } break;
|
|
1102
|
+
case PrimitiveKind::UInt32: { RETURN_INTEGER(uint32_t); } break;
|
|
1103
|
+
case PrimitiveKind::UInt32S: { RETURN_INTEGER_SWAP(uint32_t); } break;
|
|
1104
|
+
case PrimitiveKind::Int64: { RETURN_INTEGER(int64_t); } break;
|
|
1105
|
+
case PrimitiveKind::Int64S: { RETURN_INTEGER_SWAP(int64_t); } break;
|
|
1106
|
+
case PrimitiveKind::UInt64: { RETURN_INTEGER(uint64_t); } break;
|
|
1107
|
+
case PrimitiveKind::UInt64S: { RETURN_INTEGER_SWAP(uint64_t); } break;
|
|
1136
1108
|
case PrimitiveKind::String: {
|
|
1137
1109
|
const char *str;
|
|
1138
|
-
if (
|
|
1139
|
-
str = PushString(value);
|
|
1140
|
-
if (RG_UNLIKELY(!str))
|
|
1141
|
-
return;
|
|
1142
|
-
} else if (IsNullOrUndefined(value)) {
|
|
1143
|
-
str = nullptr;
|
|
1144
|
-
} else {
|
|
1145
|
-
ThrowError<Napi::TypeError>(env, "Unexpected %1 value for return value, expected string", GetValueType(instance, value));
|
|
1110
|
+
if (RG_UNLIKELY(!PushString(value, &str)))
|
|
1146
1111
|
return;
|
|
1147
|
-
}
|
|
1148
1112
|
|
|
1149
1113
|
out_reg->x0 = (uint64_t)str;
|
|
1150
1114
|
} break;
|
|
1151
1115
|
case PrimitiveKind::String16: {
|
|
1152
1116
|
const char16_t *str16;
|
|
1153
|
-
if (
|
|
1154
|
-
str16 = PushString16(value);
|
|
1155
|
-
if (RG_UNLIKELY(!str16))
|
|
1156
|
-
return;
|
|
1157
|
-
} else if (IsNullOrUndefined(value)) {
|
|
1158
|
-
str16 = nullptr;
|
|
1159
|
-
} else {
|
|
1160
|
-
ThrowError<Napi::TypeError>(env, "Unexpected %1 value for return value, expected string", GetValueType(instance, value));
|
|
1117
|
+
if (RG_UNLIKELY(!PushString16(value, &str16)))
|
|
1161
1118
|
return;
|
|
1162
|
-
}
|
|
1163
1119
|
|
|
1164
1120
|
out_reg->x0 = (uint64_t)str16;
|
|
1165
1121
|
} break;
|
|
@@ -1178,7 +1134,7 @@ void CallData::Relay(Size idx, uint8_t *own_sp, uint8_t *caller_sp, BackRegister
|
|
|
1178
1134
|
} else if (IsNullOrUndefined(value)) {
|
|
1179
1135
|
ptr = nullptr;
|
|
1180
1136
|
} else {
|
|
1181
|
-
ThrowError<Napi::TypeError>(env, "Unexpected %1 value
|
|
1137
|
+
ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected %2", GetValueType(instance, value), type->name);
|
|
1182
1138
|
return;
|
|
1183
1139
|
}
|
|
1184
1140
|
|
|
@@ -1186,7 +1142,7 @@ void CallData::Relay(Size idx, uint8_t *own_sp, uint8_t *caller_sp, BackRegister
|
|
|
1186
1142
|
} break;
|
|
1187
1143
|
case PrimitiveKind::Record: {
|
|
1188
1144
|
if (RG_UNLIKELY(!IsObject(value))) {
|
|
1189
|
-
ThrowError<Napi::TypeError>(env, "Unexpected %1 value
|
|
1145
|
+
ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected object", GetValueType(instance, value));
|
|
1190
1146
|
return;
|
|
1191
1147
|
}
|
|
1192
1148
|
|
|
@@ -1205,7 +1161,7 @@ void CallData::Relay(Size idx, uint8_t *own_sp, uint8_t *caller_sp, BackRegister
|
|
|
1205
1161
|
case PrimitiveKind::Array: { RG_UNREACHABLE(); } break;
|
|
1206
1162
|
case PrimitiveKind::Float32: {
|
|
1207
1163
|
if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) {
|
|
1208
|
-
ThrowError<Napi::TypeError>(env, "Unexpected %1 value
|
|
1164
|
+
ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected number", GetValueType(instance, value));
|
|
1209
1165
|
return;
|
|
1210
1166
|
}
|
|
1211
1167
|
|
|
@@ -1216,7 +1172,7 @@ void CallData::Relay(Size idx, uint8_t *own_sp, uint8_t *caller_sp, BackRegister
|
|
|
1216
1172
|
} break;
|
|
1217
1173
|
case PrimitiveKind::Float64: {
|
|
1218
1174
|
if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) {
|
|
1219
|
-
ThrowError<Napi::TypeError>(env, "Unexpected %1 value
|
|
1175
|
+
ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected number", GetValueType(instance, value));
|
|
1220
1176
|
return;
|
|
1221
1177
|
}
|
|
1222
1178
|
|
|
@@ -1237,7 +1193,7 @@ void CallData::Relay(Size idx, uint8_t *own_sp, uint8_t *caller_sp, BackRegister
|
|
|
1237
1193
|
} else if (IsNullOrUndefined(value)) {
|
|
1238
1194
|
ptr = nullptr;
|
|
1239
1195
|
} else {
|
|
1240
|
-
ThrowError<Napi::TypeError>(env, "Unexpected %1 value
|
|
1196
|
+
ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected %2", GetValueType(instance, value), type->name);
|
|
1241
1197
|
return;
|
|
1242
1198
|
}
|
|
1243
1199
|
|
|
@@ -1247,6 +1203,9 @@ void CallData::Relay(Size idx, uint8_t *own_sp, uint8_t *caller_sp, BackRegister
|
|
|
1247
1203
|
case PrimitiveKind::Prototype: { RG_UNREACHABLE(); } break;
|
|
1248
1204
|
}
|
|
1249
1205
|
|
|
1206
|
+
#undef RETURN_INTEGER_SWAP
|
|
1207
|
+
#undef RETURN_INTEGER
|
|
1208
|
+
|
|
1250
1209
|
err_guard.Disable();
|
|
1251
1210
|
}
|
|
1252
1211
|
|