Commit Graph

988 Commits

Author SHA1 Message Date
Eric Rahm
0938982c90 Bug 1389598 - Part 4: Remove remaining gonk refs. r=froydnj
--HG--
extra : rebase_source : 063c7f95dda063eafabfa1921366bd1957b8fe73
2017-08-11 17:45:18 -07:00
Nicholas Nethercote
57c26c9834 Bug 1387956 - Overhaul ComputedValues measurement, and add style structs measurement. r=bholley.
This patch moves measurement of ComputedValues objects from Rust to C++.
Measurement now happens (a) via DOM elements and (b) remaining elements via
the frame tree. Likewise for the style structs hanging off ComputedValues
objects.

Here is an example of the output.

> ├──27,600,448 B (26.49%) -- active/window(https://en.wikipedia.org/wiki/Barack_Obama)
> │  ├──12,772,544 B (12.26%) -- layout
> │  │  ├───4,483,744 B (04.30%) -- frames
> │  │  │   ├──1,653,552 B (01.59%) ── nsInlineFrame
> │  │  │   ├──1,415,760 B (01.36%) ── nsTextFrame
> │  │  │   ├────431,376 B (00.41%) ── nsBlockFrame
> │  │  │   ├────340,560 B (00.33%) ── nsHTMLScrollFrame
> │  │  │   ├────302,544 B (00.29%) ── nsContinuingTextFrame
> │  │  │   ├────156,408 B (00.15%) ── nsBulletFrame
> │  │  │   ├─────73,024 B (00.07%) ── nsPlaceholderFrame
> │  │  │   ├─────27,656 B (00.03%) ── sundries
> │  │  │   ├─────23,520 B (00.02%) ── nsTableCellFrame
> │  │  │   ├─────16,704 B (00.02%) ── nsImageFrame
> │  │  │   ├─────15,488 B (00.01%) ── nsTableRowFrame
> │  │  │   ├─────13,776 B (00.01%) ── nsTableColFrame
> │  │  │   └─────13,376 B (00.01%) ── nsTableFrame
> │  │  ├───3,412,192 B (03.28%) -- servo-style-structs
> │  │  │   ├──1,288,224 B (01.24%) ── Display
> │  │  │   ├────742,400 B (00.71%) ── Position
> │  │  │   ├────308,736 B (00.30%) ── Font
> │  │  │   ├────226,512 B (00.22%) ── Background
> │  │  │   ├────218,304 B (00.21%) ── TextReset
> │  │  │   ├────214,896 B (00.21%) ── Text
> │  │  │   ├────130,560 B (00.13%) ── Border
> │  │  │   ├─────81,408 B (00.08%) ── UIReset
> │  │  │   ├─────61,440 B (00.06%) ── Padding
> │  │  │   ├─────38,176 B (00.04%) ── UserInterface
> │  │  │   ├─────29,232 B (00.03%) ── Margin
> │  │  │   ├─────21,824 B (00.02%) ── sundries
> │  │  │   ├─────20,080 B (00.02%) ── Color
> │  │  │   ├─────20,080 B (00.02%) ── Column
> │  │  │   └─────10,320 B (00.01%) ── Effects
> │  │  ├───2,227,680 B (02.14%) -- computed-values
> │  │  │   ├──1,182,928 B (01.14%) ── non-dom
> │  │  │   └──1,044,752 B (01.00%) ── dom
> │  │  ├───1,500,016 B (01.44%) ── text-runs
> │  │  ├─────492,640 B (00.47%) ── line-boxes
> │  │  ├─────326,688 B (00.31%) ── frame-properties
> │  │  ├─────301,760 B (00.29%) ── pres-shell
> │  │  ├──────27,648 B (00.03%) ── pres-contexts
> │  │  └─────────176 B (00.00%) ── style-sets

The 'servo-style-structs' and 'computed-values' sub-trees are new. (Prior to
this patch, ComputedValues under DOM elements were tallied under the the
'dom/element-nodes' sub-tree, and ComputedValues not under DOM element were
ignored.) 'servo-style-structs/sundries' aggregates all the style structs that
are smaller than 8 KiB.

Other notable things done by the patch are as follows.

- It significantly changes the signatures of the methods measuring nsINode and
  its subclasses, in order to handle the tallying of style structs separately
  from element-nodes. Likewise for nsIFrame.

- It renames the 'layout/style-structs' sub-tree as
  'layout/gecko-style-structs', to clearly distinguish it from the new
  'layout/servo-style-structs' sub-tree.

- It adds some FFI functions to access various Rust-side data structures from
  C++ code.

- There is a nasty hack used twice to measure Arcs, by stepping backwards from
  an interior pointer to a base pointer. It works, but I want to replace it
  with something better eventually. The "XXX WARNING" comments have details.

- It makes DMD print a line to the console if it sees a pointer it doesn't
  recognise. This is useful for detecting when we are measuring an interior
  pointer instead of a base pointer, which is bad but easy to do when Arcs are
  involved.

- It removes the Rust code for measuring CVs, because it's now all done on the
  C++ side.

MozReview-Commit-ID: BKebACLKtCi

--HG--
extra : rebase_source : 4d9a8c6b198a0ff025b811759a6bfa9f33a260ba
2017-08-11 16:37:33 +10:00
Mike Hommey
fda40761ff Bug 1388935 - Avoid overflowing the chunk recycling limit with very large chunks. r=njn
When recycling chunks, mozjemalloc tries to avoid keeping around more
than 128MB worth of chunks around, but it doesn't actually look at the
size of the chunks that are recycled, so if chunk larger than 128MB is
recycled, it is kept as a whole, going well over the limit.

The chunks are still properly reused, and further recycling doesn't
occur, but that can limit other mmap users from getting enough address
space.

With this change, mozjemalloc now doesn't keep more than 128MB, by
splitting the chunks it recycles if they are too large.

Note this was not a problem on Windows, where chunks larger than 1MB are
never recycled (per CAN_RECYCLE).

--HG--
extra : rebase_source : 6765fd30b78ca5ddc7d55aac861355d960e47828
2017-08-10 09:22:55 +09:00
Mike Hommey
b0f2504373 Bug 1388935 - Inline chunk_dalloc_mmap into chunk_dealloc. r=njn
--HG--
extra : rebase_source : 3348f221f1f577c3af6c1b213a692e58ce347ead
2017-08-10 08:49:51 +09:00
Phil Ringnalda
fe1932364b Backed out 2 changesets (bug 1388935) for gtest crashes
Backed out changeset 208572c7abae (bug 1388935)
Backed out changeset dfb4a15b0c32 (bug 1388935)

MozReview-Commit-ID: HRttV7AIlNT
2017-08-09 22:21:37 -07:00
Mike Hommey
44b527c7d7 Bug 1388935 - Avoid overflowing the chunk recycling limit with very large chunks. r=njn
When recycling chunks, mozjemalloc tries to avoid keeping around more
than 128MB worth of chunks around, but it doesn't actually look at the
size of the chunks that are recycled, so if chunk larger than 128MB is
recycled, it is kept as a whole, going well over the limit.

The chunks are still properly reused, and further recycling doesn't
occur, but that can limit other mmap users from getting enough address
space.

With this change, mozjemalloc now doesn't keep more than 128MB, by
splitting the chunks it recycles if they are too large.

Note this was not a problem on Windows, where chunks larger than 1MB are
never recycled (per CAN_RECYCLE).

--HG--
extra : rebase_source : f81e94c6960ba253037f77de1a39c9ff74651e80
2017-08-10 09:22:55 +09:00
Mike Hommey
b206b3c597 Bug 1388935 - Inline chunk_dalloc_mmap into chunk_dealloc. r=njn
--HG--
extra : rebase_source : f6abde118d26552a681faf7df302b791d39e466a
2017-08-10 08:49:51 +09:00
Nicholas Nethercote
710682624c Bug 1387940 - Make --max-frames=8 the default for dmd.py. r=mccr8.
The current default is 24, which is equal to the maximum number of stack frames
that DMD will record. And that's a terrible value because it splits up too many
related stack traces into separate records. There is no single best value, but
8 is a much better default.

--HG--
extra : rebase_source : c423fc4fe0e490ff6d58fa8f7116bc01c86a366e
2017-08-07 14:56:15 +10:00
Wes Kocher
baf6cddc4c Merge inbound to central, a=merge
MozReview-Commit-ID: 9NFjSEt96iT
2017-08-02 17:11:51 -07:00
Nicholas Nethercote
406a9ed175 Bug 1384819 (part 3) - Remove the return value from the stack walker functions. r=glandium.
Just one caller (in DMD) actually looks at it, and that's in an unimportant way
-- if the return value was false, mLength would be zero anyway.

--HG--
extra : rebase_source : 0463ab3765744742a9e854964342d631095fa55f
2017-07-27 16:46:55 +10:00
Nicholas Nethercote
8a20eb82d2 Bug 1384819 (part 2) - Tweak FramePointerStackWalk() arguments. r=glandium.
This patch does he following.

- Avoids some unnecessary casting.

- Renames the |bp| parameter as |aBp|.

- Makes the no-op FramePointerStackWalk() signature match the real one.
  (Clearly it's dead code in all built configurations!)

--HG--
extra : rebase_source : 3fe606d1ff9b063294f4028ff884c20661ed9e0a
2017-07-27 16:46:33 +10:00
Nicholas Nethercote
08e54b7c13 Bug 1384819 (part 1) - Split MozStackWalk(). r=glandium.
MozStackWalk() is different on Windows to the other platforms. It has two extra
arguments, which can be used to walk the stack of a different thread.

This patch makes those differences clearer. Instead of having a single function
and forbidding those two arguments on non-Windows, it removes those arguments
from MozStackWalk, and splits off MozStackWalkThread() which retains them. This
also allows those arguments to have more appropriate types (HANDLE instead of
uintptr_t; CONTEXT* instead of than void*) and names (aContext instead of
aPlatformData).

The patch also removes unnecessary reinterpret_casts for the aClosure argument
at a couple of MozStackWalk() callsites.

--HG--
extra : rebase_source : 111ab7d6426d7be921facc2264f6db86c501d127
2017-07-27 12:46:47 +10:00
Botond Ballo
b93629ee1d Bug 1383919 - Use |noexcept| instead of an exception-specification in mozalloc.h. r=glandium
MozReview-Commit-ID: DwrE8cmZOQN

--HG--
extra : rebase_source : e45f35dd009a3a8a94f50afc55177976c532f16a
2017-07-24 19:19:07 -04:00
Mike Hommey
4aaef7b18a Bug 1395032 - Remove remainder of the VS CRT allocator mismatch hack. r=gps
Bug 1186064 removed most of it when we started requiring VS 2015u2, but
the "frex" function exported through mozglue.def.in was only used
through the MSVCRT being patched by fixcrt.py, which is not done anymore.
So the "frex" export is not used anymore, and so the "dumb_free_thunk"
function is not used anymore as well.

--HG--
extra : rebase_source : 879c469c317c8b6749410a4a476d6c951c9a1d0f
2017-08-30 14:06:13 +09:00
Nicholas Nethercote
f7a538edd4 Bug 1382076 - Use FramePointerStackWalk() in DMD on Win32. r=erahm.
The patch also uses a better value for skipFrames on Win64.

--HG--
extra : rebase_source : ef3d6d68fbea45e7fd571db2ba78904d97f5e21e
2017-07-20 11:33:31 +10:00
Nicholas Nethercote
7d699f9fa4 Bug 1382099 - Remove MOZ_WIDGET_GONK from memory/. r=glandium.
--HG--
extra : rebase_source : 641de85945cb2f0ccdb9d6f5207bdd22b597b318
2017-07-19 18:39:00 +10:00
Mike Hommey
4956a3cafa Bug 1379897 - Remove opt_abort. r=njn
It causes abort() on errors from munmap/VirtualFree (which in practice
don't happen except maybe in case of memory corruption), and was only
enabled on debug builds.

--HG--
extra : rebase_source : fb0c8c82dc1e2d1f14a588a82144cf82e4f4f773
2017-07-11 14:24:35 +09:00
Carsten "Tomcat" Book
31311070d9 merge mozilla-inbound to mozilla-central a=merge 2017-07-11 12:51:59 +02:00
Mike Hommey
1246710041 Bug 1379890 - Remove unused mozjemalloc stats. r=njn
Since bug 1378258 remove malloc_print_stats, there are a bunch of
allocator stats that are now unused, reducing the memory footprint of
allocator metadata.

--HG--
extra : rebase_source : 337ef3b647c20119334b6576d591006f6bb3dd16
2017-07-11 14:42:57 +09:00
Mike Hommey
1ecc9df3fc Bug 1379878 - Use C++ templates to make _malloc_message calls cleaner. r=njn
--HG--
extra : rebase_source : 695fd9ce6b1f216a8bda29b849e1372601a43fe4
2017-07-11 14:15:04 +09:00
Mike Hommey
26fb8eb7b0 Bug 1379878 - Remove umax2s, its last use was removed in bug 1378258. r=njn
--HG--
extra : rebase_source : d9cb0631662ec0015e9c6d268884adb31c5a38bb
2017-07-11 14:09:09 +09:00
Mike Hommey
860374cbca Bug 1360772 - Allow to initialize non-zeroed arena chunks. r=njn
When initializing a new chunk for use as an arena, we started by zeroing
out the chunk (if that wasn't the case) and then initializing a new
arena chunk in there. It turns out this can have a noticeable overhead,
especially when e.g. the new arena chunk is used for a large allocation
filled out by something that is realloc()ated.

OTOH, the chunk recycle code only ever keeps zeroed or arena chunks
around (there is a "recycled" type too, but in practice, at the moment,
this means they were arena chunks before). Arena chunks that were
recycled were totally emptied, so all the runs they may contain will
contain zeroed-out or poisoned data. They also contain a header, that is
overwritten by the new arena chunk initialization.

This means we can get away with reusing non-zeroed recycled chunks
without zeroing them, as long as the arena chunk header marks the runs
as madvised instead of zeroed.

Code-wise, this would benefit from getting a ChunkType out of
chunk_alloc, but this would require more refactoring than I'm willing to
do at the moment.
2017-07-11 13:55:26 +09:00
Mike Hommey
e6c1516607 Bug 1360772 - Indicate to chunk_recycle callers that pages_commit has zeroed the chunk. r=njn
Before returning a chunk, chunk_recycle calls pages_commit (when
MALLOC_DECOMMIT is enabled), which is guaranteed to zero the chunk.

The code further zeroing the chunk afterwards, which is now moved out to
chunk_alloc callers, never took advantage of that fact, duplicating the
effort of zeroing the chunk on Windows.

By indicating to the callers that the chunk has already been zeroed, we
allow callers to skip zeroing on their own.
2017-07-11 13:44:40 +09:00
Mike Hommey
78a584db8a Bug 1360772 - Make chunk_alloc callers handle zeroing when they need it. r=njn
The current code only allows chunk_calloc() callers to tell whether they
want zeroed memory or not, but some might be okay either way, assuming
they act accordingly afterwards. So move the zeroing out of chunk_alloc.
2017-07-11 13:44:39 +09:00
Mike Hommey
f26f174a0e Bug 1360772 - Store the chunk type in chunk recycling queue. r=njn 2017-07-11 13:44:21 +09:00
Mike Hommey
0380bc7b32 Bug 1360772 - Make pages_purge return whether the pages were purged. r=njn
Many functions in the mozjemalloc codebase like to return the opposite
boolean one would tend to expect. Pages_purge is one of them, and this
reverses the logic to match expectations.

Also make it static.
2017-07-11 13:11:55 +09:00
Mike Hommey
bf7a9e79f6 Bug 1379139 - Instead of not recycling huge chunks, zero them. r=njn
It turns out that not recycling some kinds of chunk can lead to the
recycle queue being starved in some scenarios. When that happens, we end
up mmap()ing new memory, but that turns out to be significantly slower.

So instead of not recycling huge chunks, we force-clean them, before
madvising so that the pages can still be reclaimed in case of memory
pressure.

--HG--
extra : rebase_source : 2dbd028daca92c9cd7c8079eb3dc5a0cfa06495b
2017-07-10 06:41:17 +09:00
Nicholas Nethercote
4325ae218a Bug 1371397 - Use FramePointerStackWalk() in DMD on Mac. r=erahm.
This avoids MozStackWalk(), which has become unusably slow on Mac due to
changes in libunwind, and gets us back to decent speed.

The code for getting the frame pointer and stack end was copied from the Gecko
Profiler, which also uses FramePointerStackWalk() on Mac.

--HG--
extra : rebase_source : 58c32c2df8716c7c8123a4a8fb692182d066caca
2017-07-07 07:08:08 +10:00
Carsten "Tomcat" Book
b5c809a8bc merge mozilla-inbound to mozilla-central a=merge 2017-07-07 10:35:44 +02:00
Mike Hommey
19448fe709 Bug 1356701 - Export unprefixed malloc and duplication functions on OSX. r=njn
Going through the system zone allocator for every call to realloc/free
on OSX is costly, because the zone allocator needs to first verify that
the allocations do belong to the allocator it invokes (which ends up
calling jemalloc's malloc_usable_size), which is unnecessary when we
expect the allocations to belong to jemalloc.

So, we export the malloc/realloc/free/etc. symbols from
libmozglue.dylib, such that libraries and programs linked against it
call directly into jemalloc instead of going through the system zone
allocator, effectively shortcutting the allocator verification.

The risk is that some things in Gecko try to realloc/free pointers it
got from system libraries, if those were allocated with a system zone
that is not jemalloc.

--HG--
extra : rebase_source : ee0b29e1275176f52e64f4648dfa7ce25d61292e
2017-07-04 15:01:50 +09:00
Mike Hommey
ed863255b4 Bug 1378592 - Remove MOZ_REPLACE_MALLOC_LINKAGE. r=froydnj
MOZ_REPLACE_MALLOC_LINKAGE was added back when there were problems with
getting weak references working properly for replace-malloc.

Versions of OSX < 10.6 needed flat namespace, but aren't supported
anymore.

Versions of Xcode < 4.5 required flat namespace + a dummy library in
order to produce proper weak references. There is virtually nobody still
building with such an ancient toolchain.

Keeping those around doesn't /really/ hurt, except recent versions of
Xcode don't expose dyldinfo in /usr/bin, used for the configure test.
Consequently, MOZ_REPLACE_MALLOC_LINKAGE ended up being set to use the
dummy library setup, which, by using flat namespace, now causes harm in
bug 1356701, causing bug 1378332.

--HG--
extra : rebase_source : e3edc1f2cf905943c33fafeb631f2f88fc87167e
2017-07-06 10:26:04 +09:00
Mike Hommey
a02826e8ee Bug 1378278 - Use nullptr in mozjemalloc. r=njn
At the same time:
- replace "(nullptr)" with "nullptr",
- replace "x == nullptr" with "!x",
- replace "x != nullptr" with "x".

--HG--
extra : rebase_source : 5bc5577d0de53244afae9ebadb84962f38306368
2017-07-05 14:02:50 +09:00
Ryan VanderMeulen
5e1e8d2f24 Backed out changeset 261d61f4eeec (bug 1356701) for causing bug 1378339. 2017-07-05 12:58:39 -04:00
Mike Hommey
230dccc3d5 Bug 1378258 - Remove malloc_print_stats. r=njn
malloc_print_stats is designed as a end-of-process dump of malloc stats,
but it has limited value in Firefox itself. It has some usefulness as
something to invoke from a debugger while Firefox is running (after
manually setting opt_print_stats to true), but it also lacks information
about live allocations, which would make it more useful.

All in all, if we want some stats about jemalloc allocations in a more
useful way, we'd be better off augmenting the jemalloc_stats() API and
make the data available to e.g. about:memory, than keeping
malloc_print_stats.

--HG--
extra : rebase_source : f6fbc97dfddd52c8620e37e2e189ae0087a845b0
2017-07-05 10:07:43 +09:00
Mike Hommey
c65bedc1c8 Bug 1356701 - Export unprefixed malloc and duplication functions on OSX. r=njn
Going through the system zone allocator for every call to realloc/free
on OSX is costly, because the zone allocator needs to first verify that
the allocations do belong to the allocator it invokes (which ends up
calling jemalloc's malloc_usable_size), which is unnecessary when we
expect the allocations to belong to jemalloc.

So, we export the malloc/realloc/free/etc. symbols from
libmozglue.dylib, such that libraries and programs linked against it
calls directly into jemalloc instead of going through the system zone
allocator, effectively shortcutting the allocator verification.

The risk is that some things in Gecko try to realloc/free pointers it
got from system libraries, if those were allocated with a system zone
that is not jemalloc.

--HG--
extra : rebase_source : 45b9b98499760a7f946878d41d2fdaadb6dff4d6
2017-07-04 15:01:50 +09:00
Petr Sumbera
a393f2a6cf Bug 1375467 - Redefining abort() in C++ requires extern "C". r=glandium 2017-06-22 05:09:05 -07:00
Jeff Gilbert
58ae26fbc7 Bug 1376057 - Replace MSVC wrappers with std::exception::_Set_raise_handler. - r=froydnj
MozReview-Commit-ID: MG5c4bzDlI
2017-06-27 11:51:34 -07:00
Mike Hommey
7ccc8afe84 Bug 1378658 - When page_purges doesn't zero pages, only record arena chunks or previously recycled chunks for future recycling. r=njn 2017-07-07 09:18:03 +09:00
Mike Hommey
29524a9451 Bug 1369626 - Remove MALLOC_XMALLOC. r=njn
Setting MALLOC_XMALLOC enables a runtime toggle that allows to make
allocations abort() on OOM instead of returning NULL. In other words,
it enables a toggle that allows to turn all allocations into infallible
allocations.

The toggle however still defaults to being disabled, which means even
when MALLOC_XMALLOC is defined when building mozjemalloc, there is no
change in behavior, unless a MALLOC_OPTIONS is set.

Even if this were useful to anyone (MALLOC_XMALLOC is only defined on
debug builds, limiting the usefulness), this is something
replace-malloc, in Firefox, is meant to be used for.

So let's remove this feature, and possibly add an equivalent
replace-malloc later if deemed necessary.

--HG--
extra : rebase_source : 1ccc893e9a8e842c3fa90e91f076a528df2f7dfe
2017-06-02 15:19:20 +09:00
Mike Hommey
1b12c351f2 Bug 1368932 - Add a testcase for a replace-malloc library that doesn't implement all functions. r=njn
--HG--
rename : memory/replace/logalloc/moz.build => memory/replace/logalloc/logalloc.mozbuild
rename : memory/replace/logalloc/replay/replay.log => memory/replace/logalloc/replay/expected_output_minimal.log
extra : rebase_source : 94f8fb4444e2e0ecda61e5ffd283ab560d1e9dfe
2017-05-31 15:04:32 +09:00
Mike Hommey
4ae1509807 Bug 1368932 - Handle missing replace_posix_memalign at the replace-malloc level. r=njn
Replace-malloc libraries, such as DMD, don't really need to care about
the details of implementing all the variants of aligned memory
allocation functions. Currently, by defining MOZ_REPLACE_ONLY_MEMALIGN
before including replace_malloc.h, they get predefined functions.

Instead of making that an opt-in at build time, we make the
replace-malloc initialization just fill the replace-malloc
malloc_table_t with implementations that rely on the replace_memalign
the library provides.

--HG--
extra : rebase_source : 0842a67d9bc27a9a86c33d14d98b9c25f39982fb
2017-05-31 13:47:17 +09:00
Mike Hommey
7fd2c94e79 Bug 1368932 - Move the replace_malloc_init_funcs function around. r=njn
--HG--
extra : rebase_source : 4e3b3bbd18a37a3ee01d6ec30449249be5481b77
2017-05-31 13:47:11 +09:00
Mike Hommey
565f74102e Bug 1368932 - Fill the replace-malloc malloc_table_t with the real allocator as a fallback. r=njn
Until now, the malloc implementation functions would call the
replace-malloc functions if they exist, and fallback to the real
allocator in no such function exists. Instead of doing this, we now
fill the empty slots in the malloc_table_t with the real allocator
functions.

--HG--
extra : rebase_source : b54634f23188906939e4dc01fc5a3007de0f3f2c
2017-05-30 15:57:28 +09:00
Mike Hommey
1a6ac2f8fb Bug 1368932 - Use a malloc_table_t for most replace-malloc function pointers, on all platforms. r=njn
We make replace_malloc_init_funcs called on all platforms and fill out a
malloc_table_t for the replace-malloc functions with what comes from
dlsym/GetProcAddress on Android/Windows, and from the dynamically linked
weak symbols replace_* on other platforms.

replace_malloc.h contains definitions of *_impl_t types for each of the
functions in the malloc_table_t, which is redundant with the
replace_*_impl_t types we were creating, so we remove those typedefs,
except for the two functions (init and get_bridge) that don't have such
a typedef. Those functions don't appear in malloc_table_t.

--HG--
extra : rebase_source : 3705a99ee07f63dbaa66973eef19ddab224e0911
2017-05-30 15:57:28 +09:00
Mike Hommey
409495f283 Bug 1368932 - Refactor such that there is only one definition of replace_malloc_init_funcs. r=njn
We want, in a subsequent patch, to have replace_malloc_init_funcs be
called on all platforms (including those relying on the replace-malloc
library being loaded already) and perform more initialization.

To prepare for that, we move the non-platform-specific pieces out.

--HG--
extra : rebase_source : 239ed363ee168bf4f8a96e0a1ca52981cb941b71
2017-05-30 15:57:28 +09:00
Mike Hommey
37b66db19d Bug 1368932 - Generate all the _impl functions with macros in replace-malloc. r=njn
All the _impl functions in replace-malloc.c are largely identical. This
replaces all of them with macro expansions.

--HG--
extra : rebase_source : 67a1809b0b0fc4645ea5041154fa3a6dcb6cce6b
2017-05-25 16:47:57 +09:00
Mike Hommey
e4fddc104f Bug 1368932 - Add argument names to malloc implementation declarations in replace-malloc. r=njn
This transforms the declarations from e.g.:
    void *realloc(void *, size_t);
into:
    void *realloc(void *arg1, size_t arg2);

--HG--
extra : rebase_source : 627eb833a98d11f044c776f9d29715ccad31174d
2017-05-25 16:04:46 +09:00
Mike Hommey
2357f45d41 Bug 1368932 - Don't rely on the default MALLOC_DECL_VOID for malloc function declarations in replace-malloc. r=njn
In practice, this induces no change in what the expanded code looks
like.

--HG--
extra : rebase_source : 0df6a5dd3ca5161c0969c814e4222eeb51f9f9a2
2017-05-25 15:58:56 +09:00
Mike Hommey
7cd6d8b45d Bug 1368932 - Factor out function declarations for malloc implementation. r=njn
--HG--
extra : rebase_source : a8df78c7ade473eb5d7c71228f0939cce4554f57
2017-05-25 15:54:05 +09:00
Mike Hommey
16215c85f1 Bug 1368932 - Remove void argument from declarations in malloc_decls.h. r=njn
This makes no significant difference in practice in the macro
expansions, but will help down the line.

--HG--
extra : rebase_source : 6d61c1f28c558321478d7e5f26390d27ae8ae3ac
2017-05-25 13:56:40 +09:00
Mike Hommey
f9a4ab0e55 Bug 1367695 - Remove leftovers from jemalloc4. r=njn
MOZ_REPLACE_JEMALLOC was only defined when building jemalloc4 as a
replace-malloc library.

--HG--
extra : rebase_source : fa5c402da07fa96448c170b6db99629469691efe
2017-05-25 16:24:13 +09:00
Mike Hommey
fade48cbe6 Bug 1365206 - Remove Sun Studio compiler optimization flags for mozjemalloc. r=gps
We don't support that compiler anymore.
2017-05-19 08:29:05 +09:00
Mike Hommey
fbbe2d361d Bug 1365460 - Remove function prototypes but keep necessary forward declarations. r=njn
--HG--
extra : rebase_source : 670aecc65cf709f2312a29c80e3c3171ccb2c8c2
2017-05-18 16:27:06 +09:00
Mike Hommey
1dfc7df618 Bug 1365460 - Make umax2s support only base 10. r=njn
Other bases are never used.

--HG--
extra : rebase_source : 6c8edcbde86480995b2d96ac513724e3212457cf
2017-05-18 16:22:10 +09:00
Mike Hommey
eaa9da1203 Bug 1365460 - Avoid unused variables. r=njn
--HG--
extra : rebase_source : 18cd68afc595aca1177e453f6c60a65de1d0dece
2017-05-18 12:24:57 +09:00
Mike Hommey
be0c2ffbc5 Bug 1365460 - Remove warning exceptions for MSVC and work around them. r=njn
--HG--
extra : rebase_source : 182c1e5583950f52a5eadc9fcf5d0b72ba4c56a9
2017-05-18 12:13:34 +09:00
Mike Hommey
61860e7f63 Bug 1365460 - Don't define integer types that MSVC >= 2015 know about. r=njn
--HG--
extra : rebase_source : 6a13970a477fda647eaed1dc381ecb993297922f
2017-05-18 12:09:38 +09:00
Mike Hommey
d3f17931b7 Bug 1365460 - Remove JEMALLOC_USES_MAP_ALIGN. r=njn
It's a Solaris-only optimization that was used as a workaround for some
infinite loop in pages_map (bug 457189). In the meanwhile, the way
pages_map works has changed in such a way the infinite loop can't happen
anymore.

Specifically, the original problem was that pages_map would try to
allocate something larger than a chunk, then deallocate it, and
reallocate at a hinted aligned address near the address of the now
deallocated mapping, hopefully getting an aligned chunk. But Solaris
would ignore the hint and the chunk would never be aligned, causing the
infinite loop.

What the code does now it over-allocate, find an aligned chunk in there,
and deallocate what ends up not being needed. Which leaves no room for
the original infinite loop.

We thus remove the workaround and put Solaris in par with other Unix
platforms.

--HG--
extra : rebase_source : 9ce4509d9c5ac6123cedabf87c5738672af35d1b
2017-05-18 11:30:52 +09:00
Mike Hommey
3dce495fff Bug 1365460 - Use MOZ_DIAGNOSTIC_ASSERT where mozjemalloc uses RELEASE_ASSERT. r=njn
In Gecko code, MOZ_RELEASE_ASSERT means assertions that happen on all
types of builds.

In mozjemalloc, RELEASE_ASSERT means assertions that happen when
MOZ_JEMALLOC_HARD_ASSERTS is set, otherwise normal assertions. Which is
confusing. On the other hand, it's very similar to
MOZ_DIAGNOSTIC_ASSERT, and we may just want to use that instead.

Moreover, with release promotion, the check setting
MOZ_JEMALLOC_HARD_ASSERTS means releases (promoted from beta) would end
up with those asserts while they're not meant to, so
MOZ_DIAGNOSTIC_ASSERT is actually closer to the intent. It however means
we'd lose the beta population running those assertions.

--HG--
extra : rebase_source : 606ab47af8d9ee793b13b806acadb9781c99a078
2017-05-18 10:57:43 +09:00
Mike Hommey
175a4c0a2a Bug 1365460 - Replace assert with MOZ_ASSERT. r=njn
--HG--
extra : rebase_source : fab2172c763518c8f08efd99b0f9d9c3fdde42af
2017-05-18 10:52:00 +09:00
Mike Hommey
7c28b3d25e Bug 1365460 - Expand the __crtInitCritSecAndSpinCount macro and remove it. r=njn
--HG--
extra : rebase_source : 1149b2446447a423704f147dad8e404792e83938
2017-05-18 10:39:08 +09:00
Mike Hommey
77cecfcb4b Bug 1365460 - Replace __DECONST with const_cast. r=njn
--HG--
extra : rebase_source : 5222652581d27e68a6af71ec8b9e2c30446c18d2
2017-05-18 10:37:08 +09:00
Mike Hommey
fdda7f976a Bug 1365460 - Remove JEMALLOC_MUNMAP/config_munmap, they are always true. r=njn
--HG--
extra : rebase_source : 420913999fc1c49ec8b6134f9768ced4355b4a2d
2017-05-18 10:34:38 +09:00
Mike Hommey
139dee33bb Bug 1365460 - Remove JEMALLOC_RECYCLE/config_recycle, they are always true. r=njn
--HG--
extra : rebase_source : de942f6ffaec1d17239a76606590f5cc2477a405
2017-05-18 10:32:30 +09:00
Mike Hommey
c6aa8aa7c7 Bug 1365460 - Remove runtime support for SysV malloc semantics. r=njn
Support for them was only enabled on debug builds, and required an
opt-in through e.g. MALLOC_OPTIONS to actually enable at runtime.

--HG--
extra : rebase_source : 60c27585c2901a73eb790cec124b880c93da6ef7
2017-05-18 10:28:28 +09:00
Mike Hommey
92ba43731c Bug 1365460 - Replace MOZ_MEMORY_DEBUG, MALLOC_DEBUG and !MALLOC_PRODUCTION with MOZ_DEBUG. r=njn
--HG--
extra : rebase_source : eeae81907bb80f78d0ab83343cc514f483d5ddc0
2017-05-18 10:22:20 +09:00
Mike Hommey
72d4bc9cc3 Bug 1365460 - Define _malloc_message as a function instead of a pointer to a function. r=njn
--HG--
extra : rebase_source : ea3088ad12ae2e0879beceac48f01ecdeb5c8f3a
2017-05-18 10:18:36 +09:00
Mike Hommey
d1b9ff45e8 Bug 1365460 - Remove support for /etc/malloc.conf. r=njn
While it makes sense for a global system allocator, it's not really
interesting for Firefox to respect that. Plus, newer versions of
jemalloc, which are more likely to be used as a global system allocator
use a different format for the options passed through that file.

--HG--
extra : rebase_source : 0f2283cf5660bc437bd097bf48c2b5989fa08011
2017-05-18 10:12:18 +09:00
Mike Hommey
f3762790b7 Bug 1365460 - Remove the inline extra malloc options. r=njn
Those options, complementing the MALLOC_OPTIONS environment variable,
were always empty since the removal of b2g.

--HG--
extra : rebase_source : 0e34cfce0b537ebb8ed3902bd46180dc205cb0e4
2017-05-18 10:06:29 +09:00
Mike Hommey
937023c28a Bug 1365460 - Remove the possibility to disable free() poisoning at runtime. r=njn
--HG--
extra : rebase_source : 1d98488d73bc8015ad1fd057ae0655b0f847d679
2017-05-18 10:03:43 +09:00
Mike Hommey
5858dd93d2 Bug 1365460 - Replace literal 0xe4/0xe5 junk/poison values with constants. r=njn
--HG--
extra : rebase_source : 085fd31f00e4afef8c990d54f77c0301b2502f3d
2017-05-18 10:02:36 +09:00
Mike Hommey
91f81f5e20 Bug 1365460 - Remove unused qr.h and ql.h headers. r=njn
--HG--
extra : rebase_source : b585b93c9523996400e50e29faa346618601cf28
2017-05-17 11:25:45 +09:00
Mike Hommey
4933268c6e Bug 1365460 - Remove unused macros from rb.h. r=njn
--HG--
extra : rebase_source : b3730f71ac83e106233ed42195a6f44fd32380a4
2017-05-17 11:23:10 +09:00
Iris Hsiao
0bbdca7c50 Merge mozilla-central to autoland
--HG--
rename : memory/mozjemalloc/jemalloc.c => memory/mozjemalloc/mozjemalloc.cpp
2017-05-18 14:15:19 +08:00
Jim Chen
9579d51797 Bug 1360321 - 3. Don't use mmap2 on Android AArch64 in mozjemalloc; r=glandium
Android NDK defines SYS_mmap2 but it expands to a nonexistent symbol.
mmap2 may not be supported in any case in some AArch64 kernels, so we
should just use mmap.

MozReview-Commit-ID: 5Vjuja5fLIL
2017-05-17 13:06:21 -04:00
Carsten "Tomcat" Book
f55349994f Backed out changeset 484c5137e19f (bug 1365194) to clean up spidermonkey 2017-05-17 11:44:17 +02:00
Carsten "Tomcat" Book
766c2581c8 Backed out changeset d8de424663b7 (bug 1365194) 2017-05-17 11:43:28 +02:00
Carsten "Tomcat" Book
9c3f61e278 Backed out changeset b56224bf370d (bug 1365194) 2017-05-17 11:43:26 +02:00
Carsten "Tomcat" Book
d0e69c4bdb Backed out changeset 4b9c2fb40653 (bug 1365194) 2017-05-17 11:43:24 +02:00
Carsten "Tomcat" Book
c994a231f0 Backed out changeset 9711f5bbda3b (bug 1365194)
--HG--
rename : memory/mozjemalloc/mozjemalloc.cpp => memory/mozjemalloc/jemalloc.c
2017-05-17 11:43:22 +02:00
Carsten "Tomcat" Book
921529ef63 Backed out changeset 4553b67c794f (bug 1365473) for breaking spidermonkey with illegal token on right side of..
--HG--
rename : memory/mozjemalloc/mozjemalloc_types.h => memory/mozjemalloc/jemalloc_types.h
2017-05-17 11:31:32 +02:00
Mike Hommey
e7764f68e0 Bug 1365473 - Rename jemalloc_types.h to mozjemalloc_types.h. r=njn
--HG--
rename : memory/mozjemalloc/jemalloc_types.h => memory/mozjemalloc/mozjemalloc_types.h
extra : rebase_source : 542d0f115f54099517f3eb9a2e0f93f8987f4f63
2017-05-12 21:52:25 +09:00
Mike Hommey
b302af7bc0 Bug 1365473 - Rename jemalloc_types.h to mozjemalloc_types.h. r=njn
--HG--
rename : memory/mozjemalloc/jemalloc_types.h => memory/mozjemalloc/mozjemalloc_types.h
extra : rebase_source : 542d0f115f54099517f3eb9a2e0f93f8987f4f63
2017-05-12 21:52:25 +09:00
Mike Hommey
67a2475101 Bug 1365194 - Compile mozjemalloc as C++. r=njn
The source file is renamed too, because the build system doesn't handle
sources changing suffix very well (at least not without a clobber).

The _GNU_SOURCE define is removed because GCC/Clang set it by default in
C++ mode.

--HG--
rename : memory/mozjemalloc/jemalloc.c => memory/mozjemalloc/mozjemalloc.cpp
extra : rebase_source : f57dbb0a66b25e70fe8c724e9250cc0d8b14f1c1
2017-05-12 21:52:25 +09:00
Mike Hommey
cfcf835a7f Bug 1365194 - Remove parts of the hacks for memalign in mozjemalloc. r=njn
The hack dates back from the originally imported jemalloc code, which
couldn't assume it's built for Firefox. Now, we can assume that, which
means the code is always built with hidden visibility by default,
removing the need for the explicit hidden visibility.

Correspondingly, when building on Solaris with GCC, the default
visibility should also prevent the inlining, making the noinline
attribute redundant. And the Sun Studio path is useless since the
compiler is not supported anymore.

--HG--
extra : rebase_source : dab0ac68af56b1f9432d312665d4ff3df01fb58a
2017-05-16 20:01:55 +09:00
Mike Hommey
0400284f88 Bug 1365194 - Make extern "C" part of MOZ_MEMORY_API and MOZ_JEMALLOC_API. r=njn
This avoids many additions of `extern "C"` in C++ code and will avoid
having to do the same to mozjemalloc once built as C++.

--HG--
extra : rebase_source : af55696262f40a9dd16a19c29edcb9bb307d4957
2017-05-16 18:46:02 +09:00
Mike Hommey
966b5bb639 Bug 1365194 - Remove MOZ_JEMALLOC_API from _malloc_options and _malloc_message. r=njn
MOZ_JEMALLOC_API makes those symbols exported, but we're going to make
MOZ_JEMALLOC_API include `extern "C"`, which GCC warns about in this
case (can't use extern on a variable that is initialized).

While we could get around this in some way, there is not much use for
those variables being exported altogether: the only reason they are is
to allow an override when linking mozjemalloc into executables, but
doing that in Firefox requires patching the build system or passing some
specific LDFLAGS. People who really need to do that might as well apply
a patch.

They also allow run-time override through LD_PRELOAD, but one might as
well use the MALLOC_OPTIONS environment variable for _malloc_options.
As for _malloc_message, it doesn't seem very useful to override, and
probably noone ever overrode it at runtime.

Note, we may want to remove them in a followup.

--HG--
extra : rebase_source : f2dbe5dbf0bbdb369cd7c6255f624f16b8e37209
2017-05-16 18:55:24 +09:00
Mike Hommey
bbdb5a1a9c Bug 1365194 - Call moz_abort directly instead of using a macro to override abort. r=njn
Using -Dabort=moz_abort actually makes the build fail in some libstdc++
headers when building as C++.

--HG--
extra : rebase_source : 77828d5c42f231372a8e75f5e3cd6af135d1d5e8
2017-05-12 21:51:16 +09:00
Mike Hommey
14503d2c39 Bug 1365194 - Compile mozjemalloc as C++. r=njn
The source file is renamed too, because the build system doesn't handle
sources changing suffix very well (at least not without a clobber).

The _GNU_SOURCE define is removed because GCC/Clang set it by default in
C++ mode.

--HG--
rename : memory/mozjemalloc/jemalloc.c => memory/mozjemalloc/mozjemalloc.cpp
extra : rebase_source : f57dbb0a66b25e70fe8c724e9250cc0d8b14f1c1
2017-05-12 21:52:25 +09:00
Mike Hommey
12cfad23f4 Bug 1365194 - Remove parts of the hacks for memalign in mozjemalloc. r=njn
The hack dates back from the originally imported jemalloc code, which
couldn't assume it's built for Firefox. Now, we can assume that, which
means the code is always built with hidden visibility by default,
removing the need for the explicit hidden visibility.

Correspondingly, when building on Solaris with GCC, the default
visibility should also prevent the inlining, making the noinline
attribute redundant. And the Sun Studio path is useless since the
compiler is not supported anymore.

--HG--
extra : rebase_source : dab0ac68af56b1f9432d312665d4ff3df01fb58a
2017-05-16 20:01:55 +09:00
Mike Hommey
2bd75405bc Bug 1365194 - Make extern "C" part of MOZ_MEMORY_API and MOZ_JEMALLOC_API. r=njn
This avoids many additions of `extern "C"` in C++ code and will avoid
having to do the same to mozjemalloc once built as C++.

--HG--
extra : rebase_source : af55696262f40a9dd16a19c29edcb9bb307d4957
2017-05-16 18:46:02 +09:00
Mike Hommey
e05de96ab1 Bug 1365194 - Remove MOZ_JEMALLOC_API from _malloc_options and _malloc_message. r=njn
MOZ_JEMALLOC_API makes those symbols exported, but we're going to make
MOZ_JEMALLOC_API include `extern "C"`, which GCC warns about in this
case (can't use extern on a variable that is initialized).

While we could get around this in some way, there is not much use for
those variables being exported altogether: the only reason they are is
to allow an override when linking mozjemalloc into executables, but
doing that in Firefox requires patching the build system or passing some
specific LDFLAGS. People who really need to do that might as well apply
a patch.

They also allow run-time override through LD_PRELOAD, but one might as
well use the MALLOC_OPTIONS environment variable for _malloc_options.
As for _malloc_message, it doesn't seem very useful to override, and
probably noone ever overrode it at runtime.

Note, we may want to remove them in a followup.

--HG--
extra : rebase_source : f2dbe5dbf0bbdb369cd7c6255f624f16b8e37209
2017-05-16 18:55:24 +09:00
Mike Hommey
782764a6fd Bug 1365194 - Call moz_abort directly instead of using a macro to override abort. r=njn
Using -Dabort=moz_abort actually makes the build fail in some libstdc++
headers when building as C++.

--HG--
extra : rebase_source : 77828d5c42f231372a8e75f5e3cd6af135d1d5e8
2017-05-12 21:51:16 +09:00
Mike Hommey
c530406a95 Bug 1365191 - Remove dead code hidden behind the never set NEEDS_PTHREAD_MMAP_UNALIGNED_TSD. r=njn
--HG--
extra : rebase_source : 79efaa1e0922c356469655f88f86b255ccc72141
2017-05-11 18:05:14 +09:00
Mike Hommey
03a5ae85e0 Bug 1365191 - Remove MALLOC_FILL from mozjemalloc. r=njn
It's always set.

--HG--
extra : rebase_source : 1f3249a8210b0e339bda0c79932fa129cebec27a
2017-05-11 17:57:30 +09:00
Mike Hommey
9fa3e56ddf Bug 1365191 - Remove MALLOC_STATS from mozjemalloc. r=njn
It's always set.

--HG--
extra : rebase_source : 221f1b8ded2f08f0608ca065cf5029f841a4915f
2017-05-11 17:55:21 +09:00
Mike Hommey
9f69a922af Bug 1365191 - Remove MALLOC_UTRACE from mozjemalloc. r=njn
It's always unset, and Firefox has the logalloc replace-malloc library
for something similar.

--HG--
extra : rebase_source : cfe66c004df0d6e5db749f01feb9af591e3d1569
2017-05-11 17:47:02 +09:00
Mike Hommey
7a7f8c62a2 Bug 1365191 - Remove MALLOC_VALIDATE in mozjemalloc. r=njn
It's always set.

--HG--
extra : rebase_source : 926b016495867e99f8a4e22dd15f91ec4c7a1b21
2017-05-11 17:39:56 +09:00
Mike Hommey
6be3fc2ba1 Bug 1365191 - Remove !MOZ_MEMORY sections in mozjemalloc. r=njn
MOZ_MEMORY is always defined when building mozjemalloc. Due to the
origin of the code, this was all FreeBSD-specific code, and if we want
to add FreeBSD support, we will probably need to add some of it, but I'd
rather avoid keeping the difference between FreeBSD and other posix
systems if we can.

--HG--
extra : rebase_source : 3afe0136e35e25361e9e1802a9738d82b97e99e5
2017-05-11 17:34:54 +09:00
Mike Hommey
7696439eba Bug 1365191 - Remove #if 0 sections in mozjemalloc. r=njn
--HG--
extra : rebase_source : 71ff171980a1e8d629230d1d92709f0abb78199c
2017-05-11 17:23:02 +09:00
Mike Hommey
cde3e9b853 Bug 1364358 - Keep track of mozjemalloc thread-local arenas. r=erahm
jemalloc_stats, as well as pre/post-fork hooks are using the `arenas`
list along the `narenas` count to iterate over all arenas setup by
mozjemalloc. Up until previous commit, that was used for automatic
multiple arenas support, which is now removed.

But mozjemalloc still supports running with multiple arenas, in the form
of opted-in, per-thread arenas. After bug 1361258, those arenas weren't
tracked, and now that `arenas` only contains the default arena, we can
now fill it with those thread-local arenas.

Keeping the automatic multiple arenas support, which we don't use and
don't really plan to, would have meant using a separate list for them.

--HG--
extra : rebase_source : f4eb55a65df8cdebff84ca709738f906d0c3c6f5
2017-05-12 21:21:11 +09:00
Mike Hommey
339b48a5ff Bug 1364358 - Remove mozjemalloc support for automatic multiple arenas. r=erahm
As per explained 2 commits earlier, we remove the support for multiple
arenas. We however keep the `arenas` list and the `narenas` count to
use it them to track the opted-in per-thread arenas.

--HG--
extra : rebase_source : 6e05cddd3dd385a0cd6a22fb028ab311b0c00678
2017-05-11 17:21:36 +09:00
Mike Hommey
938d371ff2 Bug 1364358 - Remove mozjemalloc check for multithreading. r=erahm
mozjemalloc had an optimization that shortcuts using mutexes when the
program is single-threaded. But with code evolution, the check whether
the program had multiple threads running was meant to be true all the
time.

In order to simplify the code, we just remove those checks and dead code
they were hiding in some cases.

--HG--
extra : rebase_source : 3c7a256bffef50761f6fcd6ec876ebabfcf3fdae
2017-05-11 17:18:59 +09:00
Mike Hommey
ef98dbfba5 Bug 1364358 - Remove mozjemalloc arena balancing. r=erahm
After bug 1361258, mozjemalloc uses a main arena for all allocations,
and specific threads can opt-in to use a different arena for that thread
only. Going forward, this is how we expect to support scaling across
different threads that require lots of concurrent allocations.

To simplify the mozjemalloc code, we'll remove the support for multiple
arenas.

This is the first step towards that, removing the support for arena
balancing. Everything behind the MALLOC_BALANCE macro has never been used
in practice.

--HG--
extra : rebase_source : e7ab669312f1e26a91375d11f5ad488e870bd354
2017-05-11 17:13:44 +09:00
Mike Hommey
782725e19a Bug 1363992 - Remove jemalloc 4. r=njn
--HG--
extra : rebase_source : 9794320e96279cbb8b7b66db6720c959eaa6a95b
2017-05-11 13:23:07 +09:00
Mike Hommey
02a06f7958 Bug 1363992 - Remove support for making jemalloc4 the default. r=njn
--HG--
extra : rebase_source : 77e1c13aa329637d0ec875439d572ee06e6919fa
2017-05-11 13:16:00 +09:00
Mike Hommey
1a9d4c6f33 Bug 1363992 - Remove support for system jemalloc. r=njn
--HG--
extra : rebase_source : 9141402b6f9e84c67afc14303633d328eb5b652c
2017-05-11 13:03:20 +09:00
Bobby Holley
43faf047c5 Bug 1361258 - Backout 2214b3c57c9c (bug 1291356), disabling multiple jemalloc arenas. r=glandium 2017-05-13 08:21:05 +02:00
Mike Hommey
fcd9a5550a Bug 1361258 - Use Thread Local Storage in mozjemalloc on mac. r=erahm
NO_TLS used to be hardcoded on mac because up to 10.6, __thread was not
supported. Until recently, we still supported for 10.6, and it's not the
case anymore, so we could make mac builds use __thread.

Unfortunately, on OSX, __thread circles back calling malloc to allocate
storage on first access, so we have an infinite loop problem here.
Fortunately, pthread_keys don't have this property, so we can use that
instead. It doesn't appear to have significantly more overhead (and TLS
overhead is small anyways compared to the amount of work involved in
allocating memory with mozjemalloc).

At the same time, we uniformize the initialization sequence between
mozjemalloc and mozjemalloc+replace-malloc, such that we have less
occasions for surprises when riding the trains (replace-malloc being
nightly only), ensuring the zone registration happens at the end of
mozjemalloc's initialization.
2017-05-12 18:12:20 +09:00
Mike Hommey
f5461de678 Bug 1361258 - Initial implementation for jemalloc_thread_local_arena. r=erahm
The function, when passed `true`, creates a new arena with no attachment
in the global list of arenas, and assigns it to the current thread.
When passed `false`, it restores the default arena.

Some details are left out because they don't matter yet, as the sole
initial use of the API is going to invoke the function when stylo rayon
threads start up, which happens exactly once per thread, and at thread
exit time, which happens at shutdown, if ever.

This simplifies things, and leaves those details to followup(s):
- Arenas can't simply be killed when the function is called with `false`
  again (or when the thread dies) because they may still contain valid
  allocations that could have been passed to other threads. Those arenas
  should be kept until they are empty.
- jemalloc_stats doesn't know about them and will under-report memory
  usage.
- pre/post fork hooks don't know about them and will not force-unlock
  their locks. In practice, until those arenas are used for something
  else than the style system, this can't lead to the dead-locks that
  these hooks help prevent because nothing should be touching pointers
  allocated through them after fork.
2017-05-12 18:12:15 +09:00
Julian Seward
83969e88eb Bug 1361258 - Add a jemalloc_thread_local_arena API with a binding for rust. r=glandium
The intent of the API is to allow threads to opt-in to use a separate
mozjemalloc arena.

This indroduces a dummy shell with no actual implementation.
2017-05-12 18:08:08 +09:00
Tom Tromey
b4f2234e87 Bug 1334286 - use MOZ_FORMAT_PRINTF in DMD; r=njn
Add MOZ_FORMAT_PRINTF to the appropriate spots in DMD and fix up the
one (trivial) error that this pointed out.

MozReview-Commit-ID: LS0UWV5YRoM

--HG--
extra : rebase_source : eb09be39df61a51acd46ed72a1461c495727af79
2017-04-21 15:54:05 -06:00
Tom Ritter
f8036e08d5 Bug 1332747 Change MOZ_ALWAYS_INLINE to MOZ_ALWAYS_INLINE_EVEN_DEBUG to fix MinGW Debug build r=froydnj
MozReview-Commit-ID: 7CkreJM1mHr

--HG--
extra : rebase_source : 8dc51c9c1b0e10bd7b40f3c6f65b2495dfe22cb1
2017-04-11 12:53:58 -05:00
Alex Gaynor
ce06b5614f Bug 1353847 - Updated the jemalloc mozilla README to reflect its new git url r=glandium
r=glandium

MozReview-Commit-ID: 2jqQoQAwtBW

--HG--
extra : rebase_source : 1998a05be2d153e61d3476fc8fa73cf2d93f3e49
2017-04-05 15:19:19 -04:00
Alex Gaynor
d304ba72b3 Bug 1353752 - Fixed building with jemalloc4 r=glandium
It was broken by 516551993d16.

r=glandium

MozReview-Commit-ID: BvejKjAPB84

--HG--
extra : rebase_source : efaf5c0afb7454ecc75a733e184c82cbd16c5e5f
2017-04-05 13:05:43 -04:00
Eric Rahm
3d78211d31 Bug 1349002 - Build DMD with unified sources. r=njn
DMD can be built with unified sources, additionally it doesn't need NSPR's
strcpy to build properly.

MozReview-Commit-ID: 9hZFlpWdt7
2017-03-21 12:24:43 -07:00
Wes Kocher
9b58353afe Backed out changeset 2f6d3cbedd12 (bug 1349002) for build bustage a=backout
MozReview-Commit-ID: DY4OupKVBlS
2017-03-20 18:08:43 -07:00
Eric Rahm
5b55122df3 Bug 1349002 - Build DMD with unified sources. r=njn
DMD can be built with unified sources, additionally it doesn't need NSPR's
strcpy to build properly.

MozReview-Commit-ID: 9hZFlpWdt7
2017-03-20 17:24:34 -07:00
Bevis Tseng
2a318e8c71 Bug 1332491 - Delete SelectorCacheKey synchronously. r=bz
1. The current asynchronous behavior is pointless, because we still remove the
   hashtable entry synchronously, which deletes the value, and it's the value
   we're using.
2. Trying to asynchronously delete the value is difficult, and not currently
   needed because we can't get a memory-pressure notification while we're using
   the value, and hence can't expire it from the expiration tracker.
   Note: we can't get this memory-pressure notification because the stage 2 of
   mozalloc_handle_oom() to reclaim memory when OOM is not implemented yet.
2017-03-13 14:37:19 +08:00
Joel Maher
52797e0f80 Bug 1344471 - add BUG_COMPONENT to memory/* files. r=glandium
MozReview-Commit-ID: FiUCPht3MEJ
2017-03-08 11:17:11 -05:00
Ryan VanderMeulen
90e0fe11c9 Bug 1343432 - Update jemalloc 4 to version 4.5.0. r=glandium 2017-03-01 21:06:24 -05:00
Iris Hsiao
73bf12810d Backed out changeset 24bea8bde57d (bug 1343432) for build bustage 2017-03-02 11:23:28 +08:00
Ryan VanderMeulen
5d6e7cab50 Bug 1343432 - Update jemalloc 4 to version 4.5.0. r=glandium
--HG--
extra : rebase_source : 0113418a6ba808bf2b3a60bf6e98740791bf02e4
2017-03-01 21:06:24 -05:00
Eric Rahm
6bb5fd3d99 Bug 1341621 - Avoid deadlocks in DMD when forking. r=njn
In order to avoid the possibility of a deadlock if the DMD state lock is
currently acquired when forking a |pthread_atfork| hook is added to wait for
and acquire the lock prior to forking, then release it after forking.
2017-02-23 17:47:02 -08:00
David Major
bb5fe68fae Bug 419470: Re-enable PGO for Linux mozjemalloc. r=glandium
It only took nine years.

MozReview-Commit-ID: 2zsCBMTJ6O1

--HG--
extra : rebase_source : e3be1bd1c930d32d3c7a9e2d707ed3fe6bc0936f
2017-02-22 09:46:06 +13:00
Emanuel Hoogeveen
51fc28feca Bug 1338574 - Part 8: Use MOZ_ASSERT and MOZ_CRASH_UNSAFE_OOL in mozjemalloc. r=glandium
--HG--
extra : rebase_source : 73f61842eb44bd0bfe7d3eca9267cfa10f771295
2017-02-21 18:02:07 +01:00
Emanuel Hoogeveen
9c7c14c872 Bug 1338574 - Part 1: Add MOZ_CRASH_UNSAFE_OOL and MOZ_CRASH_UNSAFE_PRINTF to crash with a runtime generated explanation string. r=froydnj
--HG--
extra : rebase_source : 3ba633aa77ab96f763ea03a8308c539c9c2aeda0
2017-02-21 18:01:41 +01:00
Wes Kocher
017c515285 Merge inbound to m-c a=merge
MozReview-Commit-ID: IKI0zVtF1n9
2017-02-15 16:18:13 -08:00
Emanuel Hoogeveen
00c7d04549 Bug 1339441 - Take the arena lock earlier in arena_dalloc(). r=glandium
--HG--
extra : rebase_source : 95e8f744a9f77381270fd8f8942765b144b844a2
2017-02-15 09:48:00 -05:00
Sylvestre Ledru
6fd3084f65 Bug 1338086 - Remove useless else blocks in order to reduce complexity in memory/ r=njn
MozReview-Commit-ID: G7jBKlDHshQ

--HG--
extra : rebase_source : 4317651e0cc87b0be1230b19ceb844cfcb4842bc
2017-02-09 11:24:39 +01:00
Benjamin Smedberg
ca77995f5d Bug 1333826 - Remove SDK_FILES, SDK_LIBRARY, and related is_sdk support in the build goop, r=mshal
MozReview-Commit-ID: 52vPyDXdFte

--HG--
extra : rebase_source : c3217730bb70eb7319152dd07536b12f49d6a597
2017-01-30 11:24:10 -05:00
Dimitry Andric
8b0557b033 Bug 1329520 - Fix "memory/mozalloc/throw_gcc.h:35:1: note: declaration missing '[[noreturn]]' (libc++ 4.0)" r=nfroyd 2017-01-27 13:55:00 +01:00
Mike Hommey
c9370d609b Bug 1332508 - Reinitialize allocator mutexes in fork() child processes. r=njn
Adapted from
4e2e3dd9cf
and
d9f7b2a430

As per the latter commit, it would seem unlocking, in fork() child
processes, mutexes that were locked in the parent process is not really
well supported on OSX 10.12. The addition of the zone_reinit_lock
function in 10.12 supports this idea.

--HG--
extra : rebase_source : b3b58558cc195d63200078085c7e9b6c9b8d83ff
2017-01-20 10:06:41 +09:00
Mike Hommey
dbc87ab49d Bug 1286613 - Update jemalloc 4 to c6943ac. r=njn
This picks the same changes as the ones we just did to
memory/build/zone.c, plus a oneliner for sparc64.

--HG--
extra : rebase_source : ca917461472e8188fbfc6e2a971b228b68014e38
2017-01-18 15:47:53 +09:00
Mike Hommey
4e8f02fe22 Bug 1286613 - Add dummy implementations for most remaining OSX zone allocator functions. r=njn
Some system libraries are using malloc_default_zone() and then using
some of the malloc_zone_* API. Under normal conditions, those functions
check the malloc_zone_t/malloc_introspection_t struct for the values
that are allowed to be NULL, so that a NULL deref doesn't happen.

As of OSX 10.12, malloc_default_zone() doesn't return the actual default
zone anymore, but returns a fake, wrapper zone. The wrapper zone defines
all the possible functions in the malloc_zone_t/malloc_introspection_t
struct (almost), and calls the function from the registered default zone
(jemalloc in our case) on its own. Without checking whether the pointers
are NULL.

This means that a system library that calls e.g.
malloc_zone_batch_malloc(malloc_default_zone(), ...) ends up trying to
call jemalloc_zone.batch_malloc, which is NULL, and crash follows.

So as of OSX 10.12, the default zone is required to have all the
functions available (really, the same as the wrapper zone), even if they
do nothing.

This is arguably a bug in libsystem_malloc in OSX 10.12, but jemalloc
still needs to work in that case.

[Adapted from
c6943acb3c]

--HG--
extra : rebase_source : 7d7a5b47fa18f56183e99c3655aee003c9be161e
2017-01-18 14:35:11 +09:00
Mike Hommey
dae510ade1 Bug 1286613 - Don't rely on OSX SDK malloc/malloc.h for malloc_zone struct definitions. r=njn
The SDK jemalloc is built against might be not be the latest for various
reasons, but the resulting binary ought to work on newer versions of
OSX.

In order to ensure this, we need the fullest definitions possible, so
copy what we need from the latest version of malloc/malloc.h available
on opensource.apple.com.

[Adapted from
c68bb41793]

--HG--
extra : rebase_source : ab19c478b568ea24095a3be62c39fb81efc1920a
2017-01-18 13:50:35 +09:00
Mike Hommey
e52769e834 Bug 1286613 - Use the same zone allocator implementation as replace-malloc for mozjemalloc. r=njn
We have been using a different zone allocator between mozjemalloc and
replace-malloc for a long time. Jemalloc 4 uses the same as
replace-malloc, albeit as part of the jemalloc upstream code base.

We've been bitten many times in the past with Apple changes breaking the
zone allocator, and each time we've had to make changes to the three
instances, although two of them are similar and the changes there are
straightforward.

It also turns out that the way the mozjemalloc zone allocator is set up,
when a new version of OSX appears with a new version of the system zone
allocator, Firefox ends up using the system allocator, because the zone
allocator version is not supported.

So, we use the same zone allocator for both replace-malloc and
mozjemalloc, making everything on par with jemalloc 4.

--HG--
extra : rebase_source : 9c0e245b5f82bb71294370d607e690c05cc89fbc
2017-01-18 11:45:45 +09:00
Mike Hommey
d293cc01a1 Bug 1286613 - Move replace-malloc zone allocator to a separate file. r=njn
The intent here is to reuse the zone allocator for mozjemalloc, to avoid
all the shortcomings of mozjemalloc using a different one. This change
only moves the replace-malloc zone allocator out of replace-malloc.c, to
make changes for mozjemalloc integration clearer.

--HG--
rename : memory/build/replace_malloc.c => memory/build/zone.c
extra : rebase_source : 8b98efaa4a88862f2967c855b511e92beb9c4031
2017-01-18 11:39:29 +09:00
Mike Hommey
50dd84a5d8 Bug 1286613 - Properly call mozjemalloc pre/post fork hooks on OSX when replace-malloc is enabled. r=njn
Somehow, we never called those hooks when replace-malloc is enabled. I'd
expect this to cause random deadlocks when forking, and I'm surprised
this hasn't surfaced. Maybe it actually causes some intermittent oranges
on automation, who knows.

This also brings consistency with what is done for jemalloc 4, and with
the mozjemalloc implementation, too, that we're going to replace with
this one in a subsequent changeset.

--HG--
extra : rebase_source : 059567d17f928098db8367e9081b631ced351110
2017-01-19 09:37:22 +09:00
John Paul Adrian Glaubitz
4b76f57494 Bug 1275204 - mozjemalloc: Use the JS arm64 allocator on Linux/sparc64. r=glandium 2017-01-11 16:09:39 +09:00
John Paul Adrian Glaubitz
dbf939ff1d Bug 1275204 - mozjemalloc: Use better pre-processor defines for sparc64. r=glandium 2017-01-11 16:05:53 +09:00
Ryan VanderMeulen
ab68dae81c Bug 1200951 - Use the same poison patterns for jemalloc4 as mozjemalloc. r=glandium
--HG--
extra : rebase_source : c44d6020934f16e53ce1c3553c5f952981bceb03
2017-01-10 22:50:36 -05:00
Ryan VanderMeulen
7d537bf11a Bug 1322027 - Update jemalloc 4 to version 4.4.0. r=glandium
--HG--
extra : rebase_source : acad2186ad3ace467a626fcf38659aaf6708c96b
2017-01-10 22:50:36 -05:00
Chris Peterson
b9fd4f1b11 Bug 1142403 - Part 3: jemalloc4 no longer requires ctl.c to be built in non-unified mode in debug builds. r=glandium
--HG--
extra : rebase_source : 9c1e00514be306552722ebd855d364b9b98b5c87
2016-12-22 18:54:59 -08:00
Mike Hommey
bbde532853 Bug 1142403 - Part 1: Don't build jemalloc4 with unified sources when built with --enable-debug. r=mshal
When built with --enable-debug, jemalloc4 makes headers define functions that
are normally inlined, and that prevents unified sources from working.

--HG--
extra : rebase_source : 9490a0a8312e9be18e639384e3450a9c924e3daf
extra : source : a67867200ec31a040bb6bf8320bde20beb34aa3e
2015-08-12 16:04:53 +09:00
Mike Hommey
d1c271f02d Bug 1321093 - Avoid logalloc-replay make check failure when libstdc++ allocates memory in some static initializer. r=njn
--HG--
extra : rebase_source : 83ef3414b74a5164b8535bdf266075d1076e0437
2016-11-30 07:22:20 +09:00
Mike Hommey
97ae022e70 Bug 1311039 - Properly detect the default malloc zone on OSX 10.12. r=njn
--HG--
extra : rebase_source : e625875064e051fa931cab5827debe9fd02d91cf
2016-11-03 10:02:06 +09:00
Emanuel Hoogeveen
b324d2ba21 Bug 1315939 - Use FINAL_LIBRARY = 'memory' in jemalloc and mozjemalloc. r=glandium
--HG--
extra : rebase_source : 94d19e08090839537ca5174baa8b37993d108acc
2016-11-10 06:57:00 -05:00
Eric Rahm
2faeed6d55 Bug 1313485 - Convert XPCOM test TestJemalloc to a gtest. r=njn
MozReview-Commit-ID: 5yzn8o33Ne5

--HG--
rename : xpcom/tests/TestJemalloc.cpp => memory/gtest/TestJemalloc.cpp
2016-11-09 10:24:22 -08:00
Ryan VanderMeulen
3445ad743b Bug 1277704 - Update jemalloc 4 to version 4.3.1. r=glandium
--HG--
extra : rebase_source : d8c50b1012085fad8d7bd940abb41d51423bc12c
2016-07-12 10:37:04 -04:00
Emanuel Hoogeveen
e0a81d7503 Bug 1309573 - Part 2: Define MOZ_HAS_MOZGLUE in various places so that the crash reason gets used. r=glandium
--HG--
extra : rebase_source : d55e8dd75469759f333366bdf9662178ff0a2474
2016-11-08 03:53:00 -05:00
Sebastian Hengst
193fc03fc6 Backed out changeset 1b545e55e42a (bug 1313485) for bustage. r=backout
--HG--
rename : memory/gtest/TestJemalloc.cpp => xpcom/tests/TestJemalloc.cpp
2016-11-07 23:46:09 +01:00
Eric Rahm
52ba7f5179 Bug 1313485 - Convert XPCOM test TestJemalloc to a gtest. r=njn
MozReview-Commit-ID: 5yzn8o33Ne5

--HG--
rename : xpcom/tests/TestJemalloc.cpp => memory/gtest/TestJemalloc.cpp
2016-11-07 14:26:25 -08:00
Mike Hommey
97f635df6b Bug 1303232 - Use per-process reduced thread-ids when munging logalloc logs. r=njn
Bug 1300948 added thread-ids to logalloc logs, and logalloc_munge.py was
munging them all as if they were all under the same namespace. But when
filtering munged logs to only contain logs from a given process,
thread-ids then don't necessarily start from 1, which would be the
desired outcome.

So use a different pool of thread-ids for each process.
2016-09-20 13:44:27 +09:00
Mike Hommey
7e7b4f9fe6 Bug 1300974 - Work around race condition leading to deadlock on fork when enabling LogAlloc. r=njn 2016-09-08 07:56:02 +09:00
Mike Hommey
39fe86c4ed Bug 1300948 - Add thread identifier to LogAlloc output. r=njn 2016-09-08 07:55:03 +09:00
Cameron McCormack
072d6a1fbe Bug 1291356 - Enable multiple jemalloc arenas for MOZ_STYLO builds. r=me
--HG--
extra : rebase_source : eaaaf6fd3aad8a99c7032ce55a1d351f2bf80af1
2016-08-26 20:21:48 +09:00
Wes Kocher
50954c6f31 Merge m-c to autoland, a=merge 2016-08-25 17:15:05 -07:00
Emanuel Hoogeveen
8210833803 Bug 1294732 - Back out all of bug 1271165 as it has served its purpose. r=glandium 2016-08-23 08:45:00 -04:00
Andrew McCreight
5772f60634 Bug 1295695 - Add maybe_pod_* methods to InfallibleAllocPolicy. r=glandium
Bug 1207519 added maybe_pod_* methods to the allocation policy
classes, but did not add them to InfallibleAllocPolicy.

I think the idea of these methods is that the callers are explicitly
opting into fallible behavior, so they will deal with any errors that
occur. For instance, in js::HashTable, this is used to try to shrink
the hash table when there are a lot of unused entries. If the shrink
fails, it just continues to use the existing block of memory.

However, having fallible methods in a supposedly infallible class is
weird, so for now, just use the infallible version.

MozReview-Commit-ID: 97D66Z4oLfl

--HG--
extra : rebase_source : 9a3e0b50a5602a8e4772da88c16e1715c25da7df
2016-08-16 11:09:05 -07:00
Ryan VanderMeulen
69113163cf Merge m-c to inbound. a=merge 2016-08-24 09:09:05 -04:00
Andrew McCreight
faa1eb2316 Bug 1295688 - InfallibleAllocPolicy should crash on overflow. r=glandium
Code that uses InfallibleAllocPolicy presumably wants for operations
to always succeed. However, Vector and HashTable can end up detecting
that growing the data structure will fail due to integer overflow, and
then will call reportAllocOverflow() and fail. I think these cases
should crash.

In addition, pod_malloc and pod_realloc should crash rather than
returning NULL when they detect overflow.

This calls mozalloc_abort rather than MOZ_CRASH directly to avoid
circular #includes, because Assertions.h includes nsTraceRefcnt.h
which includes nscore.h which includes mozalloc.h.

MozReview-Commit-ID: 1g99BXLceQI

--HG--
extra : rebase_source : 927d842588c1f85a50a7a1c50a5546d5f688555f
2016-08-16 10:56:14 -07:00
Kan-Ru Chen
b6d880aca1 Bug 1297276 - Rename mfbt/unused.h to mfbt/Unused.h for consistency. r=froydnj
The patch is generated from following command:

  rgrep -l unused.h|xargs sed -i -e s,mozilla/unused.h,mozilla/Unused.h,

MozReview-Commit-ID: AtLcWApZfES


--HG--
rename : mfbt/unused.h => mfbt/Unused.h
2016-08-24 14:47:04 +08:00
Emanuel Hoogeveen
581ecef4dd Bug 1271165 - Part 6: Change the new functions to MFBT_API to export them on OSX. r=jandem
--HG--
extra : rebase_source : cc3d6cd7cec9c822904364ace811d2c0dff98eff
2016-08-16 07:12:00 -04:00
Emanuel Hoogeveen
f7bdbc26ad Bug 1271165 - Part 4: Enable the new functionality in mozjemalloc. r=ehoogeveen 2016-08-12 07:38:00 -04:00
Emanuel Hoogeveen
57b1d1e8f2 Bug 1271165 - Part 2: Hook the new functions up and provide dummy implementations where needed. r=ehoogeveen 2016-08-12 07:37:00 -04:00
Emanuel Hoogeveen
506ca1034e Bug 1271165 - Part 1: Add protected allocation functions and supporting infrastructure to mozjemalloc. r=ehoogeveen 2016-08-12 07:36:00 -04:00
Emanuel Hoogeveen
54e158268e Bug 1271165 - Part 0: Strip trailing blanks from mozjemalloc. r=ehoogeveen 2016-08-12 07:36:00 -04:00
Alexandre Lissy
0af5b943b6 Bug 1284674 - Remove NUWA r=cyu
MozReview-Commit-ID: GyMRNzOBKw6

--HG--
extra : rebase_source : 293af1cd55f2035ce6a99f4ebf144059c32a2b8f
2016-08-02 14:54:00 +02:00
Chris Peterson
6229606616 Bug 1290645 - Remove VS2013 workarounds in memory/. r=glandium 2016-07-28 11:46:30 -07:00
Tom Tromey
5538d692d3 Bug 1286877 - do not set c-basic-offset for python-mode; r=gps
This removes the unnecessary setting of c-basic-offset from all
python-mode files.

This was automatically generated using

    perl -pi -e 's/; *c-basic-offset: *[0-9]+//'

... on the affected files.

The bulk of these files are moz.build files but there a few others as
well.

MozReview-Commit-ID: 2pPf3DEiZqx

--HG--
extra : rebase_source : 0a7dcac80b924174a2c429b093791148ea6ac204
2016-07-14 10:16:42 -06:00
Mike Hommey
63e7e7ede4 Bug 1280578 - Wrap HeapAlloc, HeapFree and HeapReAlloc on Windows. r=njn
The Win32 has non-malloc based heap allocation functions. They are not
widely used in the Gecko code base, but there are a few places that do
use them. They could be replaced with uses of malloc/free/realloc or
new/delete, but there is now an entirely separate problem that
requires wrapping those functions: the Rust static libraries are using
those functions to allocate memory.
2016-07-20 14:04:40 +09:00
Nicholas Nethercote
6f4e7b36f5 Bug 1282185 (part 2) - Fix an assertion failure in DMD. r=erahm.
--HG--
extra : rebase_source : cb2ae2a5a6fdc84bbcaba64759b0dbce1e161249
2016-07-13 19:32:27 +10:00
Nicholas Nethercote
dcf407f2a8 Bug 1282185 (part 1) - Remove a bogus assertion in DMD. r=erahm.
Since bug 1253512 landed, it's possible for DeadBlocks to lack an allocation
stack.

--HG--
extra : rebase_source : 0efc60192ed0992d2f68838d95586cd888765586
2016-07-13 18:10:56 +10:00
Mike Hommey
16529670ac Bug 1284677 - Change how the default OSX malloc zone is found. r=njn
--HG--
extra : rebase_source : b5ea2bfb37047fa9f8d4d833186694407c73adda
2016-07-08 14:48:16 +09:00
Bill McCloskey
308608ab39 Bug 1262671 - Introduce MFBT BufferList class (r=froydnj) 2016-05-27 09:57:40 -07:00
Mike Hommey
8855262939 Bug 1269171 - Change how mozalloc.h is hooked in STL wrappers. r=froydnj
Since the introduction of the STL wrappers, they have included
mozalloc.h, and multiple times, we've hit header reentrancy problems,
and worked around them as best as we could.

Taking a step back, all mozalloc.h does is:
- declare moz_* allocator functions.
- define inline implementations of various operator new/delete variants.

The first only requires the functions to be declared before they are used,
so mozalloc.h only needs to be included before anything that would use
those functions.

The second doesn't actually require a specific order, as long as the
declaration for those functions comes before their use, and they are
either declared in <new> or implicitly by the C++ compiler.

So all in all, it doesn't matter that mozalloc.h is included before the
wrapped STL headers. What matters is that it's included when STL headers
are included. So arrange things such that mozalloc.h is included after
the first wrapped STL header is fully preprocessed (and all its includes
have been included).
2016-05-22 08:32:40 +09:00
Chris Peterson
8a9e2d2bd4 Bug 1272513 - Part 2: Remove redundant -Wshadow CXXFLAGS from moz.build files. r=glandium 2016-05-14 00:54:55 -07:00
Chris Peterson
353ee65255 Bug 1272513 - Part 1: Suppress -Wshadow warnings-as-errors in some directories. r=glandium 2016-05-11 00:00:01 -07:00
Jan Beich
6d9051edd6 Bug 1259537 - Unbreak libc++ build after bug 1245076. r=glandium
MozReview-Commit-ID: 31otXvuDu4A

--HG--
extra : rebase_source : 048a81a540154b672a9249482124d396336acbc4
2016-05-01 09:32:10 +00:00
Ryan VanderMeulen
662ef75681 Bug 1269959 - Update jemalloc 4 to version 4.1.1. r=glandium
--HG--
extra : rebase_source : cf6f490bd2e366cff642d97927c8a54ef4d762a1
2016-05-03 20:26:00 -04:00
Nicholas Nethercote
2511b2c327 Bug 1267550 (part 2) - Rename MOZ_WARN_UNUSED_RESULT as MOZ_MUST_USE. r=froydnj.
It's an annotation that is used a lot, and should be used even more, so a
shorter name is better.

MozReview-Commit-ID: 1VS4Dney4WX

--HG--
extra : rebase_source : b26919c1b0fcb32e5339adeef5be5becae6032cf
2016-04-27 14:16:50 +10:00
Makoto Kato
234456a100 Bug 1091515 - Don't set 64KB page size on aarch64. r=glandium
Linux/aarch64 supports vairous page size configuration.

(From https://www.kernel.org/doc/Documentation/arm64/memory.txt)
- 4KB + 3 levels
- 4KB + 4 levels
- 64KB + 2 leves

So we shouldn't set fixed 64KB page size on aarch64.


MozReview-Commit-ID: 8IdwBMUW4me

--HG--
extra : rebase_source : 2f3d8de3ea118313cb6dc5f48b7532d9b051c1e6
2016-04-05 18:54:42 +09:00
Nicholas Nethercote
b1378bc5e8 Bug 1260329 - Properly escape the frameTable when running |dmd.py --clamp-contents|. r=mccr8.
--HG--
extra : rebase_source : 7a55328abb0a79cfa6de21734ee3d440b7625f79
2016-03-29 13:34:57 +11:00
Eric Rahm
c2edbab476 Bug 1181142 - Part 1: Make the minimum allocation size word sized on all platforms. r=glandium
Bug 691003 made the minimum allocation size word sized for Linux and OS X, we
now need to do a similar change on Windows as well. For Windows the requirement
is 8-bytes on 32-bit and 16-bytes on 64-bit.
2015-07-07 17:36:31 -07:00
Nicholas Nethercote
43969ea737 Bug 1181142 - Part 0: Update DMD tests to handle a minimum alloc size of 16 on Win64. r=erahm. 2016-03-29 16:31:21 +11:00
Nicholas Nethercote
eb9d46b90f Bug 1253512 (part 2) - Aggregate live blocks. r=erahm.
Due to the change in part 1, DMD now prints an entry for every live block,
which increases the output file size significantly in the default case. However,
a lot of those entries are identical and so can be aggregated via the existing
"num" property.

This patch does that, reducing output size by more than half.

--HG--
extra : rebase_source : 6a3709d068f2fb9bbfe3344d7406f05af896380b
2016-03-29 10:41:06 +11:00
Nicholas Nethercote
0f418f3874 Bug 1253512 (part 1) - Overhaul DMD's "sampling". r=erahm.
DMD currently uses a very hacky form of "sampling" by default to avoid
recording stack traces for all blocks. This makes DMD run faster than when it
records all stack traces.

This patch changes the sampling method used; in fact, it avoids "sampling" at
all. The existence of all heap blocks is now recorded exactly, but by default
we only record an allocation stack for each heap block if a Bernoulli trial
succeeds. This choice works well because getting the stack trace is ~100x
slower than recording the block's existence.

Overall, this approach is simpler and it also gives better output -- the choice
of which blocks to record allocation stacks for is mathematically sound, no
stack trace gets blamed for allocations it didn't do, and block counts and
sizes are now always exact.

Other specific things changed.

- All notion of sampling is removed from the various data structures.

- The --sample-below option is removed in favour of --stacks={partial,full}.

- The format of the JSON output file has changed.

- The names of various test files have changed to reflect concept changes.

--HG--
rename : memory/replace/dmd/test/full-empty-cumulative-expected.txt => memory/replace/dmd/test/complete-empty-cumulative-expected.txt
rename : memory/replace/dmd/test/full-empty-dark-matter-expected.txt => memory/replace/dmd/test/complete-empty-dark-matter-expected.txt
rename : memory/replace/dmd/test/full-empty-live-expected.txt => memory/replace/dmd/test/complete-empty-live-expected.txt
rename : memory/replace/dmd/test/full-unsampled1-dark-matter-expected.txt => memory/replace/dmd/test/complete-full1-dark-matter-expected.txt
rename : memory/replace/dmd/test/full-unsampled1-live-expected.txt => memory/replace/dmd/test/complete-full1-live-expected.txt
rename : memory/replace/dmd/test/full-unsampled2-cumulative-expected.txt => memory/replace/dmd/test/complete-full2-cumulative-expected.txt
rename : memory/replace/dmd/test/full-unsampled2-dark-matter-expected.txt => memory/replace/dmd/test/complete-full2-dark-matter-expected.txt
rename : memory/replace/dmd/test/full-sampled-live-expected.txt => memory/replace/dmd/test/complete-partial-live-expected.txt
extra : rebase_source : 47d287405dc5e9075f08addaba49e879c2c6e23f
2016-02-24 14:42:22 +11:00
Sebastian Hengst
554c274197 Backed out changeset 4593c32d5b81 (bug 1181142) for making XPCshell test_dmd.js fail on Windows 8 x64 debug. r=backout 2016-03-25 21:53:30 +01:00
Eric Rahm
9386c16326 Bug 1181142 - Part 1: Make the minimum allocation size word sized on all platforms. r=glandium
Bug 691003 made the minimum allocation size word sized for Linux and OS X, we
now need to do a similar change on Windows as well. For Windows the requirement
is 8-bytes on 32-bit and 16-bytes on 64-bit.
2015-07-07 17:36:31 -07:00
Nicholas Nethercote
5752d3b3e6 Bug 1258257 - Reduce mozjemalloc page cache size from 4 MiB to 1 MiB. r=glandium.
This reduces memory usage by up to 3 MiB per process.

MozReview-Commit-ID: Gfs9PIJM4br

--HG--
extra : rebase_source : 69ac5acf7f7f0c802a047f5bf72838e5c4d1f123
2016-03-24 16:38:45 +11:00
Ted Mielczarek
68bd5e8c4d bug 1244743 - Replace MOZ_NATIVE_X with MOZ_SYSTEM_X. r=gps
MozReview-Commit-ID: 9ip3qeAXFEe

--HG--
extra : commitid : H6aEkHprVyX
extra : rebase_source : e20d5f4b297caf66711c72cd55dd76f7f9ef9d9c
extra : histedit_source : 47545e0ea61eb66f16545f70e6d3792a389bedb1
2016-02-01 10:49:34 -05:00
Mike Hommey
8170c2d9bc Bug 1254850 - Update jemalloc 4 to version 4.1.0. r=njn 2016-03-11 09:38:28 +09:00
Ms2ger
d1f112a81b Bug 1254948 - Remove makefiles used to transition from jemalloc_config.c to jemalloc_config.cpp; r=glandium 2016-03-10 15:53:58 +01:00
Jonathan Watt
a9c7d25928 Bug 1253094, part 10 - Stop using DebugOnly for class/struct members in memory/. r=njn
MozReview-Commit-ID: LLSCgDES38Q
2016-02-26 15:52:08 +00:00
Nicholas Nethercote
460cabb8f7 Bug 1253526 (part 2) - Gut DMD's usage message. r=erahm
It's rare anyone would see it, and it just duplicates the info present in |mach
run|.

--HG--
extra : rebase_source : fbb1716616ca1ff007af4202757586627c8612b4
2016-03-04 17:12:37 +11:00
Nicholas Nethercote
ebc23cf4dc Bug 1253526 (part 1) - Remove DMD's --max-frames option. r=erahm.
Nobody uses it.

--HG--
extra : rebase_source : 6fe2af5f2b7ec19fad8f8cd49871a63599d7ebba
2016-03-04 17:02:20 +11:00
Lee Salzman
5a00a76a1f Bug 1248416 - add symbols for bad_function_call exception for C++ runtimes. r=nfroyd 2016-02-24 20:00:10 -05:00
Nicholas Nethercote
160743c7c2 Bug 1144842 (part 2) - Make --enable-dmd imply --enable-profiling. r=glandium.
This requires moving the --enable-dmd code earlier, before MOZ_PROFILING starts
being used.

--HG--
extra : rebase_source : acfdc6c4c82436c0a1834e11ddc567e37318da60
2016-01-21 16:58:50 -08:00
Andrea Marchesini
caa2f9b456 Bug 1231378 - part 4 - Fix uninitialized members of classes in netwerk/widget/storage/uriloader/memory/tools, r=smaug 2016-01-12 18:16:59 +00:00