Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Discussion options

I was bothered by the presumed waste of using 12 bytes to track which type slots are filled, rather than 12 bits.

So today I did the work to adapt the basic object structure like so: (full code at jepler@bitfield-slots)

// This struct is a variable sized struct. In order to use this as a         
// member, or allocate dynamically, use the mp_obj_empty_type_t or
// mp_obj_full_type_t structs below (which must be kept in sync).   
struct _mp_obj_type_t {
    // A type is an object so must start with this entry, which points to mp_type_type.
    mp_obj_base_t base;

    // Flags associated with this type.
    uint16_t flags;
    
    // The name of this type, a qstr.
    uint16_t name;
    
    // Slots: If a slot is populated, the corresponding bit in `filled_slots` is set.
    // The index in `slots[]` is simply the number of set bits "below" that one,
    // which can be determined with __builtin_popcnt().
    uint16_t filled_slots;
    // (16 spare bits here on most ports!)

    const void *slots[];
};

.. and changed the rest of the core as needed until unix make VARIANT=coverage test passed.

Then I noticed that cortex m4 (and everything below it) lacks a popcnt instruction. So this saved a mere 4 bytes on the "itsybitsy" build, and probably tanked performance due to all the introduced __popcountsi2 calls.. And it makes the MP_DEFINE_CONST_OBJ_TYPE_NARGS_ macros much more gruesome.

You must be logged in to vote

Replies: 0 comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
💡
Ideas
Labels
None yet
1 participant
Morty Proxy This is a proxified and sanitized view of the page, visit original site.