summaryrefslogtreecommitdiffstats
path: root/src/zone.c
Commit message (Collapse)AuthorAgeFilesLines
* Header refactoring: Pull size helpers out of jemalloc module.David Goldblatt2017-05-311-1/+1
|
* Header refactoring: move assert.h out of the catch-allDavid Goldblatt2017-04-191-0/+3
|
* Header refactoring: Split up jemalloc_internal.hDavid Goldblatt2017-04-111-1/+2
| | | | | | | | | | | | | | This is a biggy. jemalloc_internal.h has been doing multiple jobs for a while now: - The source of system-wide definitions. - The catch-all include file. - The module header file for jemalloc.c This commit splits up this functionality. The system-wide definitions responsibility has moved to jemalloc_preamble.h. The catch-all include file is now jemalloc_internal_includes.h. The module headers for jemalloc.c are now in jemalloc_internal_[externs|inlines|types].h, just as they are for the other modules.
* Remove extraneous parens around return arguments.Jason Evans2017-01-211-10/+10
| | | | This resolves #540.
* Update brace style.Jason Evans2017-01-211-58/+38
| | | | | | | Add braces around single-line blocks, and remove line breaks before function-opening braces. This resolves #537.
* Add dummy implementations for most remaining OSX zone allocator functionsMike Hommey2017-01-181-10/+108
| | | | | | | | | | | | | | | | | | | | | | | | | Some system libraries are using malloc_default_zone() and then using some of the malloc_zone_* API. Under normal conditions, those functions check the malloc_zone_t/malloc_introspection_t struct for the values that are allowed to be NULL, so that a NULL deref doesn't happen. As of OSX 10.12, malloc_default_zone() doesn't return the actual default zone anymore, but returns a fake, wrapper zone. The wrapper zone defines all the possible functions in the malloc_zone_t/malloc_introspection_t struct (almost), and calls the function from the registered default zone (jemalloc in our case) on its own. Without checking whether the pointers are NULL. This means that a system library that calls e.g. malloc_zone_batch_malloc(malloc_default_zone(), ...) ends up trying to call jemalloc_zone.batch_malloc, which is NULL, and crash follows. So as of OSX 10.12, the default zone is required to have all the functions available (really, the same as the wrapper zone), even if they do nothing. This is arguably a bug in libsystem_malloc in OSX 10.12, but jemalloc still needs to work in that case.
* Don't rely on OSX SDK malloc/malloc.h for malloc_zone struct definitionsMike Hommey2017-01-181-36/+86
| | | | | | | | | | The SDK jemalloc is built against might be not be the latest for various reasons, but the resulting binary ought to work on newer versions of OSX. In order to ensure this, we need the fullest definitions possible, so copy what we need from the latest version of malloc/malloc.h available on opensource.apple.com.
* Remove leading blank lines from function bodies.Jason Evans2017-01-131-11/+0
| | | | This resolves #535.
* Fix/refactor zone allocator integration code.Jason Evans2016-11-031-84/+107
| | | | | | | | | Fix zone_force_unlock() to reinitialize, rather than unlocking mutexes, since OS X 10.12 cannot tolerate a child unlocking mutexes that were locked by its parent. Refactor; this was a side effect of experimenting with zone {de,re}registration during fork(2).
* Formatting fixes.Jason Evans2016-09-261-9/+12
|
* Change how the default zone is foundMike Hommey2016-07-081-2/+29
| | | | | | | | | | | | On OSX 10.12, malloc_default_zone returns a special zone that is not present in the list of registered zones. That zone uses a "lite zone" if one is present (apparently enabled when malloc stack logging is enabled), or the first registered zone otherwise. In practice this means unless malloc stack logging is enabled, the first registered zone is the default. So get the list of zones to get the first one, instead of relying on malloc_default_zone.
* Avoid getting the same default zone twice in a row.Mike Hommey2016-07-081-2/+3
| | | | | | | | | | | 847ff22 added a call to malloc_default_zone() before the main loop in register_zone, effectively making malloc_default_zone() called twice without any different outcome expected in the returned result. It is also called once at the beginning, and a second time at the end of the loop block. Instead, call it only once per iteration.
* Miscellaneous s/chunk/extent/ updates.Jason Evans2016-06-061-1/+1
|
* Use huge size class infrastructure for large size classes.Jason Evans2016-06-061-4/+4
|
* Resolve bootstrapping issues when embedded in FreeBSD libc.Jason Evans2016-05-111-4/+4
| | | | | | | | | | | | | b2c0d6322d2307458ae2b28545f8a5c9903d7ef5 (Add witness, a simple online locking validator.) caused a broad propagation of tsd throughout the internal API, but tsd_fetch() was designed to fail prior to tsd bootstrapping. Fix this by splitting tsd_t into non-nullable tsd_t and nullable tsdn_t, and modifying all internal APIs that do not critically rely on tsd to take nullable pointers. Furthermore, add the tsd_booted_get() function so that tsdn_fetch() can probe whether tsd bootstrapping is complete and return NULL if not. All dangerous conversions of nullable pointers are tsdn_tsd() calls that assert-fail on invalid conversion.
* Add witness, a simple online locking validator.Jason Evans2016-04-141-4/+4
| | | | This resolves #358.
* Reuse previously computed valueDmitry-Me2015-11-121-2/+4
|
* Style and spelling fixes.Jason Evans2014-12-091-1/+1
|
* Whitespace cleanups.Jason Evans2014-09-051-7/+7
|
* Ensure the default purgeable zone is after the default zone on OS XMike Hommey2014-06-101-9/+25
|
* Prefer not_reached() over assert(false) where appropriate.Jason Evans2013-10-211-1/+1
|
* Don't register jemalloc's zone allocator if something else already replaced ↵Mike Hommey2012-11-071-1/+11
| | | | the system default zone
* Implement Valgrind support, redzones, and quarantine.Jason Evans2012-04-111-5/+5
| | | | | | | | | | | | | Implement Valgrind support, as well as the redzone and quarantine features, which help Valgrind detect memory errors. Redzones are only implemented for small objects because the changes necessary to support redzones around large and huge objects are complicated by in-place reallocation, to the point that it isn't clear that the maintenance burden is worth the incremental improvement to Valgrind support. Merge arena_salloc() and arena_salloc_demote(). Refactor i[v]salloc() to expose the 'demote' option.
* Clean up *PAGE* macros.Jason Evans2012-04-021-1/+1
| | | | | | | | | | | s/PAGE_SHIFT/LG_PAGE/g and s/PAGE_SIZE/PAGE/g. Remove remnants of the dynamic-page-shift code. Rename the "arenas.pagesize" mallctl to "arenas.page". Remove the "arenas.chunksize" mallctl, which is redundant with "opt.lg_chunk".
* Move last bit of zone initialization in zone.c, and lazy-initializeMike Hommey2012-04-021-0/+1
|
* Avoid crashes when system libraries use the purgeable zone allocatorMike Hommey2012-03-301-5/+26
|
* Move zone registration to zone.cMike Hommey2012-03-301-3/+19
|
* Make zone_{free, realloc, free_definite_size} fallback to the system ↵Mike Hommey2012-03-261-4/+17
| | | | | | | | | | | | allocator if they are called with a pointer that jemalloc didn't allocate It turns out some OSX system libraries (like CoreGraphics on 10.6) like to call malloc_zone_* functions, but giving them pointers that weren't allocated with the zone they are using. Possibly, they do malloc_zone_malloc(malloc_default_zone()) before we register the jemalloc zone, and malloc_zone_realloc(malloc_default_zone()) after. malloc_default_zone() returning a different value in both cases.
* Improve zone support for OSXMike Hommey2012-03-201-168/+23
| | | | | | | I tested a build from 10.7 run on 10.7 and 10.6, and a build from 10.6 run on 10.6. The AC_COMPILE_IFELSE limbo is to avoid running a program during configure, which presumably makes it work when cross compiling for iOS.
* Unbreak mac after commit 4e2e3ddMike Hommey2012-03-201-1/+1
|
* Add --with-mangling.Jason Evans2012-03-021-13/+13
| | | | | | | | | | Add the --with-mangling configure option, which can be used to specify name mangling on a per public symbol basis that takes precedence over --with-jemalloc-prefix. Expose the memalign() and valloc() overrides even if --with-jemalloc-prefix is specified. This change does no real harm, and simplifies the code.
* Simplify zone_good_size().Jason Evans2012-02-291-15/+3
| | | | | | Simplify zone_good_size() to avoid memory allocation. Submitted by Mike Hommey.
* Move repo contents in jemalloc/ to top level.Jason Evans2011-04-011-0/+354