| Submitter | Adam Jackson |
|---|---|
| Date | 2011-12-13 22:31:50 |
| Message ID | <1323815513-6624-2-git-send-email-ajax@redhat.com> |
| Download | mbox | patch |
| Permalink | /patch/8295/ |
| State | New |
| Headers | show |
Comments
On 12/13/11 14:31, Adam Jackson wrote: > gcc doesn't want to hoist the check for XaceHooks[hook] != NULL above the > varargs code for some reason, so do it ourselves. Perhaps because it would have to do some gymnastics to realize that in all cases we happen to either initialize prv to NULL or a pointer to a struct member initialized to Success, and that it really is equivalent to the return prv ? *prv : Success when the inlined CallCallbacks determines there's nothing to do there. (At least it took me a couple reads through the code to realize myself that this really does just fastpath that case and does not change the semantics of it.) Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Patch
diff --git a/Xext/xace.c b/Xext/xace.c index c757cad..ef69fe3 100644 --- a/Xext/xace.c +++ b/Xext/xace.c @@ -101,6 +101,10 @@ int XaceHook(int hook, ...) } u; int *prv = NULL; /* points to return value from callback */ va_list ap; /* argument list */ + + if (!XaceHooks[hook]) + return Success; + va_start(ap, hook); /* Marshal arguments for passing to callback.
gcc doesn't want to hoist the check for XaceHooks[hook] != NULL above the varargs code for some reason, so do it ourselves. Before: 40000000 trep @ 0.0010 msec (1050420.2/sec): PutImage 10x10 square 60000000 trep @ 0.0005 msec (1921147.6/sec): ShmPutImage 10x10 square After: 40000000 trep @ 0.0009 msec (1087458.5/sec): PutImage 10x10 square 60000000 trep @ 0.0005 msec (2012238.6/sec): ShmPutImage 10x10 square Signed-off-by: Adam Jackson <ajax@redhat.com> --- Xext/xace.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)