Commit Graph
260 Commits
Author SHA1 Message Date
Emanuel Hoogeveen a8d4a08a29 Bug 1405159 - Assert against freeing incorrectly offset pointers. r=glandium 2017-10-02 15:39:00 -04:00
Jan Keromnes bb8d8c9779 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 5182c9ae3d Bug 1403843 - Disable static sizes on debug builds. r=njn
Because why not, especially now that this only concerns the page size.
2017-09-28 15:15:23 +09:00
Mike Hommey 176c546eb6 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.
2017-09-28 15:27:59 +09:00
Mike Hommey 692ab6f0a3 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.
2017-09-28 11:27:43 +09:00
Mike Hommey b5cfaca116 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)
2017-09-28 08:06:23 +09:00
Mike Hommey 7e2a2bca6e 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.
2017-09-28 08:28:52 +09:00
Mike Hommey e23eb61053 Bug 1403765 - Use native TLS in the allocator on Windows. r=njn 2017-09-25 06:47:44 +09:00
Mike Hommey 53757597bf Bug 1403444 - Remove typedefs for RedBlackTrees. r=njn 2017-09-28 06:58:37 +09:00
Mike Hommey 4a90d13141 Bug 1403444 - Rename the RedBlackTree member variables. r=njn 2017-09-27 16:11:11 +09:00
Mike Hommey 98b4823fe6 Bug 1403444 - Add a helper class to avoid the tree traversal code having to use Trait::GetTreeNode noisily. r=njn 2017-09-27 16:07:22 +09:00
Mike Hommey 86dca6ded3 Bug 1403444 - Replace the rb_foreach_* macros with a range iterator. r=njn 2017-09-27 15:25:19 +09:00
Mike Hommey e1a50a9503 Bug 1403444 - Remove rbp_f_synced. r=njn
Bug 1365460 removed the macros that used it.
2017-09-27 13:50:50 +09:00
Mike Hommey 59fa5865a1 Bug 1403444 - Replace rbp_move_red_left and rbp_move_red_right with private methods. r=njn 2017-09-26 21:21:13 +09:00
Mike Hommey 39aa5dbdaf Bug 1403444 - Replace rbp_lean_left and rbp_lean_right with private methods. r=njn 2017-09-26 21:14:12 +09:00
Mike Hommey 21be374bf1 Bug 1403444 - Replace rbp_rotate_left and rbp_rotate_right with private methods. r=njn 2017-09-26 21:08:29 +09:00
Mike Hommey 04a93a4b7f Bug 1403444 - Expand rb_remove. r=njn
At the same time, simplify the expanded code to better fit in the
template.
2017-09-26 17:13:53 +09:00
Mike Hommey 6e8bfeb217 Bug 1403444 - Expand rb_insert. r=njn
At the same time, simplify the expanded code to better fit in the
template.
2017-09-26 17:07:35 +09:00
Mike Hommey 9ec3f2abf5 Bug 1403444 - Expand rbp_first and rbp_last. r=njn
At the same time, simplify the expanded code to better fit in the
template.
2017-09-26 16:59:02 +09:00
Mike Hommey 98e3089b7f Bug 1403444 - Allow First and Last to take a start node, and use that in Next and Prev. r=njn 2017-09-26 16:55:31 +09:00
Mike Hommey 5100c87e31 Bug 1403444 - Expand rb_search and rb_nsearch. r=njn
At the same time, simplify the expanded code to better fit in the
template.
2017-09-26 16:46:43 +09:00
Mike Hommey 0f3cde0d7d Bug 1403444 - Expand rbp_next and rbp_prev. r=njn
At the same time, simplify the expanded code to better fit in the
template.
2017-09-26 16:39:03 +09:00
Mike Hommey 2d5b527d24 Bug 1403444 - Trivially expand rb_node_field. r=njn
Also replace `a_field((foo))` with `a_field(foo)` in the resulting code.
2017-09-26 16:36:24 +09:00
Mike Hommey 0f7175a868 Bug 1403444 - Expand rbp_node_new. r=njn
At the same time, simplify the expanded code to better fit in the
template.
2017-09-26 16:00:27 +09:00
Mike Hommey 13721ae05c 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.
2017-09-26 15:47:50 +09:00
Mike Hommey 4a9948582c Bug 1403444 - Add methods to the RedBlackTree template class, replacing rb_wrap. r=njn 2017-09-26 15:06:00 +09:00
Mike Hommey 7d59774209 Bug 1403444 - Move miscellaneous size related constants and macros earlier in mozjemalloc.cpp. r=njn 2017-09-26 09:08:00 +09:00
Mike Hommey f1b5aca306 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)
2017-09-27 08:54:49 +09:00
Mike Hommey 46184b79d0 Bug 1403444 - Trivially expand rbp_{color,red,black}_set. r=njn 2017-09-25 10:03:56 +09:00
Mike Hommey 3dac762d6a Bug 1403444 - Trivially expand rbp_right_set. r=njn 2017-09-25 10:05:07 +09:00
Mike Hommey 53403d3f96 Bug 1403444 - Trivially expand rbp_left_set. r=njn 2017-09-25 10:04:32 +09:00
Mike Hommey 6990d4f748 Bug 1403444 - Trivially expand rbp_red_get. r=njn 2017-09-25 10:02:48 +09:00
Mike Hommey 49c8dcb1fd Bug 1403444 - Trivially expand rbp_right_get. r=njn 2017-09-25 10:02:22 +09:00
Mike Hommey 541bc1f2c0 Bug 1403444 - Trivially expand rbp_left_get. r=njn 2017-09-25 10:02:06 +09:00
Mike Hommey f5b13c424d 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.
2017-09-25 07:03:37 +09:00
Mike Hommey ae052f0676 Bug 1403444 - Apply clang-format to the rb.h macros. r=njn 2017-09-25 06:59:30 +09:00
Mike Hommey 5205e2f2e7 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.
2017-09-25 06:57:09 +09:00
Mike Hommey 2f8baea92a 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.
2017-09-03 06:49:39 +09:00
Mike Hommey 882cf56ee0 Bug 1403444 - Add getters and setters on RedBlackTreeNode. r=njn 2017-09-02 20:26:09 +09:00
Mike Hommey 00648dfc3d Bug 1403444 - Use templates for rb_node and rb_tree, and rename them. r=njn 2017-09-02 09:05:13 +09:00
Mike Hommey f2492cd5a0 Bug 1402647 - Add a memalign implementation on platforms that don't have one. r=njn 2017-09-26 06:59:03 +09:00
Mike Hommey b002191018 Bug 1402647 - Add missing stdlib.h header for system allocator. r=njn 2017-09-26 06:58:05 +09:00
Mike Hommey 45961cad4c 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.
2017-09-21 14:24:37 +09:00
Mike Hommey 27996b654b Bug 1402174 - Add a helper class implementing the base allocator functions for a given arena. r=njn 2017-09-21 14:24:37 +09:00
Mike Hommey cafee5ac7d Bug 1402174 - Add an arena argument to imalloc, ipalloc and iralloc. r=njn 2017-09-21 13:58:17 +09:00
Mike Hommey 945ee08362 Bug 1402174 - Merge imalloc and icalloc into a single function. r=njn 2017-09-21 13:23:22 +09:00
Mike Hommey 7909f391e0 Bug 1402174 - Move AlignedAllocator around, so that calloc, realloc and free and grouped with malloc and memalign. r=njn 2017-09-21 11:46:57 +09:00
Sebastian Hengst bbe81b9cf5 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 dd6ecc8400 Backed out changeset 5bba0584a7d8 (bug 1402174) 2017-09-22 16:47:25 +02:00
Sebastian Hengst f19e7931b4 Backed out changeset e356ac32e297 (bug 1402174) 2017-09-22 16:47:19 +02:00