Commit Graph

26 Commits

Author SHA1 Message Date
Matthew Parkinson
ea399660ce Fix for zero size allocations. 2019-07-02 15:58:19 +01:00
Matthew Parkinson
7a198cbda5 Aggressively optimise fast path for allocation
This change introduces a per small sizeclass free list.  That can be
used to access the free objects for that sizeclass with minimal
calculations being required.

It changes to a partial bump ptr.  We bump allocate a whole OS
page worth of objects at a go, so we don't switch as frequently
between bump and free list allocation.

The code for the fast paths has been restructured to minimise the
work required on the common case, and also it is all inlined for the
common case.

Allocating a zero sized object is moved off the fast path.  Ask for 1
byte if you want to be fast.
2019-07-01 14:35:35 +01:00
Matthew Parkinson
7a8eaec2cc Made a sizecass_t to wrap the sizeclass
This is useful as codegen is nicer if we use size_t, but the semantics
is uint8_t, and is stored as that in many places in the metadata.
Ultimately should introduce a wrapper to check this invariant.
2019-07-01 14:30:05 +01:00
David Chisnall
22d33ebf99 Add another checker.
Use nullptr where appropriate.
2019-04-29 15:00:25 +01:00
Matthew Parkinson
47428a096c Removing some casts and uses of void* 2019-04-29 11:02:47 +01:00
Matthew Parkinson
4faf9f3bee Use fewer header files
Removing some includes to reduce the code that is dragged in.
2019-04-29 11:02:47 +01:00
David Chisnall
29b45c3345 Rename the pagemap accessor to be noun-verb. 2019-04-11 10:33:36 +01:00
David Chisnall
ad0a22e571 Add missing doc comments. 2019-04-10 12:49:02 +01:00
David Chisnall
a93f43fd2f Add some type safety to other pagemap accesses.
Introduce a descriptor for the pagemap config and check that the source
descriptor is compatible with the destination type.
2019-04-09 15:52:38 +01:00
rschust
71900ef947 Created pal_consts.h. New exported functions are now prefixed with "snmalloc_". 2019-04-09 13:56:22 +01:00
rschust
f0d18760fe Exporting the global pagemap and the default memory provider's reserve function in order to support shared allocators 2019-04-09 13:56:22 +01:00
David Chisnall
c47eed1922 Tweaks to end bounds checking.
Introduce a `OnePastEnd` option for the pointer immediately after the
end of the allocation.  This simplifies some of the logic in callers,
where they wants to say 'is base + length safe to use?'.

Also restructure some of the other logic somewhat.
2019-02-15 20:05:00 +01:00
Theo Butler
057595a57e remove -1 check in calloc 2019-02-13 16:03:38 -05:00
Theo Butler
942313fec7 replace asserts with abort 2019-02-13 10:03:41 -05:00
Theo Butler
f6497e6ee3 Add malloc tests 2019-02-12 19:50:15 -05:00
theodus
ae3f9f6aec Get alloc size without wrapper 2019-02-03 08:19:11 -05:00
theodus
2b8b4c884f Do not realloc if size is in the same sizeclass 2019-02-02 17:28:02 -05:00
theodus
85cf5dd097 Avoid unnecessary allocation from realloc 2019-02-02 14:47:06 -05:00
theodus
61b310d9d6 Fix assertion failure in memalign 2019-01-30 12:14:16 -05:00
Matthew Parkinson
67fbcba653 Clang format 2019-01-24 11:22:44 +00:00
Matthew Parkinson
5240b3f8c6 Formatting 2019-01-23 11:06:07 +00:00
Matthew Parkinson
ef3a578503 Allow __je_bootstrap methods to not be compiled
The __je_bootstrap.. allocator methods can be specified that they
shouldn't  be compiled using NO_BOOTSTRAP_ALLOCATION.
2019-01-23 11:05:50 +00:00
Matthew Parkinson
8d074468ae Fix MSVC warning in malloc.cc 2019-01-23 11:03:43 +00:00
David Chisnall
c3d46a9d8e Address review comments.
Move slow_allocator into a separate header in the snmalloc namespace and
rename it for consistency with the rest of the codebase.  Delete its
copy and move constructors / assignment operators.
2019-01-18 15:57:28 +00:00
David Chisnall
e81dacc1c5 FreeBSD libc allocator fixes.
Provide a hook so that the exported malloc symbols can be weak.  This is
mostly needed so that rtld, which statically links libc.a, can override
the symbols.

Add a bootstrap allocator so that statically linked binaries can have
their TLS space allocated before malloc is called and uses TLS.
2019-01-17 10:20:14 +00:00
Matthew Parkinson
4f9d991449 Initial commit of snmalloc
History squashed from internal development.

Internal history has commit hash:
  e27a0e485c44a5003a802de2661ce3b21e120316
2019-01-15 14:17:55 +00:00