Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/make make(1): reduce memory allocation for targets
details: https://anonhg.NetBSD.org/src/rev/5a31bc4031fc
branches: trunk
changeset: 957457:5a31bc4031fc
user: rillig <rillig%NetBSD.org@localhost>
date: Sun Nov 29 00:04:22 2020 +0000
description:
make(1): reduce memory allocation for targets
This change moves the initialization and finalization of the list of
targets to the same function. They had been split before.
diffstat:
usr.bin/make/main.c | 16 ++++++++--------
usr.bin/make/nonints.h | 6 +++---
usr.bin/make/parse.c | 23 +++++++----------------
usr.bin/make/targ.c | 10 ++++------
4 files changed, 22 insertions(+), 33 deletions(-)
diffs (204 lines):
diff -r 8f026903e9d3 -r 5a31bc4031fc usr.bin/make/main.c
--- a/usr.bin/make/main.c Sat Nov 28 23:50:58 2020 +0000
+++ b/usr.bin/make/main.c Sun Nov 29 00:04:22 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.487 2020/11/28 23:43:14 rillig Exp $ */
+/* $NetBSD: main.c,v 1.488 2020/11/29 00:04:22 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -109,7 +109,7 @@
#include "trace.h"
/* "@(#)main.c 8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: main.c,v 1.487 2020/11/28 23:43:14 rillig Exp $");
+MAKE_RCSID("$NetBSD: main.c,v 1.488 2020/11/29 00:04:22 rillig Exp $");
#if defined(MAKE_NATIVE) && !defined(lint)
__COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 "
"The Regents of the University of California. "
@@ -913,7 +913,7 @@
static Boolean
runTargets(void)
{
- GNodeList *targs; /* target nodes to create */
+ GNodeList targs = LST_INIT; /* target nodes to create */
Boolean outOfDate; /* FALSE if all targets up to date */
/*
@@ -923,9 +923,9 @@
* to create.
*/
if (Lst_IsEmpty(&opts.create))
- targs = Parse_MainName();
+ Parse_MainName(&targs);
else
- targs = Targ_FindList(&opts.create);
+ Targ_FindList(&targs, &opts.create);
if (!opts.compatMake) {
/*
@@ -941,16 +941,16 @@
}
/* Traverse the graph, checking on all the targets */
- outOfDate = Make_Run(targs);
+ outOfDate = Make_Run(&targs);
} else {
/*
* Compat_Init will take care of creating all the
* targets as well as initializing the module.
*/
- Compat_Run(targs);
+ Compat_Run(&targs);
outOfDate = FALSE;
}
- Lst_Free(targs);
+ Lst_Done(&targs); /* Don't free the nodes. */
return outOfDate;
}
diff -r 8f026903e9d3 -r 5a31bc4031fc usr.bin/make/nonints.h
--- a/usr.bin/make/nonints.h Sat Nov 28 23:50:58 2020 +0000
+++ b/usr.bin/make/nonints.h Sun Nov 29 00:04:22 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: nonints.h,v 1.163 2020/11/28 22:56:01 rillig Exp $ */
+/* $NetBSD: nonints.h,v 1.164 2020/11/29 00:04:22 rillig Exp $ */
/*-
* Copyright (c) 1988, 1989, 1990, 1993
@@ -153,7 +153,7 @@
void Parse_AddIncludeDir(const char *);
void Parse_File(const char *, int);
void Parse_SetInput(const char *, int, int, NextBufProc, void *);
-GNodeList *Parse_MainName(void);
+void Parse_MainName(GNodeList *);
int Parse_GetFatals(void);
/* str.c */
@@ -204,7 +204,7 @@
GNode *Targ_GetNode(const char *);
GNode *Targ_NewInternalNode(const char *);
GNode *Targ_GetEndNode(void);
-GNodeList *Targ_FindList(StringList *);
+void Targ_FindList(GNodeList *, StringList *);
Boolean Targ_Ignore(const GNode *);
Boolean Targ_Silent(const GNode *);
Boolean Targ_Precious(const GNode *);
diff -r 8f026903e9d3 -r 5a31bc4031fc usr.bin/make/parse.c
--- a/usr.bin/make/parse.c Sat Nov 28 23:50:58 2020 +0000
+++ b/usr.bin/make/parse.c Sun Nov 29 00:04:22 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: parse.c,v 1.460 2020/11/28 23:39:58 rillig Exp $ */
+/* $NetBSD: parse.c,v 1.461 2020/11/29 00:04:22 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -117,7 +117,7 @@
#include "pathnames.h"
/* "@(#)parse.c 8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: parse.c,v 1.460 2020/11/28 23:39:58 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.461 2020/11/29 00:04:22 rillig Exp $");
/* types and constants */
@@ -208,7 +208,7 @@
* with duplicates. Kept in a separate list since the commands from .USE or
* .USEBEFORE nodes are shared with other GNodes, thereby giving up the
* easily understandable ownership over the allocated strings. */
-static StringList *targCmds;
+static StringList targCmds = LST_INIT;
#endif
/*
@@ -2862,7 +2862,7 @@
ParseAddCmd(gn, cmd);
}
#ifdef CLEANUP
- Lst_Append(targCmds, cmd);
+ Lst_Append(&targCmds, cmd);
#endif
}
}
@@ -3115,9 +3115,6 @@
sysIncPath = SearchPath_New();
defSysIncPath = SearchPath_New();
Vector_Init(&includes, sizeof(IFile));
-#ifdef CLEANUP
- targCmds = Lst_New();
-#endif
}
/* Clean up the parsing module. */
@@ -3125,7 +3122,7 @@
Parse_End(void)
{
#ifdef CLEANUP
- Lst_Destroy(targCmds, free);
+ Lst_DoneCall(&targCmds, free);
assert(targets == NULL);
SearchPath_Free(defSysIncPath);
SearchPath_Free(sysIncPath);
@@ -3140,13 +3137,9 @@
* Return a list containing the single main target to create.
* If no such target exists, we Punt with an obnoxious error message.
*/
-GNodeList *
-Parse_MainName(void)
+void
+Parse_MainName(GNodeList *mainList)
{
- GNodeList *mainList;
-
- mainList = Lst_New();
-
if (mainNode == NULL)
Punt("no target to make.");
@@ -3157,8 +3150,6 @@
Lst_Append(mainList, mainNode);
Var_Append(".TARGETS", mainNode->name, VAR_GLOBAL);
-
- return mainList;
}
int
diff -r 8f026903e9d3 -r 5a31bc4031fc usr.bin/make/targ.c
--- a/usr.bin/make/targ.c Sat Nov 28 23:50:58 2020 +0000
+++ b/usr.bin/make/targ.c Sun Nov 29 00:04:22 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: targ.c,v 1.146 2020/11/28 19:22:32 rillig Exp $ */
+/* $NetBSD: targ.c,v 1.147 2020/11/29 00:04:22 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -119,7 +119,7 @@
#include "dir.h"
/* "@(#)targ.c 8.2 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: targ.c,v 1.146 2020/11/28 19:22:32 rillig Exp $");
+MAKE_RCSID("$NetBSD: targ.c,v 1.147 2020/11/29 00:04:22 rillig Exp $");
/*
* All target nodes that appeared on the left-hand side of one of the
@@ -311,17 +311,15 @@
}
/* Return the named nodes, creating them as necessary. */
-GNodeList *
-Targ_FindList(StringList *names)
+void
+Targ_FindList(GNodeList *nodes, StringList *names)
{
StringListNode *ln;
- GNodeList *nodes = Lst_New();
for (ln = names->first; ln != NULL; ln = ln->next) {
const char *name = ln->datum;
GNode *gn = Targ_GetNode(name);
Lst_Append(nodes, gn);
}
- return nodes;
}
/* Return true if should ignore errors when creating gn. */
Home |
Main Index |
Thread Index |
Old Index