Skip to content

Commit e02b2d4

Browse files
committed
py: Temporary fix for bug where not enough VM state is allocated.
1 parent ebde0b8 commit e02b2d4

2 files changed

Lines changed: 6 additions & 12 deletions

File tree

py/showbc.c

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -206,25 +206,15 @@ void mp_show_byte_code(const byte *ip, int len) {
206206
printf("POP_JUMP_IF_FALSE " UINT_FMT, ip + unum - ip_start);
207207
break;
208208

209-
/*
210209
case MP_BC_JUMP_IF_TRUE_OR_POP:
211210
DECODE_SLABEL;
212-
if (rt_is_true(*sp)) {
213-
ip += unum;
214-
} else {
215-
sp++;
216-
}
211+
printf("JUMP_IF_TRUE_OR_POP " UINT_FMT, ip + unum - ip_start);
217212
break;
218213

219214
case MP_BC_JUMP_IF_FALSE_OR_POP:
220215
DECODE_SLABEL;
221-
if (rt_is_true(*sp)) {
222-
sp++;
223-
} else {
224-
ip += unum;
225-
}
216+
printf("JUMP_IF_FALSE_OR_POP " UINT_FMT, ip + unum - ip_start);
226217
break;
227-
*/
228218

229219
case MP_BC_SETUP_EXCEPT:
230220
DECODE_ULABEL; // except labels are always forward

py/vm.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
#define SET_TOP(val) *sp = (val)
2626

2727
mp_obj_t mp_execute_byte_code(const byte *code, const mp_obj_t *args, uint n_args, uint n_state) {
28+
n_state += 1; // XXX there is a bug somewhere which doesn't count enough state... (conwaylife and mandel have the bug)
29+
2830
// allocate state for locals and stack
2931
mp_obj_t temp_state[10];
3032
mp_obj_t *state = &temp_state[0];
@@ -86,6 +88,8 @@ bool mp_execute_byte_code_2(const byte *code_info, const byte **ip_in_out, mp_ob
8688
machine_uint_t *volatile exc_sp = &exc_stack[0] - 1; // stack grows up, exc_sp points to top of stack
8789
const byte *volatile save_ip = ip; // this is so we can access ip in the exception handler without making ip volatile (which means the compiler can't keep it in a register in the main loop)
8890

91+
// TODO if an exception occurs, do fast[0,1,2] become invalid??
92+
8993
// outer exception handling loop
9094
for (;;) {
9195
if (nlr_push(&nlr) == 0) {

0 commit comments

Comments
 (0)