Optimize riscv's cpu_fetch_syscall_args(), making it possible

for the compiler to inline the memcpy.

Reviewed by:	arichardson, mhorne
MFC after:	2 weeks
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D26528
This commit is contained in:
Edward Tomasz Napierala 2020-10-03 13:01:07 +00:00
parent 4658877815
commit f726515758
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=366392

View File

@ -96,30 +96,31 @@ int
cpu_fetch_syscall_args(struct thread *td) cpu_fetch_syscall_args(struct thread *td)
{ {
struct proc *p; struct proc *p;
register_t *ap; register_t *ap, *dst_ap;
struct syscall_args *sa; struct syscall_args *sa;
int nap;
nap = NARGREG;
p = td->td_proc; p = td->td_proc;
sa = &td->td_sa; sa = &td->td_sa;
ap = &td->td_frame->tf_a[0]; ap = &td->td_frame->tf_a[0];
dst_ap = &sa->args[0];
sa->code = td->td_frame->tf_t[0]; sa->code = td->td_frame->tf_t[0];
if (sa->code == SYS_syscall || sa->code == SYS___syscall) { if (__predict_false(sa->code == SYS_syscall || sa->code == SYS___syscall)) {
sa->code = *ap++; sa->code = *ap++;
nap--; } else {
*dst_ap++ = *ap++;
} }
if (sa->code >= p->p_sysent->sv_size) if (__predict_false(sa->code >= p->p_sysent->sv_size))
sa->callp = &p->p_sysent->sv_table[0]; sa->callp = &p->p_sysent->sv_table[0];
else else
sa->callp = &p->p_sysent->sv_table[sa->code]; sa->callp = &p->p_sysent->sv_table[sa->code];
memcpy(sa->args, ap, nap * sizeof(register_t)); KASSERT(sa->callp->sy_narg <= nitems(sa->args),
if (sa->callp->sy_narg > nap) ("Syscall %d takes too many arguments", sa->code));
panic("TODO: Could we have more then %d args?", NARGREG);
memcpy(dst_ap, ap, (NARGREG - 1) * sizeof(register_t));
td->td_retval[0] = 0; td->td_retval[0] = 0;
td->td_retval[1] = 0; td->td_retval[1] = 0;