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

1167 Коммитов

Автор SHA1 Сообщение Дата
Mike Hommey 1329eac959 Bug 1414168 - Split the condition for the main arena_bin_run_size_calc loop into pieces. r=njn
This is, practically speaking, a no-op, and will hopefully help make the
following changes clearer.

--HG--
extra : rebase_source : b704bdf2ae46c2408e0061363822b9744ef449cb
2017-11-07 07:42:21 +09:00
Mike Hommey 5a60492a53 Bug 1414155 - Define AddressRadixTree node size as a size rather than a power of 2. r=njn
--HG--
extra : rebase_source : 03799ccb0d5ba7c627cd3652777b56b7ae26b942
2017-11-03 13:50:44 +09:00
Mike Hommey 020ff16947 Bug 1414155 - Replace constants describing size class numbers. r=njn
--HG--
extra : rebase_source : 11b479c2928a236ecea94b1bc76497dee717a0b3
2017-11-03 12:21:53 +09:00
Mike Hommey a079c13bb9 Bug 1414155 - Rename chunk related constants. r=njn
--HG--
extra : rebase_source : f458cecab13bc2c9c78685eee670f76e2908d3dc
2017-11-03 12:16:11 +09:00
Mike Hommey 0cd74597a7 Bug 1414155 - Rename page size related constants. r=njn
--HG--
extra : rebase_source : db6b040ca046e350284f6a2aece2c1d1fa3c4ee4
2017-11-03 12:13:17 +09:00
Mike Hommey 89805eb175 Bug 1414155 - Replace chunk size related macros and constants. r=njn
--HG--
extra : rebase_source : 4e445e489148873f141de71d3a6ffd701e14f340
2017-11-03 12:07:16 +09:00
Mike Hommey 91ec9d43c0 Bug 1414155 - Replace size class related macros and constants. r=njn
Hopefully, this makes things a little clearer.

--HG--
extra : rebase_source : cc36c52bfb00bf1b46488e496eb524a9dc46a3e5
2017-11-03 10:10:50 +09:00
Mike Hommey 18e7756799 Bug 1414155 - Remove SIZE_INV values for QUANTUM_2POW_MIN < 4. r=njn
QUANTUM_2POW_MIN is exactly 4, and we are unlikely to ever make it
smaller. Also turn a MOZ_ASSERT into a static_assert, because it only
uses constants, and will fail if QUANTUM_2POW_MIN is lowered without
touching size_invs.

--HG--
extra : rebase_source : 7c8ee3c0ea30a88bddba816c41c6f63914f7a03c
2017-11-03 11:41:30 +09:00
Mike Hommey b4b9a5993f Bug 1414155 - Replace the cacheline-related macros with a constant. r=njn
--HG--
extra : rebase_source : 571145f154478b1703be44b73b8562de7973d788
2017-11-01 19:34:41 +09:00
Mike Hommey 26674ebcb7 Bug 1414155 - Consolidate "constant/globals". r=njn
There is a set of "constants" that are actually globals that depend on
the page size that we get at runtime, when compiling without
MALLOC_STATIC_PAGESIZE, but that are actual constants when compiling
with it. Their value was unfortunately duplicated.

We setup a set of macros allowing to make the declarations unique.

--HG--
extra : rebase_source : 56557b7ba01ee60fe85f2cd3c2a0aa910c4c93c6
2017-11-01 18:33:24 +09:00
Mike Hommey 6b7f782847 Bug 1414155 - Define pagesize_2pow in terms of pagesize, not the opposite. r=njn
At the same time, add user-defined literals to make those constants more
legible.

--HG--
extra : rebase_source : ce143ad9d8a6603179042d8cf432f00c815156c5
2017-11-01 18:07:06 +09:00
Mike Hommey 273538b95c Bug 1414155 - Move arena_chunk_map_t and arena_chunk_t around. r=njn
At the moment, while they are used before their declaration, it's from a
macro. It is desirable to replace the macros with C++ constants, which
will require the structures being defined first.

--HG--
extra : rebase_source : 7a351dafea04a7d75b6eec50fa52fb49c135e569
2017-11-01 17:54:31 +09:00
Mike Hommey 1c4a4f48fa Bug 1414155 - Factor out size classes logic for tiny, quantum and sub-page classes. r=njn
We create a new helper class that rounds up allocations sizes and
categorizes them. Compilers are smart enough to elide what they don't
need, like in malloc_good_size, they elide the code related to the
class type enum.

--HG--
extra : rebase_source : 61381e600587b045e720a85a7b46673edeb691b9
2017-11-03 08:53:34 +09:00
Mike Hommey 161c7d7841 Bug 1414155 - Move a few things around. r=njn
--HG--
extra : rebase_source : 11049459c8318e1a9f1cf535dfbce115bf57f918
2017-11-01 19:29:36 +09:00
Mike Hommey 66867e7f34 Bug 1414073 - Rename arena_bin_t fields. r=njn
At the same time, fold malloc_bin_stats_t into it.

--HG--
extra : rebase_source : 38c6a194d100783ecd0f769952de7bb4f71f17b0
2017-11-03 09:26:07 +09:00
Mike Hommey 8f8239d7bf Bug 1413570 - Disable SSE2 when building mozjemalloc on x86 during PGO profile gen phase. r=froydnj
Because of alignment issues due to the system glibc when running the
SSE2 gcov code generated during the PGO profile gen phase, Firefox
crashes when running the PGO profile. We work around the issue by
disabling SSE2 when building mozjemalloc during that phase. That
shouldn't affect the coverage data anyways, which is bound to the
original C++ code, and the profile-use code generation will still emit
SSE2 based on the coverage data if it needs to.

--HG--
extra : rebase_source : 3596fdc795cdef0789f3a2dd8f10b42cde00430f
2017-11-02 10:26:49 +09:00
Mike Hommey eab43e4a6c Bug 1413475 - Run clang-format on all files in memory/build/. r=njn
--HG--
extra : rebase_source : a0a7ebff22c2387389d2f1dc75f8a5084f76ebb7
2017-11-01 17:20:54 +09:00
Mike Hommey af14262e54 Bug 1413475 - Change comments to use C++ style // instead of /* */ in memory/build/. r=njn
--HG--
extra : rebase_source : 8d8b85e8123f414cb1e0e1eb067e0d198b3ebb8f
2017-11-01 17:15:12 +09:00
Mike Hommey 1de1ed32d0 Bug 1413475 - Normalize license boilerplates in memory/build/. r=njn
--HG--
extra : rebase_source : 9689f766211fbe1476c5e6d4774f1e95bb8e0208
2017-11-01 16:56:27 +09:00
Mike Hommey f081d2458b Bug 1413475 - Replace SIZEOF_INT_2POW with LOG2(sizeof(int)). r=njn
--HG--
extra : rebase_source : f1add73810649c8b12e2ee139528fad9186fc20b
2017-11-01 16:47:59 +09:00
Mike Hommey d07b1b083f Bug 1413475 - Inline STRERROR_BUF in mozjemalloc.cpp. r=njn
It is only used once.

--HG--
extra : rebase_source : 044e7d8ac3e6db834702ab8aedae9b44112d2932
2017-11-01 16:46:44 +09:00
Mike Hommey 7b9d775493 Bug 1413475 - Remove unused MAP_NOSYNC definition in mozjemalloc.cpp. r=njn
--HG--
extra : rebase_source : 95c760647b1c97accfb044961aae6ae1f2113f8e
2017-11-01 16:45:40 +09:00
Mike Hommey a71adf8fd9 Bug 1413475 - Move MALLOC_DECOMMIT definition closer to that of MALLOC_DOUBLE_PURGE. r=njn
--HG--
extra : rebase_source : 41e4dc84269dfa47c9b7daf4ab587dd41c7eb290
2017-11-01 16:45:24 +09:00
Mike Hommey 485f23d7b1 Bug 1413475 - Reorganize #includes in mozjemalloc.cpp. r=njn
--HG--
extra : rebase_source : 8b03bba78544e1980802c5c7e92ecead738e0408
2017-11-01 16:10:24 +09:00
Mike Hommey 66579f53a7 Bug 1413475 - Inline _CRT_SPINCOUNT in mozjemalloc.cpp. r=njn
It is only used once.

--HG--
extra : rebase_source : 589c078fac563f7e7f057e3a2904970126b6a4b9
2017-11-01 16:06:28 +09:00
Mike Hommey 36809628ea Bug 1413475 - Remove ssize_t definition from mozjemalloc.cpp. r=njn
The only use of ssize_t in mozjemalloc was removed in bug 1403444.

--HG--
extra : rebase_source : 98dde18a08a9a64b2b61698c43cbf3fc7eb74b5d
2017-11-01 15:51:06 +09:00
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