A couple of micro optimizations to improve NULL syscall performance by

about 2%.
This commit is contained in:
David Greenman 1995-08-21 18:06:48 +00:00
parent 613749bbf2
commit 4219d2b2ac
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=10157
3 changed files with 60 additions and 93 deletions

View File

@ -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 */

View File

@ -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 */

View File

@ -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 */