Commit bb0d3f5d authored by Petr Vandrovec's avatar Petr Vandrovec

[PATCH] Merge lcall7 and lcall27 code paths in ia32

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.
parent 37256d28
...@@ -130,12 +130,16 @@ ENTRY(lcall7) ...@@ -130,12 +130,16 @@ ENTRY(lcall7)
# gates, which has to be cleaned up later.. # gates, which has to be cleaned up later..
pushl %eax pushl %eax
SAVE_ALL SAVE_ALL
movl EIP(%esp), %eax # due to call gates, this is eflags, not eip.. movl %esp, %ebx
movl CS(%esp), %edx # this is eip.. pushl %ebx
movl EFLAGS(%esp), %ecx # and this is cs.. pushl $0x7
movl %eax,EFLAGS(%esp) # do_lcall:
movl %edx,EIP(%esp) # Now we move them to their "normal" places movl EIP(%ebx), %eax # due to call gates, this is eflags, not eip..
movl %ecx,CS(%esp) # 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 # Call gates don't clear TF and NT in eflags like
...@@ -147,13 +151,9 @@ ENTRY(lcall7) ...@@ -147,13 +151,9 @@ ENTRY(lcall7)
pushl %eax pushl %eax
popfl popfl
movl %esp, %ebx
pushl %ebx
andl $-8192, %ebx # GET_THREAD_INFO andl $-8192, %ebx # GET_THREAD_INFO
movl TI_EXEC_DOMAIN(%ebx), %edx # Get the execution domain movl TI_EXEC_DOMAIN(%ebx), %edx # Get the execution domain
movl 4(%edx), %edx # Get the lcall7 handler for the domain call *4(%edx) # Call the lcall7 handler for the domain
pushl $0x7
call *%edx
addl $4, %esp addl $4, %esp
popl %eax popl %eax
jmp resume_userspace jmp resume_userspace
...@@ -163,33 +163,10 @@ ENTRY(lcall27) ...@@ -163,33 +163,10 @@ ENTRY(lcall27)
# gates, which has to be cleaned up later.. # gates, which has to be cleaned up later..
pushl %eax pushl %eax
SAVE_ALL 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 movl %esp, %ebx
pushl %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 pushl $0x27
call *%edx jmp do_lcall
addl $4, %esp
popl %eax
jmp resume_userspace
ENTRY(ret_from_fork) ENTRY(ret_from_fork)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment