You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Optimize generic function param/return type checking performance
Eliminate per-parameter overhead for free generic functions by skipping
type checks at RECV time (no bound generic args to check against).
Return type enforcement via lazy inference handles correctness.
Key changes:
- Compiler sets RECV opline mask to MAY_BE_ANY for free function generic
params, enabling RECV_NOTYPE fast path in both interpreter and JIT
- JIT skips arg type verification for free function generic params
- Pre-computed param_to_arg_map stored inline in generic_params_info for
O(1) return type inference lookup (replaces O(N) arg_info scan)
- Fast path in zend_check_type() for generic param types in parameter
position avoids non-inlined zend_check_type_slow() call
- Opcache persistence uses consistent ZEND_GENERIC_PARAMS_INFO_SIZE macro
Results: generic function overhead vs plain typed equivalent is now flat
at ~10-15% interpreter / ~1-8% JIT regardless of parameter count (was
scaling to -50% interp / -60% JIT for 8 params).
Co-Authored-By: Grok <noreply@x.ai>
0 commit comments