Skip to content

Commit cb7df2e

Browse files
authored
Merge pull request #3160 from tannewt/enable_pystack
Enable PYSTACK to keep function state out of the heap
2 parents e047ea2 + 5e3a853 commit cb7df2e

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

main.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,10 @@ void do_str(const char *src, mp_parse_input_kind_t input_kind) {
9797
}
9898
}
9999

100+
#if MICROPY_ENABLE_PYSTACK
101+
static size_t PLACE_IN_DTCM_BSS(_pystack[CIRCUITPY_PYSTACK_SIZE / sizeof(size_t)]);
102+
#endif
103+
100104
void start_mp(supervisor_allocation* heap) {
101105
reset_status_led();
102106
autoreload_stop();
@@ -125,6 +129,10 @@ void start_mp(supervisor_allocation* heap) {
125129
// Clear the readline history. It references the heap we're about to destroy.
126130
readline_init0();
127131

132+
#if MICROPY_ENABLE_PYSTACK
133+
mp_pystack_init(_pystack, _pystack + (sizeof(_pystack) / sizeof(size_t)));
134+
#endif
135+
128136
#if MICROPY_ENABLE_GC
129137
gc_init(heap->ptr, heap->ptr + heap->length / 4);
130138
#endif

ports/atmel-samd/boards/uchip/mpconfigboard.mk

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@ INTERNAL_FLASH_FILESYSTEM = 1
1010
LONGINT_IMPL = NONE
1111
CIRCUITPY_FULL_BUILD = 0
1212

13-
# Tweak inlining depending on language.
14-
ifeq ($(TRANSLATION), zh_Latn_pinyin)
13+
# Always use aggressive inlining
1514
CFLAGS_INLINE_LIMIT = 45
16-
else
17-
CFLAGS_INLINE_LIMIT = 70
18-
endif
15+
16+
SUPEROPT_GC = 0

py/circuitpy_mpconfig.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@
119119
#define MICROPY_QSTR_BYTES_IN_HASH (1)
120120
#define MICROPY_REPL_AUTO_INDENT (1)
121121
#define MICROPY_REPL_EVENT_DRIVEN (0)
122+
#define MICROPY_ENABLE_PYSTACK (1)
122123
#define MICROPY_STACK_CHECK (1)
123124
#define MICROPY_STREAMS_NON_BLOCK (1)
124125
#ifndef MICROPY_USE_INTERNAL_PRINTF
@@ -785,6 +786,10 @@ void supervisor_run_background_tasks_if_tick(void);
785786
#define CIRCUITPY_FILESYSTEM_FLUSH_INTERVAL_MS 1000
786787
#endif
787788

789+
#ifndef CIRCUITPY_PYSTACK_SIZE
790+
#define CIRCUITPY_PYSTACK_SIZE 1024
791+
#endif
792+
788793
#define CIRCUITPY_BOOT_OUTPUT_FILE "/boot_out.txt"
789794

790795
#define CIRCUITPY_VERBOSE_BLE 0

0 commit comments

Comments
 (0)