make `next_code_allocation` and `prev_traceback_allocation` movable

This commit is contained in:
microDev 2021-09-12 18:04:02 +05:30
parent cf5c32be3b
commit 7316c742cf
No known key found for this signature in database
GPG Key ID: 2C0867BE60967730
3 changed files with 8 additions and 7 deletions

2
main.c
View File

@ -236,7 +236,7 @@ STATIC void cleanup_after_vm(supervisor_allocation* heap, mp_obj_t exception) {
size_t traceback_len = 0;
mp_print_t print_count = {&traceback_len, count_strn};
mp_obj_print_exception(&print_count, exception);
prev_traceback_allocation = allocate_memory(align32_size(traceback_len + 1), false, false);
prev_traceback_allocation = allocate_memory(align32_size(traceback_len + 1), false, true);
// Empirically, this never fails in practice - even when the heap is totally filled up
// with single-block-sized objects referenced by a root pointer, exiting the VM frees
// up several hundred bytes, sufficient for the traceback (which tends to be shortened

View File

@ -195,7 +195,7 @@ STATIC mp_obj_t supervisor_set_next_code_file(size_t n_args, const mp_obj_t *pos
const char *filename = mp_obj_str_get_data(args.filename.u_obj, &len);
free_memory(next_code_allocation);
if (options != 0 || len != 0) {
next_code_allocation = allocate_memory(align32_size(sizeof(next_code_info_t) + len + 1), false, false);
next_code_allocation = allocate_memory(align32_size(sizeof(next_code_info_t) + len + 1), false, true);
if (next_code_allocation == NULL) {
m_malloc_fail(sizeof(next_code_info_t) + len + 1);
}

View File

@ -34,12 +34,9 @@
enum {
CIRCUITPY_SUPERVISOR_IMMOVABLE_ALLOC_COUNT =
0
// stack + heap
2
// next_code_allocation
+ 1
// prev_traceback_allocation
+ 1
+ 2
#if INTERNAL_FLASH_FILESYSTEM == 0
+ 1
@ -59,6 +56,10 @@ enum {
CIRCUITPY_SUPERVISOR_MOVABLE_ALLOC_COUNT =
0
// next_code_allocation
+ 1
// prev_traceback_allocation
+ 1
#if CIRCUITPY_DISPLAYIO
#if CIRCUITPY_TERMINALIO
+ 1