Optimize the performance of closures corresponding to user-defined entity predicates whose calls can be resolved at compile time