This is needed so that chrome processes know where sandboxed content
processes will be writing their temp files, and so that content processes know
where to write.
MozReview-Commit-ID: BK9bTxFGvZO
We have some oddities in our jemalloc stats reporting.
- "heap-overhead-ratio" is a strange measurement: overhead / non-overhead,
expressed as a percentage. And it omits "bin_unused", which appears to be an
oversight.
- "heap-committed" also omits "bin_unused".
- There are some minor errors in memory report descriptions.
This patch fixes these and improves the heap reporting. It makes the following
reporting changes:
- "heap-allocated": Duplicated as "heap-committed/allocated". (We keep
"heap-allocated" because that's a special value used in the computation of
"heap-unclassified".)
- "heap-committed/overhead": Added; it's the same as the sum of the
"explicit/heap-overhead/*" values. Together with "heap-committed/allocated"
it shows clearly what fraction of the heap is overhead and what fraction is
useful.
- "heap-committed": Removed; now implicit as the "heap-committed/" node.
- "heap-overhead-ratio":
- Removed from memory reports; now shown as the percentage of the new
"heap-committed/overhead" node.
- Still available as a distinguished amount (because it's useful in
isolation) but renamed to heapOverheadFraction, and the telemetry ID is
renamed as MEMORY_HEAP_OVERHEAD_FRACTION.
- "heap-chunks": Removed; it's not that interesting, and can be manually
computed as "heap-mapped" / "heap-chunksize" if necessary.
Part 1: Refactored LoadLibrarySystem32 to expose the system32-path
construction code, so it can be re-used in the following patch.
MozReview-Commit-ID: J5BcI34VPnN
GetSerialNumber accesses global state through gSerialNumbers. We call
GetSerialNumber under a lock when doing normal object refcount logging.
However, we call GetSerialNumber outside of a lock when we're tracing
individual classes for nsCOMPtr refcount logging, even if we don't
actually care about nsCOMPtr refcount logging. We should call it under
a lock always.
UniquePtr is more standard than ScopedFreePtr; using standard constructs
whenever possible is preferable. In this particular case, since we
really just need a chunk of memory, we can allocate a char[] via
MakeUnique.
XPTInterfaceDescriptor::num_additional_types can easily fit in 8 bits -- in
practice it doesn't exceed 20, and there's already a check in DoTypeDescriptor
that it doesn't exceed 255. This patch shrinks it and moves that check into
XPT_InterfaceDescriptorAddTypes() so that any overflow would be detected more
reliably.
On 64-bit platforms this reduces sizeof(XPTInterfaceDescriptor) from 40 to 32
and correspondingly reduces "xpti-working-set" by 16 KiB.
The patch also changes XPT_InterfaceDescriptorAddTypes() into a local function,
because it's defined and only used in xpt_struct.cpp.
This patch:
- Removes XPTArena's ability to support arbitrary alignments.
- Hardwires two sub-arenas into XPTArena, one with alignment of 8 and one with
alignment of 1.
- Uses the first sub-arena for most allocations and the second sub-arena for C
string allocations.
These changes reduce "xpti-working-set" by 56 KiB.
The patch also renames all the used of "malloc" in XPT identifiers with
"calloc", to make clearer that the result is always zeroed.
With careful layout we can reduce sizeof(XPTTypeDescriptor) from 4 to 3, which
also reduces sizeof(XPTParamDescriptor) from 6 to 4. This reduces
"xpti-working-set" by 16 KiB.
The union-of-structs also improves readability by making it clearer exactly
which fields are used for which types.
This requires merging XPT_DoHeaderPrologue() and XPT_DoHeader(), which is
straightforward.
This reduces "xpti-working-set" by 16 KiB on 64-bit platforms.
XPTTypeDescriptor::argnum2 is unused. Removing it reduces
sizeof(XPTTypeDescriptor) from 6 bytes to 4 bytes, which reduces the
"xpti-working-set" measurement by 80 KiB (measured on 64-bit).
XPT has some functions and macros for freeing memory. However, they (a) are
only used on error paths, and (b) don't actually free memory -- they just
optionally log the "freeing" -- because piecewise freeing doesn't make sense
with arena allocation.
This patch removes all that unnecessary machinery.
RegisterBuffer() is the only place that creates an XPTState, and it also
destroys it. So the XPTState can be allocated on the stack, which voids the
need for the creation of an XPTArena.
XPT supports annotations but xpt.py doesn't generate them except for a single
empty annotation (to indicate there are no real annotations). So we can remove
almost all support for them. This also allows XPTString to be removed.