283369 Commits

Author SHA1 Message Date
rillig
7a70c4ea70 make(1): add test variant for reference counting logging 2020-11-29 21:27:08 +00:00
rillig
22d703e606 make(1): clean up memory management for CachedDirs
Previously, the reference count for a newly created CacheDir had been
set to 1 in CacheNewDir.  This was wrong because at that point, the
object had not been referenced by any nonlocal variable.  The reference
count is no longer incremented at this point.

All callers of CacheNewDir either append the newly created CachedDir to
a SearchPath via Lst_Append and CachedDir_Ref, or they assign it to a
global variable via CachedDir_Assign.

Since the reference count is no longer wrongly incremented, it does not
need to be decremented more than necessary in Dir_End.  To keep the code
simple and maintainable, all assignments to global variables are now
handled by CachedDir_Assign.  Adding a CachedDir to a list is still done
manually via Lst_Append, and the corresponding code for decrementing is
in SearchPath_Clean and SearchPath_Free.  These details may be cleaned
up in a follow-up commit.

As a result, when OpenDirs_Done is called in the unit tests, the list of
open directories is empty.  It had been non-empty in a single unit test
before (dep-wildcards.mk), as a result of calling Dir_Expand.

The additional debug logging for the reference counting is not enabled
by default since it contains memory addresses, which makes the output
dependent on the memory allocator.

The function CachedDir_Destroy has been merged into CachedDir_Undef,
which had only been used in Dir_End before.  The new name emphasizes
that it corresponds to CachedDir_Ref.
2020-11-29 18:49:36 +00:00
rillig
d55908461f make(1): fix the reference count of dotLast going negative
The memory management for dotLast is quite simple.  It is initialized
exactly once main_Init > Init_Objdir > Dir_InitDir and freed exactly
once in main_CleanUp > Dir_End.  Previously, dotLast was not freed at all.

The first call to CachedDir_Unref decremented the refCount to 0 but
didn't free anything.  Next, CachedDir_Destroy was called, which
decremented the reference count to -1, therefore skipping the actual
freeing.  This was probably an implementation mistake.

Since Dir_End is called at the very end of main_CleanUp, no code
accesses dotLast after it has been freed.
2020-11-29 16:37:10 +00:00
rillig
b52551f521 make(1): move CachedDir_Destroy up to the related functions 2020-11-29 16:04:34 +00:00
rillig
85c7000e55 make(1): extract CachedDir_Free0 from CachedDir_Destroy 2020-11-29 15:58:37 +00:00
rillig
6034552ecf make(1): remove wrong comment in Dir_InitCur
In a makefile with repeated ".CURDIR=." lines, Dir_AddDir is called with
a NULL path, once per line.  Since the path is NULL, the search for
OpenDirs_Find is skipped and the directory is always read from disk.
The freshly read directory has a refCount of 1, and the refCount never
raises above 2.

In Dir_InitCur, the directory of the previous .CURDIR has a refCount of
2, which is decremented twice and then freed.  After this, the new
directory is placed in the global 'cur', after incrementing its refCount
to 2.

It still seems wrong that the refCount of 'cur' is 2 instead of 1, but
it works well.
2020-11-29 15:14:32 +00:00
rillig
470c3b700e make(1): add debug logging for OpenDirs_Done 2020-11-29 14:29:19 +00:00
phx
26c1d7d861 Message buffer is too small, since timestamps were enforced. 2020-11-29 12:38:44 +00:00
rillig
3afe048430 make(1): extract CacheNewDir from Dir_AddDir
Change the debug output for directories that are not found.
2020-11-29 12:30:40 +00:00
rillig
9c4948c9b0 make(1): make documentation of CachedDir.refCount more precise 2020-11-29 11:17:41 +00:00
rillig
09e000705a make(1): add debug logging for reference counting of CachedDir 2020-11-29 10:57:16 +00:00
rillig
432bd0ddcb make(1): normalize order of declarations in dir.c 2020-11-29 09:51:39 +00:00
rillig
087d4a0563 make(1): remove comment about returning const
The callers modify the reference count of the CachedDir, therefore it
must be modifiable.
2020-11-29 09:42:54 +00:00
rillig
c0a61e27e9 make(1): rename Dir_Destroy to CachedDir_Destroy
It is no longer exported by the Dir module.
2020-11-29 09:38:04 +00:00
rillig
84085cca68 make(1): use space instead of tab for preprocessor directives 2020-11-29 09:27:40 +00:00
rillig
95906832b0 style: fix typo 2020-11-29 09:15:33 +00:00
rillig
59d6def469 make(1): unexport CachedDir internals 2020-11-29 08:48:24 +00:00
rillig
6f66206a01 make(1): reduce memory allocation for dirSearchPath 2020-11-29 01:40:26 +00:00
rillig
40a620462f make(1): reduce memory allocations for parsing dependencies 2020-11-29 01:35:33 +00:00
rillig
d9f6df7cec make(1): reduce memory allocations in suffix storage 2020-11-29 01:30:38 +00:00
rillig
c91d221250 make(1): reduce memory allocations in suffix handling 2020-11-29 01:24:18 +00:00
rillig
ddcc472c42 make(1): reduce memory allocation in ExpandWildcards for suffixes 2020-11-29 01:19:11 +00:00
rillig
26c51dd6fc make(1): reduce memory allocation in ExpandChildren for suffixes 2020-11-29 01:16:37 +00:00
rillig
4c46d4bd3d make(1): reduce memory allocation in suffix candidate search 2020-11-29 01:12:45 +00:00
rillig
4e0b769f19 make(1): reduce memory allocation in suffix rule handling 2020-11-29 01:10:08 +00:00
rillig
3e85c0fa41 make(1): reduce memory allocation for target handling 2020-11-29 01:05:08 +00:00
rillig
997298cde5 make(1): reduce memory allocation in suffix handling
The function Lst_MoveAll previously freed the source list.  This
function was only used in a few places, and none of them really needed
the allocation.
2020-11-29 00:54:43 +00:00
rillig
a674dd368a make(1): fix main_CleanUp in -DCLEANUP mode (broken since 1 hour)
Broken since main.c 1.486 from 2020-11-28, about 1 hour ago.
2020-11-29 00:42:01 +00:00
rillig
3e7b0787d3 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.
2020-11-29 00:04:22 +00:00
rillig
9bac525681 make(1): reduce memory allocation for toBeMade 2020-11-28 23:50:58 +00:00
rillig
0593ee75cf make(1): reduce memory allocation in Make_ProcessWait 2020-11-28 23:48:36 +00:00
rillig
49129ea461 make(1): reduce memory allocation in Make_ExpandUse 2020-11-28 23:45:25 +00:00
rillig
a10305460f make(1): reduce memory allocation in ReadBuiltinRules 2020-11-28 23:43:14 +00:00
rillig
e102bca64e make(1): reduce memory allocation for CmdOpts.create 2020-11-28 23:39:58 +00:00
rillig
e87223c304 make(1): reduce memory allocation in CmdOpts.variables 2020-11-28 23:35:44 +00:00
rillig
4929944685 make(1): reduce memory allocation in CmdOpts.makefiles 2020-11-28 23:32:22 +00:00
rillig
e27340e9d4 make(1): reduce memory allocation in OpenDirs 2020-11-28 23:22:14 +00:00
rillig
12bd7715ad make(1): reduce memory allocation in Arch_ParseArchive 2020-11-28 23:13:28 +00:00
rillig
85028cce00 make(1): replace void pointer in Dir_Destroy with proper pointer 2020-11-28 22:59:53 +00:00
rillig
9bc32ab45b make(1): replace Dir_Destroy with SearchPath_Free
The function Dir_Destroy is an implementation detail of the cached
directories, and it should not be exported to the other modules.  The
search paths, on the other hand, are the high-level API that may be used
by the other modules, as the concept of search paths is documented in
the manual page.
2020-11-28 22:56:01 +00:00
yhardy
afb8d88625 Use vn_close to release the vnodes in the error handling blocks, since
the vnodes were opened for writing. Fix proposed on current-users
and improved by hannken@.
2020-11-28 22:53:06 +00:00
riastradh
19264dce03 evbarm: Bump efirng entropy estimate.
I'm not really happy with this, but my lack of confidence in the
remaining question marks about this (no real documentation about the
underlying physical processes, and a slightly self-inconsistent uefi
spec) is outweighed by the value of not distracting people with
entropy warnings on systems that are almost certainly fine.
2020-11-28 22:16:23 +00:00
rillig
2c1f8b4c34 make(1): rename some Dir functions to SearchPath
These functions have the search path as their main subject.
2020-11-28 22:13:56 +00:00
rillig
aa3ed0e416 make(1): reduce pointer indirection for archives 2020-11-28 19:26:10 +00:00
rillig
673efe08f3 make(1): reduce pointer indirection for GNode.implicitParents 2020-11-28 19:22:32 +00:00
rillig
eac02ebf12 make(1): reduce pointer indirection for GNode.cohorts 2020-11-28 19:20:03 +00:00
rillig
04763a4014 make(1): reduce pointer indirection for GNode.order_pred and order_succ 2020-11-28 19:16:53 +00:00
rillig
5a24a58276 make(1): reduce memory allocation for GNode.parents and GNode.children 2020-11-28 19:12:28 +00:00
rillig
e93d02d95f make(1): remove pointer indirection from GNode.commands
Just to save a few memory allocations.  No noticeable effect on the
performance though.
2020-11-28 18:55:52 +00:00
rillig
461723e058 make(1): improve type of local variable in Var_Export1 2020-11-28 16:36:19 +00:00