During native signal delivery, arrange to have the signal handler invoked

directly, using the trampoline only for the return path.  Saves a jsr and
movqd insn in the trampoline.
Changes gratuitously ripped off the i386 work for same.
This commit is contained in:
simonb 2002-07-09 23:10:03 +00:00
parent 1322c69689
commit cf4396a2d7
4 changed files with 36 additions and 36 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: frame.h,v 1.7 1998/04/11 17:30:40 matthias Exp $ */
/* $NetBSD: frame.h,v 1.8 2002/07/09 23:10:03 simonb Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
@ -94,11 +94,11 @@ struct switchframe {
* Signal frame
*/
struct sigframe {
int sf_signum;
int sf_code;
struct sigcontext *sf_scp;
sig_t sf_handler;
struct sigcontext sf_sc;
int sf_ra; /* return address for handler */
int sf_signum; /* "signum" argument for handler */
int sf_code; /* "code" argument for handler */
struct sigcontext *sf_scp; /* "scp" argument for handler */
struct sigcontext sf_sc; /* actual saved context */
};
#endif /* _NS532_FRAME_H_ */

View File

@ -1,4 +1,4 @@
# $NetBSD: genassym.cf,v 1.8 2000/06/29 07:51:46 mrg Exp $
# $NetBSD: genassym.cf,v 1.9 2002/07/09 23:10:03 simonb Exp $
#
# Copyright (c) 1982, 1990 The Regents of the University of California.
@ -98,9 +98,6 @@ define REGS_FP offsetof(struct reg, r_fp)
define REGS_SB offsetof(struct reg, r_sb)
define REGS_PSR offsetof(struct reg, r_psr)
define SIGF_HANDLER offsetof(struct sigframe, sf_handler)
define SIGF_SC offsetof(struct sigframe, sf_sc)
define IV_VEC offsetof(struct iv, iv_vec)
define IV_ARG offsetof(struct iv, iv_arg)
define IV_CNT offsetof(struct iv, iv_cnt)

View File

@ -1,4 +1,4 @@
/* $NetBSD: locore.s,v 1.65 2002/05/28 10:11:26 simonb Exp $ */
/* $NetBSD: locore.s,v 1.66 2002/07/09 23:10:04 simonb Exp $ */
/*
* Copyright (c) 1993 Philip A. Nelson.
@ -148,10 +148,12 @@ KENTRY(delay, 4) /* bsr 2 cycles; 80 ns */
*/
ENTRY_NOPROFILE(sigcode)
jsr 0(SIGF_HANDLER(sp))
addr SIGF_SC(sp),tos /* scp (the call may have clobbered */
/* the copy at SIGF_SCP(sp)). */
movqd 0,tos /* Push a fake return address. */
/*
* Handler has returned here as if we called it. The sigcontext
* is on the stack after the 3 args "we" pushed.
*/
addr 12(sp),4(sp) /* get pointer to sigcontext
and put it in the argument slot */
movd SYS___sigreturn14,r0
svc
movd 0,0 /* Illegal instruction. */

View File

@ -1,4 +1,4 @@
/* $NetBSD: machdep.c,v 1.128 2002/07/04 23:32:06 thorpej Exp $ */
/* $NetBSD: machdep.c,v 1.129 2002/07/09 23:10:04 simonb Exp $ */
/*-
* Copyright (c) 1996 Matthias Pfaller.
@ -348,10 +348,24 @@ sendsig(sig, mask, code)
fp--;
/* Build stack frame for signal trampoline. */
switch (ps->sa_sigdesc[sig].sd_vers) {
#if 1 /* COMPAT_16 */
case 0:
frame.sf_ra = (int)p->p_sigctx.ps_sigcode;
break;
#endif /* COMPAT_16 */
case 1:
frame.sf_ra = (int)ps->sa_sigdesc[sig].sd_tramp;
break;
default:
/* Don't know what trampoline version; kill it. */
sigexit(p, SIGILL);
}
frame.sf_signum = sig;
frame.sf_code = code;
frame.sf_scp = &fp->sf_sc;
frame.sf_handler = catcher;
/* Save the register context. */
frame.sf_sc.sc_fp = regs->r_fp;
@ -394,26 +408,13 @@ sendsig(sig, mask, code)
}
/*
* Build context to run handler in. Note the trampoline version
* numbers are coordinated with machine-dependent code in libc.
* Build context to run handler in. We invoke the handler
* directly, only returning via the trampoline. Note the
* trampoline version numbers are coordinated with machine-
* dependent code in libc.
*/
switch (ps->sa_sigdesc[sig].sd_vers) {
#if 1 /* COMPAT_16 */
case 0:
regs->r_sp = (int)fp;
regs->r_pc = (int)p->p_sigctx.ps_sigcode;
break;
#endif /* COMPAT_16 */
case 1:
regs->r_sp = (int)fp;
regs->r_pc = (int)ps->sa_sigdesc[sig].sd_tramp;
break;
default:
/* Don't know what trampoline version; kill it. */
sigexit(p, SIGILL);
}
regs->r_sp = (int)fp;
regs->r_pc = (int)catcher;
/* Remember that we're now on the signal stack. */
if (onstack)