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

1123 Коммитов

Автор SHA1 Сообщение Дата
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
Mike Hommey 960f44ef3e Bug 1418153 - Add Large to SizeClass::ClassType. r=njn
And refactor arena_ralloc as a consequence.

--HG--
extra : rebase_source : a5f72e5f1b6a56b165baf5103e83410580a035d3
2017-11-15 14:50:33 +09:00
Mike Hommey ef84807f38 Bug 1418153 - Remove impossible condition. r=njn
Since the old size arena_ralloc is given is already a size class, when
the size class for the new size is the same as the old size, the new
size can't be larger than the old size, so there's never anything to
zero.

--HG--
extra : rebase_source : dd468de60b2ed87718ec4e26f13d3b0c8932f455
2017-11-16 15:35:37 +09:00
Mike Hommey b73d32f806 Bug 1418153 - Fold imalloc into arena_t::Malloc. r=njn
--HG--
extra : rebase_source : 796fdd6f5147eed29ff359ca7b35e7f70985eda1
2017-11-14 08:31:53 +09:00
Mike Hommey ef76658bce Bug 1418153 - Move huge_malloc/huge_palloc to methods of arena_t. r=njn
--HG--
extra : rebase_source : 20db86c1c87854aceda07323a48d077341d84547
2017-11-14 08:29:39 +09:00
Mike Hommey 68fc08c5af Bug 1418153 - Move ipalloc to a method of arena_t. r=njn
--HG--
extra : rebase_source : fff27ddebdbed11de05e11a93f8cd9edca6e2660
2017-11-14 08:21:09 +09:00
Mike Hommey 93f3b706b5 Bug 1418153 - Rename arena_t::Palloc to arena_t::PallocLarge. r=njn
--HG--
extra : rebase_source : 7fbe7f4883ddea9f13c2567fa76e675621c79bb2
2017-11-14 08:16:28 +09:00
Mike Hommey 3ac39f1599 Bug 1418153 - Move arena selection one level up the call stack. r=njn
We intend to move some functions to methods of the arena_t class. Moving
the arena selection out of them is the first step towards that.

--HG--
extra : rebase_source : b8380c3a0c90ed817a1dbbe8d60e6107b78ec677
2017-11-14 08:00:17 +09:00
Mike Hommey 161d7afcbd Bug 1418104 - Add various realloc, junk and poisoning unit tests. r=njn
--HG--
extra : rebase_source : c79887f72197e5308a74fb5e68a94565ca6464a8
2017-11-16 16:41:41 +09:00
Mike Hommey 2c84ef6b8a Bug 1418104 - Allow to pass parameters when creating arenas. r=njn
The immediate goal for this is to allow determinism in an arena used for
an upcoming test, by essentially disabling purge on that specific arena.
We do that by allowing arenas to be created with a specific setting for
mMaxDirty.

Incidentally, this allows to cleanup the mMaxDirty initialization for
thread-local arenas.

Longer term, this would allow to tweak arenas with more parameters, on
a per arena basis.

--HG--
extra : rebase_source : e4b844185d132aca9ee10224fc626f8293be0a34
2017-11-17 07:27:35 +09:00
Mike Hommey c4587b9a17 Bug 1418104 - Initialize the allocator in jemalloc_stats. r=njn
Some unit tests rely on jemalloc_stats to get information such as chunk
size or page size. They can do so before any allocation happens, when
using gtest filters. So it is preferable for jemalloc_stats to
initialize the allocator.

--HG--
extra : rebase_source : 6696ec1cdaa3b121a3d12cb7b6049b79c656d271
2017-11-16 16:35:03 +09:00
Mike Hommey 398c8e8356 Bug 1417309 - Add the necessary bits to support a --enable-project=memory option. r=nalexander
The option allows to iterate on the allocator code without requiring a
complete setup to build Firefox.
2017-11-16 08:37:36 +09:00
Nathan Froyd f51359bd19 Bug 1325632 - part 5 - ensure that we compile with -fno-sized-deallocation when possible; r=chmanchester
We currently turn off the C++14 sized-deallocation facility on MSVC, and
we'd like to ensure we do the same thing for clang and gcc.  To do so,
we add new functionality to moz.configure for checking and adding
compilation flags, similar to the facility for checking and adding
warning flags.  The newly added facility is then used to add
-fno-sized-deallocation to the compilation flags, when the option is
supported.

Once we do this, we can't define the sized deallocation functions in
mozalloc.h; the compiler will complain that we are using
-fno-sized-deallocation, yet defining these special functions that we'll
never use.  These functions were added for MinGW, where we needed to
compile with C++14 ahead of other platforms to be compatible with MSVC
headers.  But they're no longer necessary, though they would be if we
removed -fno-sized-deallocation; the compiler will complain if we do
that and we'll add them back at that point.
2017-11-15 14:53:16 -04:00
Mike Hommey 1f75d81c1c Bug 1417234 - Use SRWLock as Mutex for mozjemalloc on Windows. r=njn
SRWLock is more lightweight than CriticalSection, but is only available
on Windows Vista and more. So until we actually dropped support Windows
XP, we had to use CriticalSection.

Now that all supported Windows versions do have SRWLock, this is a
switch we can make, and not only because SRWLock is more lightweight,
but because it can be statically initialized like on other platforms,
allowing to use the same initialization code as on other platforms,
and removing the requirement for a DllMain, which in turn can allow
to statically link mozjemalloc in some cases, instead of requiring a
shared library (DllMain only works on shared libraries), or manually
call the initialization function soon enough.

There is a downside, though: SRWLock, as opposed to CriticalSection, is
not fair, meaning it can have thread scheduling implications, and can
theoretically increase latency on some threads. However, it is the
default used by Rust Mutex, meaning it's at least good enough there.
Let's see how things go with this.

--HG--
extra : rebase_source : 337dc4e245e461fd0ea23a2b6b53981346a545c6
2017-11-14 12:58:33 +09:00
Ryan VanderMeulen 6c84e6c823 Bug 1402283 - Fix typo. r+a=RyanVM 2017-11-10 17:07:27 -05:00
Mike Hommey 1e661e8113 Bug 1402283 - Fix non-Nightly build bustage. r+a=RyanVM 2017-11-10 16:55:37 -05:00
Mike Hommey 41ede31cd3 Bug 1402283 - Enforce arena matching on moz_arena_{realloc,free}. r=njn
This enforces the API contract as described in memory/build/malloc_decls.h.
2017-11-10 16:05:24 +09:00
Mike Hommey 1dbfb30e4e Bug 1402283 - Associate an arena to each huge allocation. r=njn
Currently, huge allocations are completely independent from arenas. But
in order to ensure that e.g. moz_arena_realloc can't reallocate huge
allocations from another arena, we need to track which arena was
responsible for the huge allocation. We do that in the corresponding
extent_node_t.
2017-11-10 16:05:22 +09:00
Mike Hommey 60238a717e Bug 1402283 - Replace isalloc/isalloc_validate with static methods of a new AllocInfo class. r=njn
Both functions do essentially the same thing, one having more validation
than the other. We can use a template with a boolean parameter to avoid
the duplication.

Furthermore, we're soon going to require, in some cases, more
information than just the size of the allocation, so we wrap their
result in a helper class that gives information about an active
allocation.
2017-11-10 16:05:21 +09:00
Mike Hommey a6f4d02c4c Bug 1402283 - Make arena_ralloc use the same arena as the original pointer when none is provided. r=njn
When using plain realloc() on a pointer that was allocated with
moz_arena_malloc, we want the resulting pointer to still belong to the
same arena.
2017-11-10 16:05:19 +09:00
Mike Hommey e9f49d03b4 Bug 1402283 - Rename extent_node_t fields. r=njn 2017-11-10 16:05:17 +09:00
Mike Hommey e68ddaa1c2 Bug 1415454 - Replace log2 lookup table with FloorLog2. r=njn
FloorLog2 expands to, essentially, a compiler builtin/intrinsic, that,
in turn, expands to a single machine instruction on tier 1 and other
platforms. On platforms where that's not the case, we can expect the
compiler to generate fast code anyways. So overall, this is all better
than manually using a log2 lookup table.

Also replace a manual power-of-two check with mozilla::IsPowerOfTwo,
which does the same test.

--HG--
extra : rebase_source : e8164c254723c74ef83e798073327ec6afa6f1fb
2017-11-08 16:20:40 +09:00
Mike Hommey 3a2a081a07 Bug 1415454 - Remove the unused arena_bin_t* argument to arena_t::AllocRun. r=njn
--HG--
extra : rebase_source : 6c01dad41bc348237f1ee099bc4bd8138738dfde
2017-11-03 15:54:20 +09:00
Mike Hommey 2b7e3e93bd Bug 1415454 - Inline MallocBinEasy and MallocBinHard. r=njn
They are both only used once, are trivial wrappers, and even repeat the
same assertions.

--HG--
extra : rebase_source : b40b26e303cb69a451e63937efd8a666053954e5
2017-11-03 15:48:40 +09:00
Mike Hommey 80c65dc086 Bug 1414168 - Rename arena_run_t fields. r=njn
--HG--
extra : rebase_source : 2d80b0a7e3634a84f8b7b6dd229d6cd42d59d290
2017-11-03 15:23:44 +09:00