aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkSmallAllocator.h
diff options
context:
space:
mode:
authorGravatar benjaminwagner <benjaminwagner@google.com>2016-11-03 08:08:23 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-11-03 08:08:23 -0700
commitdc46bf10ae380914a3f81053e5a60e9c28409ec4 (patch)
tree6deed66102c9d7f41eef9dfeec162edd3c7fd3ea /src/core/SkSmallAllocator.h
parente736e0c2d52a29a3b88a29ab39b3a90a5a2443a0 (diff)
Revert of Try to use only std::aligned_storage. (patchset #2 id:20001 of https://codereview.chromium.org/2468243002/ )
Reason for revert: DM failure: https://luci-milo.appspot.com/swarming/task/324387bf30100f10 c:\b\work\skia\src\core\sklinearbitmappipeline.cpp:49: fatal error: "assert(sizeof(Variant) <= sizeof(fSpace))" Original issue's description: > Try to use only std::aligned_storage. This does not change the API. > > BUG=skia: > GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2468243002 > TBR=reed@google.com > > Committed: https://skia.googlesource.com/skia/+/e736e0c2d52a29a3b88a29ab39b3a90a5a2443a0 TBR=mtklein@chromium.org,bsalomon@google.com,mtklein@google.com,reed@google.com,herb@google.com # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=skia: Review-Url: https://codereview.chromium.org/2474073002
Diffstat (limited to 'src/core/SkSmallAllocator.h')
-rw-r--r--src/core/SkSmallAllocator.h12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/core/SkSmallAllocator.h b/src/core/SkSmallAllocator.h
index b39e359d52..9095fa57fc 100644
--- a/src/core/SkSmallAllocator.h
+++ b/src/core/SkSmallAllocator.h
@@ -93,7 +93,7 @@ public:
// There is space in fStorage.
rec->fStorageSize = storageRequired;
rec->fHeapStorage = nullptr;
- rec->fObj = static_cast<void*>(bytes() + fStorageUsed);
+ rec->fObj = static_cast<void*>(fStorage.fBytes + fStorageUsed);
fStorageUsed += storageRequired;
}
rec->fKillProc = DestroyT<T>;
@@ -129,11 +129,13 @@ private:
static_cast<T*>(ptr)->~T();
}
- char* bytes() { return reinterpret_cast<char*>(&fStorage); }
-
- using Storage = typename std::aligned_storage<kTotalBytes, 16>::type;
+ struct SK_STRUCT_ALIGN(16) Storage {
+ // we add kMaxObjects * 15 to account for the worst-case slop, where each allocation wasted
+ // 15 bytes (due to forcing each to be 16-byte aligned)
+ char fBytes[kTotalBytes + kMaxObjects * 15];
+ };
- Storage fStorage[kMaxObjects];
+ Storage fStorage;
// Number of bytes used so far.
size_t fStorageUsed;
uint32_t fNumObjects;