Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[i386] : Optimize copystr assembly routines

This patch optimizes copyoutstr(9), copyinstr(9) and copystr(9) assembly routines
in sys/arch/i386/i386/copy.S in case the last argument (done) is a NULL pointer.

Indeed, previous code was loading actually copied size in %ecx before checking
whether the last argument (done, aka 20(%esp)) is NULL or not.

In case (done == NULL), there is no need to load the copied size in %ecx,
we can therefore save two instructions from being executed.

This patch moves the two instructions responsible for loading the copied size
in %ecx after the test (done != NULL) is done.
  • Loading branch information...
commit 7080dc4a1f8861e5e3b8f4b0b05580698f1dc219 1 parent 81a01e8
Yann Sionneau authored
Showing with 4 additions and 4 deletions.
  1. +4 −4 sys/arch/i386/i386/copy.S
View
8 sys/arch/i386/i386/copy.S
@@ -434,11 +434,11 @@ NENTRY(copystr_efault)
NENTRY(copystr_fault)
copystr_return:
/* Set *lencopied and return %eax. */
- movl 20(%esp),%ecx
- subl %edx,%ecx
movl 24(%esp),%edx
testl %edx,%edx
jz 8f
+ movl 20(%esp),%ecx
+ subl %edx,%ecx
movl %ecx,(%edx)
8: popl %edi
@@ -478,11 +478,11 @@ ENTRY(copystr)
movl $ENAMETOOLONG,%eax
6: /* Set *lencopied and return %eax. */
- movl 20(%esp),%ecx
- subl %edx,%ecx
movl 24(%esp),%edx
testl %edx,%edx
jz 7f
+ movl 20(%esp),%ecx
+ subl %edx,%ecx
movl %ecx,(%edx)
7: popl %edi
Please sign in to comment.
Something went wrong with that request. Please try again.