WebAssembly port of libffi - Portable foreign function interface library providing a C interface to other programming languages.
A comprehensive WebAssembly implementation of libffi v3.5.2 with TypeScript-first developer experience, SIMD optimizations, and WASM-native features.
- Full API support - All standard libffi functions including Raw API, closures, and Go closures
- WASM32/WASM64 - Automatic detection and support for both pointer sizes
- Complex numbers - Complete support for complex float, double, and long double
- Variadic functions - Full printf-style variadic function support
- TypeScript-first API - Object-oriented interface with complete type safety
- CDN dynamic loading - Load from wasm.discere.cloud with fallback support
- SIMD bulk operations - 16-byte vector operations for performance-critical paths
- ES6 module output - Modern JavaScript integration with proper exports
- 25M+ CIF preparations/sec - Optimized call interface setup
- SIMD memory operations - Fast bulk clearing and copying for ≥16 byte operations
- Memory pooling - Reduced allocation overhead for frequent operations
- LTO + Closure Compiler - Maximum optimization with dead code elimination
npm install @discere-os/libffi.wasm
import LibFFI, { FFIType } from '@discere-os/libffi.wasm'
const ffi = new LibFFI()
await ffi.initialize()
const intType = { size: 4, alignment: 4, type: FFIType.SINT32 }
const cif = ffi.prepareCall(intType, [intType, intType])
pnpm install
pnpm test # Comprehensive vitest suite with real WASM
pnpm benchmark # Performance measurement
MIT License - Compatible with official libffi v3.5.2 licensing.
This WebAssembly port is part of a larger effort to bring professional desktop applications to browsers with native performance.
👨💻 About the Maintainer: Isaac Johnston (@superstructor) - Building foundational browser-native computing infrastructure through systematic C/C++ to WebAssembly porting.
📊 Impact: 70+ open source WASM libraries enabling professional applications like Blender, GIMP, and scientific computing tools to run natively in browsers.
🚀 Your Support Enables:
- Continued maintenance and updates
- Performance optimizations
- New library ports and integrations
- Documentation and tutorials
- Cross-browser compatibility testing
💖 Sponsor this work to help build the future of browser-native computing.