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

Issue 23455061: Add sk_calloc and sk_calloc_throw to SkMemory_new_handler.cpp. (Closed)

Created:
7 years, 2 months ago by mtklein
Modified:
7 years, 2 months ago
CC:
chromium-reviews, erikwright+watch_chromium.org, Robert Sesek
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Visibility:
Public.

Description

Add sk_calloc and sk_calloc_throw to SkMemory_new_handler.cpp. After finding that calloc can be significantly faster than malloc+bzero on some platforms (notably, Android), Skia wants to start experimenting with using calloc where possible. For this, we've added sk_calloc and sk_calloc_throw to the SkMemory API. This CL is my ham-handed approach to add calloc support to SkMemory_new_handler.cpp. It seems to me that this exists as an alternative to SkMemory_malloc.cpp so that we can try to dodge any OOM crash that the underlying malloc implementation might helpfully provide? I've tried to mimic what I saw here for the non-throwing malloc onto sk_calloc, and just did some refactoring to make this code look a bit more like the current SkMemory_malloc.cpp. BUG=skia:1662 Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=227563

Patch Set 1 #

Total comments: 7

Patch Set 2 : unchecked_malloc -> unchecked_alloc #

Patch Set 3 : stray whitespace #

Total comments: 5

Patch Set 4 : throwOnFailure -> throw_on_failure #

Unified diffs Side-by-side diffs Delta from patch set Stats (+69 lines, -39 lines) Patch
M base/process/memory.h View 1 chunk +1 line, -0 lines 0 comments Download
M base/process/memory_mac.mm View 1 2 3 3 chunks +14 lines, -3 lines 0 comments Download
M skia/ext/SkMemory_new_handler.cpp View 1 2 3 3 chunks +54 lines, -36 lines 0 comments Download

Messages

Total messages: 17 (0 generated)
mtklein
Hi guys, I'm in unfamiliar code here so I've picked most likely reviewers via blame. ...
7 years, 2 months ago (2013-09-24 20:12:19 UTC) #1
Scott Hess - ex-Googler
I think LGTM from the osx side. rsesek FYI. https://codereview.chromium.org/23455061/diff/1/base/process/memory_mac.mm File base/process/memory_mac.mm (right): https://codereview.chromium.org/23455061/diff/1/base/process/memory_mac.mm#newcode505 base/process/memory_mac.mm:505: ...
7 years, 2 months ago (2013-09-24 21:05:53 UTC) #2
mtklein
https://codereview.chromium.org/23455061/diff/1/base/process/memory_mac.mm File base/process/memory_mac.mm (right): https://codereview.chromium.org/23455061/diff/1/base/process/memory_mac.mm#newcode505 base/process/memory_mac.mm:505: ThreadLocalBooleanAutoReset flag(g_unchecked_malloc.Pointer(), true); On 2013/09/24 21:05:54, shess wrote: > ...
7 years, 2 months ago (2013-09-24 21:12:18 UTC) #3
Scott Hess - ex-Googler
still LGTM.
7 years, 2 months ago (2013-09-24 21:21:32 UTC) #4
Stephen White
LGTM https://codereview.chromium.org/23455061/diff/11001/skia/ext/SkMemory_new_handler.cpp File skia/ext/SkMemory_new_handler.cpp (right): https://codereview.chromium.org/23455061/diff/11001/skia/ext/SkMemory_new_handler.cpp#newcode17 skia/ext/SkMemory_new_handler.cpp:17: // new_handler itself will crash on failure when ...
7 years, 2 months ago (2013-09-24 22:35:02 UTC) #5
mtklein
https://codereview.chromium.org/23455061/diff/11001/skia/ext/SkMemory_new_handler.cpp File skia/ext/SkMemory_new_handler.cpp (right): https://codereview.chromium.org/23455061/diff/11001/skia/ext/SkMemory_new_handler.cpp#newcode78 skia/ext/SkMemory_new_handler.cpp:78: void* sk_calloc_throw(size_t size) { On 2013/09/24 22:35:02, Stephen White ...
7 years, 2 months ago (2013-09-26 14:44:16 UTC) #6
mtklein
Nico, do you mind taking a look at this OWNERS approval?
7 years, 2 months ago (2013-09-26 14:50:15 UTC) #7
mtklein
*for* OWNERS approval... sigh. On Thu, Sep 26, 2013 at 10:50 AM, <mtklein@google.com> wrote: > ...
7 years, 2 months ago (2013-09-26 15:03:56 UTC) #8
mtklein
Ping? On Thu, Sep 26, 2013 at 11:03 AM, Mike Klein <mtklein@google.com> wrote: > *for* ...
7 years, 2 months ago (2013-10-02 14:12:21 UTC) #9
mtklein
+darin Darin, can you take a look for OWNERS approval? I don't seem to be ...
7 years, 2 months ago (2013-10-04 16:02:16 UTC) #10
darin (slow to review)
base/ changes LGTM https://codereview.chromium.org/23455061/diff/11001/skia/ext/SkMemory_new_handler.cpp File skia/ext/SkMemory_new_handler.cpp (right): https://codereview.chromium.org/23455061/diff/11001/skia/ext/SkMemory_new_handler.cpp#newcode21 skia/ext/SkMemory_new_handler.cpp:21: static inline void* throwOnFailure(size_t size, void* ...
7 years, 2 months ago (2013-10-05 06:11:59 UTC) #11
mtklein
https://codereview.chromium.org/23455061/diff/11001/skia/ext/SkMemory_new_handler.cpp File skia/ext/SkMemory_new_handler.cpp (right): https://codereview.chromium.org/23455061/diff/11001/skia/ext/SkMemory_new_handler.cpp#newcode21 skia/ext/SkMemory_new_handler.cpp:21: static inline void* throwOnFailure(size_t size, void* p) { On ...
7 years, 2 months ago (2013-10-07 17:32:36 UTC) #12
darin (slow to review)
OK, LGTM
7 years, 2 months ago (2013-10-08 04:02:46 UTC) #13
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/mtklein@google.com/23455061/24001
7 years, 2 months ago (2013-10-08 12:21:53 UTC) #14
commit-bot: I haz the power
Step "update" is always a major failure. Look at the try server FAQ for more ...
7 years, 2 months ago (2013-10-08 13:51:17 UTC) #15
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/mtklein@google.com/23455061/24001
7 years, 2 months ago (2013-10-08 17:13:12 UTC) #16
commit-bot: I haz the power
7 years, 2 months ago (2013-10-08 19:22:43 UTC) #17
Message was sent while issue was closed.
Change committed as 227563

Powered by Google App Engine
This is Rietveld 408576698