Граф коммитов

1247 Коммитов

Автор SHA1 Сообщение Дата
Emilio Cobos Álvarez fffb25b74f Bug 1465585: Switch from mozilla::Move to std::move. r=froydnj
This was done automatically replacing:

  s/mozilla::Move/std::move/
  s/ Move(/ std::move(/
  s/(Move(/(std::move(/

Removing the 'using mozilla::Move;' lines.

And then with a few manual fixups, see the bug for the split series..

MozReview-Commit-ID: Jxze3adipUh
2018-06-01 10:45:27 +02:00
Margareta Eliza Balazs 03394c438d Merge inbound to mozilla-central. a=merge 2018-05-24 12:37:58 +03:00
Mike Hommey 7c246fac68 Bug 1460838 - Avoid static initializers in mozjemalloc with MSVC. r=njn
--HG--
extra : rebase_source : dd2106192a90fbade6f89dfa1169c6e9ab3a553b
2018-05-24 11:23:10 +09:00
Andreea Pavel 8469234a9f Bug 1461964 - removed mac 10.6 reference r=njn 2018-05-20 23:08:00 +03:00
Tom Ritter 4e3daa47c1 Bug 1460720 Do not define _aligned_malloc - instead define _aligned_malloc_impl and export _aligned_malloc r=glandium
MozReview-Commit-ID: 3EwAd81Iz7r

--HG--
extra : rebase_source : 899303e4c5db39b24451692f59a9d3bd1f9fd5a2
2018-05-15 11:10:48 -05:00
Tom Ritter 799ec67a16 Bug 1448749 Resolve undefined references to '_imp__mozalloc_abort' in the MinGW build r=glandium
MozReview-Commit-ID: 5enjU5Xp8G9

--HG--
extra : rebase_source : 21e8f5aff8f3d6f26fd9127e0b30099031a587a7
2018-05-16 22:02:05 -05:00
Masatoshi Kimura e98b2c42f0 Bug 1445601 - Stop using LoadLibraryA in replace_malloc. r=glandium
MozReview-Commit-ID: 8EzDtCIlg7F

--HG--
extra : rebase_source : cf909f472c1c0007b2ff759d011435b8b6bc0f37
2018-03-25 13:12:03 +09:00
David Major fa8d998487 Bug 1447795: Add even more UseItOrLoseIt to SmokeDMD.cpp 2018-04-01 09:37:42 -04:00
Tom Ritter 5fda6df793 Bug 1446466 Remove Nightly-only restriction on jemalloc arena implementation r=glandium
MozReview-Commit-ID: CC2cftngmli

--HG--
extra : rebase_source : 5cc5d5b0638b29074cc0e497f4669ebabcf6578a
2018-03-21 20:53:46 -05:00
Tom Ritter 51a8daef9d Bug 1446466 Crash if moz_dispose_arena is called, and comment out all callers r=glandium
Bug 1364359 is to fix a leaked arena. Until that is fixed; it is unsafe to
call moz_dispose_arena more than once.

MozReview-Commit-ID: KIby1RLtrPK

--HG--
extra : rebase_source : 6ea41001e9f0c4d5eb24ee678d6c1c0218991ac3
2018-03-21 20:49:35 -05:00
Margareta Eliza Balazs adebb06ac1 Merge inbound to mozilla-central. a=merge 2018-03-28 00:48:11 +03:00
Carl Corcoran 6766b3d082 Bug 1448546: Adding sized operator delete overloads on Windows builds; r=froydnj
MozReview-Commit-ID: EzhNZEf0suT

--HG--
extra : rebase_source : 695258d519654c9f0f69dc8a1446f28136ae8273
extra : source : 013cfa5c5f358aa02784a8a20bf181d3751d0bbf
2018-03-27 14:42:17 +02:00
Nathan Froyd 3d6d46eaba Bug 1448030 - use SprintfLiteral in fillAbortMessage; r=glandium
The SprintfLiteral checker complains that:

  snprintf(msg, sizeof(msg), ...);

should be using SprintfLiteral instead.  Let's do that.
2018-03-27 10:51:32 -04:00
David Major 0fab6b57fc Bug 1447795 - Add some more UseItOrLoseIt to SmokeDMD.cpp. r=njn 2018-03-21 13:52:00 +02:00
Nathan Froyd b68dfdbc2d Bug 1435407 - declare our wrapped delete definitions with noexcept(true); r=glandium
This behavior matches what gets used in mozalloc.h to define these
wrappers, and is particularly necessary for newer versions of clang to
not complain about our definitions.
2018-03-13 11:10:06 -05:00
Andreea Pavel 6e194b7c24 Merge mozilla-central to mozilla-inbound. a=merge on a CLOSED TREE 2018-03-02 18:24:58 +02:00
Mike Hommey 61d75ea276 Bug 1442468 - Remove workaround for http://code.google.com/p/android/issues/detail?id=23203. r=froydnj
That NDK bug has been fixed since r8c, and we now require something more
recent than that. This effectively reverts the changes from bug 720621
and bug 734832.

--HG--
extra : rebase_source : 9ff76a790ec4135dc0172cfd0f11fc1ecef7df64
2018-03-01 15:15:02 +09:00
Nathan Froyd 9133c59dba Bug 1442325 - remove some dead preprocessor logic; r=glandium
We always compile with C++11 (er, C++14), so there's no need to include
clauses that suggest otherwise.
2018-03-02 07:06:08 -05:00
Florian Quèze c714053d73 Bug 1433175 - scripted patch to replace Components.classes[, Components.interfaces.nsI, Components.utils. and Components.results. with Cc, Ci, Cu and Cr, r=Mossop. 2018-02-28 18:51:33 +01:00
Mike Hommey 5f11951b9b Bug 1441335 - Fix base allocator commit evaluation. r=njn
Base allocator commit stats were added in bug 515556, along other commit
stats, but they have actually been wrong since then: the committed count
is updated with the difference between pbase_next_addr and
base_next_decommitted *after* the latter is set to the former, making
the difference always 0.

--HG--
extra : rebase_source : a2aed523314549a37a61bd4ab300c98f198f9252
2018-02-27 07:39:34 +09:00
Mike Hommey ef4741aa26 Bug 1439470 - Remove some now unnecessary checks. r=njn
Since TreeNode::{Left,Right,Color} is always a valid call to make, we
don't need to check if for nullity before calling those functions.

This effectively kind of reverts some parts of bug 1412722.

--HG--
extra : rebase_source : 3deb316f463b51fdbb3aebc2e57e437018b3a829
2018-02-15 20:25:57 +09:00
Mike Hommey 6442687426 Bug 1439470 - Turn TreeNode(nullptr) into a "virtual" sentinel. r=njn
The code before bug 1412722 benefitted from the sentinel being an actual
node object, and some code paths ended up checking its color (always
black) or getting its right and left node, that always returned to the
sentinel.

When TreeNode currently contains a nullptr, all those lead to a null
deref if the calling code is not doing the right checks, which happens
to be the case in at least some places. Instead of relying on the
callers doing the right thing, make the TreeNode do the right thing when
it contains a nullptr, effectively acting as the sentinel in that case.

We additionally ensure that nothing in the calling code will be trying
to change the color or left/right pointers on the sentinel, which is an
extra safe net compared to the code before bug 1412722.

--HG--
extra : rebase_source : 09ab0bf8682092ef6d9a0a5921be3da787d0d548
2018-02-15 20:20:11 +09:00
Mike Hommey 1c0141e333 Bug 1439470 - Turn TreeNode into a smart pointer-like type. r=njn
This will allow the upcoming changes to add some safety back to the code
after bug 1412722.

--HG--
extra : rebase_source : 5033b8034cabaf5a7fdd578459588d5099402d02
2018-02-15 20:15:00 +09:00
Andreea Pavel e7ca112682 Backed out 3 changesets (bug 1439470) for failing automation.py on a CLOSED TREE
Backed out changeset c43ee00c3e6b (bug 1439470)
Backed out changeset cf9d00862149 (bug 1439470)
Backed out changeset f95559ae3134 (bug 1439470)
2018-02-20 13:39:28 +02:00
Mike Hommey a70ca542aa Bug 1439470 - Remove some now unnecessary checks. r=njn
Since TreeNode::{Left,Right,Color} is always a valid call to make, we
don't need to check if for nullity before calling those functions.

This effectively kind of reverts some parts of bug 1412722.

--HG--
extra : rebase_source : 172f1c042bdbb4d500e1afb4d57774ab76826876
2018-02-15 20:25:57 +09:00
Mike Hommey b4f9300f41 Bug 1439470 - Turn TreeNode(nullptr) into a "virtual" sentinel. r=njn
The code before bug 1412722 benefitted from the sentinel being an actual
node object, and some code paths ended up checking its color (always
black) or getting its right and left node, that always returned to the
sentinel.

When TreeNode currently contains a nullptr, all those lead to a null
deref if the calling code is not doing the right checks, which happens
to be the case in at least some places. Instead of relying on the
callers doing the right thing, make the TreeNode do the right thing when
it contains a nullptr, effectively acting as the sentinel in that case.

We additionally ensure that nothing in the calling code will be trying
to change the color or left/right pointers on the sentinel, which is an
extra safe net compared to the code before bug 1412722.

--HG--
extra : rebase_source : ac61ea259ac49bf76e2f8f6f54dda991498d4664
2018-02-15 20:20:11 +09:00
Mike Hommey 4489841597 Bug 1439470 - Turn TreeNode into a smart pointer-like type. r=njn
This will allow the upcoming changes to add some safety back to the code
after bug 1412722.

--HG--
extra : rebase_source : c906e9b3168fe738cba8a3de3fdf4efee1f0d4df
2018-02-15 20:15:00 +09:00
Mike Hommey c60ee1a610 Bug 1439474 - Make double-free crashes more identifiable. r=njn
- Turn MOZ_DIAGNOSTIC_ASSERTs related to double-frees into
MOZ_RELEASE_ASSERTs with a crash message making them more identifiable
than the asserted condition.
- In huge_dalloc, MOZ_RELEASE_ASSERT early, instead of letting
RedBlackTree::Remove end up crashing because the node is not in the
tree.

--HG--
extra : rebase_source : e051caaf371e88a9db6b5153f58c8a4aa4cde757
2018-02-20 11:39:04 +09:00
Mike Hommey 5c18ecad6b Bug 1438427 - Fix wrong change from bug 1412722 in RedBlackTree::Remove. r=njn
Before bug 1412722, which removed the sentinels, the code looked like:

  if (rbp_r_c->Right()->Left()->IsBlack()) {

At that point in the code, rbp_r_c is the root node of the tree. If
rbp_r_c->Right() was the sentinel, ->Right()->Left() would be the
sentinel too, and the sentinel is black. Which means the condition would
be true.

The code after was:

  if (rbp_r_c->Right() && (!rbp_r_c->Right()->Left() ||
                           rbp_r_c->Right()->Left()->IsBlack())) {

The second half correctly deals with the case of
rbp_r_c->Right()->Left() being the sentinel. But the first half now
makes things different: ->Right() being null would correspond to the
previous case where it was the sentinel, and the test would not return
true in that case when it would have before. When ->Right() is not null,
things are normal again.

The correct check is to make the branch taken when ->Right() is null.

Now, looking under which conditions we may get in that branch wrongly:
- The root node's right link must be empty, which means a very small tree.
- The comparison between the removed key and the root node must indicate
  the key is greater than the value of the root node.
- There's another case where the comparison result (rbp_r_cmp) can be
  eGreater, when it is reassigned under one of the branches under the
  eEqual test, and that branch is only taken when ->Right() on the root
  node was non-null, which was the non-broken case.

So it would seem we can't reach that code when rbp_r_c->Right() is null
anyways, so it /should/ practically make no difference. Better safe than
sorry, though. It's hard to tell anything from crash stats, because
since the templatization in bug 1403444, all crashes fit in one bucket,
when there used to be 5 functions before :(

While here, add a missing include in rb.h.

--HG--
extra : rebase_source : 2ebcb84345ad52059b0c081b9e2e1af1d0bbb7bc
2018-02-15 14:38:52 +09:00
Bobby Holley 3d8a3d0d6d Bug 1436541 - Don't clobber the thread-local arenas when we happen to hit a large allocation. r=glandium
MozReview-Commit-ID: 9i5B76vkNfr
2018-02-07 18:17:48 -08:00
Mike Hommey e483ecaab0 Bug 1424709 - Force disable the OSX system "nano allocator". r=spohl
We're not actually using it, and it messes up with the zone allocator in
mozjemalloc after fork(). See the lengthy analysis in
https://bugzilla.mozilla.org/show_bug.cgi?id=1424709#c34 and following.

--HG--
extra : rebase_source : c58e13b897dde7b32d83c43fbb2a04a0db3a5dc9
2018-01-31 17:18:01 +09:00
Kris Maglione 918ed6c474 Bug 1431533: Part 5a - Auto-rewrite code to use ChromeUtils import methods. r=florian
This was done using the following script:
37e3803c7a/processors/chromeutils-import.jsm

MozReview-Commit-ID: 1Nc3XDu0wGl

--HG--
extra : source : 12fc4dee861c812fd2bd032c63ef17af61800c70
extra : intermediate-source : 34c999fa006bffe8705cf50c54708aa21a962e62
extra : histedit_source : b2be2c5e5d226e6c347312456a6ae339c1e634b0
2018-01-29 15:20:18 -08:00
Cosmin Sabou 9a65a40178 Backed out 3 changesets (bug 1431533) for Android mochitest failures on testEventDispatcher on a CLOSED TREE
Backed out changeset a1eca62826a1 (bug 1431533)
Backed out changeset 34c999fa006b (bug 1431533)
Backed out changeset e2674287e57f (bug 1431533)
2018-01-30 07:17:48 +02:00
Kris Maglione 6476f95b13 Bug 1431533: Part 5a - Auto-rewrite code to use ChromeUtils import methods. r=florian
This was done using the following script:
37e3803c7a/processors/chromeutils-import.jsm

MozReview-Commit-ID: 1Nc3XDu0wGl

--HG--
extra : source : 12fc4dee861c812fd2bd032c63ef17af61800c70
2018-01-29 15:20:18 -08:00
Brindusan Cristian af8879d1eb Backed out 2 changesets (bug 1431533) for ESlint failures on a CLOSED TREE
Backed out changeset 6e56f4c8843e (bug 1431533)
Backed out changeset 12fc4dee861c (bug 1431533)
2018-01-30 02:32:43 +02:00
Kris Maglione c276bb9375 Bug 1431533: Part 5a - Auto-rewrite code to use ChromeUtils import methods. r=florian
This was done using the following script:
37e3803c7a/processors/chromeutils-import.jsm

MozReview-Commit-ID: 1Nc3XDu0wGl

--HG--
extra : rebase_source : c004a023389f1f6bf3d2f3efe93c13d423b23ccd
2018-01-29 15:20:18 -08:00
Marco Castelluccio 871dbb2b23 Bug 1403005 - Don't run memory/replace/logalloc/replay in coverage builds. r=glandium
--HG--
extra : rebase_source : b2f451d764f8efb92082d8b987e74744091bfe4c
2018-01-16 15:45:40 +01:00
Chris Peterson 37efe4d0e6 Bug 1428535 - Add missing override specifiers to overridden virtual functions. r=froydnj
MozReview-Commit-ID: DCPTnyBooIe

--HG--
extra : rebase_source : cfec2d96faeb11656d86d760a34e0a04cacddb13
extra : intermediate-source : 6176724d63788b0fe8caa3f91607c2d93dbaa7ec
extra : source : eebbb0600447f9b64aae3bcd47b4be66c02a51ea
2017-11-05 19:37:28 -08:00
Mike Hommey 3e46ee7dc9 Bug 1417504 - Also wrap Heap{Alloc,ReAlloc,Free} when building without our allocator. r=njn
Bug 1280578 added some wrapping for the Win32 Heap* functions, mainly
for the rust static libraries that use them. Because pointer ownership
might cross the C++/Rust boundary, and because about:memory uses
malloc_usable_size/msize, we need both C++ and Rust to still use the
same heap on builds where our allocator is not enabled.

--HG--
extra : rebase_source : 37a25b376a02ea07c187fb161d2005141e783820
2017-12-19 14:46:23 +09:00
Mike Hommey 2fc6190633 Bug 1423802 - Remove the dummy fallible library. r=nalexander
Bug 1423803 was attempting to remove the fallible library but didn't do
so on Android because of this bug. We can now fully retire it.

--HG--
extra : rebase_source : de38872a08d24768eadfbe81652cfcd6aa7aa041
2017-12-07 12:16:50 +09:00
Gurzau Raul 91d3bc0100 Merge inbound to mozilla-central r=merge a=merge 2017-12-09 00:36:15 +02:00
Ryan VanderMeulen 01e424a4bc Bug 1423649 - Fix compiler errors that happen when building with VS2017 15.5. r=rillian 2017-12-08 10:40:08 -05:00
Sylvestre Ledru 5de63ef061 Bug 1394734 - Replace CONFIG['MSVC'] by CONFIG['CC_TYPE'] r=glandium
MozReview-Commit-ID: 5orfnoude7h

--HG--
extra : rebase_source : 1ed9a6b56e1d27221a07624767a7fb0e6147117f
2017-12-08 13:46:13 +01:00
Sylvestre Ledru 9bfe27d903 Bug 1394734 - Replace CONFIG['GNU_C*'] by CONFIG['CC_TYPE'] r=glandium
MozReview-Commit-ID: 7duJk2gSd4m

--HG--
extra : rebase_source : 7312fe276e561e8c034a5f6749774ae812727f9c
2017-12-07 22:09:15 +01:00
Mike Hommey 154fd9c9ad Bug 1424116 - Change the definition of mozilla::fallible again. r=njn
In bug 1423803, mozilla::fallible was made an "alias" of std::nothrow.
Except C++ doesn't allow compilers to be too smart, and in many cases,
they would actually create data fields to hold a copy of std::nothrow,
even creating a static initializer on non-optimized builds to do so.

By turning it into a reference, we allow compilers to just use
std::nothrow directly, as if it were passed directly, but they can still
create unused data fields. Turning it into a static allows compilers to
skip the data fields altogether.

On a local linux64 build, this saves 242 bytes of .bss.

Note this does change a `lea` (address calculation) into a `mov` (read),
but it shouldn't matter too much.

--HG--
extra : rebase_source : 9c08e8263aef267b8ad5962b0248c7effcb67796
2017-12-08 11:51:59 +09:00
Mike Hommey cd4d96f039 Bug 1424114 - Remove the string.h/cstring include in mozalloc.h. r=njn
While here, change the string.h include to cstring in mozalloc.cpp.

--HG--
extra : rebase_source : d60eac8b5fdb358b43eb32978d5d40a426d50648
2017-12-08 11:47:15 +09:00
Mike Hommey abab5abf88 Bug 1423803 - Turn mozilla::fallible into an alias for std::nothrow. r=njn
The std::nothrow variant of operator new is effectively a fallible
operator new. It is used in third party code.

The duplication with our own fallible operator new is unfortunate, and
we can reduce it by making one an alias of the other.

We keep the fallible library as a dummy on Android because bug 1423802
induces some linking problems.

--HG--
extra : rebase_source : d7b915aaafde40057e87b7ad4bbd82d348e4f12d
2017-12-07 11:32:29 +09:00
Mike Hommey c6b6415a7b Bug 1423512 - Remove unnecessary XPCOM_GLUE define in DMD. r=njn
This was added in bug 1122337 back when the stackwalker was still
in XPCOM, which it isn't anymore, so XPCOM_GLUE is not necessary
anymore.

--HG--
extra : rebase_source : e550671c26e250843d34cb2b83497c861225883f
2017-12-06 09:52:55 +09:00
Dorel Luca ed8dc2034d Merge inbound to mozilla-central r=merge a=merge 2017-12-07 00:01:19 +02:00
Mike Hommey 627d9acca4 Bug 1423461 - Report the right size to the OOM handler for moz_xcalloc. r=njn
--HG--
extra : rebase_source : 536f6504394b14a4968b24fbc719017111a428cf
2017-12-06 16:10:30 +09:00
Mike Hommey 33ca8ff779 Bug 1423461 - Use mozilla/Likely.h in mozalloc.cpp. r=njn
Back when mozalloc.cpp was written, mozilla/Likely.h didn't exist.

--HG--
extra : rebase_source : da3b4c8839a97e3ac2d40da158905ac38c088683
2017-12-06 16:05:08 +09:00
Mike Hommey a646756fb7 Bug 1423461 - Use noexcept in mozalloc.h on android. r=njn
Bug 1163171 removed support for building for android with GCC, and we
don't need to use throw() anymore. We can use the same code as for other
non-Windows platforms.

--HG--
extra : rebase_source : 9c2c2179a6d214096619ff0ae1d1a42912beda79
2017-12-06 11:38:59 +09:00
Mike Hommey 41a56e83c2 Bug 1423461 - Remove MOZALLOC_INLINE, and always use MOZ_ALWAYS_INLINE_EVEN_DEBUG. r=njn
MOZ_ALWAYS_INLINE_EVEN_DEBUG is always defined through
mozilla/Attributes.h, so the fallbacks are never used in practice. They
are just there from the old days when mozalloc.h didn't use
mozilla/Attributes.h.

--HG--
extra : rebase_source : 0d55068ab5fcec3f4bcafecd8c3ce371597f8cfe
2017-12-06 11:31:48 +09:00
Mike Hommey 3f1f5c9fc2 Bug 1423114 - Remove moz_xposix_memalign and moz_xvalloc. r=njn
They are both infallible wrappers of posix_memalign and valloc.
There is also moz_xmemalign, which wraps memalign, which is mostly
always available as of bug 1402647.

None of them are actually used, but it's still desirable to at least
have one infallible variant, so keep moz_xmemalign and remove the other
two.

While here, we actually make both memalign and moz_xmemalign always
available.

--HG--
extra : rebase_source : 1c3ca4b3e3310543145f3181dfa4e764be1d6ff8
2017-12-05 17:34:19 +09:00
Mike Hommey 4c95537eeb Bug 1423094 - Remove USE_STATIC_LIBS=True-related code in mozalloc. r=gps
--HG--
extra : rebase_source : 52a4df6d15f9aa5eb0479cef4e98e9e41eb5164c
2017-12-05 16:30:21 +09:00
Mike Hommey 8aa92edf03 Bug 1423094 - Remove mozalloc_staticruntime. r=gps
--HG--
extra : rebase_source : 3b6678d4b36e405b2acc18b8fd75b5db7d45bf4c
2017-12-05 15:39:39 +09:00
David Major ad7ff3a791 Bug 1423287 - Simplify NtCurrentTeb() handling. r=njn 2017-12-06 09:36:00 -05:00
Narcis Beleuzu dfd58840d1 Backed out changeset 8a4050c7e0fd (bug 1423114) for bustages on memory/mozalloc/mozalloc.cpp r=backout on a CLOSED TREE 2017-12-06 00:27:11 +02:00
Mike Hommey a1947c3098 Bug 1423119 - Remove the sole use of MOZALLOC_HAVE_XMALLOC. r=erahm
When this was added, the xpcom glue was still a thing, and there was a
distinction between things that would build with mozalloc available and
others. There is no such distinction anymore. Anything that has access
to xpcom has access to infallible allocator functions.

--HG--
extra : rebase_source : 04bce114e940c53709275d0354ea7240df4a051e
2017-12-05 17:45:20 +09:00
Mike Hommey 5f1f0bbdc4 Bug 1423114 - Remove moz_xposix_memalign and moz_xvalloc. r=njn
They are both infallible wrappers of posix_memalign and valloc.
There is also moz_xmemalign, which wraps memalign, which is always
available as of bug 1402647.

None of them are actually used, but it's still desirable to at least
have one infallible variant, so keep moz_xmemalign and remove the other
two.

While here, we actually make moz_xmemalign always available, since
memalign is always available.

--HG--
extra : rebase_source : 17300bc03a715e5d36b4b687f22050622c1c70c8
2017-12-05 17:34:19 +09:00
Mike Hommey a5aef799e1 Bug 1423109 - Use MOZ_{BEGIN,END}_EXTERN_C in mozalloc.h. r=njn
--HG--
extra : rebase_source : 9d1c8c59b58273c1efe9a124e41eccc254600346
2017-12-05 17:04:45 +09:00
Mike Hommey 660ec9e47b Bug 1423109 - Remove Sun Pro compiler specific preprocessor directives from mozalloc.h. r=njn
As of bug 1255813, compiling with Sun Pro compiler is not supported.

--HG--
extra : rebase_source : 3c925ec389a5607047330f743d45f3c5eca7b7f8
2017-12-05 17:00:02 +09:00
Mike Hommey 1b2c8764a2 Bug 1423107 - Remove moz_posix_memalign. r=njn
--HG--
extra : rebase_source : 47e9db8d98082fbccdb80c5ac0ca21fff0c5c888
2017-12-05 16:52:34 +09:00
Mike Hommey d7c4757af3 Bug 1423107 - Replace uses of moz_posix_memalign with posix_memalign. r=njn
moz_posix_memalign is a wrapper for posix_memalign that only exists if
posix_memalign exists.

On OSX, it has a fallback for an under-specified bug where it
purportedly returns a pointer that doesn't have the requested alignment.
That fallback was added in bug 414946, over 6 years ago, before jemalloc
was even enabled on OSX.

Considering posix_memalign is used directly in many other places in
Gecko, that we almost always use mozjemalloc, which doesn't have these
problems, and that in all likeliness, the bug was in some old version of
OSX that is not supported anymore, the fallback does not seem all that
useful.

So, just use posix_memalign directly.

--HG--
extra : rebase_source : b2151b5fb598dc20cbd70308555059f7545b18b2
2017-12-05 16:46:17 +09:00
Mike Hommey b796bc0e6d Bug 1423000 - Run clang-format in memory/replace/logalloc. r=njn
--HG--
extra : rebase_source : 6372d6eb88bad9da824e6a2a99380554e1ae04f5
2017-12-05 08:28:32 +09:00
Mike Hommey 3dc24c3f35 Bug 1423000 - Re-run clang-format on memory/build. r=njn
Most adjustements come from some recent .clang-format changes. A few
were overlooked from changes to the code.

--HG--
extra : rebase_source : c397762ea739fec05256a8c0132541bf4c727c32
2017-12-03 14:22:05 +09:00
Mike Hommey 55b2629bb8 Bug 1423000 - Always log allocator function calls. r=njn
So far, logalloc has avoided logging calls that e.g. return null
pointers, but both to make the code more generic and to enable logging
of error conditions, we now log every call.

--HG--
extra : rebase_source : 5e41914552f44e330f8f9c12b34fd6d30fdf30a7
2017-11-30 07:55:12 +09:00
Mike Hommey c617c4a119 Bug 1423000 - Don't use a separate replace-malloc library for the minimal-logalloc test. r=njn
Instead, only register a minimal set of functions when an environment
variable is set.

--HG--
extra : rebase_source : 94f2403ed9afe2acab1f56714d60fb32401076dc
2017-12-03 13:59:16 +09:00
Mike Hommey 2ff212b9f9 Bug 1423000 - Use mozjemalloc mutexes in logalloc. r=njn
Instead of the chromium one, which required some tricks.

--HG--
extra : rebase_source : f2918c33ff5263f50b81ac4606aa0ab3059cdc36
2017-12-03 14:23:23 +09:00
Mike Hommey ab9b4f676d Bug 1423000 - Move mozjemalloc mutexes to a separate header. r=njn
Also change the definition of the StaticMutex constructor to unconfuse clang-format.

--HG--
extra : rebase_source : aa2aa07c8c324e1253c20b34d850230579d45632
2017-12-03 14:21:19 +09:00
Mike Hommey 938618a5e1 Bug 1423000 - Reject some more invalid logalloc replay logs. r=njn
For functions with no result, such as free, it's invalid for some string
to appear after the closing parenthesis.

--HG--
extra : rebase_source : d7a72c064c408ba9c4a8722ebbaafb878633e857
2017-11-30 10:33:18 +09:00
Mike Hommey c142d8c12f Bug 1423000 - Move MemSlot lookup for replay results into the Replay methods. r=njn
This allows all methods to have the same signature.

--HG--
extra : rebase_source : 6c6e952d00ba5f92c2cf368fa871e8979f640780
2017-11-30 10:31:25 +09:00
Mike Hommey 94fe24fd79 Bug 1423000 - Count jemalloc_stats as an operation. r=njn
While jemalloc_stats is not actively doing anything, it can be
cumbersome to not have it count as an operation, because the operation
count shown on jemalloc_stats doesn't match the line number in the input
replay log, and the offset grows as the number of jemalloc_stats
operations grows.

While here, also update a comment about the replay log format.

--HG--
extra : rebase_source : da0ad9a990487ebdfadae7f8fcfad85e82b482fc
2017-11-30 10:18:39 +09:00
Mike Hommey ddec58883e Bug 1423000 - Remove Replay::Commit. r=njn
It adds an uncompressible and noticeable time overhead to replaying
logs, even when one is not interested in measuring RSS. This has caused
me to clear the method body on multiple occasions.

If necessary, it is possible to enable zero or junk at the allocator
level for the same effect.

--HG--
extra : rebase_source : a4c44e97986668e712b500266d7fffe985e85881
2017-11-30 10:48:41 +09:00
Mike Hommey 2b2a874b47 Bug 1420355 - Statically link DMD. r=njn
--HG--
extra : rebase_source : 8e7cf975d096116b666532f3fe8aa5a7f61b5725
2017-11-28 08:10:48 +09:00
Mike Hommey 50d09b60b0 Bug 1420355 - Allow to statically link replace-malloc libraries. r=njn
And statically link logalloc.

Statically linking is the default, except when building with
--enable-project=memory, allowing to use the generated libraries from
such builds with Firefox.

--HG--
extra : rebase_source : efe9edce8db6a6264703e0105c2192edc5ca8415
2017-11-23 17:24:19 +09:00
Mike Hommey 1e631092c5 Bug 1420355 - Don't initialize DMD if the DMD environment variable is not given. r=njn
This makes things slightly more inconvenient (having to set two
environment variables instead of one for the simplest case) until a few
patches down the line, when DMD is statically linked, at which point it
will get down to one environment variable every time.

--HG--
extra : rebase_source : 08dc3c05318b572ae1026227d0369fa8bf21b20f
2017-11-28 08:10:07 +09:00
Mike Hommey 7c59f18de8 Bug 1420355 - Don't initialize logalloc if MALLOC_LOG is not given. r=njn
Now that replace_init can opt-out of registering the replace-malloc
functions, don't do so when MALLOC_LOG was not set in the environment.

While one would normally set MALLOC_LOG alongside one of the environment
variable necessary to load the replace-malloc library, we're also going,
in a subsequent change, to allow statically linking replace-malloc
libraries, taking full advantage of this change.

--HG--
extra : rebase_source : 944a9d7af33f88f793ee0104bd5e58ec508e4f58
2017-11-23 13:54:16 +09:00
Mike Hommey 8b50bbe85b Bug 1420355 - Remove fallbacks when DMD is initializing. r=njn
As of bug 1420353, DMD's replace_* functions can't be called before
replace_init places them in the malloc function table, which only
happens after DMD::Init has run, meaning DMD is always initialized
by the time any of its replace_* function can be called.

--HG--
extra : rebase_source : 96bf4d01b6fac5cbb4712f56c572791cc4972f77
2017-11-28 08:05:58 +09:00
Mike Hommey 449973411b Bug 1420355 - Don't declare replace_* functions in replace_malloc.h. r=njn
The original purpose of those declarations was to avoid the function
definitions being wrong, as well as forcing them being exported
properly (as extern "C", as weak symbols when necessary, etc.), but:

- The implementations being C++, function overloads simply allowed
  functions with the same name to have a different signature.

- As of bug 1420353, the functions don't need to be exported anymore,
  nor do we care whether their symbols are mangled. Furthermore, they're
  now being assigned to function table fields, meaning there is type
  checking in place, now.

So all in all, these declarations can be removed.

Also, as further down the line we're going to statically link the
replace-malloc libraries, avoid symbol conflicts by making those
functions static.

--HG--
extra : rebase_source : 0dbb15f2c85bc873e7eb662b8d757f99b0732270
2017-11-28 07:18:15 +09:00
Mike Hommey 2b959b7c6e Bug 1420355 - Don't link logalloc against the static runtime on Windows. r=njn
This was never strictly required (for instance, DMD doesn't do that),
and would make things harder with the subsequent changes.

--HG--
extra : rebase_source : 29ea08d41f54da7f99120f9fe9af4017f61d8a4b
2017-11-28 17:11:40 +09:00
Csoregi Natalia 4ce8d0124c Backed out 7 changesets (bug 1420355) for mass failures on OS X and Android. r=backout on a CLOSED TREE
Backed out changeset a7ed89e13a4c (bug 1420355)
Backed out changeset fd6702e6e0a0 (bug 1420355)
Backed out changeset 0479dda078a2 (bug 1420355)
Backed out changeset e69357ccca9e (bug 1420355)
Backed out changeset 3742a4b69ba2 (bug 1420355)
Backed out changeset 451cd087922f (bug 1420355)
Backed out changeset d80b5c4e1dd0 (bug 1420355)
2017-11-29 03:08:46 +02:00
Mike Hommey 7c62087a43 Bug 1420355 - Statically link DMD. r=njn
--HG--
extra : rebase_source : 46800c9c0c5006a5a32f11abc209da27e65ae0f5
2017-11-28 08:10:48 +09:00
Mike Hommey d60e80991e Bug 1420355 - Allow to statically link replace-malloc libraries. r=njn
And statically link logalloc.

Statically linking is the default, except when building with
--enable-project=memory, allowing to use the generated libraries from
such builds with Firefox.

--HG--
extra : rebase_source : efe9edce8db6a6264703e0105c2192edc5ca8415
2017-11-23 17:24:19 +09:00
Mike Hommey 0a3b6c9813 Bug 1420355 - Don't initialize DMD if the DMD environment variable is not given. r=njn
This makes things slightly more inconvenient (having to set two
environment variables instead of one for the simplest case) until a few
patches down the line, when DMD is statically linked, at which point it
will get down to one environment variable every time.

--HG--
extra : rebase_source : 08dc3c05318b572ae1026227d0369fa8bf21b20f
2017-11-28 08:10:07 +09:00
Mike Hommey e38859b199 Bug 1420355 - Don't initialize logalloc if MALLOC_LOG is not given. r=njn
Now that replace_init can opt-out of registering the replace-malloc
functions, don't do so when MALLOC_LOG was not set in the environment.

While one would normally set MALLOC_LOG alongside one of the environment
variable necessary to load the replace-malloc library, we're also going,
in a subsequent change, to allow statically linking replace-malloc
libraries, taking full advantage of this change.

--HG--
extra : rebase_source : 944a9d7af33f88f793ee0104bd5e58ec508e4f58
2017-11-23 13:54:16 +09:00
Mike Hommey 3e3dbe9627 Bug 1420355 - Remove fallbacks when DMD is initializing. r=njn
As of bug 1420353, DMD's replace_* functions can't be called before
replace_init places them in the malloc function table, which only
happens after DMD::Init has run, meaning DMD is always initialized
by the time any of its replace_* function can be called.

--HG--
extra : rebase_source : 96bf4d01b6fac5cbb4712f56c572791cc4972f77
2017-11-28 08:05:58 +09:00
Mike Hommey ef6af827be Bug 1420355 - Don't declare replace_* functions in replace_malloc.h. r=njn
The original purpose of those declarations was to avoid the function
definitions being wrong, as well as forcing them being exported
properly (as extern "C", as weak symbols when necessary, etc.), but:

- The implementations being C++, function overloads simply allowed
  functions with the same name to have a different signature.

- As of bug 1420353, the functions don't need to be exported anymore,
  nor do we care whether their symbols are mangled. Furthermore, they're
  now being assigned to function table fields, meaning there is type
  checking in place, now.

So all in all, these declarations can be removed.

Also, as further down the line we're going to statically link the
replace-malloc libraries, avoid symbol conflicts by making those
functions static.

--HG--
extra : rebase_source : 0dbb15f2c85bc873e7eb662b8d757f99b0732270
2017-11-28 07:18:15 +09:00
Mike Hommey 8771ae803b Bug 1420355 - Don't link logalloc against the static runtime on Windows. r=njn
This was never strictly required (for instance, DMD doesn't do that),
and would make things harder with the subsequent changes.

--HG--
extra : rebase_source : 29ea08d41f54da7f99120f9fe9af4017f61d8a4b
2017-11-28 17:11:40 +09:00
Mike Hommey feda5d4e15 Bug 1420353 - Don't define replace_init through malloc_decls.h. r=njn
The definition for replace_init is only used in two places:
replace_malloc.h and mozjemalloc.cpp. Invoking the malloc_decls.h
machinery for just that one function is a lot of overhead, and things
are actually simpler doing the declaration directly, especially thanks
to the use of C++11 decltype to avoid duplication of the function
type.

This has the additional advantage that now malloc_decls.h only contains
the allocator API.

While here, replace the MOZ_WIDGET_ANDROID ifdef with ANDROID.

--HG--
extra : rebase_source : 50ddf044f43904575598f17bd4c3477fc1a1155f
2017-11-24 16:36:29 +09:00
Mike Hommey 32ecc64ada Bug 1420353 - Change how replace-malloc initializes, part 2. r=njn
Because one entry point is simpler than two, we make replace_init fulfil
both the roles of replace_init and replace_get_bridge.

Note this should be binary compatible with older replace-malloc
libraries, albeit not detecting their bridge (and with the
previous change, they do not register anyways). So loading older
replace-malloc libraries should do nothing, but not crash in awful ways.

--HG--
extra : rebase_source : aaf83e706ee34f45cfa75551a2f0998e5c5b8726
2017-11-24 16:02:05 +09:00
Mike Hommey 845f9c5d82 Bug 1420353 - Change how replace-malloc initializes, part 1. r=njn
The allocator API is a moving target, and every time we change it, the
surface for replace-malloc libraries grows. This causes some build
system problems, because of the tricks in replace_malloc.mk, which
require the full list of symbols.

Considering the above and the goal of moving some of the replace-malloc
libraries into mozglue, it becomes simpler to reduce the replace-malloc
exposure to the initialization functions.

So instead of the allocator poking into replace-malloc libraries for all
the functions, we expect their replace_init function to alter the table
of allocator functions it's passed to register its own functions.

This means replace-malloc implementations now need to copy the original
table, which is not a bad thing, as it allows function calls with one
level of indirection less. It also replace_init functions to not
actually register the replace-malloc functions in some cases, which will
be useful when linking some replace-malloc libraries into mozglue.

Note this is binary compatible with previously built replace-malloc
libraries, but because those libraries wouldn't update the function
table, they would stay disabled.

--HG--
extra : rebase_source : 2518f6ebe76b4c82359e98369de6a5a8c3ca9967
2017-11-22 17:24:29 +09:00
Gurzau Raul 21905d169e Merge mozilla-central to mozilla-inbound. r=merge a=merge CLOSED TREE 2017-11-24 00:38:13 +02:00
Mike Hommey 1b044f7203 Bug 1416170 - Don't use long double constants. r=njn
Some platforms (at least powerpc64) apparently can't handle long double
constants. So use double constants instead.

--HG--
extra : rebase_source : dd7f87cfff13f63566845e03a0bd6f4a8146f421
2017-11-23 11:58:14 +09:00
Mike Hommey c2346512fd Bug 1418389 - Partially revert bug 1417234. r=njn
Bug 1417234 replaced all uses of CRITICAL_SECTION with SRWLocks in the
allocator on Windows, and this seems to have incurred performance
regressions on speedometer.

OTOH, there is a real benefit from not having to manually initialize the
allocator.

So we restore the use of CRITICAL_SECTIONs for Mutexes in the allocator,
except for the initialization lock, which is remaining as a SRWLock.

Talos indicates this solves the regression in large part, but is not
definitive as whether it has the same effect as a pure backout of bug
1417234. We'll see how things go over time.

--HG--
extra : rebase_source : a52b8d08159f6fce8286578114af84e55851a86b
2017-11-23 07:25:08 +09:00
Gabriele Svelto 5ff191810d Bug 1402519 - When the crash reporter code is disabled at configure time replace it with a dummy implementation; r=ted.mielczarek
MozReview-Commit-ID: F5QbaI1LlmZ

--HG--
extra : rebase_source : f05c929911d27dc1598bc040df54022cd90aa06a
2017-11-14 14:49:33 +01:00
Mike Hommey e760c78ddc Bug 1419217 - Change comparison functions for red-black trees. r=njn
- This makes all of them return an enum, quite similar to rust.
- This makes all of them derive from a single implementation of an
  integer comparison.
- This implements that integer comparison in terms of simple operations,
  rather than "smart" computation, which turns out to allow compilers
  to do better optimizations.
  See https://blogs.msdn.microsoft.com/oldnewthing/20171117-00/?p=97416

--HG--
extra : rebase_source : 89710d7954f445d43e6da55aaf171b1f57dce5fc
2017-11-21 09:11:54 +09:00
Mike Hommey b20067214e Bug 1418123 - Apply junk on huge and large reallocations. r=njn
Zero and junk should have the same scope, but currently huge and large
reallocs are zeroed when zeroing is enabled, but are not junked when
junking is enabled. This makes things straight, leaning on the side of
filling the added bytes, rather than not.

This has an actual effect on debug builds, where junk is enabled by
default.

--HG--
extra : rebase_source : f409cae7ea720f69239d896d155b653efc648feb
2017-11-16 16:34:31 +09:00
Mike Hommey a6bafc7783 Bug 1418123 - Factor out the zero/junk logic. r=njn
--HG--
extra : rebase_source : fe8f184e072982b1995b4059f799a0b6c22af668
2017-11-10 16:59:21 +09:00
Mike Hommey 7e4604b23d Bug 1418153 - Move arena_ralloc/huge_ralloc to methods of arena_t. r=njn
This also creates a new arena_t::Ralloc function replacing parts of
iralloc, the other part being inlined in the unique caller.

--HG--
extra : rebase_source : 76a9ca77e651c99641d8906faea8e469d8eea041
2017-11-17 09:50:27 +09:00