summaryrefslogtreecommitdiffstats
path: root/sys/kern/subr_trap.c
diff options
context:
space:
mode:
authordg <dg@FreeBSD.org>1995-08-21 18:06:48 +0000
committerdg <dg@FreeBSD.org>1995-08-21 18:06:48 +0000
commitf635c53ade00821254633ea97e10171c3fbce449 (patch)
tree9efecc1a8f948455bfd004981ec8f2f796c80d14 /sys/kern/subr_trap.c
parent2caa66b6de6e6875c2a3a4ec856234ff9da55fa4 (diff)
downloadFreeBSD-src-f635c53ade00821254633ea97e10171c3fbce449.zip
FreeBSD-src-f635c53ade00821254633ea97e10171c3fbce449.tar.gz
A couple of micro optimizations to improve NULL syscall performance by
about 2%.
Diffstat (limited to 'sys/kern/subr_trap.c')
-rw-r--r--sys/kern/subr_trap.c51
1 files changed, 20 insertions, 31 deletions
diff --git a/sys/kern/subr_trap.c b/sys/kern/subr_trap.c
index d581b62..37d8e2e 100644
--- a/sys/kern/subr_trap.c
+++ b/sys/kern/subr_trap.c
@@ -35,7 +35,7 @@
* SUCH DAMAGE.
*
* from: @(#)trap.c 7.4 (Berkeley) 5/13/91
- * $Id: trap.c,v 1.57 1995/07/16 14:10:55 peter Exp $
+ * $Id: trap.c,v 1.58 1995/07/30 17:49:24 davidg Exp $
*/
/*
@@ -798,7 +798,7 @@ syscall(frame)
struct sysent *callp;
struct proc *p = curproc;
u_quad_t sticks;
- int error, opc;
+ int error;
int args[8], rval[2];
u_int code;
@@ -806,14 +806,9 @@ syscall(frame)
if (ISPL(frame.tf_cs) != SEL_UPL)
panic("syscall");
- code = frame.tf_eax;
p->p_md.md_regs = (int *)&frame;
- params = (caddr_t)frame.tf_esp + sizeof (int) ;
-
- /*
- * Reconstruct pc, assuming lcall $X,y is 7 bytes, as it is always.
- */
- opc = frame.tf_eip - 7;
+ params = (caddr_t)frame.tf_esp + sizeof(int);
+ code = frame.tf_eax;
/*
* Need to check if this is a 32 bit or 64 bit syscall.
*/
@@ -822,25 +817,25 @@ syscall(frame)
* Code is first argument, followed by actual args.
*/
code = fuword(params);
- params += sizeof (int);
+ params += sizeof(int);
} else if (code == SYS___syscall) {
/*
* Like syscall, but code is a quad, so as to maintain
* quad alignment for the rest of the arguments.
*/
- code = fuword(params + _QUAD_LOWWORD * sizeof(int));
+ code = fuword(params);
params += sizeof(quad_t);
}
if (p->p_sysent->sv_mask)
- code = code & p->p_sysent->sv_mask;
+ code &= p->p_sysent->sv_mask;
if (code >= p->p_sysent->sv_size)
callp = &p->p_sysent->sv_table[0];
else
callp = &p->p_sysent->sv_table[code];
- if ((i = callp->sy_narg * sizeof (int)) &&
+ if ((i = callp->sy_narg * sizeof(int)) &&
(error = copyin(params, (caddr_t)args, (u_int)i))) {
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSCALL))
@@ -871,14 +866,17 @@ syscall(frame)
break;
case ERESTART:
- frame.tf_eip = opc;
+ /*
+ * Reconstruct pc, assuming lcall $X,y is 7 bytes.
+ */
+ frame.tf_eip -= 7;
break;
case EJUSTRETURN:
break;
default:
- bad:
+bad:
if (p->p_sysent->sv_errsize)
if (error >= p->p_sysent->sv_errsize)
error = -1; /* XXX */
@@ -906,14 +904,13 @@ void
linux_syscall(frame)
struct trapframe frame;
{
- caddr_t params;
int i;
struct proc *p = curproc;
struct sysent *callp;
u_quad_t sticks;
- int error, opc;
+ int error;
int rval[2];
- int code;
+ u_int code;
struct linux_syscall_args {
int arg1;
int arg2;
@@ -932,20 +929,13 @@ linux_syscall(frame)
if (ISPL(frame.tf_cs) != SEL_UPL)
panic("linux syscall");
- code = frame.tf_eax;
p->p_md.md_regs = (int *)&frame;
- params = (caddr_t)frame.tf_esp + sizeof (int) ;
+ code = frame.tf_eax;
- /* Reconstruct pc, subtract size of int 0x80 */
- opc = frame.tf_eip - 2;
- if (code == 0) {
- code = fuword(params);
- params += sizeof (int);
- }
if (p->p_sysent->sv_mask)
- code = code & p->p_sysent->sv_mask;
+ code &= p->p_sysent->sv_mask;
- if (code < 0 || code >= p->p_sysent->sv_size)
+ if (code >= p->p_sysent->sv_size)
callp = &p->p_sysent->sv_table[0];
else
callp = &p->p_sysent->sv_table[code];
@@ -956,7 +946,6 @@ linux_syscall(frame)
#endif
rval[0] = 0;
- rval[1] = frame.tf_edx;
error = (*callp->sy_call)(p, &args, rval);
@@ -973,14 +962,14 @@ linux_syscall(frame)
break;
case ERESTART:
- frame.tf_eip = opc;
+ /* Reconstruct pc, subtract size of int 0x80 */
+ frame.tf_eip -= 2;
break;
case EJUSTRETURN:
break;
default:
- bad:
if (p->p_sysent->sv_errsize)
if (error >= p->p_sysent->sv_errsize)
error = -1; /* XXX */
OpenPOWER on IntegriCloud