)]}'
{
  "commit": "c2d11212ca79d9fed19f52e8d34f6999bbd653e2",
  "tree": "2d8978a94e1e2f150adf735436c32b5037352380",
  "parents": [
    "1b32e72073d52cb835ab947238e1c0217f87b58f"
  ],
  "author": {
    "name": "Thomas Haller",
    "email": "thaller@redhat.com",
    "time": "Wed Dec 20 09:55:32 2023 +0100"
  },
  "committer": {
    "name": "Thomas Haller",
    "email": "thaller@redhat.com",
    "time": "Wed Jan 17 16:15:39 2024 +0100"
  },
  "message": "gobject: use per-object bit-lock instead of global RWLock for GWeakRef\n\nReplace the global RWLock with a per-object locking.\n\ng_object_unref() needs to take a lock for GWeakRef while decrementing\nthe reference count to zero. That is also the case, when no weak refs\nactually are registered because we cannot know that in a race free\nmanner without taking the lock. Replace the global RWLock with a\nper-object bit lock.\n\nNow there are actually two locks. The per-object lock\nOPTIONAL2_BIT_LOCK_G_WEAK_REF and a bit lock WEAK_REF_LOCK on\n`\u0026weak_ref-\u003epriv.p`.\n\nThe object lock OPTIONAL2_BIT_LOCK_G_WEAK_REF must be taken first, we\ncannot take it after having a WEAK_REF_LOCK lock. This prevents dead\nlocks.\n\nDownsides:\n\n- this requires to grow the GObject size (on x86_64) to add a\n  GObjectPrivate for \"optional2_flags\". We cannot use the bitlock\n  on \"optional_flags\", because while holding _weak_ref_lock(), we\n  need to be able to call g_object_ref(). g_object_ref() locks on\n  OPTIONAL_BIT_LOCK_TOGGLE_REFS. If OPTIONAL2_BIT_LOCK_G_WEAK_REF were on\n  the same \"optional_flags\" as OPTIONAL_BIT_LOCK_TOGGLE_REFS, it would\n  mean we have cases where we take\n\n     OPTIONAL2_BIT_LOCK_G_WEAK_REF \u0026\u0026 _weak_ref_lock()\n\n  and cases where we take\n\n    _weak_ref_lock() \u0026\u0026 OPTIONAL_BIT_LOCK_TOGGLE_REFS\n\n  That would deadlock. We need distinct locks for that. Add another\n  gint field in GObjectPrivate for the bitlock OPTIONAL2_BIT_LOCK_G_WEAK_REF.\n\n- now `g_weak_ref_set()` also temporarily raises the ref count on the\n  old object. That is because we must keep the old object alive to take\n  a OPTIONAL2_BIT_LOCK_G_WEAK_REF lock. Taking and dropping references\n  emit toggle notifications, which is a visible change in behavior.\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "0f31c60da0e2d7f8b6491303b7b1a572e2186229",
      "old_mode": 33188,
      "old_path": "gobject/gobject.c",
      "new_id": "1b24a2311b8576ed7b6e52055785dd4c54d4d028",
      "new_mode": 33188,
      "new_path": "gobject/gobject.c"
    }
  ]
}
