diff options
Diffstat (limited to 'py')
-rw-r--r-- | py/compile.c | 2 | ||||
-rw-r--r-- | py/vm.c | 9 |
2 files changed, 6 insertions, 5 deletions
diff --git a/py/compile.c b/py/compile.c index c90772a7e3..1f0d90570e 100644 --- a/py/compile.c +++ b/py/compile.c @@ -1745,7 +1745,7 @@ void compile_while_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) { // And, if the loop never runs, the loop variable should never be assigned void compile_for_stmt_optimised_range(compiler_t *comp, mp_parse_node_t pn_var, mp_parse_node_t pn_start, mp_parse_node_t pn_end, mp_parse_node_t pn_step, mp_parse_node_t pn_body, mp_parse_node_t pn_else) { START_BREAK_CONTINUE_BLOCK - comp->break_label |= MP_EMIT_BREAK_FROM_FOR; + // note that we don't need to pop anything when breaking from an optimise for loop uint top_label = comp_next_label(comp); uint entry_label = comp_next_label(comp); @@ -44,7 +44,7 @@ // With these macros you can tune the maximum number of function state bytes // that will be allocated on the stack. Any function that needs more // than this will use the heap. -#define VM_MAX_STATE_ON_STACK (40) +#define VM_MAX_STATE_ON_STACK (10 * sizeof(machine_uint_t)) #define DETECT_VM_STACK_OVERFLOW (0) #if 0 @@ -160,8 +160,8 @@ mp_vm_return_kind_t mp_execute_bytecode(const byte *code, const mp_obj_t *args, #if DETECT_VM_STACK_OVERFLOW if (vm_return_kind == MP_VM_RETURN_NORMAL) { - if (code_state->sp != code_state->state) { - printf("Stack misalign: %d\n", code_state->sp - code_state->state); + if (code_state->sp < code_state->state) { + printf("VM stack underflow: " INT_FMT "\n", code_state->sp - code_state->state); assert(0); } } @@ -178,7 +178,7 @@ mp_vm_return_kind_t mp_execute_bytecode(const byte *code, const mp_obj_t *args, } } if (overflow) { - printf("VM stack overflow state=%p n_state+1=%u\n", code_state->state, n_state); + printf("VM stack overflow state=%p n_state+1=" UINT_FMT "\n", code_state->state, n_state); assert(0); } } @@ -203,6 +203,7 @@ mp_vm_return_kind_t mp_execute_bytecode(const byte *code, const mp_obj_t *args, assert(0); *ret = mp_const_none; ret_kind = MP_VM_RETURN_NORMAL; + break; } // free the state if it was allocated on the heap |