[webkit-dev] std::shared_ptr?

2013-10-26 Thread Brendan Long
On 10/25/2013 06:38 PM, Darin Adler wrote:
 We are replacing PassOwnPtr and OwnPtr with std::unique_ptr. This is
 part of a general trend where we are adopting some C++11 language and
 library features.
Is there any plan to replace RefPtr with std::shared_ptr too, or is
there some reason why that would be a bad idea?
___
webkit-dev mailing list
webkit-dev@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-dev


Re: [webkit-dev] std::shared_ptr?

2013-10-26 Thread Ryosuke Niwa
I don't think we can afford to use shared_ptr.  As far as I know, it
allocates a new memory space for each object to be shared.  Doing that for
every DOM node will probably be prohibitively expensive.


- R. Niwa


On Sat, Oct 26, 2013 at 11:16 AM, Brendan Long s...@brendanlong.com wrote:

 On 10/25/2013 06:38 PM, Darin Adler wrote:
  We are replacing PassOwnPtr and OwnPtr with std::unique_ptr. This is
  part of a general trend where we are adopting some C++11 language and
  library features.
 Is there any plan to replace RefPtr with std::shared_ptr too, or is
 there some reason why that would be a bad idea?
 ___
 webkit-dev mailing list
 webkit-dev@lists.webkit.org
 https://lists.webkit.org/mailman/listinfo/webkit-dev

___
webkit-dev mailing list
webkit-dev@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-dev


Re: [webkit-dev] std::shared_ptr?

2013-10-26 Thread Brendan Long
One of the answers on this Stack Overflow question
http://stackoverflow.com/questions/3628081/shared-ptr-horrible-speed
suggests that we can fix the memory issue by using `making_shared`:

 *use* |make_shared|
http://en.cppreference.com/w/cpp/memory/shared_ptr/make_shared *to
allocate them*, because (unfortunately) the normal constructor allocates
two different blocks: one for the object and one for the counter and
deleter.

Unfortunately, it looks like
http://nerds-central.blogspot.com/2012/03/sharedptr-performance-issues-and.html
they're really slow because they're thread-safe, but that may also apply
to RefPtr.
___
webkit-dev mailing list
webkit-dev@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-dev


Re: [webkit-dev] std::shared_ptr?

2013-10-26 Thread Benjamin Poulain
On 10/26/13, 8:51 PM, Brendan Long wrote:
 One of the answers on this Stack Overflow question
 http://stackoverflow.com/questions/3628081/shared-ptr-horrible-speed
 suggests that we can fix the memory issue by using `making_shared`:
 
 *use* |make_shared|
 http://en.cppreference.com/w/cpp/memory/shared_ptr/make_shared *to
 allocate them*, because (unfortunately) the normal constructor allocates
 two different blocks: one for the object and one for the counter and
 deleter.
 
 Unfortunately, it looks like
 http://nerds-central.blogspot.com/2012/03/sharedptr-performance-issues-and.html
 they're really slow because they're thread-safe, but that may also apply
 to RefPtr.

RefPtr is not thread-safe.

The count itself is maintained by the objects, not the smart pointer.
The vast majority of objects are not thread-safe either due to obvious
performance problems.

Benjamin
___
webkit-dev mailing list
webkit-dev@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-dev