⚠ This page is served via a proxy. Original site: https://github.com
This service does not collect credentials or authentication data.
Skip to content
Open
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
3 changes: 1 addition & 2 deletions compat/mimalloc/alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ extern inline void* _mi_page_malloc_zero(mi_heap_t* heap, mi_page_t* page, size_
// zero the block? note: we need to zero the full block size (issue #63)
if mi_unlikely(zero) {
mi_assert_internal(page->block_size != 0); // do not call with zero'ing for huge blocks (see _mi_malloc_generic)
mi_assert_internal(!mi_page_is_huge(page));
#if MI_PADDING
mi_assert_internal(page->block_size >= MI_PADDING_SIZE);
#endif
Expand Down Expand Up @@ -528,7 +527,7 @@ static std_new_handler_t mi_get_new_handler(void) {
}
#else
// note: on windows we could dynamically link to `?get_new_handler@std@@YAP6AXXZXZ`.
static std_new_handler_t mi_get_new_handler() {
static std_new_handler_t mi_get_new_handler(void) {
return NULL;
}
#endif
Expand Down
2 changes: 1 addition & 1 deletion compat/mimalloc/mimalloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ terms of the MIT license. A copy of the license can be found in the file
#ifndef MIMALLOC_H
#define MIMALLOC_H

#define MI_MALLOC_VERSION 226 // major + 2 digits minor
#define MI_MALLOC_VERSION 227 // major + 2 digits minor

// ------------------------------------------------------
// Compiler specific attributes
Expand Down
4 changes: 2 additions & 2 deletions compat/mimalloc/mimalloc/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -1093,15 +1093,15 @@ static inline size_t mi_popcount(size_t x) {
extern mi_decl_hidden bool _mi_cpu_has_fsrm;
extern mi_decl_hidden bool _mi_cpu_has_erms;
static inline void _mi_memcpy(void* dst, const void* src, size_t n) {
if ((_mi_cpu_has_fsrm && n <= 128) || (_mi_cpu_has_erms && n > 128)) {
if (_mi_cpu_has_fsrm && n <= 127) { // || (_mi_cpu_has_erms && n > 128)) {
__movsb((unsigned char*)dst, (const unsigned char*)src, n);
}
else {
memcpy(dst, src, n);
}
}
static inline void _mi_memzero(void* dst, size_t n) {
if ((_mi_cpu_has_fsrm && n <= 128) || (_mi_cpu_has_erms && n > 128)) {
if (_mi_cpu_has_fsrm && n <= 127) { // || (_mi_cpu_has_erms && n > 128)) {
__stosb((unsigned char*)dst, 0, n);
}
else {
Expand Down
1 change: 1 addition & 0 deletions compat/mimalloc/mimalloc/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,7 @@ typedef struct mi_segment_s {
struct mi_segment_s* next; // the list of freed segments in the cache (must be first field, see `segment.c:mi_segment_init`)
bool was_reclaimed; // true if it was reclaimed (used to limit on-free reclamation)
bool dont_free; // can be temporarily true to ensure the segment is not freed
bool free_is_zero; // if free spans are zero

size_t abandoned; // abandoned pages (i.e. the original owning thread stopped) (`abandoned <= used`)
size_t abandoned_visits; // count how often this segment is visited during abondoned reclamation (to force reclaim if it takes too long)
Expand Down
14 changes: 3 additions & 11 deletions compat/mimalloc/page.c
Original file line number Diff line number Diff line change
Expand Up @@ -1031,17 +1031,9 @@ void* _mi_malloc_generic(mi_heap_t* heap, size_t size, bool zero, size_t huge_al
mi_assert_internal(mi_page_block_size(page) >= size);

// and try again, this time succeeding! (i.e. this should never recurse through _mi_page_malloc)
void* p;
if mi_unlikely(zero && mi_page_is_huge(page)) {
// note: we cannot call _mi_page_malloc with zeroing for huge blocks; we zero it afterwards in that case.
p = _mi_page_malloc_zero(heap, page, size, false, usable);
mi_assert_internal(p != NULL);
_mi_memzero_aligned(p, mi_page_usable_block_size(page));
}
else {
p = _mi_page_malloc_zero(heap, page, size, zero, usable);
mi_assert_internal(p != NULL);
}
void* const p = _mi_page_malloc_zero(heap, page, size, zero, usable);
mi_assert_internal(p != NULL);

// move singleton pages to the full queue
if (page->reserved == page->used) {
mi_page_to_full(page, mi_page_queue_of(page));
Expand Down
6 changes: 5 additions & 1 deletion compat/mimalloc/segment.c
Original file line number Diff line number Diff line change
Expand Up @@ -773,6 +773,7 @@ static mi_page_t* mi_segment_span_allocate(mi_segment_t* segment, size_t slice_i

// and initialize the page
page->is_committed = true;
page->is_zero_init = segment->free_is_zero;
page->is_huge = (segment->kind == MI_SEGMENT_HUGE);
segment->used++;
return page;
Expand Down Expand Up @@ -882,6 +883,7 @@ static mi_segment_t* mi_segment_os_alloc( size_t required, size_t page_alignment
segment->subproc = tld->subproc;
segment->commit_mask = commit_mask;
segment->purge_expire = 0;
segment->free_is_zero = memid.initially_zero;
mi_commit_mask_create_empty(&segment->purge_mask);

mi_segments_track_size((long)(segment_size), tld);
Expand Down Expand Up @@ -1024,7 +1026,7 @@ static mi_slice_t* mi_segment_page_clear(mi_page_t* page, mi_segments_tld_t* tld
_mi_stat_decrease(&tld->stats->page_committed, inuse);
_mi_stat_decrease(&tld->stats->pages, 1);
_mi_stat_decrease(&tld->stats->page_bins[_mi_page_stats_bin(page)], 1);

// reset the page memory to reduce memory pressure?
if (segment->allow_decommit && mi_option_is_enabled(mi_option_deprecated_page_reset)) {
size_t psize;
Expand All @@ -1043,6 +1045,8 @@ static mi_slice_t* mi_segment_page_clear(mi_page_t* page, mi_segments_tld_t* tld
// and free it
mi_slice_t* slice = mi_segment_span_free_coalesce(mi_page_to_slice(page), tld);
segment->used--;
segment->free_is_zero = false;

// cannot assert segment valid as it is called during reclaim
// mi_assert_expensive(mi_segment_is_valid(segment, tld));
return slice;
Expand Down
Loading