mirror of
https://github.com/micropython/micropython.git
synced 2026-01-04 19:20:22 +01:00
py: Slightly simplify compile and emit of star/double-star arguments.
Saves a few bytes of code space and eliminates need for rot_two bytecode (hence saving RAM and execution time, by a tiny bit).
This commit is contained in:
@@ -2316,14 +2316,6 @@ STATIC void emit_native_call_function(emit_t *emit, mp_uint_t n_positional, mp_u
|
||||
} else {
|
||||
assert(vtype_fun == VTYPE_PYOBJ);
|
||||
if (star_flags) {
|
||||
if (!(star_flags & MP_EMIT_STAR_FLAG_SINGLE)) {
|
||||
// load dummy entry for non-existent pos_seq
|
||||
emit_native_load_null(emit);
|
||||
emit_native_rot_two(emit);
|
||||
} else if (!(star_flags & MP_EMIT_STAR_FLAG_DOUBLE)) {
|
||||
// load dummy entry for non-existent kw_dict
|
||||
emit_native_load_null(emit);
|
||||
}
|
||||
emit_get_stack_pointer_to_reg_for_pop(emit, REG_ARG_3, n_positional + 2 * n_keyword + 3); // pointer to args
|
||||
emit_call_with_2_imm_args(emit, MP_F_CALL_METHOD_N_KW_VAR, 0, REG_ARG_1, n_positional | (n_keyword << 8), REG_ARG_2);
|
||||
emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET);
|
||||
@@ -2340,14 +2332,6 @@ STATIC void emit_native_call_function(emit_t *emit, mp_uint_t n_positional, mp_u
|
||||
|
||||
STATIC void emit_native_call_method(emit_t *emit, mp_uint_t n_positional, mp_uint_t n_keyword, mp_uint_t star_flags) {
|
||||
if (star_flags) {
|
||||
if (!(star_flags & MP_EMIT_STAR_FLAG_SINGLE)) {
|
||||
// load dummy entry for non-existent pos_seq
|
||||
emit_native_load_null(emit);
|
||||
emit_native_rot_two(emit);
|
||||
} else if (!(star_flags & MP_EMIT_STAR_FLAG_DOUBLE)) {
|
||||
// load dummy entry for non-existent kw_dict
|
||||
emit_native_load_null(emit);
|
||||
}
|
||||
emit_get_stack_pointer_to_reg_for_pop(emit, REG_ARG_3, n_positional + 2 * n_keyword + 4); // pointer to args
|
||||
emit_call_with_2_imm_args(emit, MP_F_CALL_METHOD_N_KW_VAR, 1, REG_ARG_1, n_positional | (n_keyword << 8), REG_ARG_2);
|
||||
emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET);
|
||||
|
||||
Reference in New Issue
Block a user