Skip to content

Make next_code_allocation and prev_traceback_allocation movable #5333

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Sep 14, 2021
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
2 changes: 1 addition & 1 deletion main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions ports/atmel-samd/boards/arduino_mkr1300/mpconfigboard.mk
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ CHIP_FAMILY = samd21
INTERNAL_FLASH_FILESYSTEM = 1
LONGINT_IMPL = NONE
CIRCUITPY_FULL_BUILD = 0

CIRCUITPY_RAINBOWIO = 0
2 changes: 2 additions & 0 deletions ports/atmel-samd/boards/arduino_nano_33_iot/mpconfigboard.mk
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ CHIP_FAMILY = samd21
INTERNAL_FLASH_FILESYSTEM = 1
LONGINT_IMPL = NONE
CIRCUITPY_FULL_BUILD = 0

CIRCUITPY_RAINBOWIO = 0
2 changes: 2 additions & 0 deletions ports/atmel-samd/boards/arduino_zero/mpconfigboard.mk
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ CHIP_FAMILY = samd21
INTERNAL_FLASH_FILESYSTEM = 1
LONGINT_IMPL = NONE
CIRCUITPY_FULL_BUILD = 0

CIRCUITPY_RAINBOWIO = 0
3 changes: 2 additions & 1 deletion ports/atmel-samd/boards/sensebox_mcu/mpconfigboard.mk
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ LONGINT_IMPL = NONE
CIRCUITPY_FULL_BUILD = 0

# There are many pin definitions on this board; it doesn't quite fit on very large translations.
# So remove what might be least likely module to be used.
# Remove a couple of modules.
CIRCUITPY_ONEWIREIO = 0
CIRCUITPY_RAINBOWIO = 0
2 changes: 2 additions & 0 deletions ports/nrf/boards/simmel/mpconfigboard.mk
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@ CIRCUITPY_COUNTIO = 0
CIRCUITPY_DISPLAYIO = 0
CIRCUITPY_ERRNO = 0
CIRCUITPY_FRAMEBUFFERIO = 0
CIRCUITPY_GETPASS = 0
CIRCUITPY_KEYPAD = 0
CIRCUITPY_MSGPACK = 0
CIRCUITPY_NEOPIXEL_WRITE = 0
CIRCUITPY_NVM = 0
CIRCUITPY_PIXELBUF = 0
CIRCUITPY_PULSEIO = 0
CIRCUITPY_PWMIO = 1
CIRCUITPY_RAINBOWIO = 0
CIRCUITPY_RGBMATRIX = 0
CIRCUITPY_ROTARYIO = 0
CIRCUITPY_RTC = 1
Expand Down
2 changes: 1 addition & 1 deletion shared-bindings/supervisor/__init__.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
11 changes: 6 additions & 5 deletions supervisor/shared/memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down