Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,13 @@ macro(linklibs project)
endmacro()

if(MSVC)
add_compile_options(/WX /W4 /wd4127 /wd4324 /wd4201 /std:c++latest)
# Force to always compile with W4
if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
endif()
add_compile_options(/WX /wd4127 /wd4324 /wd4201)
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Zi")
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /DEBUG")
else()
Expand Down
2 changes: 1 addition & 1 deletion src/ds/aba.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ namespace snmalloc
(__int64*)&expect);
# else
# if defined(__GNUC__) && !defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_16)
#error You must compile with -mcx16 to enable 16-bit atomic compare and swap.
#error You must compile with -mcx16 to enable 16-byte atomic compare and swap.
# endif
Cmp xchg{value, expect.aba + 1};

Expand Down
4 changes: 0 additions & 4 deletions src/mem/alloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,6 @@ namespace snmalloc
}
};

static_assert(
SUPERSLAB_SIZE == SuperslabPagemap::GRANULARITY,
"The superslab size should be the same as the pagemap granularity");

#ifndef SNMALLOC_DEFAULT_PAGEMAP
# define SNMALLOC_DEFAULT_PAGEMAP snmalloc::SuperslabMap
#endif
Expand Down
19 changes: 15 additions & 4 deletions src/mem/allocconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,17 @@ namespace snmalloc
#endif
;

// Specifies smaller slab and super slab sizes for address space
// constrained scenarios.
static constexpr size_t ADDRESS_SPACE_CONSTRAINED =
#ifdef IS_ADDRESS_SPACE_CONSTRAINED
true
#else
// In 32 bit uses smaller superslab.
(!bits::is64())
#endif
;

static constexpr size_t RESERVE_MULTIPLE =
#ifdef USE_RESERVE_MULTIPLE
USE_RESERVE_MULTIPLE
Expand Down Expand Up @@ -85,14 +96,14 @@ namespace snmalloc
static constexpr size_t MIN_ALLOC_SIZE = 1 << MIN_ALLOC_BITS;

// Slabs are 64 kb.
static constexpr size_t SLAB_BITS = 16;
static constexpr size_t SLAB_BITS = ADDRESS_SPACE_CONSTRAINED ? 14 : 16;
static constexpr size_t SLAB_SIZE = 1 << SLAB_BITS;
static constexpr size_t SLAB_MASK = ~(SLAB_SIZE - 1);

// Superslabs are composed of this many slabs. Slab offsets are encoded as
// a byte, so the maximum count is 256. This must be a power of two to
// allow fast masking to find a superslab start address.
static constexpr size_t SLAB_COUNT_BITS = 8;
static constexpr size_t SLAB_COUNT_BITS = ADDRESS_SPACE_CONSTRAINED ? 6 : 8;
static constexpr size_t SLAB_COUNT = 1 << SLAB_COUNT_BITS;
static constexpr size_t SUPERSLAB_SIZE = SLAB_SIZE * SLAB_COUNT;
static constexpr size_t SUPERSLAB_MASK = ~(SUPERSLAB_SIZE - 1);
Expand All @@ -111,8 +122,8 @@ namespace snmalloc
MIN_ALLOC_SIZE >= (sizeof(void*) * 2),
"MIN_ALLOC_SIZE must be sufficient for two pointers");
static_assert(
SLAB_BITS == (sizeof(uint16_t) * 8),
"SLAB_BITS must be the bits in a uint16_t");
SLAB_BITS <= (sizeof(uint16_t) * 8),
"SLAB_BITS must not be more than the bits in a uint16_t");
static_assert(
SLAB_COUNT == bits::next_pow2_const(SLAB_COUNT),
"SLAB_COUNT must be a power of 2");
Expand Down
6 changes: 0 additions & 6 deletions src/mem/pagemap.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,6 @@ namespace snmalloc
}

public:
static constexpr size_t GRANULARITY = 1 << GRANULARITY_BITS;

T get(void* p)
{
bool success;
Expand Down Expand Up @@ -245,10 +243,6 @@ namespace snmalloc
static constexpr size_t ENTRIES = 1ULL << (COVERED_BITS + CONTENT_BITS);
static constexpr size_t SHIFT = GRANULARITY_BITS;

public:
static constexpr size_t GRANULARITY = 1 << GRANULARITY_BITS;

private:
std::atomic<T> top[ENTRIES];

public:
Expand Down
2 changes: 1 addition & 1 deletion src/mem/slab.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ namespace snmalloc
{
// This slab is being bump allocated.
p = (void*)((size_t)this + head - 1);
meta->head = head + (uint16_t)rsize;
meta->head = (head + (uint16_t)rsize) & (SLAB_SIZE - 1);
if (meta->head == 1)
{
meta->set_full();
Expand Down
2 changes: 0 additions & 2 deletions src/pal/pal_plain.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ namespace snmalloc
class PALPlainMixin : public State
{
public:
PALPlainMixin() : State() {}

// Notify platform that we will not be using these pages
void notify_not_using(void*, size_t) noexcept {}

Expand Down