RCSID sync from oksh; reduce hash table #elements if !MKSH_SMALL to speed up

This commit is contained in:
tg 2012-03-03 21:30:59 +00:00
parent 82ebd9320b
commit e141394a83
5 changed files with 36 additions and 24 deletions

View File

@ -1,4 +1,4 @@
# $MirOS: src/bin/mksh/check.t,v 1.515 2012/02/06 17:42:20 tg Exp $
# $MirOS: src/bin/mksh/check.t,v 1.516 2012/03/03 21:30:54 tg Exp $
# $OpenBSD: bksl-nl.t,v 1.2 2001/01/28 23:04:56 niklas Exp $
# $OpenBSD: history.t,v 1.5 2001/01/28 23:04:56 niklas Exp $
# $OpenBSD: read.t,v 1.3 2003/03/10 03:48:16 david Exp $
@ -29,7 +29,7 @@
# http://www.freebsd.org/cgi/cvsweb.cgi/src/tools/regression/bin/test/regress.sh?rev=HEAD
expected-stdout:
@(#)MIRBSD KSH R40 2012/02/06
@(#)MIRBSD KSH R40 2012/03/03
description:
Check version of shell.
stdin:

27
main.c
View File

@ -1,7 +1,7 @@
/* $OpenBSD: main.c,v 1.47 2011/09/07 11:33:25 otto Exp $ */
/* $OpenBSD: tty.c,v 1.9 2006/03/14 22:08:01 deraadt Exp $ */
/* $OpenBSD: io.c,v 1.22 2006/03/17 16:30:13 millert Exp $ */
/* $OpenBSD: table.c,v 1.14 2012/02/02 08:42:46 otto Exp $ */
/* $OpenBSD: table.c,v 1.15 2012/02/19 07:52:30 otto Exp $ */
/*-
* Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
@ -34,7 +34,7 @@
#include <locale.h>
#endif
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.204 2012/03/03 21:13:50 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.205 2012/03/03 21:30:56 tg Exp $");
extern char **environ;
@ -218,8 +218,8 @@ main_init(int argc, const char *argv[], Source **sp, struct block **lp)
/* define built-in commands and see if we were called as one */
ktinit(APERM, &builtins,
/* currently 50 builtins -> 80% of 64 (2^6) */
6);
/* currently up to 50 builtins */
/* 80% of 64 = 2^6 */ 6, /* 66% of 128 = 2^7 */ 7);
for (i = 0; mkshbuiltins[i].name != NULL; i++)
if (!strcmp(ccp, builtin(mkshbuiltins[i].name,
mkshbuiltins[i].func)))
@ -247,10 +247,10 @@ main_init(int argc, const char *argv[], Source **sp, struct block **lp)
coproc_init();
/* set up variable and command dictionaries */
ktinit(APERM, &taliases, 0);
ktinit(APERM, &aliases, 0);
ktinit(APERM, &taliases, 0, 0);
ktinit(APERM, &aliases, 0, 0);
#ifndef MKSH_NOPWNAM
ktinit(APERM, &homedirs, 0);
ktinit(APERM, &homedirs, 0, 0);
#endif
/* define shell keywords */
@ -1528,8 +1528,15 @@ tgrow(struct table *tp)
/* multiplication cannot overflow: alloc2 checked that */
memset(ntblp, 0, i * sizeof(struct tbl *));
/* table can get 80% full except when reaching its limit */
tp->nfree = (tp->tshift == 30) ? 0x3FFF0000UL : ((i * 4) / 5);
/* table can get very full when reaching its size limit */
tp->nfree = (tp->tshift == 30) ? 0x3FFF0000UL :
/* but otherwise, only 80% (MKSH_SMALL) or 66% (normal) */
#ifdef MKSH_SMALL
((i * 4) / 5)
#else
((i * 2) / 3)
#endif
;
tp->tbls = ntblp;
if (otblp == NULL)
return;
@ -1559,7 +1566,7 @@ tgrow(struct table *tp)
}
void
ktinit(Area *ap, struct table *tp, uint8_t initshift)
ktinit_real(Area *ap, struct table *tp, uint8_t initshift)
{
tp->areap = ap;
tp->tbls = NULL;

13
sh.h
View File

@ -1,6 +1,6 @@
/* $OpenBSD: sh.h,v 1.30 2010/01/04 18:07:11 deraadt Exp $ */
/* $OpenBSD: shf.h,v 1.6 2005/12/11 18:53:51 deraadt Exp $ */
/* $OpenBSD: table.h,v 1.7 2005/12/11 20:31:21 otto Exp $ */
/* $OpenBSD: table.h,v 1.8 2012/02/19 07:52:30 otto Exp $ */
/* $OpenBSD: tree.h,v 1.10 2005/03/28 21:28:22 deraadt Exp $ */
/* $OpenBSD: expand.h,v 1.6 2005/03/30 17:16:37 deraadt Exp $ */
/* $OpenBSD: lex.h,v 1.11 2006/05/29 18:22:24 otto Exp $ */
@ -152,9 +152,9 @@
#endif
#ifdef EXTERN
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.521 2012/02/06 17:42:23 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.522 2012/03/03 21:30:57 tg Exp $");
#endif
#define MKSH_VERSION "R40 2012/02/06"
#define MKSH_VERSION "R40 2012/03/03"
/* arithmetic types: C implementation */
#if !HAVE_CAN_INTTYPES
@ -1730,7 +1730,12 @@ void coproc_write_close(int);
int coproc_getfd(int, const char **);
void coproc_cleanup(int);
struct temp *maketemp(Area *, Temp_type, struct temp **);
void ktinit(Area *, struct table *, uint8_t);
void ktinit_real(Area *, struct table *, uint8_t);
#ifdef MKSH_SMALL
#define ktinit(ap, tp, s80, s66) ktinit_real((ap), (tp), (s80))
#else
#define ktinit(ap, tp, s80, s66) ktinit_real((ap), (tp), (s66))
#endif
struct tbl *ktscan(struct table *, const char *, uint32_t, struct tbl ***);
/* table, name (key) to search for, hash(n) */
#define ktsearch(tp, s, h) ktscan((tp), (s), (h), NULL)

6
syn.c
View File

@ -23,7 +23,7 @@
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/syn.c,v 1.73 2012/01/03 15:32:08 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/syn.c,v 1.74 2012/03/03 21:30:58 tg Exp $");
extern short subshell_nesting_level;
extern void yyskiputf8bom(void);
@ -794,8 +794,8 @@ initkeywords(void)
struct tbl *p;
ktinit(APERM, &keywords,
/* currently 28 keywords -> 80% of 64 (2^6) */
6);
/* currently 28 keywords */
/* 80% of 64 = 2^6 */ 6, /* 66% of 64 = 2^6 */ 6);
for (tt = tokentab; tt->name; tt++) {
if (tt->reserved) {
p = ktenter(&keywords, tt->name, hash(tt->name));

10
var.c
View File

@ -26,7 +26,7 @@
#include <sys/sysctl.h>
#endif
__RCSID("$MirOS: src/bin/mksh/var.c,v 1.140 2011/12/31 00:47:46 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/var.c,v 1.141 2012/03/03 21:30:59 tg Exp $");
/*-
* Variables
@ -74,8 +74,8 @@ newblock(void)
l->argv = e->loc->argv;
}
l->exit = l->error = NULL;
ktinit(&l->area, &l->vars, 0);
ktinit(&l->area, &l->funs, 0);
ktinit(&l->area, &l->vars, 0, 0);
ktinit(&l->area, &l->funs, 0, 0);
l->next = e->loc;
e->loc = l;
}
@ -130,8 +130,8 @@ initvar(void)
struct tbl *tp;
ktinit(APERM, &specials,
/* currently 12 specials -> 80% of 16 (2^4) */
4);
/* currently 12 specials */
/* 80% of 16 = 2^4 */ 4, /* 66% of 32 = 2^5 */ 5);
while (i < V_MAX - 1) {
tp = ktenter(&specials, initvar_names[i],
hash(initvar_names[i]));