mark Function exec pointer as noexcept
Summary: Function implements move and nuke operations via a type-erased pointer to an exec function. Both operations are explicitly noexcept but the function pointer which these operations call is not marked as noexcept. So the compiler emits unnecessary exception-handling code/data around the call. The exception-handling stuff make generated code larger and in theory may also hinder possible optimizations. But when the exec function pointer as marked as `noexcept`, the compiler may elide the exception-handling stuff, shrinking generated code and in theory permitting a class of optimizations. It is not possible for the underlying move operation to throw an exception since, if the move operation of the contained callable could throw an exception, the contained callable would be on-heap and not in-situ, and the underlying move operation would just be an infallible relocation of the in-situ `Function` state. It is possible for the underlying nuke operation to throw an exception since the destructor of the contained callable could throw an exception. But this is rare. In this case, the exec function would contain exception-handling stuff; but in general, it would not. And this would merely moves where the exception-handling stuff is for the nuke operation, from one side of the type-erasure to the other side. Reviewed By: ot, philippv, luciang Differential Revision: D32904616 fbshipit-source-id: 5853a2d81a30bef565b350b72f5f35e6c9c9a45b
Showing
Please register or sign in to comment