Subject: Saving some insns in copyin/out() in locore.s
To: None <tech-kern@netbsd.org>
From: Bang Jun-Young <junyoung@mogua.com>
List: tech-kern
Date: 10/03/2002 22:40:12
Hi,

Here is a patch against locore.s that replaces pushl/popl pair with
a single movl instruction for a bit of speedup. Is it okay?


Index: locore.s
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/i386/i386/locore.s,v
retrieving revision 1.261
diff -u -r1.261 locore.s
--- locore.s	2002/10/01 12:56:55	1.261
+++ locore.s	2002/10/03 13:25:25
@@ -980,11 +980,10 @@
 ENTRY(i386_copyout)
 	pushl	%esi
 	pushl	%edi
-	pushl	$0
 	
-	movl	16(%esp),%esi
-	movl	20(%esp),%edi
-	movl	24(%esp),%eax
+	movl	12(%esp),%esi
+	movl	16(%esp),%edi
+	movl	20(%esp),%eax
 
 	/*
 	 * We check that the end of the destination buffer is not past the end
@@ -1058,10 +1057,10 @@
 	rep
 	movsb
 
-	popl	PCB_ONFAULT(%edx)
+	xorl	%eax,%eax
 	popl	%edi
 	popl	%esi
-	xorl	%eax,%eax
+	popl	%eax,PCB_ONFAULT(%edx)
 	ret
 #endif /* I386_CPU */
 
@@ -1070,11 +1069,10 @@
 ENTRY(i486_copyout)
 	pushl	%esi
 	pushl	%edi
-	pushl	$0
 	
-	movl	16(%esp),%esi
-	movl	20(%esp),%edi
-	movl	24(%esp),%eax
+	movl	12(%esp),%esi
+	movl	16(%esp),%edi
+	movl	20(%esp),%eax
 
 	/*
 	 * We check that the end of the destination buffer is not past the end
@@ -1100,10 +1098,10 @@
 	rep
 	movsb
 
-	popl	PCB_ONFAULT(%edx)
+	xorl	%eax,%eax
 	popl	%edi
 	popl	%esi
-	xorl	%eax,%eax
+	movl	%eax,PCB_ONFAULT(%edx)
 	ret
 #endif /* I486_CPU || I586_CPU || I686_CPU */
 
@@ -1123,12 +1121,11 @@
 	pushl	%esi
 	pushl	%edi
 	GET_CURPCB(%eax)
-	pushl	$0
 	movl	$_C_LABEL(copy_fault),PCB_ONFAULT(%eax)
 	
-	movl	16(%esp),%esi
-	movl	20(%esp),%edi
-	movl	24(%esp),%eax
+	movl	12(%esp),%esi
+	movl	16(%esp),%edi
+	movl	20(%esp),%eax
 
 	/*
 	 * We check that the end of the destination buffer is not past the end
@@ -1153,10 +1150,10 @@
 	movsb
 
 	GET_CURPCB(%edx)
-	popl	PCB_ONFAULT(%edx)
+	xorl	%eax,%eax
 	popl	%edi
 	popl	%esi
-	xorl	%eax,%eax
+	movl	%eax,PCB_ONFAULT(%edx)
 	ret
 #endif /* I386_CPU || I486_CPU || I586_CPU || I686_CPU */
 
@@ -1167,7 +1164,7 @@
 /* LINTSTUB: Ignore */
 NENTRY(copy_fault)
 	GET_CURPCB(%edx)
-	popl	PCB_ONFAULT(%edx)
+	movl	$0,PCB_ONFAULT(%edx)
 	popl	%edi
 	popl	%esi
 	ret

Jun-Young

-- 
Bang Jun-Young <junyoung@mogua.com>