[Webkit-unassigned] [Bug 31639] Add asserts to RefCounted to make sure ref/deref happens on the right thread.

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Wed Dec 2 18:49:45 PST 2009


https://bugs.webkit.org/show_bug.cgi?id=31639


Dmitry Titov <dimich at chromium.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #43545|0                           |1
        is obsolete|                            |
  Attachment #44201|                            |review?, commit-queue-
               Flag|                            |




--- Comment #2 from Dmitry Titov <dimich at chromium.org>  2009-12-02 18:49:45 PST ---
Created an attachment (id=44201)
 --> (https://bugs.webkit.org/attachment.cgi?id=44201)
Proposed patch.

Adds ASSERT to RefCountedBase to verify the ref()/deref() and hasOneref(),
refCount() happen on the same thread.

For objects that are intentionally used in cross-process scenario, there is
disableThreadVerification() which excludes them from the checks. I used this to
exclude Stringimpl and classes used in IconDatabase.

Also, the checks only are activated when refcount becomes >= 2 and deactivated
when refcount goes below 2 (borrowed the idea from CrossThreadRefCounted). This
prevents the assertions in a very typical scenario when object is created on
one thread and then passed via PassRefPtr to another thread where it is used
exclusively and then destroyed. It seems it's mostly ok to transfer an object
with refcount 1 between threads - so the asserts are only activated when
refcount is >1, meaning the object is actually 'shared'.

Perf impact on Debug build is about 2% on run-webkit-tests, and there are no
asserts fired during the run.

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the webkit-unassigned mailing list