From 15466865e07b623dceeb51f54aa6b47eb4881b43 Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Mon, 2 May 2022 03:46:57 -0700 Subject: add a comment --- src/javascript/jsc/bindings/JSFFIFunction.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/javascript/jsc/bindings/JSFFIFunction.h') diff --git a/src/javascript/jsc/bindings/JSFFIFunction.h b/src/javascript/jsc/bindings/JSFFIFunction.h index 1037785eb..8f65bf632 100644 --- a/src/javascript/jsc/bindings/JSFFIFunction.h +++ b/src/javascript/jsc/bindings/JSFFIFunction.h @@ -23,6 +23,19 @@ using namespace JSC; using FFIFunction = JSC::EncodedJSValue (*)(JSC::JSGlobalObject* globalObject, JSC::CallFrame* callFrame); +/** + * Call a C function with low overhead, modeled after JSC::JSNativeStdFunction + * + * The C function is expected to know how to get the arguments out of the JSC::CallFrame and + * return a JSC::EncodedJSValue. To do that, the argumentOffset is inlined at compile-time + * into Bun's binary and again inlined into the C function. + * + * This is used by functions compiled with TinyCC + * + * It was about 20% faster than using the JavaScriptCore C API for functions with 1 argument + * + * Note: there is no wrapper function here + */ class JSFFIFunction final : public JSC::JSFunction { public: using Base = JSFunction; -- cgit v1.2.3