Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(51)

Issue 2723423002: Start BindStateBase ref count from 1 instead of 0 (Closed)

Created:
3 years, 9 months ago by tzik
Modified:
3 years, 8 months ago
Reviewers:
dcheng
CC:
chromium-reviews, gavinp+memory_chromium.org, vmpstr+watch_chromium.org, haraken
Target Ref:
refs/heads/master
Project:
chromium
Visibility:
Public.

Description

Start BindStateBase ref count from 1 instead of 0 The first atomic increments of ref counts are generally unneeded if the ref count starts from 1 instead of 0, and we can detect an invalid AddRef from 0 to 1 in that case. Especially, the ref count in BindStateBase is incremented 300k times in its constructor by the first page load from the browser boot, and also it sometimes hits invalid state. Note that 300k atomic increments are probably not so time consuming as we can measure. This CL adds `base::AdoptRef` to scoped_refptr for ref counted types whose ref count start from 1, and converts BindStateBase to use it. Review-Url: https://codereview.chromium.org/2723423002 Cr-Commit-Position: refs/heads/master@{#461372} Committed: https://chromium.googlesource.com/chromium/src/+/65f39693c549f42146b26cd35b13fa6a94fa0744

Patch Set 1 #

Patch Set 2 : . #

Patch Set 3 : fix #

Patch Set 4 : +comment. +DCHECK. #

Total comments: 2

Patch Set 5 : tag struct -> enum #

Patch Set 6 : . #

Patch Set 7 : fix #

Patch Set 8 : +test #

Total comments: 7

Patch Set 9 : wip #

Patch Set 10 : . #

Total comments: 2

Patch Set 11 : rm dead code. +test #

Total comments: 2

Patch Set 12 : +MAKE_REF_COUNT_START_FROM_ONE. +document #

Total comments: 2

Patch Set 13 : s/MAKE_REF_COUNT_START_FROM_ONE/REQUIRE_ADOPTION_FOR_REFCOUNTED_TYPE()/ #

Unified diffs Side-by-side diffs Delta from patch set Stats (+209 lines, -11 lines) Patch
M base/BUILD.gn View 1 2 3 4 5 6 7 8 9 10 11 12 1 chunk +1 line, -0 lines 0 comments Download
M base/callback_internal.h View 1 2 3 4 5 6 7 8 9 10 11 12 1 chunk +2 lines, -0 lines 0 comments Download
M base/callback_internal.cc View 1 2 3 4 5 6 7 8 1 chunk +2 lines, -3 lines 0 comments Download
M base/memory/ref_counted.h View 1 2 3 4 5 6 7 8 9 10 11 12 11 chunks +132 lines, -5 lines 0 comments Download
M base/memory/ref_counted.cc View 1 2 3 4 5 6 7 8 9 10 11 12 2 chunks +4 lines, -2 lines 0 comments Download
M base/memory/ref_counted_delete_on_sequence.h View 1 2 3 4 5 6 7 8 1 chunk +5 lines, -1 line 0 comments Download
M base/memory/ref_counted_unittest.cc View 1 2 3 4 5 6 7 8 9 10 11 12 3 chunks +38 lines, -0 lines 0 comments Download
A base/memory/ref_counted_unittest.nc View 1 2 3 4 5 6 7 8 9 1 chunk +25 lines, -0 lines 0 comments Download

Messages

Total messages: 74 (60 generated)
tzik
PTAL
3 years, 9 months ago (2017-03-06 13:42:10 UTC) #19
dcheng
"also it sometimes hits invalid state." Can you explain what this means? In general, I'm ...
3 years, 9 months ago (2017-03-06 22:09:19 UTC) #22
tzik
On 2017/03/06 22:09:19, dcheng wrote: > "also it sometimes hits invalid state." There are a ...
3 years, 9 months ago (2017-03-07 13:35:55 UTC) #30
tzik
https://codereview.chromium.org/2723423002/diff/60001/base/memory/ref_counted.h File base/memory/ref_counted.h (right): https://codereview.chromium.org/2723423002/diff/60001/base/memory/ref_counted.h#newcode391 base/memory/ref_counted.h:391: struct AdoptRefTag {}; On 2017/03/06 22:09:18, dcheng wrote: > ...
3 years, 9 months ago (2017-03-07 13:39:42 UTC) #32
dcheng
Is it possible to scope this to Callback only? I'm a bit uncomfortable with exposing ...
3 years, 9 months ago (2017-03-08 07:39:43 UTC) #35
tzik
On 2017/03/08 07:39:43, dcheng wrote: > Is it possible to scope this to Callback only? ...
3 years, 9 months ago (2017-03-21 14:05:18 UTC) #44
dcheng
Sorry for the review delay =( https://codereview.chromium.org/2723423002/diff/140001/base/memory/ref_counted.h File base/memory/ref_counted.h (right): https://codereview.chromium.org/2723423002/diff/140001/base/memory/ref_counted.h#newcode39 base/memory/ref_counted.h:39: explicit RefCountedBase(size_t initial_ref_count ...
3 years, 8 months ago (2017-03-30 04:26:16 UTC) #47
tzik
https://codereview.chromium.org/2723423002/diff/140001/base/memory/ref_counted.h File base/memory/ref_counted.h (right): https://codereview.chromium.org/2723423002/diff/140001/base/memory/ref_counted.h#newcode84 base/memory/ref_counted.h:84: return ref_count_ == 0; On 2017/03/30 04:26:15, dcheng wrote: ...
3 years, 8 months ago (2017-03-30 13:16:28 UTC) #54
dcheng
LGTM https://codereview.chromium.org/2723423002/diff/180001/base/memory/ref_counted_unittest.cc File base/memory/ref_counted_unittest.cc (right): https://codereview.chromium.org/2723423002/diff/180001/base/memory/ref_counted_unittest.cc#newcode129 base/memory/ref_counted_unittest.cc:129: base::subtle::kStartRefCountFromOneTag; On 2017/03/30 13:16:28, tzik wrote: > We ...
3 years, 8 months ago (2017-03-30 21:15:25 UTC) #57
tzik
Added document and a macro to opt-in. Could you take another look to them? https://codereview.chromium.org/2723423002/diff/200001/base/callback_internal.cc ...
3 years, 8 months ago (2017-03-31 13:31:00 UTC) #60
dcheng
LGTM https://codereview.chromium.org/2723423002/diff/220001/base/memory/ref_counted.h File base/memory/ref_counted.h (right): https://codereview.chromium.org/2723423002/diff/220001/base/memory/ref_counted.h#newcode186 base/memory/ref_counted.h:186: #define MAKE_REF_COUNT_START_FROM_ONE \ Two nits 1) Make this ...
3 years, 8 months ago (2017-04-03 00:07:30 UTC) #63
tzik
https://codereview.chromium.org/2723423002/diff/220001/base/memory/ref_counted.h File base/memory/ref_counted.h (right): https://codereview.chromium.org/2723423002/diff/220001/base/memory/ref_counted.h#newcode186 base/memory/ref_counted.h:186: #define MAKE_REF_COUNT_START_FROM_ONE \ On 2017/04/03 00:07:28, dcheng wrote: > ...
3 years, 8 months ago (2017-04-03 03:48:23 UTC) #66
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2723423002/240001
3 years, 8 months ago (2017-04-03 05:23:02 UTC) #71
commit-bot: I haz the power
3 years, 8 months ago (2017-04-03 05:29:20 UTC) #74
Message was sent while issue was closed.
Committed patchset #13 (id:240001) as
https://chromium.googlesource.com/chromium/src/+/65f39693c549f42146b26cd35b13...

Powered by Google App Engine
This is Rietveld 408576698