Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/bin/sh Use a volative local shadow of a field in an (on-stac...



details:   https://anonhg.NetBSD.org/src/rev/7bac34e5f671
branches:  trunk
changeset: 359432:7bac34e5f671
user:      kre <kre%NetBSD.org@localhost>
date:      Wed Jan 05 15:25:44 2022 +0000

description:
Use a volative local shadow of a field in an (on-stack) non-volatile struct
that is to be referenced after a return from setjmp() via longjmp().

This doesn't ever seem to have caused a problem, but I think using
volative vars is required here.

For reasons I never bothered to discover, even though this change
certainly requires a store into stack memory which wasn't required
before, earlier measurements showed the shell getting (slightly) smaller
with this change in place.

NFCI

diffstat:

 bin/sh/eval.c |  9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

diffs (44 lines):

diff -r 20cf2e0e37fc -r 7bac34e5f671 bin/sh/eval.c
--- a/bin/sh/eval.c     Wed Jan 05 01:46:28 2022 +0000
+++ b/bin/sh/eval.c     Wed Jan 05 15:25:44 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: eval.c,v 1.187 2021/12/05 04:35:38 msaitoh Exp $       */
+/*     $NetBSD: eval.c,v 1.188 2022/01/05 15:25:44 kre Exp $   */
 
 /*-
  * Copyright (c) 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)eval.c     8.9 (Berkeley) 6/8/95";
 #else
-__RCSID("$NetBSD: eval.c,v 1.187 2021/12/05 04:35:38 msaitoh Exp $");
+__RCSID("$NetBSD: eval.c,v 1.188 2022/01/05 15:25:44 kre Exp $");
 #endif
 #endif /* not lint */
 
@@ -1218,6 +1218,7 @@
        /* Execute the command. */
        switch (cmdentry.cmdtype) {
                volatile int saved;
+               struct funcdef * volatile savefunc;
 
        case CMDFUNCTION:
                VXTRACE(DBG_EVAL, ("Shell function%s:  ",vforked?" VF":""),
@@ -1233,7 +1234,7 @@
                INTOFF;
                savelocalvars = localvars;
                localvars = NULL;
-               reffunc(cmdentry.u.func);
+               reffunc(savefunc = cmdentry.u.func);
                INTON;
                if (setjmp(jmploc.loc)) {
                        if (exception == EXSHELLPROC) {
@@ -1245,7 +1246,7 @@
                        }
                        if (saved)
                                popredir();
-                       unreffunc(cmdentry.u.func);
+                       unreffunc(savefunc);
                        poplocalvars();
                        localvars = savelocalvars;
                        funclinebase = savefuncline;



Home | Main Index | Thread Index | Old Index