]> git.neil.brown.name Git - history.git/commitdiff
[PATCH] Merge lcall7 and lcall27 code paths in ia32
authorPetr Vandrovec <vandrove@vc.cvut.cz>
Wed, 20 Nov 2002 04:00:09 +0000 (20:00 -0800)
committerPetr Vandrovec <vandrove@vc.cvut.cz>
Wed, 20 Nov 2002 04:00:09 +0000 (20:00 -0800)
lcall7 and lcall27 code paths are almost identical, except one
constant. This code merges these two paths together, by moving
constant to the beginning of function.

It is possible to eliminate even more of lcall7 and lcall27
code paths, but at cost of splitting SAVE_ALL into two halves,
and I do not want to do that. But if you think that it is worth
of effort, I can save 16 more bytes, but at cost of speed.

Side effects of merge is that now stack is addressed relative
to %ebx instead of relative to %esp, so generated code is
shorter and faster.

arch/i386/kernel/entry.S

index 512a6602f90b1c7f1c2051928d7cb82d9bae98cd..830c84025de1329cc44bfbb41c71cc39ecf8f248 100644 (file)
@@ -130,12 +130,16 @@ ENTRY(lcall7)
                                # gates, which has to be cleaned up later..
        pushl %eax
        SAVE_ALL
-       movl EIP(%esp), %eax    # due to call gates, this is eflags, not eip..
-       movl CS(%esp), %edx     # this is eip..
-       movl EFLAGS(%esp), %ecx # and this is cs..
-       movl %eax,EFLAGS(%esp)  #
-       movl %edx,EIP(%esp)     # Now we move them to their "normal" places
-       movl %ecx,CS(%esp)      #
+       movl %esp, %ebx
+       pushl %ebx
+       pushl $0x7
+do_lcall:
+       movl EIP(%ebx), %eax    # due to call gates, this is eflags, not eip..
+       movl CS(%ebx), %edx     # this is eip..
+       movl EFLAGS(%ebx), %ecx # and this is cs..
+       movl %eax,EFLAGS(%ebx)  #
+       movl %edx,EIP(%ebx)     # Now we move them to their "normal" places
+       movl %ecx,CS(%ebx)      #
 
        #
        # Call gates don't clear TF and NT in eflags like
@@ -147,13 +151,9 @@ ENTRY(lcall7)
        pushl %eax
        popfl
 
-       movl %esp, %ebx
-       pushl %ebx
        andl $-8192, %ebx       # GET_THREAD_INFO
        movl TI_EXEC_DOMAIN(%ebx), %edx # Get the execution domain
-       movl 4(%edx), %edx      # Get the lcall7 handler for the domain
-       pushl $0x7
-       call *%edx
+       call *4(%edx)           # Call the lcall7 handler for the domain
        addl $4, %esp
        popl %eax
        jmp resume_userspace
@@ -163,33 +163,10 @@ ENTRY(lcall27)
                                # gates, which has to be cleaned up later..
        pushl %eax
        SAVE_ALL
-       movl EIP(%esp), %eax    # due to call gates, this is eflags, not eip..
-       movl CS(%esp), %edx     # this is eip..
-       movl EFLAGS(%esp), %ecx # and this is cs..
-       movl %eax,EFLAGS(%esp)  #
-       movl %edx,EIP(%esp)     # Now we move them to their "normal" places
-       movl %ecx,CS(%esp)      #
-
-       #
-       # Call gates don't clear TF and NT in eflags like
-       # traps do, so we need to do it ourselves.
-       # %eax already contains eflags (but it may have
-       # DF set, clear that also)
-       #
-       andl $~(DF_MASK | TF_MASK | NT_MASK),%eax
-       pushl %eax
-       popfl
-
        movl %esp, %ebx
        pushl %ebx
-       andl $-8192, %ebx       # GET_THREAD_INFO
-       movl TI_EXEC_DOMAIN(%ebx), %edx # Get the execution domain
-       movl 4(%edx), %edx      # Get the lcall7 handler for the domain
        pushl $0x27
-       call *%edx
-       addl $4, %esp
-       popl %eax
-       jmp resume_userspace
+       jmp do_lcall
 
 
 ENTRY(ret_from_fork)