Skip to content
  • Punit Agrawal's avatar
    gclosure: Optimise g_closure_[ref|unref]() · a1a9ab17
    Punit Agrawal authored
    Using the CHANGE_FIELD() macro to implement reference counting leads
    to poor code generation. This is due to -
    
    * the fields of GClosure are defined as bitfields
    * using volatile bitfields forces extra loads
    
    Create specialised macros that operate on short (15bits for ref_count
    and 1 bit for meta_marshal_nouse) and use them to implement
    g_closure_[ref|unref](). The macros make use of the recently
    introduced g_atomic_int16_[add|dec_and_test]() atomic helpers.
    
    The existing asserts in place ensure that the value of ref_count
    doesn't spill over into the additional bit used for atomic
    instructions (meta_marshal_nouse).
    
    https://bugzilla.gnome.org/show_bug.cgi?id=791706
    a1a9ab17