Skip to content

Commit 12a5e17

Browse files
committed
py: Add finer configuration of static funcs when not in stackless mode.
Also rename call_args_t to mp_call_args_t.
1 parent dbc0191 commit 12a5e17

4 files changed

Lines changed: 16 additions & 7 deletions

File tree

py/objfun.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ STATIC void dump_args(const mp_obj_t *a, mp_uint_t sz) {
142142
// Set this to enable a simple stack overflow check.
143143
#define VM_DETECT_STACK_OVERFLOW (0)
144144

145+
#if MICROPY_STACKLESS
145146
mp_code_state *mp_obj_fun_bc_prepare_codestate(mp_obj_t self_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) {
146147
MP_STACK_CHECK();
147148
mp_obj_fun_bc_t *self = self_in;
@@ -176,6 +177,7 @@ mp_code_state *mp_obj_fun_bc_prepare_codestate(mp_obj_t self_in, mp_uint_t n_arg
176177

177178
return code_state;
178179
}
180+
#endif
179181

180182
STATIC mp_obj_t fun_bc_call(mp_obj_t self_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) {
181183
MP_STACK_CHECK();

py/runtime.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,11 @@ mp_obj_t mp_call_method_n_kw(mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *a
577577
return mp_call_function_n_kw(args[0], n_args + adjust, n_kw, args + 2 - adjust);
578578
}
579579

580-
void mp_call_prepare_args_n_kw_var(bool have_self, mp_uint_t n_args_n_kw, const mp_obj_t *args, call_args_t *out_args) {
580+
// This function only needs to be exposed externally when in stackless mode.
581+
#if !MICROPY_STACKLESS
582+
STATIC
583+
#endif
584+
void mp_call_prepare_args_n_kw_var(bool have_self, mp_uint_t n_args_n_kw, const mp_obj_t *args, mp_call_args_t *out_args) {
581585
mp_obj_t fun = *args++;
582586
mp_obj_t self = MP_OBJ_NULL;
583587
if (have_self) {
@@ -723,7 +727,7 @@ void mp_call_prepare_args_n_kw_var(bool have_self, mp_uint_t n_args_n_kw, const
723727
}
724728

725729
mp_obj_t mp_call_method_n_kw_var(bool have_self, mp_uint_t n_args_n_kw, const mp_obj_t *args) {
726-
call_args_t out_args;
730+
mp_call_args_t out_args;
727731
mp_call_prepare_args_n_kw_var(have_self, n_args_n_kw, args, &out_args);
728732

729733
mp_obj_t res = mp_call_function_n_kw(out_args.fun, out_args.n_args, out_args.n_kw, out_args.args);

py/runtime.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,16 +97,19 @@ mp_obj_t mp_call_function_n_kw(mp_obj_t fun, mp_uint_t n_args, mp_uint_t n_kw, c
9797
mp_obj_t mp_call_method_n_kw(mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args);
9898
mp_obj_t mp_call_method_n_kw_var(bool have_self, mp_uint_t n_args_n_kw, const mp_obj_t *args);
9999

100-
typedef struct _call_args_t {
100+
typedef struct _mp_call_args_t {
101101
mp_obj_t fun;
102102
mp_uint_t n_args, n_kw, n_alloc;
103103
mp_obj_t *args;
104-
} call_args_t;
104+
} mp_call_args_t;
105105

106+
#if MICROPY_STACKLESS
106107
// Takes arguments which are the most general mix of Python arg types, and
107108
// prepares argument array suitable for passing to ->call() method of a
108109
// function object (and mp_call_function_n_kw()).
109-
void mp_call_prepare_args_n_kw_var(bool have_self, mp_uint_t n_args_n_kw, const mp_obj_t *args, call_args_t *out_args);
110+
// (Only needed in stackless mode.)
111+
void mp_call_prepare_args_n_kw_var(bool have_self, mp_uint_t n_args_n_kw, const mp_obj_t *args, mp_call_args_t *out_args);
112+
#endif
110113

111114
void mp_unpack_sequence(mp_obj_t seq, mp_uint_t num, mp_obj_t *items);
112115
void mp_unpack_ex(mp_obj_t seq, mp_uint_t num, mp_obj_t *items);

py/vm.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -906,7 +906,7 @@ unwind_jump:;
906906
code_state->sp = sp;
907907
code_state->exc_sp = MP_TAGPTR_MAKE(exc_sp, currently_in_except_block);
908908

909-
call_args_t out_args;
909+
mp_call_args_t out_args;
910910
mp_call_prepare_args_n_kw_var(false, unum, sp, &out_args);
911911

912912
mp_code_state *new_state = mp_obj_fun_bc_prepare_codestate(out_args.fun,
@@ -977,7 +977,7 @@ unwind_jump:;
977977
code_state->sp = sp;
978978
code_state->exc_sp = MP_TAGPTR_MAKE(exc_sp, currently_in_except_block);
979979

980-
call_args_t out_args;
980+
mp_call_args_t out_args;
981981
mp_call_prepare_args_n_kw_var(true, unum, sp, &out_args);
982982

983983
mp_code_state *new_state = mp_obj_fun_bc_prepare_codestate(out_args.fun,

0 commit comments

Comments
 (0)