Summary: | eliminate default ref. count of 0 in RefCounted class | ||||||||
---|---|---|---|---|---|---|---|---|---|
Product: | WebKit | Reporter: | Darin Adler <darin> | ||||||
Component: | Web Template Framework | Assignee: | Darin Adler <darin> | ||||||
Status: | RESOLVED FIXED | ||||||||
Severity: | Normal | CC: | eric | ||||||
Priority: | P2 | ||||||||
Version: | 528+ (Nightly build) | ||||||||
Hardware: | All | ||||||||
OS: | All | ||||||||
Attachments: |
|
Description
Darin Adler
2008-02-09 06:46:01 PST
Created attachment 19016 [details]
add explicit initialization of RefCounted to 0 almost everywhere
Comment on attachment 19016 [details]
add explicit initialization of RefCounted to 0 almost everywhere
r=me.
It seems like changing everything to start with a ref count of 1 is a lot of work for little gain. The malloc() should always dwarf the ref() call I would think. Then again, maybe the parser could benefit from this? How does one change RefPtr to take advantage of such a change? (Since a stated goal has long been to get rid of most raw pointers in WebCore and instead us scoped/smart pointers like RefPtr.)
(In reply to comment #2) > It seems like changing everything to start with a ref count of 1 is a lot of > work for little gain. The malloc() should always dwarf the ref() call I would > think. I once thought this too, but recent measurements seem to indicate otherwise. For example, Geoff Garen got a 1% speedup with <http://trac.webkit.org/projects/webkit/changeset/30042>, which is also something that happens only once per object. I predict this will be well worth it; we should start seeing speed-ups soon. This also ends up with a much more elegant usage model. We don't want you to be able to create an object with a ref count of 0. That's just a recipe for leaking. Instead we make objects and put them in PassRefPtr right away. It'll be less elegant during the transition. Comment on attachment 19016 [details]
add explicit initialization of RefCounted to 0 almost everywhere
Eric reviewed and said r=me, but forgot to set review+.
(In reply to comment #2) > How does one change RefPtr to take advantage of such a change? You don't have to change RefPtr. You just call adoptRef on the result of new rather than putting it in a RefPtr or PassRefPtr without adoptRef. Here's an example: <http://trac.webkit.org/projects/webkit/changeset/30109>. The short-term scaffolding is the need to add explicit initialization of RefCounted. Once the default is changed to 1 we can remove those again. Committed revision 30122. This task won't be completely done until I take out the RefCounted default of 0 and we get rid of the last few clients. Then I'll change the default to 1 for the future. Comment on attachment 19016 [details]
add explicit initialization of RefCounted to 0 almost everywhere
Clearing review flag since this was landed.
Created attachment 19043 [details]
patch for next step -- actually remove the default
Comment on attachment 19043 [details]
patch for next step -- actually remove the default
r=me
|