通用调用路径
🌐 Generic call path
通用调用路径会将每个 JavaScript 参数转换为它在 C++ 中的本地表示,并通过 libffi 调用该符号。它支持 node:ffi 接受的所有签名,并且是其他调用路径在参数验证和错误行为上参考的实现。
🌐 The generic call path converts each JavaScript argument to its native
representation in C++ and calls the symbol through libffi. It supports every
signature that node:ffi accepts and is the reference implementation for the
argument validation and error behavior that the other call paths reproduce.
当 Fast API 调用路径不可用,并且主机是大端模式或签名没有参数时,会直接在这个调用路径上创建一个函数。
🌐 A function is created directly on this call path when the Fast API call path is unavailable and either the host is big-endian or the signature has no arguments.
通用调用路径也处理其他调用路径转交的单独调用,比如 Fast API 函数的未优化或去优化调用点,以及传递非 bigint 指针类值的共享缓冲调用。
🌐 The generic call path also serves individual calls handed off by the other call
paths, such as unoptimized or deoptimized call sites of a Fast API function and
shared buffer calls that pass non-bigint pointer-like values.
使用 library.registerCallback() 创建的回调总是用 libffi 闭包实现的。它们独立于任何函数使用的调用路径。
🌐 Callbacks created with library.registerCallback() are always implemented
with libffi closures. They are independent of the call path used by any
function.