Skip to content

Commit d419081

Browse files
committedJan 25, 2024
py/mpconfig: Disable qstr hashing at minimum feature level.
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]>
1 parent 8486e28 commit d419081

File tree

7 files changed

+4
-10
lines changed

7 files changed

+4
-10
lines changed
 

‎ports/cc3200/mpconfigport.h

-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@
5959
#else
6060
#define MICROPY_CPYTHON_COMPAT (0)
6161
#endif
62-
#define MICROPY_QSTR_BYTES_IN_HASH (1)
6362

6463
// fatfs configuration used in ffconf.h
6564
#define MICROPY_FATFS_ENABLE_LFN (2)

‎ports/nrf/mpconfigport.h

-1
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,6 @@
281281
#define MICROPY_PY_SYS (1)
282282
#define MICROPY_PY_SYS_PATH_ARGV_DEFAULTS (1)
283283
#define MICROPY_PY___FILE__ (1)
284-
#define MICROPY_QSTR_BYTES_IN_HASH (2)
285284
#endif
286285

287286
#ifndef MICROPY_PY_UBLUEPY

‎ports/pic16bit/mpconfigport.h

-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
// options to control how MicroPython is built
3030
#define MICROPY_OBJ_REPR (MICROPY_OBJ_REPR_B)
3131
#define MICROPY_ALLOC_PATH_MAX (64)
32-
#define MICROPY_QSTR_BYTES_IN_HASH (1)
3332
#define MICROPY_EMIT_X64 (0)
3433
#define MICROPY_EMIT_THUMB (0)
3534
#define MICROPY_EMIT_INLINE_THUMB (0)

‎ports/powerpc/mpconfigport.h

-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535

3636
// #define MICROPY_DEBUG_VERBOSE (1)
3737

38-
#define MICROPY_QSTR_BYTES_IN_HASH (1)
3938
#define MICROPY_QSTR_EXTRA_POOL mp_qstr_frozen_const_pool
4039
#define MICROPY_ALLOC_PATH_MAX (256)
4140
#define MICROPY_EMIT_X64 (0)

‎ports/samd/mpconfigport.h

-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
#define MICROPY_GC_STACK_ENTRY_TYPE uint16_t
3636
#define MICROPY_GC_ALLOC_THRESHOLD (0)
3737
#define MICROPY_ALLOC_PATH_MAX (256)
38-
#define MICROPY_QSTR_BYTES_IN_HASH (1)
3938

4039
// MicroPython emitters
4140
#define MICROPY_PERSISTENT_CODE_LOAD (1)

‎ports/unix/variants/minimal/mpconfigvariant.h

-3
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,3 @@
6464
// Enable just the sys and os built-in modules.
6565
#define MICROPY_PY_SYS (1)
6666
#define MICROPY_PY_OS (1)
67-
68-
// The minimum sets this to 1 to save flash.
69-
#define MICROPY_QSTR_BYTES_IN_HASH (2)

‎py/mpconfig.h

+4-2
Original file line numberDiff line numberDiff line change
@@ -290,10 +290,12 @@
290290

291291
// Number of bytes used to store qstr hash
292292
#ifndef MICROPY_QSTR_BYTES_IN_HASH
293-
#if MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES
293+
#if MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES
294294
#define MICROPY_QSTR_BYTES_IN_HASH (2)
295-
#else
295+
#elif MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES
296296
#define MICROPY_QSTR_BYTES_IN_HASH (1)
297+
#else
298+
#define MICROPY_QSTR_BYTES_IN_HASH (0)
297299
#endif
298300
#endif
299301

0 commit comments

Comments
 (0)