Skip to content

Commit

Permalink
py/mpconfig: Disable qstr hashing at minimum feature level.
Browse files Browse the repository at this point in the history
This will apply to bare-arm and minimal, as well as the minimal unix
variant.

Change the default to MICROPY_QSTR_BYTES_IN_HASH=1 for the CORE,BASIC
levels, 2 for >=EXTRA.

Removes explicit setting of MICROPY_QSTR_BYTES_IN_HASH==1 in ports that
don't set the feature level (because 1 is implied by the default level,
CORE). Applies to cc3200, pic16bt, powerpc.

Removes explicit setting for nRF (which sets feature level). Also for samd,
which sets CORE for d21 and FULL for d51. This means that d21 is unchanged
with MICROPY_QSTR_BYTES_IN_HASH==1, but d51 now moves from 1 to 2 (roughly
adds 1kiB).

The only remaining port which explicitly set bytes-in-hash is rp2 because
it's high-flash (hence CORE level) but lowish-SRAM, so it's worthwhile
saving the RAM for runtime qstrs.

This work was funded through GitHub Sponsors.

Signed-off-by: Jim Mussared <[email protected]>
  • Loading branch information
jimmo committed Jan 25, 2024
1 parent 8486e28 commit d419081
Show file tree
Hide file tree
Showing 7 changed files with 4 additions and 10 deletions.
1 change: 0 additions & 1 deletion ports/cc3200/mpconfigport.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
#else
#define MICROPY_CPYTHON_COMPAT (0)
#endif
#define MICROPY_QSTR_BYTES_IN_HASH (1)

// fatfs configuration used in ffconf.h
#define MICROPY_FATFS_ENABLE_LFN (2)
Expand Down
1 change: 0 additions & 1 deletion ports/nrf/mpconfigport.h
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,6 @@
#define MICROPY_PY_SYS (1)
#define MICROPY_PY_SYS_PATH_ARGV_DEFAULTS (1)
#define MICROPY_PY___FILE__ (1)
#define MICROPY_QSTR_BYTES_IN_HASH (2)
#endif

#ifndef MICROPY_PY_UBLUEPY
Expand Down
1 change: 0 additions & 1 deletion ports/pic16bit/mpconfigport.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
// options to control how MicroPython is built
#define MICROPY_OBJ_REPR (MICROPY_OBJ_REPR_B)
#define MICROPY_ALLOC_PATH_MAX (64)
#define MICROPY_QSTR_BYTES_IN_HASH (1)
#define MICROPY_EMIT_X64 (0)
#define MICROPY_EMIT_THUMB (0)
#define MICROPY_EMIT_INLINE_THUMB (0)
Expand Down
1 change: 0 additions & 1 deletion ports/powerpc/mpconfigport.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@

// #define MICROPY_DEBUG_VERBOSE (1)

#define MICROPY_QSTR_BYTES_IN_HASH (1)
#define MICROPY_QSTR_EXTRA_POOL mp_qstr_frozen_const_pool
#define MICROPY_ALLOC_PATH_MAX (256)
#define MICROPY_EMIT_X64 (0)
Expand Down
1 change: 0 additions & 1 deletion ports/samd/mpconfigport.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
#define MICROPY_GC_STACK_ENTRY_TYPE uint16_t
#define MICROPY_GC_ALLOC_THRESHOLD (0)
#define MICROPY_ALLOC_PATH_MAX (256)
#define MICROPY_QSTR_BYTES_IN_HASH (1)

// MicroPython emitters
#define MICROPY_PERSISTENT_CODE_LOAD (1)
Expand Down
3 changes: 0 additions & 3 deletions ports/unix/variants/minimal/mpconfigvariant.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,3 @@
// Enable just the sys and os built-in modules.
#define MICROPY_PY_SYS (1)
#define MICROPY_PY_OS (1)

// The minimum sets this to 1 to save flash.
#define MICROPY_QSTR_BYTES_IN_HASH (2)
6 changes: 4 additions & 2 deletions py/mpconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -290,10 +290,12 @@

// Number of bytes used to store qstr hash
#ifndef MICROPY_QSTR_BYTES_IN_HASH
#if MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES
#if MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES
#define MICROPY_QSTR_BYTES_IN_HASH (2)
#else
#elif MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES
#define MICROPY_QSTR_BYTES_IN_HASH (1)
#else
#define MICROPY_QSTR_BYTES_IN_HASH (0)
#endif
#endif

Expand Down

0 comments on commit d419081

Please sign in to comment.