On 7/8/21 8:30 AM, Laurent Vivier wrote:
Le 08/07/2021 à 16:11, Philippe Mathieu-Daudé a écrit :
Convert the host_to_target_errno_table[] array to a switch case
to allow compiler optimizations. Extract the errnos list as to
a new includible unit, using a generic macro. Remove the code
related to target_to_host_errno_table[] initialization.
Is there some performance penalties by using a switch() rather than an array[] ?
In many cases, definitely not. The compiler does notice the identity function when host
and guest errnos match.
In the other case, I would doubt (without evidence) there's much penalty. The switch
becomes a table lookup + indirect branch + immediate load + return. Or a really good
compiler transforms to a different array lookup.
r~