The Fil-C Optimized Calling Convention
a day ago
- #memory safety
- #optimization
- #calling convention
- Fil-C achieves memory safety for adversarial behavior, including wrong function pointer casts, mismatched signatures across modules, and incorrect use of arguments.
- In common cases with correct usage, Fil-C generates efficient code, passing arguments and return values in registers, similar to Yolo-C.
- Fil-C uses a generic calling convention as a fallback, where arguments are copied into thread-local CC buffers, and capabilities are checked.
- Optimizations include a register-based calling convention using arithmetically encoded signatures and generic call thunks for mismatches.
- Direct calls avoid resolution and checks by emitting signature-mangled implementations and weak thunks for handling mismatches.
- ELF symbol tricks and COMDAT handling are used to optimize calls, especially for inline functions and weak definitions.
- The arithmetic encoding supports up to 16 arguments, 2 return values, and specific types, with fallback to generic calling convention.
- Overall, Fil-C balances safety and efficiency, catching misuse while optimizing common cases for performance.