unix: Enable MICROPY_GC_SPLIT_HEAP on coverage build.

With a new option to evenly split the GC heap over multiple areas.  This
adds code coverage for gc_add() and code associated with
MICROPY_GC_SPLIT_HEAP.
pull/8947/head
Rob Knegjens 2022-04-13 09:52:22 -07:00 zatwierdzone przez Damien George
rodzic 4a48531803
commit d2e4cf00cc
3 zmienionych plików z 26 dodań i 0 usunięć

Wyświetl plik

@ -477,8 +477,22 @@ MP_NOINLINE int main_(int argc, char **argv) {
pre_process_options(argc, argv);
#if MICROPY_ENABLE_GC
#if !MICROPY_GC_SPLIT_HEAP
char *heap = malloc(heap_size);
gc_init(heap, heap + heap_size);
#else
assert(MICROPY_GC_SPLIT_HEAP_N_HEAPS > 0);
char *heaps[MICROPY_GC_SPLIT_HEAP_N_HEAPS];
long multi_heap_size = heap_size / MICROPY_GC_SPLIT_HEAP_N_HEAPS;
for (size_t i = 0; i < MICROPY_GC_SPLIT_HEAP_N_HEAPS; i++) {
heaps[i] = malloc(multi_heap_size);
if (i == 0) {
gc_init(heaps[i], heaps[i] + multi_heap_size);
} else {
gc_add(heaps[i], heaps[i] + multi_heap_size);
}
}
#endif
#endif
#if MICROPY_ENABLE_PYSTACK
@ -729,7 +743,13 @@ MP_NOINLINE int main_(int argc, char **argv) {
#if MICROPY_ENABLE_GC && !defined(NDEBUG)
// We don't really need to free memory since we are about to exit the
// process, but doing so helps to find memory leaks.
#if !MICROPY_GC_SPLIT_HEAP
free(heap);
#else
for (size_t i = 0; i < MICROPY_GC_SPLIT_HEAP_N_HEAPS; i++) {
free(heaps[i]);
}
#endif
#endif
// printf("total bytes = %d\n", m_get_total_bytes_allocated());

Wyświetl plik

@ -120,6 +120,10 @@
#define MICROPY_EMIT_ARM (1)
#endif
#define MICROPY_ENABLE_GC (1)
// Number of heaps to assign if MICROPY_GC_SPLIT_HEAP=1
#ifndef MICROPY_GC_SPLIT_HEAP_N_HEAPS
#define MICROPY_GC_SPLIT_HEAP_N_HEAPS (1)
#endif
#define MICROPY_MALLOC_USES_ALLOCATED_SIZE (1)
#define MICROPY_MEM_STATS (1)
#define MICROPY_DEBUG_PRINTERS (1)

Wyświetl plik

@ -32,6 +32,8 @@
// Enable additional features.
#define MICROPY_DEBUG_PARSE_RULE_NAME (1)
#define MICROPY_GC_SPLIT_HEAP (1)
#define MICROPY_GC_SPLIT_HEAP_N_HEAPS (4)
#define MICROPY_TRACKED_ALLOC (1)
#define MICROPY_FLOAT_HIGH_QUALITY_HASH (1)
#define MICROPY_REPL_EMACS_WORDS_MOVE (1)