py/objcell: Make cell get/set funcs static-inline to reduce code size.

Change in code size is:

       bare-arm:   -36 -0.062%
    minimal x86:   -92 -0.056%
       unix x64:   -72 -0.014%
    unix nanbox:  -276 -0.060%
          stm32:    +0 +0.000% PYBV10
          stm32:   -40 +0.021% NUCLEO_L073RZ
         cc3200:   -16 -0.009%
        esp8266:  +176 +0.025% GENERIC
          esp32:   -28 -0.002% GENERIC
         mimxrt:   -56 -0.016% TEENSY40
     renesas-ra:    +0 +0.000% RA6M2_EK
            nrf:    +0 +0.000% pca10040
            rp2:   -64 -0.013% PICO
           samd:   -32 -0.023% ADAFRUIT_ITSYBITSY_M4_EXPRESS

Ports like stm32 that build the VM with -O3 have no change because the
savings from the inlining are offset by additional gcc performance
optimisations in the VM.

Signed-off-by: Damien George <damien@micropython.org>
pull/9310/head
Damien George 2022-06-19 00:54:40 +10:00
rodzic a506335524
commit 5d3a0bb59c
2 zmienionych plików z 15 dodań i 17 usunięć

Wyświetl plik

@ -838,8 +838,21 @@ mp_obj_t mp_obj_subscr(mp_obj_t base, mp_obj_t index, mp_obj_t val);
mp_obj_t mp_generic_unary_op(mp_unary_op_t op, mp_obj_t o_in);
// cell
mp_obj_t mp_obj_cell_get(mp_obj_t self_in);
void mp_obj_cell_set(mp_obj_t self_in, mp_obj_t obj);
typedef struct _mp_obj_cell_t {
mp_obj_base_t base;
mp_obj_t obj;
} mp_obj_cell_t;
static inline mp_obj_t mp_obj_cell_get(mp_obj_t self_in) {
mp_obj_cell_t *self = (mp_obj_cell_t *)MP_OBJ_TO_PTR(self_in);
return self->obj;
}
static inline void mp_obj_cell_set(mp_obj_t self_in, mp_obj_t obj) {
mp_obj_cell_t *self = (mp_obj_cell_t *)MP_OBJ_TO_PTR(self_in);
self->obj = obj;
}
// int
// For long int, returns value truncated to mp_int_t

Wyświetl plik

@ -26,21 +26,6 @@
#include "py/obj.h"
typedef struct _mp_obj_cell_t {
mp_obj_base_t base;
mp_obj_t obj;
} mp_obj_cell_t;
mp_obj_t mp_obj_cell_get(mp_obj_t self_in) {
mp_obj_cell_t *self = MP_OBJ_TO_PTR(self_in);
return self->obj;
}
void mp_obj_cell_set(mp_obj_t self_in, mp_obj_t obj) {
mp_obj_cell_t *self = MP_OBJ_TO_PTR(self_in);
self->obj = obj;
}
#if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_DETAILED
STATIC void cell_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) {
(void)kind;