@@ -131,17 +131,16 @@ typedef struct {
131
131
supervisor_allocation * pystack ;
132
132
#endif
133
133
supervisor_allocation * heap ;
134
- } stacks ;
134
+ } vm_memory_t ;
135
135
136
136
static void reset_devices (void ) {
137
137
#if CIRCUITPY_BLEIO_HCI
138
138
bleio_reset ();
139
139
#endif
140
140
}
141
141
142
- #if MICROPY_ENABLE_PYSTACK
143
- STATIC stacks __attribute__ ((noinline )) alloc_stacks (void ) {
144
- stacks res ;
142
+ STATIC vm_memory_t allocate_vm_memory (void ) {
143
+ vm_memory_t res ;
145
144
#if MICROPY_ENABLE_PYSTACK
146
145
mp_int_t pystack_size = CIRCUITPY_PYSTACK_SIZE ;
147
146
#if CIRCUITPY_OS_GETENV
@@ -164,9 +163,8 @@ STATIC stacks __attribute__ ((noinline)) alloc_stacks(void) {
164
163
res .heap = allocate_remaining_memory ();
165
164
return res ;
166
165
}
167
- #endif
168
166
169
- STATIC void start_mp (stacks combo ) {
167
+ STATIC void start_mp (vm_memory_t vm_memory ) {
170
168
supervisor_workflow_reset ();
171
169
172
170
// Stack limit should be less than real stack size, so we have a chance
@@ -194,11 +192,11 @@ STATIC void start_mp(stacks combo) {
194
192
readline_init0 ();
195
193
196
194
#if MICROPY_ENABLE_PYSTACK
197
- mp_pystack_init (combo .pystack -> ptr , combo .pystack -> ptr + get_allocation_length (combo .pystack ) / sizeof (size_t ));
195
+ mp_pystack_init (vm_memory .pystack -> ptr , vm_memory .pystack -> ptr + get_allocation_length (vm_memory .pystack ) / sizeof (size_t ));
198
196
#endif
199
197
200
198
#if MICROPY_ENABLE_GC
201
- gc_init (combo .heap -> ptr , combo .heap -> ptr + get_allocation_length (combo .heap ) / 4 );
199
+ gc_init (vm_memory .heap -> ptr , vm_memory .heap -> ptr + get_allocation_length (vm_memory .heap ) / 4 );
202
200
#endif
203
201
mp_init ();
204
202
mp_obj_list_init ((mp_obj_list_t * )mp_sys_path , 0 );
@@ -298,7 +296,7 @@ STATIC void count_strn(void *data, const char *str, size_t len) {
298
296
* (size_t * )data += len ;
299
297
}
300
298
301
- STATIC void cleanup_after_vm (stacks combo , mp_obj_t exception ) {
299
+ STATIC void cleanup_after_vm (vm_memory_t vm_memory , mp_obj_t exception ) {
302
300
// Get the traceback of any exception from this run off the heap.
303
301
// MP_OBJ_SENTINEL means "this run does not contribute to traceback storage, don't touch it"
304
302
// MP_OBJ_NULL (=0) means "this run completed successfully, clear any stored traceback"
@@ -378,9 +376,9 @@ STATIC void cleanup_after_vm(stacks combo, mp_obj_t exception) {
378
376
// Free the heap last because other modules may reference heap memory and need to shut down.
379
377
filesystem_flush ();
380
378
stop_mp ();
381
- free_memory (combo .heap );
379
+ free_memory (vm_memory .heap );
382
380
#if MICROPY_ENABLE_PYSTACK
383
- free_memory (combo .pystack );
381
+ free_memory (vm_memory .pystack );
384
382
#endif
385
383
supervisor_move_memory ();
386
384
@@ -436,8 +434,8 @@ STATIC bool run_code_py(safe_mode_t safe_mode, bool *simulate_reset) {
436
434
};
437
435
#endif
438
436
439
- stacks combo = alloc_stacks ();
440
- start_mp (combo );
437
+ vm_memory_t vm_memory = allocate_vm_memory ();
438
+ start_mp (vm_memory );
441
439
442
440
#if CIRCUITPY_USB
443
441
usb_setup_with_vm ();
@@ -485,7 +483,7 @@ STATIC bool run_code_py(safe_mode_t safe_mode, bool *simulate_reset) {
485
483
486
484
487
485
// Finished executing python code. Cleanup includes filesystem flush and a board reset.
488
- cleanup_after_vm (combo , _exec_result .exception );
486
+ cleanup_after_vm (vm_memory , _exec_result .exception );
489
487
_exec_result .exception = NULL ;
490
488
491
489
// If a new next code file was set, that is a reason to keep it (obviously). Stuff this into
@@ -781,8 +779,8 @@ STATIC void __attribute__ ((noinline)) run_boot_py(safe_mode_t safe_mode) {
781
779
782
780
// Do USB setup even if boot.py is not run.
783
781
784
- stacks combo = alloc_stacks ();
785
- start_mp (combo );
782
+ vm_memory_t vm_memory = allocate_vm_memory ();
783
+ start_mp (vm_memory );
786
784
787
785
#if CIRCUITPY_USB
788
786
// Set up default USB values after boot.py VM starts but before running boot.py.
@@ -868,7 +866,7 @@ STATIC void __attribute__ ((noinline)) run_boot_py(safe_mode_t safe_mode) {
868
866
869
867
port_post_boot_py (true);
870
868
871
- cleanup_after_vm (combo , _exec_result .exception );
869
+ cleanup_after_vm (vm_memory , _exec_result .exception );
872
870
_exec_result .exception = NULL ;
873
871
874
872
port_post_boot_py (false);
@@ -883,8 +881,8 @@ STATIC int run_repl(void) {
883
881
int exit_code = PYEXEC_FORCED_EXIT ;
884
882
stack_resize ();
885
883
filesystem_flush ();
886
- stacks combo = alloc_stacks ();
887
- start_mp (combo );
884
+ vm_memory_t vm_memory = allocate_vm_memory ();
885
+ start_mp (vm_memory );
888
886
889
887
#if CIRCUITPY_USB
890
888
usb_setup_with_vm ();
@@ -927,7 +925,7 @@ STATIC int run_repl(void) {
927
925
exit_code = PYEXEC_DEEP_SLEEP ;
928
926
}
929
927
#endif
930
- cleanup_after_vm (combo , MP_OBJ_SENTINEL );
928
+ cleanup_after_vm (vm_memory , MP_OBJ_SENTINEL );
931
929
932
930
// Also reset bleio. The above call omits it in case workflows should continue. In this case,
933
931
// we're switching straight to another VM so we want to reset.
0 commit comments