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

Issue 1927003004: Mac: Introduce "StaticCast" variants of base::mac::FooCastStrict, which do not typecheck in Release (Closed)

Created:
4 years, 7 months ago by tapted
Modified:
4 years, 7 months ago
Reviewers:
Mark Mentovai, Nico
CC:
chromium-reviews, chrome-apps-syd-reviews_chromium.org
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Mac: Introduce "StaticCast" variants of base::mac::FooCastStrict, which do not typecheck in Release The FooCastStrict methods in foundation_util.h DCHECK on a failed cast. In Release the DCHECK is skipped, but the type is still checked (and nil is returned on failure). This adds a runtime cost and hides potential Release-only bugs that may be getting absorbed by the runtime. Provide CFStaticCast and ObjCStaticCast which, in Release, just do the cast and are always inlineable. Context: this started with an investigation of a performance bottleneck in RenderTextMac which flagged calls to NSClassFromString(@"NSFont") as being surprisingly expensive. BUG=605131

Patch Set 1 #

Patch Set 2 : Remove typechecking from all the FooCastStrict variants #

Patch Set 3 : Make CFCastStrict inlineable #

Patch Set 4 : rebase #

Total comments: 2

Patch Set 5 : Split out NSClassFromString stuff #

Total comments: 3

Patch Set 6 : Add StaticCast variants #

Unified diffs Side-by-side diffs Delta from patch set Stats (+46 lines, -30 lines) Patch
M base/mac/foundation_util.h View 1 2 3 4 5 4 chunks +39 lines, -22 lines 0 comments Download
M ui/gfx/render_text_mac.mm View 1 2 3 4 5 2 chunks +7 lines, -8 lines 0 comments Download

Messages

Total messages: 16 (6 generated)
tapted
Hi Nico - WDYT? Note there is a behaviour change in Release -- now returns ...
4 years, 7 months ago (2016-04-29 02:40:37 UTC) #5
Nico
In general I think this is cool, but a) Mento wrote this, so he should ...
4 years, 7 months ago (2016-04-29 02:50:57 UTC) #6
tapted
+mento - WDYT? On 2016/04/29 02:50:57, Nico wrote: > In general I think this is ...
4 years, 7 months ago (2016-04-29 03:17:45 UTC) #8
tapted
mark: ping? WDYT..
4 years, 7 months ago (2016-05-05 07:15:07 UTC) #9
Mark Mentovai
https://codereview.chromium.org/1927003004/diff/80001/base/mac/foundation_util.h File base/mac/foundation_util.h (right): https://codereview.chromium.org/1927003004/diff/80001/base/mac/foundation_util.h#newcode279 base/mac/foundation_util.h:279: return (T)(cf_val); So now in release mode, the “strict” ...
4 years, 7 months ago (2016-05-05 13:26:31 UTC) #10
tapted
https://codereview.chromium.org/1927003004/diff/80001/base/mac/foundation_util.h File base/mac/foundation_util.h (right): https://codereview.chromium.org/1927003004/diff/80001/base/mac/foundation_util.h#newcode279 base/mac/foundation_util.h:279: return (T)(cf_val); On 2016/05/05 13:26:31, Mark Mentovai wrote: > ...
4 years, 7 months ago (2016-05-06 01:57:09 UTC) #11
tapted
On 2016/05/06 01:57:09, tapted wrote: > how would you feel about adding > another variant ...
4 years, 7 months ago (2016-05-06 03:29:58 UTC) #13
Mark Mentovai
https://codereview.chromium.org/1927003004/diff/80001/base/mac/foundation_util.h File base/mac/foundation_util.h (right): https://codereview.chromium.org/1927003004/diff/80001/base/mac/foundation_util.h#newcode279 base/mac/foundation_util.h:279: return (T)(cf_val); tapted wrote: > currently they may protect ...
4 years, 7 months ago (2016-05-06 15:34:41 UTC) #14
tapted
Sorry for the radio silence - I had a WIP response ages ago but it ...
4 years, 7 months ago (2016-05-25 05:35:18 UTC) #15
Mark Mentovai
4 years, 7 months ago (2016-05-25 14:06:27 UTC) #16
Message was sent while issue was closed.
I was a little surprised that the “strict” cast used DCHECK instead of CHECK.
That’s not how I remembered it, but it’s how it’s always been. I’d support
giving the “strict” variant fatal-in-release semantics.

Powered by Google App Engine
This is Rietveld 408576698