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

1191 Коммитов

Автор SHA1 Сообщение Дата
Mike Hommey 673c2f9373 Bug 1402284 - Separate arenas created from moz_arena_* functions from others. r=njn
We introduce the notion of private arenas, separate from other arenas
(main and thread-local). They are kept in a separate arena tree, and
arena lookups from moz_arena_* functions only access the tree of
private arenas. Iteration still goes through all arenas, private and
non-private.

--HG--
extra : rebase_source : 86c43c7c920b01eb6fa1fa214d612fd9220eac3e
2017-10-31 07:13:39 +09:00
Mike Hommey 4092f53e8a Bug 1402284 - Move arena tree related globals to a static singleton of a new class. r=njn
We create the ArenaCollection class to handle operations on the
arena tree. Ideally, iter() would trigger locking, but the
prefork/postfork code complicates things, so we leave this for later.

--HG--
extra : rebase_source : bd7021098baf0ec01c14063294098edea4473d36
2017-10-28 07:13:58 +09:00
Mike Hommey e23a5782c2 Bug 1402284 - Initialize arena_t objects via a constructor instead of manually with an Init method. r=njn
Note we use a local variable for fallible allocator because using plain
`new (fallible)` would require some figuring out for non-Firefox builds
(e.g.  standalone js).

--HG--
extra : rebase_source : 2132f98ebc7e37a139b673f80631e672bcf8ed15
2017-10-28 08:42:59 +09:00
Mike Hommey b4a43c8f3a Bug 1402284 - Make RedBlackTree::{Insert,Remove} work when the type has a constructor. r=njn
RedBlackTree::{Insert,Remove} allocate an object on the stack for its
RedBlackTreeNode, and that shouldn't have side effects if the type
happens to have a constructor. This will allow to add constructors to
some of the mozjemalloc types.

--HG--
extra : rebase_source : 14dbb7d73c86921701d83156186df5d645530dda
2017-10-30 09:55:18 +09:00
Phil Ringnalda 6841cb2510 Backed out 4 changesets (bug 1402284) for build bustage
CLOSED TREE

Backed out changeset f894ea204bb4 (bug 1402284)
Backed out changeset a0c193d65799 (bug 1402284)
Backed out changeset 8f83dc111aed (bug 1402284)
Backed out changeset 7b7818155442 (bug 1402284)

MozReview-Commit-ID: DNthJ588QYa
2017-10-31 20:06:26 -07:00
Mike Hommey a9fed04a18 Bug 1402284 - Separate arenas created from moz_arena_* functions from others. r=njn
We introduce the notion of private arenas, separate from other arenas
(main and thread-local). They are kept in a separate arena tree, and
arena lookups from moz_arena_* functions only access the tree of
private arenas. Iteration still goes through all arenas, private and
non-private.

--HG--
extra : rebase_source : ec48631a4a65520892331c1fcd62db37ed35ba1d
2017-10-31 07:13:39 +09:00
Mike Hommey ca87c7c8ba Bug 1402284 - Move arena tree related globals to a static singleton of a new class. r=njn
We create the ArenaCollection class to handle operations on the
arena tree. Ideally, iter() would trigger locking, but the
prefork/postfork code complicates things, so we leave this for later.

--HG--
extra : rebase_source : 90c96575d65c920f75aa621ba119d354d1ce252a
2017-10-28 07:13:58 +09:00
Mike Hommey bdc5d4ce61 Bug 1402284 - Initialize arena_t objects via a constructor instead of manually with an Init method. r=njn
Note we use the deprecated `new (fallible_t())` form because using `new
(fallible)` would require some figuring out for non-Firefox builds (e.g.
standalone js).

--HG--
extra : rebase_source : 0159d8476a1b5509330517c00af6c387d522722d
2017-10-28 08:42:59 +09:00
Mike Hommey 6d94984475 Bug 1402284 - Make RedBlackTree::{Insert,Remove} work when the type has a constructor. r=njn
RedBlackTree::{Insert,Remove} allocate an object on the stack for its
RedBlackTreeNode, and that shouldn't have side effects if the type
happens to have a constructor. This will allow to add constructors to
some of the mozjemalloc types.

--HG--
extra : rebase_source : 14dbb7d73c86921701d83156186df5d645530dda
2017-10-30 09:55:18 +09:00
Mike Hommey ef31a72488 Bug 1413096 - Remove SIZEOF_PTR and SIZEOF_PTR_2POW. r=njn
--HG--
extra : rebase_source : e9a7082ebb944352da80face0e5796429aaed340
2017-10-30 11:43:10 +09:00
Mike Hommey 87e49e764d Bug 1413096 - Replace ffs with MathAlgorithms functions. r=njn
- In the cases where it's used on powers of 2, replace it with
  FloorLog2() + 1.
- In the cases where it's used on any kind of number, replace it with
  CountTrailingZeroes, which is `ffs(x) - 1`.
- In the case of tiny allocations in arena_t::MallocSmall, we rearrange
  the code so that the intent is clearer, which also simplifies the
  expression for the mBins offset: mBins[0] is the first tiny bucket,
  for allocations of sizes 1 << TINY_MIN_2POW, mBins[1] for allocations
  of size 1 << (TINY_MIN_2POW + 1), etc. up to small_min. So the offset
  is really the log2 of the normalized size.

--HG--
extra : rebase_source : 954a655dcaa93857dc976078e133704bb141de0d
2017-10-30 17:44:16 +09:00
Mike Hommey 331ef2d1a6 Bug 1413096 - Remove unnecessary call to ffs. r=njn
Comparing ffs(x) == ffs(y), when x and y are guaranteed to be powers of
2 (or 0, or 1), is the same as x == y.

--HG--
extra : rebase_source : d6cc3399d85fa9fda2559435e99adbfb82ac8da0
2017-10-30 17:57:55 +09:00
Mike Hommey 3c71490814 Bug 1413096 - Remove pow2_ceil in favor of RoundUpPow2. r=njn
--HG--
extra : rebase_source : ef24e37398e992e2f64a08ffae30f374babca37f
2017-10-30 17:22:36 +09:00
Mike Hommey 5a7f5e0d8e Bug 1413096 - Use CheckedInt for overflow check in calloc. r=njn
Also use in in _recalloc.

--HG--
extra : rebase_source : 1ecc1f029958cd0b25e6e480f5afb94b56dd1139
2017-10-30 11:28:17 +09:00
Mike Hommey e30b520850 Bug 1413096 - Add "using namespace mozilla" to mozjemalloc.cpp. r=njn
--HG--
extra : rebase_source : 438f0c3729111e97cf1e5b9cb5e230eda796e7bd
2017-10-30 17:19:44 +09:00
Mike Hommey 19b1e09699 Bug 1413096 - Add missing header guard. r=njn
--HG--
extra : rebase_source : fdb40a44f0ff212a2a5367f4de7663129888f41a
2017-10-30 11:00:46 +09:00
Mike Hommey 26d6ac76c0 Bug 1412722 - Remove RedBlackTree sentinel. r=njn
The sentinel was taking as much space as one element of the tree, while
only really used for its RedBlackTreeNode, wasting space.

This results in some decrease in struct sizes, for example on 64-bits
linux:
- arena_bin_t: 80 -> 56
- arena_t (excluding mBins): 224 -> 144
- arena_t + dynamic size of mBins: 3024 -> 2104

It also decreases the size of several globals:
- gChunksBySize, gChunksByAddress, huge: 64 -> 8
- gArenaTree: 312 -> 8

--HG--
extra : rebase_source : d5bb52f93e064ab4cca3fb07b2c5a77ce57fb7db
2017-10-28 08:36:32 +09:00
Mike Hommey 7f63a01cca Bug 1412717 - Make malloc_initialized atomic. r=njn
Interestingly, this turns single-instruction checks into
two-instructions checks (at least with GCC, from one cmpb to a movl
followed by a testl), but this is due to Atomic<bool> being actually
backed by a uint32_t, not by the use of atomics.

--HG--
extra : rebase_source : cfc0bec2113b44635120216b4abbbbbe9028b286
2017-10-30 09:30:41 +09:00
Mike Hommey 5b2f666e8a Bug 1412235 - Be consistent about the magic number assertions in mozjemalloc. r=njn
- First, MOZ_DIAGNOSTIC_ASSERT_ENABLED is always true when MOZ_DEBUG is
  set, so don't check for MOZ_DEBUG.
- Second, all the magic number assertions should be
  MOZ_DIAGNOSTIC_ASSERTs instead of MOZ_ASSERTs.

--HG--
extra : rebase_source : 5601cd13604e21c46a9f0ad8b0b4d6fc399b853e
2017-10-27 17:29:12 +09:00
Mike Hommey 7fca98c0c3 Bug 1412234 - Make all allocator API entry points handle initialization properly. r=njn
Some need initialization to happen, some can be skipped when the
allocator was not initialized, and others should crash.

--HG--
extra : rebase_source : d6c2697ca27f6110fe52a067440a0583e0ed0ccd
2017-10-27 17:25:18 +09:00
Mike Hommey 5b0f50a0fc Bug 1412234 - Make malloc_init return whether the allocator was successfully initialized. r=njn
--HG--
extra : rebase_source : 744ffd666b626059197bebf90acfe3fd670847d4
2017-10-27 17:05:47 +09:00
Mike Hommey fc8b83f39a Bug 1412221 - Fix build bustage in mozjemalloc.cpp. r=me 2017-10-29 14:00:28 +01:00
Mike Hommey 7dcb29d53f Bug 1412221 - Run clang-format on mozjemalloc.cpp. r=njn
--HG--
extra : histedit_source : 450ca93d0ee5b0a53a649a1116cf9c2bf22f3eb4
2017-10-29 13:53:37 +01:00
Mike Hommey 7ac11ce77e Bug 1412221 - Change comments to use C++ style // instead of /* */. r=njn
clang-format doesn't handle multi-line /* */ well.

--HG--
extra : histedit_source : 2cf4811a7861072f5039a4139e403283073d7d90
2017-10-29 13:53:31 +01:00
Mike Hommey d00d68c730 Bug 1412221 - Use pages_unmap instead of repeating the same code. r=njn
--HG--
extra : histedit_source : d23385b0e30046f0f7e0cd145478ba01a66036c3
2017-10-29 13:53:26 +01:00
Mike Hommey d7db18ae90 Bug 1412221 - Remove unnecessary parentheses around return values. r=njn
--HG--
extra : histedit_source : 20b11718133f9449c562572c0150682f91aa11d9
2017-10-29 13:53:20 +01:00
Mike Hommey aabcfdd6ab Bug 1412221 - Fix clang-tidy warnings in mozjemalloc.cpp. r=njn
Also rearrange some code accordingly, but don't fix indentation issues
just yet.

Also apply changes from the google-readability-braces-around-statements
check.

But don't apply the modernize-use-nullptr recommendation about
strerror_r because it's wrong (bug #1412214).

--HG--
extra : histedit_source : 2d61af7074fbdc5429902d9c095c69ea30261769
2017-10-29 13:53:14 +01:00
Sebastian Hengst d9ec2086d0 Backed out changeset 5 changesets (bug 1412221) for build bustage at memory/build/mozjemalloc.cpp:4390: jump to label 'RETURN'. r=backout
Backed out changeset f75f427fde1d
Backed out changeset 6278aa5fec1d
Backed out changeset eefc284bbf13
Backed out changeset e2b391ae4688
Backed out changeset 58070c2511c6

--HG--
extra : histedit_source : d14fa171a5cf4d9400cae7f94d5cc64a1e58b98d%2C856ad5b650074a1dcff2edb0b95adc20aaf38db3
2017-10-29 13:50:49 +01:00
Mike Hommey 5acf4b9bbe Bug 1412221 - Run clang-format on mozjemalloc.cpp. r=njn
--HG--
extra : rebase_source : 5e582f64182131e600e8557b8c7c957ef53c2bcc
2017-10-27 16:48:25 +09:00
Mike Hommey 732a4acab4 Bug 1412221 - Change comments to use C++ style // instead of /* */. r=njn
clang-format doesn't handle multi-line /* */ well.

--HG--
extra : rebase_source : f814f4a973499c3d7759ea0f17543513fb047f39
2017-10-27 16:33:14 +09:00
Mike Hommey 56e7d2c532 Bug 1412221 - Use pages_unmap instead of repeating the same code. r=njn
--HG--
extra : rebase_source : 374b0536bd5b553594a907bfe50d89e44acb02f1
2017-10-27 16:02:22 +09:00
Mike Hommey 4aef26adda Bug 1412221 - Remove unnecessary parentheses around return values. r=njn
--HG--
extra : rebase_source : cfbba2665a43e956df78ccc4a811c31324836255
2017-10-27 15:37:28 +09:00
Mike Hommey 7df73744bb Bug 1412221 - Fix clang-tidy warnings in mozjemalloc.cpp. r=njn
Also rearrange some code accordingly, but don't fix indentation issues
just yet.

Also apply changes from the google-readability-braces-around-statements
check.

But don't apply the modernize-use-nullptr recommendation about
strerror_r because it's wrong (bug #1412214).

--HG--
extra : rebase_source : 28b07aca01fd0275127341233755852cccda22fe
2017-10-27 14:57:09 +09:00
Mike Hommey 5bf6af5d52 Bug 1229384 - Make pages_commit fallible. r=njn
This will make allocation operations return nullptr in the face of OOM,
allowing callers to either handle the allocation error or for the normal
OOM machinery, which also records the requested size, to kick in.

--HG--
extra : rebase_source : 723048645cb3f0db269c91f9d023bb06825a817b
2017-10-27 10:31:50 +09:00
Mike Hommey c77051041e Bug 1229384 - In SplitRun, adjust the set of available runs after committing pages. r=njn
On its own, this change is unnecessary. But it prepares for pages_commit
becoming fallible in next commit, allowing a possibly early return while
leaving metadata in a consistent state: runs are still available for
future use even if they couldn't be committed immediately.

--HG--
extra : rebase_source : 971e5c49882409c00ac61ec641d469dcc94e5cc2
2017-10-26 18:12:04 +09:00
Mike Hommey 8fbdcde064 Bug 1229384 - Invert the meaning of the arena_ralloc_large and arena_t::RallocGrowLarge return type. r=njn
--HG--
extra : rebase_source : 6d0dcf1e8d1051597a542be38fe0a8641fb0acb0
2017-10-27 10:14:04 +09:00
Mike Hommey 8e876fc0b0 Bug 1229384 - Reformat and apply Gecko style to a few functions. r=njn
--HG--
extra : rebase_source : 8f6e51933649b7a0d74457f00ad7491ebedac06e
2017-10-26 11:11:32 +09:00
Nathan Froyd 3096def324 Bug 1396892 - fix tautological pointer comparison warning, for real; r=me
Whoops, the files that we care about in this directory are C++ files, so
we should be turning warnings off in CXXFLAGS, not CFLAGS.
2017-10-27 16:07:47 -04:00
Mike Hommey 5289738fd4 Bug 1412168 - Replace CHUNK_ADDR2{BASE,OFFSET} with functions. r=njn
--HG--
extra : rebase_source : a7ded5dc74eabd802a30a9266b56cd3343fa5def
2017-10-26 10:34:37 +09:00
Mike Hommey ce11a1b648 Bug 1411786 - Use mozilla::Atomic for the recycled size count. r=njn
--HG--
extra : rebase_source : e2483afafc85935badbe0448582a0f5bb37c9b8d
2017-10-26 09:51:00 +09:00
Mike Hommey e5c6d53dcb Bug 1411786 - Rename chunk recycling-related globals. r=njn
--HG--
extra : rebase_source : b82ad235f305f113fdd7c96d884257b51a259709
2017-10-26 09:43:43 +09:00
Mike Hommey d9ff14e160 Bug 1411786 - Make the chunk size and recycle limit constant. r=njn
Bug 1403843 made more things constant, but missed a few that don't
depend on the page size.

--HG--
extra : rebase_source : 036722744ff7054de9d081bde1f4c7b035fd9501
2017-10-26 09:38:48 +09:00
Mike Hommey e7924e7a2e Bug 1411786 - More tidying of chunk allocation and recycling code. r=njn
- Move variable declarations to their initialization.
- Remove gotos and use RAII.

--HG--
extra : rebase_source : 9d983452681edf63593d033727ba6faebe418afe
2017-10-26 08:50:49 +09:00
Mike Hommey c27356ae7a Bug 1411786 - Rename chunk_{recycle,record,alloc,dealloc} arguments. r=njn
Also reformat a few things clang-format left out.

--HG--
extra : rebase_source : 4edd02ae12ae62462b06714a687ecbc49e3af814
2017-10-26 08:48:18 +09:00
Mike Hommey 378bd53e94 Bug 1411786 - clang-format chunk_{recycle,record,alloc,dealloc}. r=njn
--HG--
extra : rebase_source : adeb9db953c3227ee9dbba594282eb0a150d3a64
2017-10-26 08:36:26 +09:00
Mike Hommey e68fafc392 Bug 1411786 - Use globals for chunk recycling. r=njn
The chunk_recycle and chunk_record functions are never called with
different red-black trees than the globals, so just use them directly
instead of passing them as argument. The functions were already using
the associated global mutex anyways.

At the same time, rename them.

--HG--
extra : rebase_source : c45bb2e584c61b458eab4343562eb3a5a64543a3
2017-10-26 08:29:07 +09:00
Mike Hommey 08a70c0752 Bug 1411786 - Don't call chunk_recycle for base allocations. r=njn
Instead of calling it with a boolean indicating whether the call was for
base allocations or not, and return immediately if it was, avoid the
call altogether.

--HG--
extra : rebase_source : abb2a3d0eaefc16efd2e828f09a330ab2a3b8b1f
2017-10-26 08:24:08 +09:00
Mike Hommey df85ef19a7 Bug 1300900 - Add a helper around jemalloc_ptr_info for debuggers. r=njn
jemalloc_ptr_info takes an outparam, which makes it harder to use in a
debugger: you'd need to find some memory to use as outparam and pass
that in.

So for convenience, we add a non-exported symbol for use in debuggers,
which just returns a pointer to a static buffer for the result.

lldb:
(lldb) print *Debug::jemalloc_ptr_info($0)
(jemalloc_ptr_info_t) $1 = (tag = TagLiveSmall, addr=0x000000011841dd80, size = 160)

gdb:
(gdb) print *Debug::jemalloc_ptr_info($0)
$1 = {tag = TagLiveSmall, addr = 0x7f8e7ebd0dc0, size = 96}

windbg:
0:040> .call Debug::jemalloc_ptr_info(0x6187880)
Thread is set up for call, 'g' will execute.
WARNING: This can have serious side-effects,
including deadlocks and corruption of the debuggee.
0:040> g
.call returns:
struct jemalloc_ptr_info_t * 0x7501f3f4
   +0x000 tag              : 1 ( TagLiveSmall )
   +0x004 addr             : 0x06187880 Void
   +0x008 size             : 0x20

--HG--
extra : rebase_source : 09aedd48aabee3e273a17000a61b1d09cdd619b9
2017-10-25 08:01:41 +09:00
Mike Hommey 1ab6142261 Bug 1411429 - Remove unused mozjemalloc huge stats. r=njn
Bug 1378258 removed malloc_print_stats and bug 1379890 further removed
the subsequently unused arena stats. It turns out there are also some
huge stats that have been unused since bug 1378258, and that are still
there, so remove them.

--HG--
extra : rebase_source : ae71c7507143503dff8d2e517352a97eb53e4676
2017-10-25 07:20:37 +09:00
Mike Hommey ffe63a7d7f Bug 1411201 - Don't disable inlining in mozjemalloc on debug builds. r=njn
The way inlining is disabled in mozjemalloc is via a #define of "inline"
to nothing, which is a dubious way to do that. This makes the compiler
trigger warnings we -Werror on for some static functions. While there
are such functions in mozjemalloc.cpp that could be fixed by wrapping
them in the right #ifdefs, there are also others coming from headers,
and it's not something that can be fixed in a satisfactory way.

The right way to disable inlining is to pass the right compiler flags
for that. But inlining is the least of the problems to debug optimized
C++ code, so it feels like if debugging requires some optimization
tweaking, it should be done manually with compile flags when needed,
instead of fiddling with #defines to remove keywords.

--HG--
extra : rebase_source : 962c3409f86060c4d5ddf966778b58b64f89c31d
2017-10-24 18:42:24 +09:00
Mike Hommey d2222ba092 Bug 1411158 - Remove some warning exceptions in memory/build/moz.build. r=njn
Bug 1403444 massively refactored the red-black tree code, with the
result of removing the warnings the old code was triggering. We can thus
remove the exceptions for those warnings now.

--HG--
extra : rebase_source : 76c7ce7a7282471399c7592601f6986bfb33b256
2017-10-24 14:48:05 +09:00
Mike Hommey a465ba783c Bug 1411155 - Fix MOZ_DEBUG parts of mozjemalloc. r=njn
--HG--
extra : rebase_source : 5a2005255ad499530f0e01b2e7577e707b1b4446
2017-10-24 14:11:14 +09:00
Mike Hommey 55703dd1f1 Bug 1411084 - Use RAII for mutex locking in mozjemalloc. r=njn
This leaves out a few manual Lock/Unlock calls.

--HG--
extra : rebase_source : ce20e8e63474b43b469b953de0558d9904e2229e
2017-10-06 17:49:40 +09:00
Sylvestre Ledru d60d69e2cb Bug 1411001 - Remove the +x permissions on cpp & h files r=froydnj
MozReview-Commit-ID: DjDkL20wRg0

--HG--
extra : rebase_source : a343d83d1f4e97e4ba56d0f57fec93079df0b5ea
2017-10-23 20:59:55 +02:00
Mike Hommey 4bc374f630 Bug 1409294 - Make arena_t::Init return whether initialization succeeded. r=njn
--HG--
extra : rebase_source : efd32943313cef9a680fc38b0c2182e3c175c27e
2017-10-17 17:37:50 +09:00
Mike Hommey 79eba188f7 Bug 1409273 - Replace malloc_mutex_* with class methods. r=njn
Ideally, we'd be reusing some Mutex class we have in Gecko, the base one
in mozglue/misc being the best candidate. However, the contraints in
mozjemalloc make that unconvenient:
- Can't have a constructor because malloc_init() would likely run before
  it, and that would mean the mutexes would be re-initialized.
- Can't have a destructor because code will run after static
  destructors, and some of that code likely will invoke the allocator,
  and we can't have destructed mutexes by then.
- Can't use pthread_mutex on OSX because that loops back into the
  allocator.

Accomodating the use of Gecko mutexes around those constraints would
mean much more code than just implementing a new mutex class, so the
latter is preferred.

--HG--
extra : rebase_source : d2e180a5007390c620aa6d7921340b9784c7699f
2017-10-06 17:20:04 +09:00
Mike Hommey 9f2dd4775e Bug 1407468 - Replace multiple !JS_STANDALONE with MOZ_WIDGET_TOOLKIT. r=mshal
--HG--
extra : rebase_source : 4f9f9f583c3422ed0f8d1d65ea8e7575bd9baf2c
2017-10-05 14:50:01 +09:00
Tom Ritter fdab21a20a Bug 1406197 Declare sized deallocators (that ignore the size) to correct a MinGW warning r=glandium
MozReview-Commit-ID: Dl4uu6evlbs

--HG--
extra : rebase_source : f9b04123b1f09a49155f0bb24704f9e11818ff5a
2017-10-10 13:16:10 -05:00
Mike Hommey a055106404 Bug 1407469 - Remove malloc_spin_*. r=njn
The malloc_spin_* functions have ended up being strictly identical to
the malloc_mutex_* functions, so use the latter instead of the former.

--HG--
extra : rebase_source : 746bdf57cb4a33fd65335174a748cb567630e05b
2017-10-06 16:50:17 +09:00
Mike Hommey 03333cae7c Bug 1406303 - Don't heap-allocate the global chunk radix tree. r=njn
Now that the radix tree structure has a fixed size, we can just allocate
the chunk radix tree object statically.

--HG--
extra : rebase_source : 6a5f022d46da1b24401b197751e594903987b7f6
2017-10-06 16:18:01 +09:00
Mike Hommey 5ad57b4c9d Bug 1406303 - Make the number of significant bits used by the radix tree a template parameter. r=njn
All the parameters of the radix tree (bits per level, height) are
derived from the aBits argument to ::Create in a straightforward way.
aBits itself is a constant at the call point, making them all constants,
so we can turn all of them as constants at compile time instead of
storing as data.

--HG--
extra : rebase_source : aa1be8e97ed4133d7fc106fb3ea678a759476bef
2017-10-06 15:50:00 +09:00
Mike Hommey 8dd493542b Bug 1406303 - Only store 2 levels of bit sizes for the radix tree. r=njn
All levels except the first are using the same size, and in some cases,
even the first uses the same size. Only storing those two different
sizes allows to fix the class size, while not making the code
significantly more complex.

--HG--
extra : rebase_source : 8028c18de2fa84060c5baff7c95cd0a70e7a3c6b
2017-10-06 15:24:07 +09:00
Mike Hommey 69e46849e9 Bug 1406303 - Simplify the calculation of AddressRadixTree's height. r=njn
The tree height was defined as:
  height = aBits / bits_per_level;
  if (height * bits_per_level != aBits) {
    height++;
  }

What's wanted here is a height that covers all the bits, where the first
level might cover less than bits_per_level.

So aBits / bits_per_level gets us the height covered by levels with
exactly bits_per_level bits. The tree height is one more when there
are remaining bits.

Put differently, we can write aBits as:
  aBits = bits_per_level * x + y

with y < bits_per_level.

We have:
  aBits / bits_per_level = x.
  height = x when y = 0, and x + 1 when y > 0.

We're looking for a number z such that
  height = (aBits + z) / bits_per_level.

Or:
  height = (bits_per_level * x + y + z) / bits_per_level.
         = x + (y + z) / bits_per_level.

So we're looking for a z such that
  (y + z) / bits_per_level = 0 when y = 0
                           = 1 when y > 0

The properties of the integer division are such that the above means:
  0 <= y + z < bits_per_level when y = 0
  bits_per_level <= y + z < 2 * bits_per_level when y > 0

Which gives us:
  0 <= z < bits_per_level
  bits_per_level - y <= z < 2 * bits_per_level - y when y > 0

y being < bit_per_level per the constraint further above,
  2 * bits_per_level - y > bits_per_level.

So all in all, we want a z such that
  bits_per_level - y <= z < bits_per_level with 0 < y < bits_per_level

The largest value where this is true is z = bits_per_level - 1.

In summary,
  height = (aBits + bits_per_level - 1) / bits_per_level

is the same as the height as originally defined.

With that formula, it's self evident that height * bits_per_level is
always >= aBits, so we remove the assertion.

--HG--
extra : rebase_source : 8ca2e5fbad7d4ad537f26508af5aa250483f1f08
2017-10-06 11:32:27 +09:00
Mike Hommey aaefadc3a4 Bug 1406303 - Simplify the calculation of AddressRadixTree's bits_per_level. r=njn
bits_per_level was defined as:
  ffs(pow2_ceil((kNodeSize / sizeof(void*)))) - 1

kNodeSize is (1U << 14) when SIZEOF_PTR is 4 (sizeof(void*) being the
same). Otherwise, it's CACHELINE, which is (1U << 6).
The most important part, though, is that it's always a power of 2.
And it's divided by sizeof(void*) which is always a power or 2.
The result of that division is thus always a power of 2, as long as
kNodeSize is larger than the size of a pointer, which it is.

The argument to pow2_ceil being a power of 2, pow2_ceil is a noop,
so it can go away. And the argument to ffs being a power of 2, it
returns one more than n that matches 1 << n == value. So overall
the expression returns the number of shifts for
kNodeSize / SIZEOF_PTR.

Transforming kNodeSize to a number of shifts/power of 2, the expression
can then be simplified as kNodeSize2Pow - SIZEOF_PTR_2POW.

--HG--
extra : rebase_source : a22a378ba6622e2a4fbcf28811c7042cea9da24a
2017-09-28 15:35:21 +09:00
Mike Hommey a814a27087 Bug 1406303 - Turn malloc_rtree_t into a C++ class. r=njn
The only semantic change is in the value returned by Set, which now
returns whether the value could be set or not.

--HG--
extra : rebase_source : a80f5d6fdb3672715887e69215f55df0cedb231e
2017-10-06 10:49:24 +09:00
Mike Hommey cce7100e5e Bug 1406303 - Refactor malloc_rtree_get/set. r=njn
There is a lot of redundancy between malloc_rtree_get and
malloc_rtree_set. Essentially, they both look up a slot, and either get
a value or set a value in that slot. malloc_rtree_get doesn't create a
tree path for the slot when it doesn't exist. And the
MALLOC_RTREE_GET_GENERATE macro machinery makes malloc_rtree_get retry
with a lock and validate both results agree in debug builds.

By introducing a malloc_rtree_get_slot function that returns a slot,
optionally creating a tree path to it, we remove the redundancy between
_get and _set, and we can avoid the macro machinery as well.

--HG--
extra : rebase_source : bbbdd33e81e8bfdc11c028f882ab877bba26f7f3
2017-09-28 12:18:14 +09:00
Emanuel Hoogeveen 02d10f1bfa Bug 1405159 - Assert against freeing incorrectly offset pointers. r=glandium 2017-10-02 15:39:00 -04:00
Nicholas Nethercote a6fede36c2 Bug 1384814 - Remove critical address machinery from Mac implementation of MozStackWalk(). r=glandium.
It seemingly hasn't been needed since Mac OS 10.7. A diagnostic assertion that
has been in place for a while hasn't caught any uses of it.

--HG--
extra : rebase_source : 9834849eec9174267c7df8de7fd22840ffa36d8f
2017-10-03 13:53:14 +11:00
Jan Keromnes 30acb879f3 Bug 1403660 - Do not use 'else' after 'break' in /memory/build/rb.h. r=njn 2017-09-28 08:01:00 -04:00
Mike Hommey fd18ca4367 Bug 1403843 - Disable static sizes on debug builds. r=njn
Because why not, especially now that this only concerns the page size.

--HG--
extra : rebase_source : 9ff92d2551e0bb8633072e0c8d5aa36c570314e1
2017-09-28 15:15:23 +09:00
Mike Hommey 450b12cd79 Bug 1403843 - Make quantum, small and chunk sizes always static. r=njn
Bug 571209 made many different kinds of sizes static at build time, as
opposed to configurable at run-time. While the dynamic sizes can be
useful to quickly test tweaks to e.g. quantum sizes, a
replace-malloc-built allocator could just as well do the same. This
need, however, is very rare, and doesn't justify keeping the sizes
dynamic on platforms where static sizes can't be used for the page size
because page size may vary depending on kernel options.

So we make every size that doesn't depend on the page size static,
whether MALLOC_STATIC_SIZES is enabled or not.

This makes no practical difference on tier-1 platforms, except Android
aarch64, which will benefit from more static sizes.

--HG--
extra : rebase_source : 28243a67e4fe41154c23dc39b45405479854d31d
2017-09-28 15:27:59 +09:00
Mike Hommey 2e77077792 Bug 1403821 - Don't force the allocator to be always compiled with optimizations. r=froydnj
This was done in bug 1104634 because back then the Android NDK had a
broken combination of compiler and libc, where the compiler would emit
calls to the ffs function, but the libc wouldn't contain them, but only
when building without optimization.

Things have changed in the meanwhile, and recent NDK doesn't have this
problem. So we can remove the hack.

--HG--
extra : rebase_source : 22d6c279a60d0d23161ca1addd5b5e9a3411d8ab
2017-09-28 11:27:43 +09:00
Mike Hommey 7ee99ec56b Bug 1403824 - Keep track of arenas in the arena tree. r=njn
Bug 1402174 made all arenas registered in a Red-Black tree. Which means
they are iterable through that tree, making the arenas list now redundant.
The list is also inconvenient, since it needs to be constantly
reallocated, and the allocator in charge of the list doesn't know how to
free things.

Iteration of arenas is not on any hot path anyways, so even though
iterating the RB tree is slower, it doesn't matter.

So we remove the arenas list, and keep a direct pointer to the main
arena for convenience (instead of calling First() on the RB tree every
time)

--HG--
extra : rebase_source : 31f12b2de18a886eb4f8f078e11040aad3fdc800
2017-09-28 08:06:23 +09:00
Mike Hommey 3e25c152cf Bug 1403766 - Always use some sort of thread local storage in the allocator. r=njn
As we're going to enable stylo on Android at some point, we'll have to
have thread local arenas there, which means Android needs to be using
thread local storage. Since Android is the last use of NO_TLS in the
allocator code base, remove it.

--HG--
extra : rebase_source : 658cbc94b4478950f683bd104b7e5da27cd08a2e
2017-09-28 08:28:52 +09:00
Mike Hommey 4877b48a43 Bug 1403765 - Use native TLS in the allocator on Windows. r=njn
--HG--
extra : rebase_source : d6f46f9f4a09079f62f44b6aed6dd4bd8d60530c
2017-09-25 06:47:44 +09:00
Mike Hommey d8428609d8 Bug 1403444 - Remove typedefs for RedBlackTrees. r=njn
--HG--
extra : rebase_source : 0cc425c0e941108a4387ac594f6f258c68a35f4e
2017-09-28 06:58:37 +09:00
Mike Hommey 33d3d2113b Bug 1403444 - Rename the RedBlackTree member variables. r=njn
--HG--
extra : rebase_source : 5bfc9d0711af7acfbe3f8a6711e82f103ae13ece
2017-09-27 16:11:11 +09:00
Mike Hommey f0908215f5 Bug 1403444 - Add a helper class to avoid the tree traversal code having to use Trait::GetTreeNode noisily. r=njn
--HG--
extra : rebase_source : b73d82b3529e4910d890cb9dfb08cacdff5b7a64
2017-09-27 16:07:22 +09:00
Mike Hommey 8c16cb5da2 Bug 1403444 - Replace the rb_foreach_* macros with a range iterator. r=njn
--HG--
extra : rebase_source : 6a487f1f660ec15cea8b91e89fc473b8cc17a669
2017-09-27 15:25:19 +09:00
Mike Hommey cb629a1000 Bug 1403444 - Remove rbp_f_synced. r=njn
Bug 1365460 removed the macros that used it.

--HG--
extra : rebase_source : 6f732916e3cdbf2b1dfd8e929fb9424a1e41352a
2017-09-27 13:50:50 +09:00
Mike Hommey 8f6d19c631 Bug 1403444 - Replace rbp_move_red_left and rbp_move_red_right with private methods. r=njn
--HG--
extra : rebase_source : e93e7256d3c94fc4aad9469fa00cd65f68c0a5e4
2017-09-26 21:21:13 +09:00
Mike Hommey d5840a27d6 Bug 1403444 - Replace rbp_lean_left and rbp_lean_right with private methods. r=njn
--HG--
extra : rebase_source : 08fd0203f37706563a3c584225bb1790a1bd57b9
2017-09-26 21:14:12 +09:00
Mike Hommey 0938630279 Bug 1403444 - Replace rbp_rotate_left and rbp_rotate_right with private methods. r=njn
--HG--
extra : rebase_source : 1f576d36ae451d03a96b2a7285912c2a2fb4d1e5
2017-09-26 21:08:29 +09:00
Mike Hommey fb8f789c51 Bug 1403444 - Expand rb_remove. r=njn
At the same time, simplify the expanded code to better fit in the
template.

--HG--
extra : rebase_source : 05be3b680645da9665449e5417efdf862d7e5f96
2017-09-26 17:13:53 +09:00
Mike Hommey 8d2fab69cf Bug 1403444 - Expand rb_insert. r=njn
At the same time, simplify the expanded code to better fit in the
template.

--HG--
extra : rebase_source : 610d774220fd2dbe40872f16e86eca57c11b31c3
2017-09-26 17:07:35 +09:00
Mike Hommey dcd990824b Bug 1403444 - Expand rbp_first and rbp_last. r=njn
At the same time, simplify the expanded code to better fit in the
template.

--HG--
extra : rebase_source : a61d3eb96da054a50bc016dc6a4969f42adf9dfa
2017-09-26 16:59:02 +09:00
Mike Hommey 3c5e2cba4f Bug 1403444 - Allow First and Last to take a start node, and use that in Next and Prev. r=njn
--HG--
extra : rebase_source : a2d00f91ad98e7bd1478624a0a9b374de52f543b
2017-09-26 16:55:31 +09:00
Mike Hommey d4ac54ef7d Bug 1403444 - Expand rb_search and rb_nsearch. r=njn
At the same time, simplify the expanded code to better fit in the
template.

--HG--
extra : rebase_source : d68bce212b04b927e32d360b0d606692a336598a
2017-09-26 16:46:43 +09:00
Mike Hommey 28b7741df7 Bug 1403444 - Expand rbp_next and rbp_prev. r=njn
At the same time, simplify the expanded code to better fit in the
template.

--HG--
extra : rebase_source : 6f6344a703c7cf56ddf97efabbd05d47f389266a
2017-09-26 16:39:03 +09:00
Mike Hommey bc635f3082 Bug 1403444 - Trivially expand rb_node_field. r=njn
Also replace `a_field((foo))` with `a_field(foo)` in the resulting code.

--HG--
extra : rebase_source : acc6c43320e9ee932e878c13cc2d6766a158cdba
2017-09-26 16:36:24 +09:00
Mike Hommey b3937aa599 Bug 1403444 - Expand rbp_node_new. r=njn
At the same time, simplify the expanded code to better fit in the
template.

--HG--
extra : rebase_source : a903717427dbb8b2cd05ec462b821131d0000ea2
2017-09-26 16:00:27 +09:00
Mike Hommey 6561941f93 Bug 1403444 - Expand rb_new, rb_first, rb_last, rb_next and rb_prev. r=njn
At the same time, simplify the expanded code to better fit in the
template.

--HG--
extra : rebase_source : fa002197c5f4801ae7cf8b704b023393fc4cc6b5
2017-09-26 15:47:50 +09:00
Mike Hommey 8392daa18e Bug 1403444 - Add methods to the RedBlackTree template class, replacing rb_wrap. r=njn
--HG--
extra : rebase_source : e0f71386b0097034b5e6c629113dff38e574ea74
2017-09-26 15:06:00 +09:00
Mike Hommey 4ec0ed7879 Bug 1403444 - Move miscellaneous size related constants and macros earlier in mozjemalloc.cpp. r=njn
--HG--
extra : rebase_source : e277943abe1aa664bb7c24388f425fac0dc170aa
2017-09-26 09:08:00 +09:00
Mike Hommey 81cb21567f Bug 1403444 - Replace some uses of IsRed() with Color() or IsBlack(). r=njn
The trivial expansion of macros ended up creating cases like
  expr.IsRed() ? NodeColor::Red : NodeColor::Black
which practically speaking, is the same as
  expr.Color()
so we replace those.

There are also a bunch of expr.IsRed() == false, which are replaced with
expr.IsBlack() (adding that method at the same time)

--HG--
extra : rebase_source : ab50212ff80f0c0151e7df329d8933ccd45f9781
2017-09-27 08:54:49 +09:00
Mike Hommey 3787074984 Bug 1403444 - Trivially expand rbp_{color,red,black}_set. r=njn
--HG--
extra : rebase_source : ebef4dedd44ce3bf181ba840a33e975ae2f423c3
2017-09-25 10:03:56 +09:00
Mike Hommey d0d3055917 Bug 1403444 - Trivially expand rbp_right_set. r=njn
--HG--
extra : rebase_source : f3824bc5e3992e78671418a0f65daf3bffce2d56
2017-09-25 10:05:07 +09:00
Mike Hommey a9819bb805 Bug 1403444 - Trivially expand rbp_left_set. r=njn
--HG--
extra : rebase_source : 1fc855c907ddeb1dd21473003cae8f9b32e23336
2017-09-25 10:04:32 +09:00
Mike Hommey 7776a84304 Bug 1403444 - Trivially expand rbp_red_get. r=njn
--HG--
extra : rebase_source : dae723877cb4fc04cd085a7b9a441a2df38e68c9
2017-09-25 10:02:48 +09:00
Mike Hommey d3ada6727c Bug 1403444 - Trivially expand rbp_right_get. r=njn
--HG--
extra : rebase_source : f5ee449b8683266aa2143d53b3316f782c5d5ac7
2017-09-25 10:02:22 +09:00
Mike Hommey d871a7f54e Bug 1403444 - Trivially expand rbp_left_get. r=njn
--HG--
extra : rebase_source : 99cb24df5ce2377ac24194e5bf79b23dd08269f0
2017-09-25 10:02:06 +09:00
Mike Hommey 2a81acdfab Bug 1403444 - Abstract red-black-tree link field reference with a new macro. r=njn
While we're going in the opposite direction, moving away from macros,
upcoming intermediate steps are going to "manually" expand macros, but
later steps will require changing how the link field reference is done,
and having it in a single location then will be more convenient.

--HG--
extra : rebase_source : 6dde414ce392924081a41b7e3f66ae848cb14be5
2017-09-25 07:03:37 +09:00
Mike Hommey 4b17f4882c Bug 1403444 - Apply clang-format to the rb.h macros. r=njn
--HG--
extra : rebase_source : d1a55373811fea242c5b91666ba545532e6bbdde
2017-09-25 06:59:30 +09:00
Mike Hommey f43e83a278 Bug 1403444 - Use a fixed size for the stack space used during rb_foreach. r=njn
That stack space would matter if recursion was involved, but there
isn't any, and a max of 1440 bytes temporarily allocated on the stack
is not really a problem.

--HG--
extra : rebase_source : 2968fafe9d604d9e6c03ac93c21d8a3a087043a4
2017-09-25 06:57:09 +09:00
Mike Hommey bba7d810d3 Bug 1403444 - Make the "static" part of what the rb_wrap macro expands to.. r=njn
All uses of rb_wrap have "static" as first argument to rb_wrap, move that
in the macro itself.

--HG--
extra : rebase_source : cbfe87d0539452c044b415c725cb7ce6ebb5628c
2017-09-03 06:49:39 +09:00
Mike Hommey b8a3c5fa7f Bug 1403444 - Add getters and setters on RedBlackTreeNode. r=njn
--HG--
extra : rebase_source : db31bf584071164346463cd54ca359547fcd0eb6
2017-09-02 20:26:09 +09:00
Mike Hommey 02f0da2a19 Bug 1403444 - Use templates for rb_node and rb_tree, and rename them. r=njn
--HG--
extra : rebase_source : ab470e80a786d290f0df61f4adf2c128f9ecb925
2017-09-02 09:05:13 +09:00
Mike Hommey 77ff4db6d7 Bug 1402647 - Add a memalign implementation on platforms that don't have one. r=njn
--HG--
extra : rebase_source : bf1ff9da4c4647f5e930194d0d008466f0b2b593
2017-09-26 06:59:03 +09:00
Mike Hommey d7703e388f Bug 1402647 - Add missing stdlib.h header for system allocator. r=njn
--HG--
extra : rebase_source : caa72506b79e02f953911ab859244d9f9909f389
2017-09-26 06:58:05 +09:00
Mike Hommey 633a0d02d9 Bug 1402174 - Initial actual implementation of the moz_arena_* API. r=njn
Things left for followups:
- Full cleanup of disposed arenas: bug 1364359.
- Random arena Ids: bug 1402282.
- Enforcing the arena to match on moz_arena_{realloc,free}: bug 1402283.
- Make it impossible to use arenas not created with moz_create_arena
  with moz_arena_* functions: bug 1402284.

Until it's proven to require a different data structure, arena lookup by
Id is done through the use of the same RB tree used everywhere else in
the allocator.

At this stage, the implementation of the API doesn't ride the trains,
but the API can be used safely and will fall back to normal allocations
transparently for the caller.

--HG--
extra : rebase_source : aaa9bdab5b4e0c534da0c9c7a299028fc8d66dc8
2017-09-21 14:24:37 +09:00
Mike Hommey 3efd8d6f3a Bug 1402174 - Add a helper class implementing the base allocator functions for a given arena. r=njn
--HG--
extra : rebase_source : 7ddcabf5385f2fc975cf44e4eb6ccdc890d6b7e2
2017-09-21 14:24:37 +09:00
Mike Hommey 46c03f6281 Bug 1402174 - Add an arena argument to imalloc, ipalloc and iralloc. r=njn
--HG--
extra : rebase_source : 60c1ef94e4014f7ef688263541653529e63216d8
2017-09-21 13:58:17 +09:00
Mike Hommey c6730d314b Bug 1402174 - Merge imalloc and icalloc into a single function. r=njn
--HG--
extra : rebase_source : ee06bd77753e94503ce207db8608515a27ef8ea4
2017-09-21 13:23:22 +09:00
Mike Hommey e9474c957e Bug 1402174 - Move AlignedAllocator around, so that calloc, realloc and free and grouped with malloc and memalign. r=njn
--HG--
extra : rebase_source : 139ffe643ca4c6e21f1426c06e92c5d80b32eb3d
2017-09-21 11:46:57 +09:00
Sebastian Hengst 836fbd6f31 Backed out changeset 14dac365b5f6 (bug 1402174) for frequently asserting rbp_i_cmp > 0, at mozjemalloc.cpp:2381. r=backout 2017-09-22 16:48:08 +02:00
Sebastian Hengst 55910de1c7 Backed out changeset 5bba0584a7d8 (bug 1402174) 2017-09-22 16:47:25 +02:00
Sebastian Hengst a42fb039a7 Backed out changeset e356ac32e297 (bug 1402174) 2017-09-22 16:47:19 +02:00
Sebastian Hengst 4af0b5f14d Backed out changeset c589ad71d9ca (bug 1402174) 2017-09-22 16:47:14 +02:00
Sebastian Hengst d6967d0dd4 Backed out changeset b23c870c7e45 (bug 1402174) 2017-09-22 16:47:08 +02:00
Mike Hommey 480bbbd368 Bug 1402174 - Initial actual implementation of the moz_arena_* API. r=njn
Things left for followups:
- Full cleanup of disposed arenas: bug 1364359.
- Random arena Ids: bug 1402282.
- Enforcing the arena to match on moz_arena_{realloc,free}: bug 1402283.
- Make it impossible to use arenas not created with moz_create_arena
  with moz_arena_* functions: bug 1402284.

Until it's proven to require a different data structure, arena lookup by
Id is done through the use of the same RB tree used everywhere else in
the allocator.

At this stage, the implementation of the API doesn't ride the trains,
but the API can be used safely and will fall back to normal allocations
transparently for the caller.

--HG--
extra : rebase_source : 089e4cbb62c239713f40763ab819c79e5cbe28ce
2017-09-21 14:24:37 +09:00
Mike Hommey 5a1dbfeca3 Bug 1402174 - Add a helper class implementing the base allocator functions for a given arena. r=njn
--HG--
extra : rebase_source : c4eb19c295a0f1524024b8d2e6c7a0ade92b23fa
2017-09-21 14:24:37 +09:00
Mike Hommey 9ceb2cae10 Bug 1402174 - Add an arena argument to imalloc, ipalloc and iralloc. r=njn
--HG--
extra : rebase_source : d44937b08fb61b15e729b0a3fc508921fb96d027
2017-09-21 13:58:17 +09:00
Mike Hommey 74a50e4e4e Bug 1402174 - Merge imalloc and icalloc into a single function. r=njn
--HG--
extra : rebase_source : e6a17a3506ef4dddad13ab6e211b269b46ef99a8
2017-09-21 13:23:22 +09:00
Mike Hommey 494f947a18 Bug 1402174 - Move AlignedAllocator around, so that calloc, realloc and free and grouped with malloc and memalign. r=njn
--HG--
extra : rebase_source : 1973f90f98a19b4e60f742b7f3aef307bb304e7d
2017-09-21 11:46:57 +09:00
Mike Hommey 5cd3519571 Bug 1052573 - Add an API for allocation in separate arenas. r=njn
The implementation is not doing anything just yet. This will be done in
a followup bug.

--HG--
extra : rebase_source : e301eac77c6bd8247c09d369074ecb8d7b5a1a2f
2017-09-22 07:22:38 +09:00
Mike Hommey c43db36061 Bug 1052573 - Move macro helpers to mozjemalloc.h. r=njn
--HG--
extra : rebase_source : de717a2ddb13afc29ec3d795fbf1ae72b6ed1d26
2017-09-21 14:10:06 +09:00
Mike Hommey 21a0a419d0 Bug 1052573 - Separate the base allocator functions in malloc_decls.h. r=njn
malloc, free, calloc, realloc and memalign constitute some sort of
minimal interface to the allocator. posix_memalign, aligned_alloc and
valloc are already defined in terms of memalign. The remaining functions
are not related to active allocation.

--HG--
extra : rebase_source : ee27ca70e271f3abef76c7782724d607b52f58b1
2017-09-21 10:31:09 +09:00
Mike Hommey 00433d9cf4 Bug 1401099 - Move arena_ralloc_large_grow to a method of arena_t. r=njn
--HG--
extra : rebase_source : 0a1863785b2c3a22946ee735c73afa5ac764f076
2017-09-15 20:50:42 +09:00
Mike Hommey 3c2c85e407 Bug 1401099 - Move arena_ralloc_large_shrink to a method of arena_t. r=njn
--HG--
extra : rebase_source : 3b9aede58b3c9163b8a28a4371120d471533f8eb
2017-09-15 20:44:34 +09:00
Mike Hommey 24adb9a7a8 Bug 1401099 - Move arena_dalloc_large to a method of arena_t. r=njn
--HG--
extra : rebase_source : dbc79744f42ed99709ed9857ec5d91ceaea83b0d
2017-09-15 20:40:36 +09:00
Mike Hommey eea012c8aa Bug 1401099 - Move arena_dalloc_small to a method of arena_t. r=njn
--HG--
extra : rebase_source : 9cc4efbbcd0da012be9fa4e5dd3262d89bdab161
2017-09-15 20:37:47 +09:00
Mike Hommey 05188caf59 Bug 1401099 - Move arena_palloc to a method of arena_t. r=njn
--HG--
extra : rebase_source : 0c64ea5c0681704a85e15977a8803403d06d0962
2017-09-15 20:28:23 +09:00
Mike Hommey 91f0d70f6f Bug 1401099 - Move arena_malloc to a method of arena_t. r=njn
--HG--
extra : rebase_source : c06e3c5a63a12ba48f7f4bc52390ba9c8670f722
2017-09-15 19:20:09 +09:00
Mike Hommey cd573d5abc Bug 1401099 - Move arena_malloc_large to a method of arena_t. r=njn
--HG--
extra : rebase_source : 837d0d67556097140ff6141f2876fdbbb70d4e08
2017-09-15 19:14:00 +09:00
Mike Hommey 3576cd2578 Bug 1401099 - Move arena_malloc_small to a method of arena_t. r=njn
--HG--
extra : rebase_source : 7df0043060caf4cd14fc48428296428acf1771c7
2017-09-15 19:11:52 +09:00
Mike Hommey 2c4099f29f Bug 1401099 - Move arena_bin_nonfull_run_get to a method of arena_t. r=njn
--HG--
extra : rebase_source : 808f7ba52a4fc4f99a283ae894296cafac5166da
2017-09-15 18:23:33 +09:00
Mike Hommey 003004a71a Bug 1401099 - Move arena_bin_malloc_hard to a method of arena_t. r=njn
--HG--
extra : rebase_source : 2bed3221e38714d00ab95937d20ac5faafc89e9e
2017-09-15 18:20:11 +09:00
Mike Hommey 577b65d3c1 Bug 1401099 - Move arena_bin_malloc_easy to a method of arena_t. r=njn
--HG--
extra : rebase_source : 8675de21e7c79e3c458367f3f10b1331efe55094
2017-09-15 18:18:11 +09:00
Mike Hommey 0ec33d017f Bug 1401099 - Move arena_run_trim_tail to a method of arena_t. r=njn
--HG--
extra : rebase_source : e105fa4b8aae6b41c12e2f72293cdf68489a939d
2017-09-15 18:14:33 +09:00
Mike Hommey 3cc5f23c76 Bug 1401099 - Move arena_run_trim_head to a method of arena_t. r=njn
--HG--
extra : rebase_source : 2a2d2b9d454d69d0d1924f60d4771b39a1dddfb2
2017-09-15 18:11:12 +09:00
Mike Hommey b6e66b7b02 Bug 1401099 - Move arena_run_split to a method of arena_t. r=njn
--HG--
extra : rebase_source : 919dc2b9980ae59340553bcbfa029ba9c1bf9479
2017-09-15 18:08:23 +09:00
Mike Hommey 99d28b4355 Bug 1401099 - Move arena_run_dalloc to a method of arena_t. r=njn
--HG--
extra : rebase_source : 5cf37d39b6d8bdb591352051b3f37a2e3982dc69
2017-09-15 18:01:27 +09:00
Mike Hommey 7cb9914a15 Bug 1401099 - Move arena_run_alloc to a method of arena_t. r=njn
--HG--
extra : rebase_source : 6a683f4d0cf5ad68c670dbe8ea9d3a34acf11549
2017-09-15 17:57:11 +09:00
Mike Hommey d2ba03c881 Bug 1401099 - Move arena_chunk_dealloc to a method of arena_t. r=njn
--HG--
extra : rebase_source : 973b8764903f4e9c65aaaa053bb394a8a9ff2acb
2017-09-15 17:50:48 +09:00
Mike Hommey d6d578553d Bug 1401099 - Move arena_chunk_init to a method of arena_t. r=njn
--HG--
extra : rebase_source : d30e062f7117743a0c88fdf0325b0a395bff5658
2017-09-15 17:43:36 +09:00
Mike Hommey 11cfd193d1 Bug 1401099 - Move arena_new to a method of arena_t. r=njn
--HG--
extra : rebase_source : d0a9a0cebb4e8a1a74c5a48e42fb952310798604
2017-09-15 17:38:58 +09:00
Mike Hommey beb406f1a7 Bug 1401099 - Move hard_purge_arena to a method of arena_t. r=njn
--HG--
extra : rebase_source : af20d24ba0dd8ce6c9e42703688c1bca98594b4d
2017-09-15 17:34:53 +09:00
Mike Hommey a980219f16 Bug 1401099 - Move arena_purge to a method of arena_t. r=njn
--HG--
extra : rebase_source : d48623ce7ea7be5489c89a575bc1409de34e834a
2017-09-15 17:32:21 +09:00
Mike Hommey cb3efd88ef Bug 1401099 - Use Gecko style names for arena_t members. r=njn
--HG--
extra : rebase_source : cefcbc29323145557faed6c676867500c21c6ba4
2017-09-15 17:20:01 +09:00
Mike Hommey 707bc83a01 Bug 1401875 - Replace MALLOC_DECL_VOID with a clever use of templates. r=njn
This effectively means malloc_hook_table_t is now C++ only, which is not
a big problem.

This also makes some functions use a return construct with functions
that don't return a value (such as free). While that is not allowed in
ISO C, it's allowed in C++, so the simplification is welcome (although,
retrospectively, it turns out C compilers don't complain about it
without -pedantic).

--HG--
extra : rebase_source : defd88ca3f6d478e61a4b970393dba60fb6ca81d
2017-09-21 15:27:12 +09:00
Mike Hommey 4a2740def4 Bug 1401453 - Don't keep libmemory.a separate anymore. r=gps
This was done in bug 736564 for the xulrunner SDK, which later became
the firefox SDK, which is now gone. So we don't actually need to keep it
separate anymore (except for logalloc/replay, which still needs to link
it directly, so we keep the library definition intact so it can be
referenced ; we just don't DIST_INSTALL it anymore, and always make it
linked into mozglue)

--HG--
extra : rebase_source : e4d0627ec907fe0139df5c0b2b9f7d04b43c7c78
2017-09-20 14:23:57 +09:00
Sebastian Hengst bc68e8f407 merge mozilla-inbound to mozilla-central. r=merge a=merge
MozReview-Commit-ID: 9Z3Ly8icnvh
2017-09-20 11:48:02 +02:00
Mike Hommey 7bbdb00059 No bug - Remove a comment that has no significance after bug 1395776. r=me 2017-09-20 11:53:00 +09:00
Mike Hommey d4a847cce0 Bug 1401101 - Remove the generic replace-malloc library. r=njn
It is one of the moving parts when adding new memory allocation APIs.

It was added in bug 1168719 and the only thing that actually used it
was the sampling-based memory profiler, which was removed in bug
1385953. We however keep the replace-malloc bridge entry point so that
something else, in the future, may still provide the feature.

--HG--
extra : rebase_source : dd4a226171429e2a4ab5666b0873e7b945f161e6
2017-09-19 15:58:33 +09:00
Mike Hommey 078c8d1896 Bug 1399921 - Register zone allocator independently, and delay jemalloc initialization on mac. r=njn
In bug 1361258, we unified the initialization sequence on mac, and
chose to make the zone registration happen after jemalloc
initialization.

The order between jemalloc init and zone registration shouldn't actually
matter, because jemalloc initializes the first time the allocator is
actually used.

On the other hand, in some build setups (e.g. with light optimization),
the initialization of the thread_arena thread local variable can happen
after the forced jemalloc initialization because of the order the
corresponding static initializers run. In some levels of optimization,
the thread_arena initializer resets the value the jemalloc
initialization has set, which subsequently makes choose_arena() return
a bogus value (or hit an assertion in ThreadLocal.h on debug builds).

So instead of initializing jemalloc from a static initializer, which
then registers the zone, we instead register the zone and let jemalloc
initialize itself when used, which increases the chances of the
thread_arena initializer running first.

--HG--
extra : rebase_source : 4d9a5340d097ac8528dc4aaaf0c05bbef40b59bb
2017-09-15 07:34:48 +09:00
Mike Hommey 50182c9f53 Bug 1400146 - Gracefully handle the allocator not being initialized in isalloc_validate. r=njn
isalloc_validate is the function behind malloc_usable_size. If for some
reason malloc_usable_size is called before mozjemalloc is initialized,
this can lead to an unexpected crash.

The chance of this actually happening is rather slim on Linux
and Windows (although still possible), and impossible on Mac, due to the
fact the earlier something can end up calling it is after the
mozjemalloc zone is registered, which happens after initialization.

... except with bug 1399921, which reorders that initialization, and
puts the zone registration first. There's then a slim chance for the
zone allocator to call into zone_size, which calls malloc_usable_size,
to determine whether a pointer allocated by some other zone belongs to
mozjemalloc's.

And it turns out that does happen, during the startup of the
plugin-container process on OSX 10.10 (but not more recent versions).

--HG--
extra : rebase_source : 331d093b03add7b2c2ce440593f5aeccaaf4dd1f
2017-09-15 15:13:52 +09:00
Mike Hommey f3bff41d59 Bug 1400096 - Don't define the operator new/delete functions as mangled in mozmem_wrap.cpp. r=njn
Now that this is a C++ file, and that the function names are not
mangled, we can just use the actual C++ names.

We do however need to replace MOZ_MEMORY_API, which implies extern "C",
with MFBT_API.

Also use the correct type for the size given to operator new. It
happened to work before because the generated code would just jump to
malloc without touching any register, but on aarch64, unsigned int was
the wrong type.

--HG--
extra : rebase_source : 8045f30e9c609dd7d922c77d85ac017638df6961
2017-09-15 10:28:33 +09:00
Mike Hommey 9741c8e076 Bug 1400096 - Build mozmemory_wrap as C++. r=njn
And since the build system doesn't handle transitions from foo.c to
foo.cpp properly without a clobber, we work around the issue by
switching to unified sources.

--HG--
rename : memory/build/mozmemory_wrap.c => memory/build/mozmemory_wrap.cpp
extra : rebase_source : 3f074b4ccab255bb0eb16841f79582060fafbc86
2017-09-15 10:19:37 +09:00
Mike Hommey 747992864b Bug 1400096 - Annotate mozmemory_wrap.c windows functions as MOZ_MEMORY_API. r=njn
It happens to work because of mozglue.def, but we might as well have the
right annotations (which will also make things correct when building this
file to C++)

--HG--
extra : rebase_source : 61056dc21c9c29bab62ad5d648e94dd56dc53b14
2017-09-15 10:12:24 +09:00
Mike Hommey 57ecf449b4 Bug 1400096 - Remove mozmem_malloc_impl wrapping for operator methods exposed in mozmemory_wrap.c. r=njn
This used to be necessary because those functions might be prefixed with
__wrap_, and linked against with -Wl,--wrap, but that's not been the case
since bug 1077366. Furthermore, mozmem_malloc_impl nowadays only does
something on Windows, and those operators are only exposed on Android.

--HG--
extra : rebase_source : ca34442bfbc5fc8be20ffcfacb9afa0f2f818b82
2017-09-15 09:54:01 +09:00
Phil Ringnalda eab70d0a07 Backed out changeset 0e349b74bfc6 (bug 1399921) for failure to thrive on Mac
MozReview-Commit-ID: HoBhxzIzn2d
2017-09-14 20:36:41 -07:00
Mike Hommey c53e695a6e Bug 1399921 - Register zone allocator independently, and delay jemalloc initialization on mac. r=njn
In bug 1361258, we unified the initialization sequence on mac, and
chose to make the zone registration happen after jemalloc
initialization.

The order between jemalloc init and zone registration shouldn't actually
matter, because jemalloc initializes the first time the allocator is
actually used.

On the other hand, in some build setups (e.g. with light optimization),
the initialization of the thread_arena thread local variable can happen
after the forced jemalloc initialization because of the order the
corresponding static initializers run. In some levels of optimization,
the thread_arena initializer resets the value the jemalloc
initialization has set, which subsequently makes choose_arena() return
a bogus value (or hit an assertion in ThreadLocal.h on debug builds).

So instead of initializing jemalloc from a static initializer, which
then registers the zone, we instead register the zone and let jemalloc
initialize itself when used, which increases the chances of the
thread_arena initializer running first.

--HG--
extra : rebase_source : 4d9a5340d097ac8528dc4aaaf0c05bbef40b59bb
2017-09-15 07:34:48 +09:00
Mike Hommey e4f4d5fc59 Bug 1400063 - Automatically declare jemalloc_* functions in mozmemory.h. r=njn
There is a lot of churn involved in adding new API surface to
mozjemalloc, and mozmemory.h is one. Instead of declaring
everything manually in there, "generate" the declarations through
malloc_decls.h.

--HG--
extra : rebase_source : 1416fa972319c419112c4a8b16759d90692db5b2
2017-09-14 18:28:12 +09:00
Ryan VanderMeulen 277d6a438f Merge m-c to inbound. a=merge 2017-09-14 10:52:18 -04:00
Nathan Froyd f8fda5a9b5 Bug 1396889 - don't warn about infinite recursion in mozalloc_abort; r=glandium
mozalloc_abort is not marked as a noreturn function on ARM, so clang
complains when abort calls mozalloc_abort, which calls MOZ_CRASH, which
calls abort().  We know this is OK, so just disable the warning.
2017-09-14 09:52:50 -04:00
Mike Hommey 9f3c42a57e Bug 1397101 - Only use a thread local arena for small sizes. r=njn
The bin-unused count in memory reports indicates how much memory is
used by runs of small and sub-page allocations that is not actually
allocated. This is generally thought as an indicator of fragmentation.

While this is generally true, with the use of thread local arenas by
stylo, combined with how stylo allocates memory, it ends up also being
an indicator of wasted memory.

For instance, over the lifetime of an AWSY iteration, there are only a
few allocations that ends up in the bucket for 2048 allocated bytes. In
the "worst" case, there's only one. But the run size for such
allocations is 132KiB. Which means just because we're allocating one
buffer of size between 1024 and 2048 bytes, we end up wasting 130+KiB.
Per thread.

Something similar happens with size classes of 512 and 1024, where the
run size is respectively 32KiB and 64KiB, and where there's at most a
handful of allocations of each class ever happening per thread.

Overall, an allocation log from a full AWSY iteration reveals that there
are only 448 of 860700 allocations happening on the stylo arenas that
involve sizes above (and excluding) 512 bytes, so 0.05%.

While there are improvements that can be done to mozjemalloc so that it
doesn't waste more than one page per sub-page size class, they are
changes that are too low-level to land at this time of the release
cycle. However, considering the numbers above and the fact that the
stylo arenas are only really meant to avoid lock contention during the
heavy parallel work involved, a short term, low risk, strategy is to
just delegate all sub-page (> 512, < 4096) and large (>= 4096) to the
main arena. Technically speaking, only sub-page allocations are causing
this waste, but it's more consistent to just delegate everything above
512 bytes.

This should save 132KiB + 64KiB = 196KiB per stylo thread.

--HG--
extra : rebase_source : c7233d60305365e76aa124045b1c9492068d9415
2017-09-14 07:36:39 +09:00
Mike Hommey 965981b68d Bug 1397101 - Reduce the number of dirty pages we allow to be kept in thread local arenas. r=njn
Until bug 1361258, there was only ever one mozjemalloc arena, and the
number of dirty pages we allow to be kept dirty, fixed to 1MB per arena,
was, in fact, 1MB for an entire process.

With stylo using thread local arenas, we now can have multiple arenas
per process, multiplying that number of dirty pages.

While those dirty pages may be reused later on, when other allocations
end up filling them later on, the fact that a relatively large number of
them is kept around for each stylo thread (in proportion to the amount of
memory ever allocated by stylo), combined with the fact that the memory
use from stylo depends on the workload generated by the pages being
visited, those dirty pages may very well not be used for a rather long
time. This is less of a problem with the main arena, used for most
everything else.

So, for each arena except the main one, we decrease the number of dirty
pages we allow to be kept around to 1/8 of the current value. We do this
by introducing a per-arena configuration of that maximum number.

--HG--
extra : rebase_source : 75eebb175b3746d5ca1c371606cface50ec70f2f
2017-09-14 07:26:30 +09:00
Mike Hommey f98e560253 Bug 1399031 - Use mozilla/ThreadLocal.h in mozjemalloc. r=njn
--HG--
extra : rebase_source : 46e7abf6f46939cfa0862930feea5f245935b8d4
2017-09-12 16:29:11 +09:00
Mike Hommey 1e26a193e9 Bug 1399031 - Remove the setting of NO_TLS when PIC is not defined in mozjemalloc: it's always defined. r=njn
But it's also useless besides that test, so remove the PIC define.

--HG--
extra : rebase_source : 87b8934c1f8b6ed94e5ba3e2150f92dab9285769
2017-09-12 16:06:56 +09:00
Mike Hommey 05e3823899 Bug 1399350 - Remove jemalloc_*_impl macros. r=njn
Those macros are one more thing that needs to be added when the
mozjemalloc API surface is increased, but after bug 1399350, nothing
actually needs them, so remove them.

--HG--
extra : rebase_source : 2bf62cc6c179540482722a72b0d0c134d2ac2a19
2017-09-13 14:25:21 +09:00
Sebastian Hengst 6af41593df merge mozilla-central to mozilla-inbound. r=merge a=merge 2017-09-12 11:37:58 +02:00
Mike Hommey 6981b76dbc No bug - Remove the TODO item that was implemented in bug 1300948. r=me 2017-09-12 16:34:43 +09:00
Mike Hommey 8cdad036f1 Bug 1398965 - Fold memory/mozjemalloc into memory/build. r=njn
The files relevant to the memory allocator are currently spread between
memory/mozjemalloc and memory/build, and the distinction was
historically from sharing some Mozilla-specific things between
mozjemalloc and jemalloc3. That distinction is not useful anymore, so
we fold everything together.

As we will likely rename the allocator at some point in the future, it
is preferable to move away from the mozjemalloc directory rather than in
its direction.

--HG--
rename : memory/mozjemalloc/Makefile.in => memory/build/Makefile.in
rename : memory/mozjemalloc/mozjemalloc.cpp => memory/build/mozjemalloc.cpp
rename : memory/mozjemalloc/mozjemalloc.h => memory/build/mozjemalloc.h
rename : memory/mozjemalloc/mozjemalloc_types.h => memory/build/mozjemalloc_types.h
rename : memory/mozjemalloc/rb.h => memory/build/rb.h
2017-09-12 13:14:35 +09:00
Mike Hommey 175ddd015f Bug 1398965 - Remove MOZ_JEMALLOC_IMPL in favor of MOZ_MEMORY_IMPL. r=njn
In practice, they mean the same thing, and there's only one place where
MOZ_JEMALLOC_IMPL was used.
2017-09-12 13:06:43 +09:00
Mike Hommey be1493b6fc Bug 1396723 - Use DoublyLinkedList in mozjemalloc. r=froydnj
Mozjemalloc uses its own doubly linked list, which, being inherited from
C code, doesn't do much type checking, and, in practice, is rather
similar to DoublyLinkedList, so use the latter instead.

--HG--
extra : rebase_source : 9eb7334b6dde05f9af0eaea4184e532c69d0264e
2017-09-02 08:55:42 +09:00
Chris Manchester fab07bc443 Bug 1386876 - Replace all uses of NO_VISIBILITY_FLAGS with a template and remove NO_VISIBILITY_FLAGS. r=glandium
MozReview-Commit-ID: 194U1WMCAM0

--HG--
extra : rebase_source : 365b68b0a1772d238ae9b84966e53dcd1197fd85
2017-05-01 18:12:35 -07:00
Chris Manchester c0a229d4c3 Bug 1386876 - Replace all uses of DISABLE_STL_WRAPPING with a template, remove DISABLE_STL_WRAPPING. r=glandium
MozReview-Commit-ID: FMEtb5PY7iP

--HG--
extra : rebase_source : 3cdee7528846462c758e623d6bcd2e6e17dbabff
2017-09-11 11:33:26 -07:00
Nathan Froyd c88ec30451 Bug 1396892 - turn off -Wtautological-pointer-compare in memory/build/ for Android; r=njn
clang warns about this code in mozmemory_wrap.c in the reimplementation
of vasprintf, complaining that `fmt` cannot be null:

    if (str == NULL || fmt == NULL) {
                       ^~~    ~~~~

clang is apparently exploiting knowledge about the requirements of
vasprintf here, but defensive programming on the part of our
reimplementation seems like the wiser course.  Let's turn off the
warning.
2017-09-07 08:20:12 -04:00
Mike Hommey 938f8a3862 Bug 1396681 - Remove some typedefs in mozjemalloc. r=njn
Previously being a C codebase, mozjemalloc was using typedefs, avoiding
long "struct foo" uses. C++ doesn't need typedefs to achieve that, so we
can remove all that. We however keep a few typedefs in headers that are
still included from other C source files.

--HG--
extra : rebase_source : d0d807bcb76078c0ce36e4554b10803bfb36ddbb
2017-09-02 08:15:39 +09:00
Mike Hommey acb85e2b41 Bug 1396361 - Avoid crashing when some system library calls malloc_zone_free(zone, NULL). r=njn
Some system libraries call malloc_zone_free directly instead of free,
and sometimes they do that with the wrong zone. When that happens, we
circle back, trying to find the right zone, and call malloc_zone_free
with the right one, but when we can't find one, we crash, which matches
what the system free() would do. Except in one case where the pointer
we're being passed is NULL, in which case we can't trace it back to any
zone, but shouldn't crash (system free() explicitly doesn't crash in
that case).

--HG--
extra : rebase_source : 17efdcd80f1a53be7ab6b7293bfb6060a9aa4a48
2017-09-04 07:32:42 +09:00
Mike Hommey e8e9ecbd5d Bug 1395776 - Make _recalloc, _expand and _msize go through replace-malloc when enabled. r=njn
--HG--
extra : rebase_source : 454d6dc58681a9bde3564216d013746c0f189add
2017-08-31 14:17:49 +09:00
Mike Hommey 551fcf616e Bug 1395776 - Share the posix_memalign, aligned_alloc and valloc implementations between mozjemalloc and replace-malloc. r=njn
--HG--
extra : rebase_source : ed41b23993cdee89d28b835ee0ee196c15977427
2017-08-31 14:17:19 +09:00
Mike Hommey e77f51a721 Bug 1395776 - Fold replace-malloc into mozjemalloc. r=njn
Add the MPL 2.0 license header per bug 1395449.

--HG--
extra : rebase_source : c85544a178aba7e77b5b8031851b8e16b22a3848
2017-08-31 12:02:01 +09:00
Mike Hommey 24484e3284 Bug 1395776 - Remove useless goto. r=njn
--HG--
extra : rebase_source : 760898d1521d2c27658e0494677cfecd0375894f
2017-08-31 11:47:22 +09:00
Mike Hommey 89443bb39f Bug 1395776 - Add a level of indirection on top of mozjemalloc. r=njn
Practically speaking, with code inlining, this doesn't change anything,
but will allow, in a subsequent change, to easily divert the exported
allocation functions (malloc, etc.) in order to inject replace-malloc
in the pipeline.

The added macro magic is copied from replace-malloc.c.

At the same time, reformat the functions we're touching.

--HG--
extra : rebase_source : f615909101f832f3cc471e23a3cc44a60886843f
2017-08-31 10:29:11 +09:00
Mike Hommey dfc6786a68 Bug 1395776 - Move usable_ptr_t definition to mozjemalloc_types.h. r=njn
Because malloc_decls.h is meant to be included multiple times, it
shouldn't actually declare things itself.

--HG--
extra : rebase_source : 9d6f9b2c61407265377845963a19ace2614160f4
2017-08-31 09:51:23 +09:00
Mike Hommey 72d9b36a8c Bug 1395776 - Uniformize valloc implementations in replace-malloc and mozjemalloc. r=njn
valloc is supposed to page-align data, but mozjemalloc's definition of
pagesize is statically compiled in and might not match the actual page
size at runtime (because of MALLOC_STATIC_SIZES). We change valloc in
mozjemalloc to use the runtime page size.

--HG--
extra : rebase_source : c5b1b56e783b311ac1620a87d910e019e3f18b49
2017-08-31 11:36:09 +09:00
Mike Hommey b0303d9e77 Bug 1395776 - Uniformize posix_memalign implementations in replace-malloc and mozjemalloc. r=njn
--HG--
extra : rebase_source : bbbee18feef2d11b71d5d5a48e98017bfae78722
2017-08-31 11:35:24 +09:00
Sebastian Hengst 43bc951ac7 merge mozilla-inbound to mozilla-central. r=merge a=merge
MozReview-Commit-ID: ES9rKhiQo10
2017-09-01 10:38:51 +02:00
Nicholas Nethercote c419d5fa48 Bug 1389305 (attempt 2) - Add jemalloc_ptr_info() and moz_malloc_enclosing_size_of(). r=glandium.
--HG--
extra : rebase_source : 93a6cfcc916fb239581c2892f24b24c6fc65ac71
2017-09-01 11:52:23 +10:00
Mike Hommey 01f5dbf93d Bug 1395070 - Replace MOZ_MEMORY_BSD with __FreeBSD_kernel__. r=njn
While MOZ_MEMORY_BSD is set for kFreeBSD, FreeBSD and NetBSD, the only
use of MOZ_MEMORY_BSD is along a check for __GLIBC__ which can only be
true on GNU/kFreeBSD, which doesn't have a XP_ macro, but which we
usually match with __FreeBSD_kernel__.

--HG--
extra : rebase_source : 2f143f8ed641f4e338024a58e20c62b2b30e653a
2017-08-30 16:58:42 +09:00
Mike Hommey 214207b152 Bug 1395070 - Replace MOZ_MEMORY_SOLARIS with XP_SOLARIS. r=njn
--HG--
extra : rebase_source : 5ce65228f7d45da354f6447b3e54781a8553e33b
2017-08-30 16:57:46 +09:00
Mike Hommey c5dc8a36e4 Bug 1395070 - Replace MOZ_MEMORY_ANDROID with ANDROID. r=njn
For some reason, we don't have a XP_ macro for Android, and we generally use
ANDROID or MOZ_WIDGET_ANDROID. The former is more appropriate.

--HG--
extra : rebase_source : 50576584f194aaf6b090fd530598ce9954e170b3
2017-08-30 16:56:42 +09:00
Mike Hommey c50122ffb7 Bug 1395070 - Replace MOZ_MEMORY_LINUX with XP_LINUX. r=njn
--HG--
extra : rebase_source : 013c8019777cd87663e60def10a2df549c9308a2
2017-08-30 16:55:30 +09:00
Mike Hommey 2367bdac74 Bug 1395070 - Replace MOZ_MEMORY_DARWIN with XP_DARWIN. r=njn
--HG--
extra : rebase_source : 9e92062072cc45c524d30e9b2e28930687bf45a4
2017-08-30 16:54:17 +09:00
Mike Hommey e290647690 Bug 1395070 - Replace MOZ_MEMORY_WINDOWS with XP_WIN. r=njn
--HG--
extra : rebase_source : 1c63dca430aa6c81472463d27df41f2acdc2df88
2017-08-30 16:53:10 +09:00
Mike Hommey 57c65279a0 Bug 1395088 - Remove the jemalloc_bool type. r=njn
Back when it was added (for Windows CE, in bug 488608), mozjemalloc was
C and all the supported compilers didn't support C99 bools. Now
mozjemalloc is C++, and all the supported compilers support C99 bools
for the cases where the type is used from C.

--HG--
extra : rebase_source : b9c710a0c48dc36cb473af59e3119131d13523ce
2017-08-30 18:04:47 +09:00
Mike Hommey 0eb2652011 Bug 1395063 - Use MOZ_CRASH directly in mozjemalloc. r=njn
Back when mozjemalloc was considered third-party, and before bug
1365194, mozjemalloc was calling abort() and that was redirectory to
MOZ_CRASH through a moz_abort() function. Bug 1365194 changed that so
that moz_abort is called directly instead of abort, but the indirection
is actually not necessary anymore.

So we just kill moz_abort, which is unused anywhere else, and use
MOZ_CRASH directly.

Note this will (obviously) change crash signatures involving moz_abort.

--HG--
extra : rebase_source : 67698ffd8c5e52e62b9a0b7f28efb0352c8fe8ce
2017-08-30 16:20:08 +09:00
Sylvestre Ledru 64ca35fefe Bug 1387572 - Silent the -Wuninitialized warning r=glandium
MozReview-Commit-ID: DjUumKhNQHz

--HG--
extra : rebase_source : 5bec2af822a54ff2c40b5944d3360b7c889c5ccb
2017-08-04 21:51:18 +02:00
Tom Ritter 1243cb04e0 Bug 1392594 Make variable DebugOnly to address unused variable warning r=glandium
MozReview-Commit-ID: 1qQQGjeWeel

--HG--
extra : rebase_source : f527762cc8d0b572c5315d2a6a11db8e69fbc999
2017-08-24 22:55:35 -05:00