summaryrefslogtreecommitdiff
path: root/py/vm.c
diff options
context:
space:
mode:
Diffstat (limited to 'py/vm.c')
-rw-r--r--py/vm.c45
1 files changed, 9 insertions, 36 deletions
diff --git a/py/vm.c b/py/vm.c
index 0cc26021e..8f5bb1ee5 100644
--- a/py/vm.c
+++ b/py/vm.c
@@ -26,8 +26,6 @@
#define SET_TOP(val) *sp = (val)
mp_obj_t mp_execute_byte_code(const byte *code, const mp_obj_t *args, uint n_args, uint n_state) {
- n_state += 1; // XXX there is a bug somewhere which doesn't count enough state... (conwaylife and mandel have the bug)
-
// allocate state for locals and stack
mp_obj_t temp_state[10];
mp_obj_t *state = &temp_state[0];
@@ -82,7 +80,6 @@ bool mp_execute_byte_code_2(const byte *code_info, const byte **ip_in_out, mp_ob
machine_uint_t unum;
qstr qst;
mp_obj_t obj1, obj2;
- mp_obj_t fast0 = fastn[0], fast1 = fastn[-1], fast2 = fastn[-2];
nlr_buf_t nlr;
volatile machine_uint_t currently_in_except_block = 0; // 0 or 1, to detect nested exceptions
@@ -90,8 +87,6 @@ bool mp_execute_byte_code_2(const byte *code_info, const byte **ip_in_out, mp_ob
machine_uint_t *volatile exc_sp = &exc_stack[0] - 1; // stack grows up, exc_sp points to top of stack
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)
- // TODO if an exception occurs, do fast[0,1,2] become invalid??
-
// outer exception handling loop
for (;;) {
if (nlr_push(&nlr) == 0) {
@@ -148,15 +143,15 @@ bool mp_execute_byte_code_2(const byte *code_info, const byte **ip_in_out, mp_ob
break;
case MP_BC_LOAD_FAST_0:
- PUSH(fast0);
+ PUSH(fastn[0]);
break;
case MP_BC_LOAD_FAST_1:
- PUSH(fast1);
+ PUSH(fastn[-1]);
break;
case MP_BC_LOAD_FAST_2:
- PUSH(fast2);
+ PUSH(fastn[-2]);
break;
case MP_BC_LOAD_FAST_N:
@@ -166,16 +161,7 @@ bool mp_execute_byte_code_2(const byte *code_info, const byte **ip_in_out, mp_ob
case MP_BC_LOAD_DEREF:
DECODE_UINT;
- if (unum == 0) {
- obj1 = fast0;
- } else if (unum == 1) {
- obj1 = fast1;
- } else if (unum == 2) {
- obj1 = fast2;
- } else {
- obj1 = fastn[-unum];
- }
- PUSH(rt_get_cell(obj1));
+ PUSH(rt_get_cell(fastn[-unum]));
break;
case MP_BC_LOAD_NAME:
@@ -204,15 +190,15 @@ bool mp_execute_byte_code_2(const byte *code_info, const byte **ip_in_out, mp_ob
break;
case MP_BC_STORE_FAST_0:
- fast0 = POP();
+ fastn[0] = POP();
break;
case MP_BC_STORE_FAST_1:
- fast1 = POP();
+ fastn[-1] = POP();
break;
case MP_BC_STORE_FAST_2:
- fast2 = POP();
+ fastn[-2] = POP();
break;
case MP_BC_STORE_FAST_N:
@@ -222,16 +208,7 @@ bool mp_execute_byte_code_2(const byte *code_info, const byte **ip_in_out, mp_ob
case MP_BC_STORE_DEREF:
DECODE_UINT;
- if (unum == 0) {
- obj1 = fast0;
- } else if (unum == 1) {
- obj1 = fast1;
- } else if (unum == 2) {
- obj1 = fast2;
- } else {
- obj1 = fastn[-unum];
- }
- rt_set_cell(obj1, POP());
+ rt_set_cell(fastn[-unum], POP());
break;
case MP_BC_STORE_NAME:
@@ -479,8 +456,7 @@ bool mp_execute_byte_code_2(const byte *code_info, const byte **ip_in_out, mp_ob
case MP_BC_MAKE_CLOSURE:
DECODE_UINT;
- obj1 = POP();
- PUSH(rt_make_closure_from_id(unum, obj1));
+ SET_TOP(rt_make_closure_from_id(unum, TOP()));
break;
case MP_BC_CALL_FUNCTION:
@@ -514,9 +490,6 @@ bool mp_execute_byte_code_2(const byte *code_info, const byte **ip_in_out, mp_ob
case MP_BC_YIELD_VALUE:
nlr_pop();
*ip_in_out = ip;
- fastn[0] = fast0;
- fastn[-1] = fast1;
- fastn[-2] = fast2;
*sp_in_out = sp;
return true;