Commit Graph

30 Commits

Author SHA1 Message Date
David Chisnall
829d8e856b Tweak some tests to avoid the slowest path.
By caching the result of the first call to ThreadAlloc::get(), we were
always hitting a code path that should be hit once per thread in normal
operation.
2019-07-05 09:42:01 +01:00
David Chisnall
b8a5d7fca9 Lazily initialise TLS on slow paths.
Copying an idea from mimalloc, initialise the TLS variable to a global
allocator that doesn't own any memory and then lazily check when we hit
a slow path (which we always do when using the global allocator, because
it doesn't own any memory) if we are the global allocator and replace
it.

There is a slight complication compared to mimalloc's version of this
idea.  Snmalloc collects outgoing messages and it's possible for the
first operation in a thread to be a free of memory allocated by a
different thread.  We address this by initialising the queues with a
size value indicating that they are full and then do the lazy check when
about to insert a message that would make a queue full.  This will then
trigger lazy creation of an allocator.

Global initialisation doesn't work for the fake allocator, so skip most
of its constructor.
2019-07-05 09:41:32 +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
Matthew Parkinson
8fcedfc290 Fix the GCC build (#40)
* Make it compile with GCC.  
* Add GCC to CI.
* Add warning to documentation about using GCC.
2019-05-05 19:58:37 +01:00
Matthew Parkinson
5030fff9bd Missing include from test. 2019-04-29 11:02:47 +01:00
David Chisnall
ca804c1815 [NFC] clang-format 2019-04-11 17:36:14 +01:00
David Chisnall
5c1abffdda Fix missing const. 2019-04-11 17:25:53 +01:00
David Chisnall
9b3641df91 Address Matt's review comments. 2019-04-11 17:08:16 +01:00
David Chisnall
9d24f7e24f Fix callers of renamed function. 2019-04-11 10:42:50 +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
David Chisnall
ef50a0282b Attempt to make CI faster.
- Don't run an expensive functionality test in debug builds.
- Don't run the different cache configurations (they're probably going
  away soon because they help only in synthetic benchmarks).
2019-02-25 16:33:57 +00:00
David Chisnall
6a5359b177 Pull aligned allocation out of the PAL.
The PAL can now advertise that it supports aligned allocation.  If it
does not, then the memory provider will do the alignment for it.

This change still leaves the PAL responsible for systematic testing, but
it should now be much easier to lift that out.
2019-02-25 12:54:16 +00:00
Matthew Parkinson
ccccd686fb Merge pull request #16 from Microsoft/Sizeclass
Simplified sizeclass calculations and added tests.
2019-02-19 13:07:08 +00:00
Matthew Parkinson
e7d90966f6 Made the malloc tests run on Windows 2019-02-15 14:36:47 +00:00
Theo Butler
a3fb2b9531 cleanup some tests 2019-02-14 22:31:45 -05:00
Theo Butler
d2909eed0a Merge branch 'master' into malloc-tests 2019-02-14 22:30:48 -05:00
Matthew Parkinson
8b9a525500 Added zero test at threshold. 2019-02-14 19:59:36 +00: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
24ba068dce remove randomness from malloc tests 2019-02-13 08:42:51 -05:00
theodus
a9615bc6aa mark variables unused in release build 2019-02-12 20:22:10 -05:00
Theo Butler
f6497e6ee3 Add malloc tests 2019-02-12 19:50:15 -05:00
Matthew Parkinson
9981bad9b5 clang format 2019-02-11 14:47:12 +00:00
Matthew Parkinson
fdcad7feb4 Add test for sizeclass calculations 2019-02-11 14:47:12 +00:00
Matthew Parkinson
67fbcba653 Clang format 2019-01-24 11:22:44 +00:00
Matthew Parkinson
28a28bb1ed Simple example of using two allocators in one application.
Example to simulate using two allocators in one application.  This will
be useful for scenarios in openenclave.
2019-01-23 13:19:46 +00:00
Matthew Parkinson
e51f1c3d50 Namespace test globals for external_pointer
Some times the global count was leading to a warning with a local count
in the test.
2019-01-23 11:03:13 +00:00
Matthew Parkinson
dc19b5ace2 Test to check external pointer on deallocated objects
This fails an assertion as it reads from a "head" and assumes it is a
sizeclass. This leads to accessing memory out of bounds.
2019-01-18 21:11:01 +00:00
Matthew Parkinson
272bebb927 Reduce size of test on 32bit 2019-01-16 14:38:10 +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