Commit Graph

227 Commits

Author SHA1 Message Date
Matthew Parkinson
b756ca08a7 Address GCC8 warning
The bootstrapping allocator needs to perform a memcpy to bypass the
removed move constructors on std::atomic.  This is safe as there is no
concurrency at this point, but GCC is unhappy with this.

This commit moves CI to GCC8 and disables this warning for that line.
2020-03-01 20:48:03 +00:00
Amaury Chamayou
fdc582b619 Fix formatting 2020-02-27 16:21:24 +00:00
Amaury Chamayou
bd5702fa05 Fix recent OpenEnclave + snmalloc Release build 2020-02-27 14:12:28 +00:00
Matthew Parkinson
be47aea0c8 Tidying 2020-02-26 21:24:02 +00:00
Matthew Parkinson
c1c8a7bfee Clang format. 2020-02-26 20:59:38 +00:00
Matthew Parkinson
9f53ec0ef8 Reduce dependence on C++ runtime
If the external thread statics are used, then
we don't need to include some C++ runtime
concepts. This refactoring moves some global initialization under
conditional compilation.
2020-02-26 17:55:29 +00:00
Matthew Parkinson
c9da18a145 Improve Debug test speed.
Removed some very expensive debug checks off the fast path
of deallocation.
2020-02-06 13:05:40 +00:00
Matthew Parkinson
1d72024a9f Merge pull request #124 from microsoft/alignment
Make Large allocations naturally aligned
2020-02-05 14:40:13 +00:00
Matthew Parkinson
de64a8c0c2 CF and Add checks to CI. 2020-02-05 13:41:49 +00:00
Matthew Parkinson
28658a47f0 Code review feedback. 2020-02-05 12:47:24 +00:00
Matthew Parkinson
02427f98f0 Clangformat. 2020-02-04 14:12:28 +00:00
Matthew Parkinson
9e1c12636c Issue with low-memory notification
The low-memory notification was getting into an infinite loop.  This
fixes the loop termination, and provides a test for platforms which
support low-memory notification.
2020-02-04 13:22:55 +00:00
Matthew Parkinson
bad94e80d3 Clangformat 2020-02-04 10:24:57 +00:00
Matthew Parkinson
350df5d13d New strategy for producing aligned blocks of memory
On platforms that do not support aligned mmap/VirtualAlloc,
we need to produce heavily aligned blocks to guarantee we can meet
all possible alignment requests.

This commit grabs a block much larger than requested, and then produces
"offcuts" before and after the block of smaller/same "large_classes".  This
enables one mmap/virtual alloc request to services many other requests
for aligned memory.
2020-02-04 10:19:22 +00:00
Matthew Parkinson
4fea7b8bb1 Make Pals only return amount of memory requested
The PAL API previously allowed for returning more memory than asked for.
This was when the PAL performed the alignment work, now this is done in
large alloc, so removing from the PAL.
2020-02-04 10:19:22 +00:00
Matthew Parkinson
6e8edefc99 Make all large allocations naturally aligned
This makes any large allocation naturally aligned to its size. This
means all alignment requests can be handled without checks.
2020-02-04 10:19:22 +00:00
Matthew Parkinson
053b5a30ef Minor code tidying. 2020-01-29 16:37:46 +00:00
Matthew Parkinson
2e289573c8 Move all decommit strategy into LargeAllocator
The code for decommit was distribured in the code base.
Removing Decommit All means that it can logically reside in
lthe arge allocator.
2020-01-29 12:29:32 +00:00
Matthew Parkinson
2e4b289991 Removed DecommitAll strategy
The DecommitAll strategy performs badly.  We are not
functionally testing it, and it does not seem investing in it due to its
performance.
2020-01-29 11:58:57 +00:00
Matthew Parkinson
a2b56f9740 Remove a notify_using that regressed perf
The performance on Windows was significantly regressed by the
notify_using during the bump allocation.  This change removes that.
It appears that the pages are already committed by
the large allocator.
2020-01-29 11:25:13 +00:00
Matthew Parkinson
0affc069cf Make snmalloc build on Windows with Clang
Fixes a few places where Clang complains about Windows specific code,
and also uses macros supported by Clang on Windows.  A few places
separating platform and compiler specific code, as MSVC and WIN32 were
used interchangably previously.
2020-01-26 19:46:18 +00:00
SchrodingerZhu
8304dedd17 add rust support (#113)
* add rust support

* move aligned_size to sizeclass.h

* add static qualifier

* adjust CMakeLists.txt, may broke CI tests

* fix msvc's complaining on c++17

* use SNMALLOC_FAST_PATH as the decorator of aligned_size

* adapt new alignment algorithm and add related test

Co-authored-by: mjp41 <mattpark@microsoft.com>

* fix test cases for msvc

* add extra test for size == 0

* treat memory block of same sizeclass as the same

* fix formatting problem

* remove extra declarations

Co-authored-by: Matthew Parkinson <mjp41@users.noreply.github.com>
2020-01-23 07:08:18 +00:00
Matthew Parkinson
4212ac8e4e Improve codegen for sized free. (#115)
For languages like Verona or Rust, the deallocation calls know the
size of the object originally requested.  This change optimises that
code path to create a much better fast path.
2020-01-22 17:41:08 +00:00
Matthew Parkinson
e8e0f60ccf Fix GCC 9 error. 2020-01-07 11:06:12 +00:00
Nathaniel Filardo
2fa60c719f POISON only integer pointers
For architectures that can't manipulate pointers like integers, don't
try XORing them like this.  It's not ideal -- perhaps we should have
"else" branches to these tests.
2019-12-05 11:19:48 +00:00
Nathaniel Filardo
ef40f1cf1d Replace "AAL" type with "Aal" to parallel "Pal" 2019-12-04 16:56:28 +00:00
Nathaniel Filardo
4d6759aca4 Make "pal_supports" not a function
But rather a template vardecl, as per C++14
2019-12-04 16:54:41 +00:00
Nathaniel Filardo
7afc6da566 pagemap: cast to size_t then do bit manip
Makes the CHERI compiler happier
2019-11-27 10:17:31 +00:00
Nathaniel Filardo
5ae8ecedee metaslab: further use of pointer align funcs 2019-11-27 10:17:31 +00:00
Nathaniel Filardo
f8115a81b1 pagemap: cast uintptr_t to size_t before bit math
Not strictly necessary, but makes the CHERI compiler happier to see that
we're using a decidedly integral type rather than a possibly tagged
quantity.
2019-11-27 10:17:31 +00:00
Nathaniel Filardo
d13d810b66 Explicitly compute the size of two pointers
Don't use bits::is64() when setting MIN_ALLOC_BITS
2019-11-27 10:17:31 +00:00
Nathaniel Filardo
df2a2dc228 metaslab: rephrase assertion in terms of pointer_diff 2019-11-26 15:50:22 +00:00
Nathaniel Filardo
4dd77d35ab largealloc: rephrase pointer comparison 2019-11-26 15:50:22 +00:00
Nathaniel Filardo
f7c131e4ac largealloc: use pointer, not address_t, for cursor 2019-11-26 15:50:22 +00:00
Nathaniel Filardo
83c467eb92 ds/address: add pointer diff function
And use it rather than open-coding subtraction of two address_cast-s.
2019-11-26 15:50:22 +00:00
Nathaniel Filardo
eb2d8890de Additional provenance preservation 2019-11-26 15:37:52 +00:00
Nathaniel Filardo
ef7985510c address.h: add pointer alignment functions
More explicit than address_cast and bitwise and
2019-11-26 15:37:52 +00:00
Nathaniel Filardo
20e804728b Move bits::is_aligned_block to address.h
And chase consequences
2019-11-26 15:33:09 +00:00
Nathaniel Filardo
261249d9cb Preserve provenance through pointer offsetting 2019-11-26 14:59:54 +00:00
Nathaniel Filardo
ad96ba05c1 largealloc: don't zero memory twice
If the decommit strategy is DecommitSuperLazy, then both the constexpr
if and the ordinary if would fire; add an else so we only fall into one.
2019-11-26 14:59:54 +00:00
Nathaniel Filardo
6f8623b5d7 Remove spurious store to pagemap
The same operation was just done one the other side of the loop above
and the loop does not modify this location in the map.
2019-11-26 14:59:54 +00:00
Nathaniel Filardo
2af4c64698 Improve commentary 2019-11-26 14:58:47 +00:00
Nathaniel Filardo
7251022e24 superslab: reorder initialization
Setting kind and then immediately testing it seems wrong.
2019-11-26 14:58:08 +00:00
Matthew Parkinson
11923154e8 Merge pull request #100 from CTSRD-CHERI/for-upstream-static-pagemap-slabmap
Deconflate "pagemap"
2019-11-25 16:26:55 +00:00
Nathaniel Filardo
e870960655 Some minor chunkmap commentary 2019-11-25 15:22:53 +00:00
Nathaniel Filardo
7ed80e7244 Report error on pagemap ABI mismatch 2019-11-25 15:22:53 +00:00
Nathaniel Filardo
d5b478ecb3 Deconflate "Pagemap" objects
There are two things calling themselves pagemaps:

- the src/mem/pagemap.h objects of that name

- the SuperslabMap object gets called a PageMap inside the Allocator

Rename the latter to chunkmap, with appropriate case and snake,
everywhere, and pull it out to its own file (chunkmap.h).

The default implementation of a chunkmap is a purely static object, but
we nevertheless instantiate it per allocator, so that other
implementations can use stateful instances when interposing on the
mutation methods.  Note that the "get" method, however, must remain
static to support the interface required by Allocator objects.
2019-11-21 15:35:56 +00:00
Matthew Parkinson
7faefbbb0e Merge pull request #102 from microsoft/cq-free
Code quality for `free`
2019-11-21 12:13:06 +00:00
Matthew Parkinson
1d0c42449e CR feedback 2019-11-21 11:39:55 +00:00
Matthew Parkinson
df1dfa55db improved comments and rename field
Replaced used with needed, the number of objects needed empty this slab.

Some mild improvement to the comments.
2019-11-21 11:39:55 +00:00