#pragma once namespace Zig { class GlobalObject; } #include "root.h" #include "JavaScriptCore/JSFunction.h" #include "JavaScriptCore/VM.h" #include "headers-handwritten.h" #include "BunClientData.h" #include "JavaScriptCore/CallFrame.h" namespace JSC { class JSGlobalObject; } namespace Zig { 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 * * There is no wrapper function. It does zero bounds checking on the arguments. * It does not check for exceptions. It does not check for return value. * It is the caller's responsibility to not buffer overflow the arguments * For all those reasons, this shouldn't be used directly. */ class JSFFIFunction final : public JSC::JSFunction { public: using Base = JSFunction; static constexpr unsigned StructureFlags = Base::StructureFlags; static constexpr bool needsDestruction = false; static void destroy(JSCell* cell) { static_cast(cell)->JSFFIFunction::~JSFFIFunction(); } template static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) { if constexpr (mode == JSC::SubspaceAccess::Concurrently) return nullptr; return WebCore::subspaceForImpl( vm, [](auto& spaces) { return spaces.m_clientSubspaceForFFIFunction.get(); }, [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForFFIFunction = std::forward(space); }, [](auto& spaces) { return spaces.m_subspaceForFFIFunction.get(); }, [](auto& spaces, auto&& space) { spaces.m_subspaceForFFIFunction = std::forward(space); }); } DECLARE_EXPORT_INFO; JS_EXPORT_PRIVATE static JSFFIFunction* create(VM&, Zig::GlobalObject*, unsigned length, const String& name, FFIFunction, Intrinsic = NoIntrinsic, NativeFunction nativeConstructor = callHostFunctionAsConstructor); static Structure* createStructure(VM& vm, JSGlobalObject* globalObject, JSValue prototype) { ASSERT(globalObject); return Structure::create(vm, globalObject, prototype, TypeInfo(JSFunctionType, StructureFlags), info()); } const FFIFunction function() { return m_function; } void* dataPtr; private: JSFFIFunction(VM&, NativeExecutable*, JSGlobalObject*, Structure*, FFIFunction&&); void finishCreation(VM&, NativeExecutable*, unsigned length, const String& name); DECLARE_VISIT_CHILDREN; FFIFunction m_function; }; } // namespace JSC extern "C" Zig::JSFFIFunction* Bun__CreateFFIFunction(Zig::GlobalObject* globalObject, const ZigString* symbolName, unsigned argCount, Zig::FFIFunction functionPointer, bool strong); ue='derrick/fix/http-lowercase-headers'>derrick/fix/http-lowercase-headers Unnamed repository; edit this file 'description' to name the repository.
aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2023-07-05Fix incorrect signaturesGravatar Ashcon Partovi 3-21/+21
2023-07-05Fix detect-libcGravatar Ashcon Partovi 16-98/+116
2023-07-05Update websocket_http_client.zigGravatar Dylan Conway 1-0/+2
2023-07-05Fixes #3512 (#3526)Gravatar Jarred Sumner 9-38/+168
* Fixes #3512 * Fix `clearTimeout` and `clearInterval` not cancelling jobs same-tick --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-07-05Fixes #3515 (#3523)Gravatar Jarred Sumner 4-190/+182
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-07-05Fixes #3520 (#3522)Gravatar Jarred Sumner 3-23/+37
* Fixes #3520 * Update html_rewriter.zig --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-07-05add envs on tests (#3518)Gravatar Ciro Spaciari 4-0/+20
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2023-07-04Update build-idGravatar Jarred Sumner 1-1/+1
2023-07-04Fix build determinism issue (thanks to @alexlamsl)Gravatar Jarred Sumner 1-2/+2
cc @dylan-conway this was the cause
2023-07-04boopGravatar Jarred Sumner 10-55/+55
2023-07-04use sengrid account on nodemailer test (#3517)bun-v0.6.13Gravatar Ciro Spaciari 2-14/+15
2023-07-04[tls] fix servername (#3513)Gravatar Ciro Spaciari 4-8/+109
* fix servername * add postgres tls tests * update test packages * add basic CRUD test
2023-07-04Add alias for readBigUInt64BE ... (#3514)Gravatar Ai Hoshino 2-4/+58
* Add alias for `readBigUInt64BE` ... Close: https://github.com/oven-sh/bun/issues/3338 * add some tests for `readBigUint64BE` alias * format code
2023-07-04reduce countGravatar Jarred Sumner 1-2/+2
2023-07-04bumpGravatar Jarred Sumner 3-2/+2
2023-07-04Fix crashGravatar Jarred Sumner 1-5/+8