From b4ebad3310b238bb85ea1f0d7b78b4fcb3d146df Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Sat, 31 May 2014 16:50:46 +0300 Subject: vm: Factor out structure with code execution state and pass it around. This improves stack usage in callers to mp_execute_bytecode2, and is step forward towards unifying execution interface for function and generators (which is important because generators don't even support full forms of arguments passing (keywords, etc.)). --- py/bc.h | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'py/bc.h') diff --git a/py/bc.h b/py/bc.h index 6c1e45b2b..6c604fe1c 100644 --- a/py/bc.h +++ b/py/bc.h @@ -36,8 +36,21 @@ typedef struct _mp_exc_stack { byte opcode; } mp_exc_stack_t; +typedef struct _mp_code_state { + const byte *code_info; + const byte *ip; + mp_obj_t *sp; + // bit 0 is saved currently_in_except_block value + mp_exc_stack_t *exc_sp; + uint n_state; + // Variable-length + mp_obj_t state[0]; + // Variable-length, never accessed by name, only as (void*)(state + n_state) + //mp_exc_stack_t exc_state[0]; +} mp_code_state; + mp_vm_return_kind_t mp_execute_bytecode(const byte *code, const mp_obj_t *args, uint n_args, const mp_obj_t *args2, uint n_args2, mp_obj_t *ret); -mp_vm_return_kind_t mp_execute_bytecode2(const byte *code_info, const byte **ip_in_out, mp_obj_t *fastn, mp_obj_t **sp_in_out, mp_exc_stack_t *exc_stack, mp_exc_stack_t **exc_sp_in_out, volatile mp_obj_t inject_exc); +mp_vm_return_kind_t mp_execute_bytecode2(mp_code_state *code_state, volatile mp_obj_t inject_exc); void mp_bytecode_print(const byte *code, int len); void mp_bytecode_print2(const byte *code, int len); -- cgit v1.2.3