First of all, the call stack is not accessed and is not reset every time the method starts. During normal execution, only one zero check is performed, which has no noticeable overhead. The call stack is accessed only when the parameter is null and an exception must be thrown.
Claims are not generated for private methods (because they cannot be called from Java code, and the Kotlin compiler ensures that the Kotlin code calling the method does not miss any null values). Therefore, the best way to avoid overhead is to write the inner loop of your simulation code using private methods.
You can disable claim generation by using the -Xno-param-assertions and -Xno-call-assertions for the command line compiler. Please note that these options are not supported and may be removed in the future.
yole
source share