Commit Graph
64 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
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 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 86dca6ded3 Bug 1403444 - Replace the rb_foreach_* macros with a range iterator. r=njn 2017-09-27 15:25:19 +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 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 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 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
Sebastian Hengst 34929afc2d Backed out changeset c589ad71d9ca (bug 1402174) 2017-09-22 16:47:14 +02:00
Sebastian Hengst d027eb0845 Backed out changeset b23c870c7e45 (bug 1402174) 2017-09-22 16:47:08 +02:00
Mike Hommey 70b6083d81 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 1939c8a130 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 e4cb8a67a2 Bug 1402174 - Add an arena argument to imalloc, ipalloc and iralloc. r=njn 2017-09-21 13:58:17 +09:00
Mike Hommey dc6860cfde Bug 1402174 - Merge imalloc and icalloc into a single function. r=njn 2017-09-21 13:23:22 +09:00
Mike Hommey 7a5ac194ce 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
Mike Hommey d036245c15 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.
2017-09-22 07:22:38 +09:00
Mike Hommey 684ed0f653 Bug 1052573 - Move macro helpers to mozjemalloc.h. r=njn 2017-09-21 14:10:06 +09:00
Mike Hommey 73f9951cff Bug 1401099 - Move arena_ralloc_large_grow to a method of arena_t. r=njn 2017-09-15 20:50:42 +09:00
Mike Hommey d2575a825a Bug 1401099 - Move arena_ralloc_large_shrink to a method of arena_t. r=njn 2017-09-15 20:44:34 +09:00
Mike Hommey 490a84c096 Bug 1401099 - Move arena_dalloc_large to a method of arena_t. r=njn 2017-09-15 20:40:36 +09:00
Mike Hommey baabef673e Bug 1401099 - Move arena_dalloc_small to a method of arena_t. r=njn 2017-09-15 20:37:47 +09:00
Mike Hommey 1370b42a13 Bug 1401099 - Move arena_palloc to a method of arena_t. r=njn 2017-09-15 20:28:23 +09:00
Mike Hommey 2f008c4df6 Bug 1401099 - Move arena_malloc to a method of arena_t. r=njn 2017-09-15 19:20:09 +09:00
Mike Hommey 11b51f7c56 Bug 1401099 - Move arena_malloc_large to a method of arena_t. r=njn 2017-09-15 19:14:00 +09:00
Mike Hommey cb98a89586 Bug 1401099 - Move arena_malloc_small to a method of arena_t. r=njn 2017-09-15 19:11:52 +09:00
Mike Hommey 591daa64f3 Bug 1401099 - Move arena_bin_nonfull_run_get to a method of arena_t. r=njn 2017-09-15 18:23:33 +09:00
Mike Hommey 9603d50cf6 Bug 1401099 - Move arena_bin_malloc_hard to a method of arena_t. r=njn 2017-09-15 18:20:11 +09:00
Mike Hommey d85dae9ac2 Bug 1401099 - Move arena_bin_malloc_easy to a method of arena_t. r=njn 2017-09-15 18:18:11 +09:00
Mike Hommey 2ea3ca0d1e Bug 1401099 - Move arena_run_trim_tail to a method of arena_t. r=njn 2017-09-15 18:14:33 +09:00
Mike Hommey 731d31bbf9 Bug 1401099 - Move arena_run_trim_head to a method of arena_t. r=njn 2017-09-15 18:11:12 +09:00
Mike Hommey 6ef9686795 Bug 1401099 - Move arena_run_split to a method of arena_t. r=njn 2017-09-15 18:08:23 +09:00
Mike Hommey faf1748d86 Bug 1401099 - Move arena_run_dalloc to a method of arena_t. r=njn 2017-09-15 18:01:27 +09:00
Mike Hommey 2dbc0d3b60 Bug 1401099 - Move arena_run_alloc to a method of arena_t. r=njn 2017-09-15 17:57:11 +09:00
Mike Hommey 31597134b1 Bug 1401099 - Move arena_chunk_dealloc to a method of arena_t. r=njn 2017-09-15 17:50:48 +09:00
Mike Hommey 67e81acc3a Bug 1401099 - Move arena_chunk_init to a method of arena_t. r=njn 2017-09-15 17:43:36 +09:00
Mike Hommey 64a2c7f781 Bug 1401099 - Move arena_new to a method of arena_t. r=njn 2017-09-15 17:38:58 +09:00
Mike Hommey 5fa52755ea Bug 1401099 - Move hard_purge_arena to a method of arena_t. r=njn 2017-09-15 17:34:53 +09:00