This is the mail archive of the
mailing list for the glibc project.
Re: [PATCH] Optimize i386 syscall inlining for GCC 5
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: Zack Weinberg <zackw at panix dot com>
- Cc: GNU C Library <libc-alpha at sourceware dot org>
- Date: Wed, 12 Aug 2015 17:10:17 -0700
- Subject: Re: [PATCH] Optimize i386 syscall inlining for GCC 5
- Authentication-results: sourceware.org; auth=none
- References: <20150812192001 dot GA12730 at intel dot com> <20150812221203 dot GA4224 at intel dot com> <CAKCAbMi1e9CniEZVRbgb7W=m0=zFrBes8=h+ev1e_Ofg8GnzCw at mail dot gmail dot com>
On Wed, Aug 12, 2015 at 4:37 PM, Zack Weinberg <firstname.lastname@example.org> wrote:
> If I'm reading that right, it's still not quite optimal; there's an
> unnecessary register shuffle after the system call... better would be
> push %ebx
> mov $0x2d,%eax
> mov 0x8(%esp),%ebx
> call __x86.get_pc_thunk.cx
> add $_GLOBAL_OFFSET_TABLE_,%ecx
> call *%gs:0x10
> mov __curbrk(%ecx),%edx
> mov %eax,(%edx)
> cmp %eax,%ebx
> ja 1f
> xor %eax,%eax
> pop %ebx
> ; set errno and return -1
> I think the compiler might've done it the way it did because then it
> could hoist the xor %eax,%eax above the comparison, but the branch is
> so unlikely that that's not a good choice.
> But also, in context, I think it would be more helpful if you could
> show the generated assembly for a *six*-argument syscall, ne?
I am looking into overhauling i386 syscall implementation. I
think I can do much better for libc.so.