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

Unified Diff: third_party/WebKit/Source/wtf/typed_arrays/ArrayBufferContents.cpp

Issue 1977493003: Remove accounting from ArrayBuffer::Allocator (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix typo Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/wtf/typed_arrays/ArrayBufferContents.cpp
diff --git a/third_party/WebKit/Source/wtf/typed_arrays/ArrayBufferContents.cpp b/third_party/WebKit/Source/wtf/typed_arrays/ArrayBufferContents.cpp
index 7c3997240d2f984ff7644ea20fa7ee65339ebf16..466d5ed12744f7850d6da0a274a0695cc69ab427 100644
--- a/third_party/WebKit/Source/wtf/typed_arrays/ArrayBufferContents.cpp
+++ b/third_party/WebKit/Source/wtf/typed_arrays/ArrayBufferContents.cpp
@@ -99,8 +99,6 @@ void ArrayBufferContents::copyTo(ArrayBufferContents& other)
void ArrayBufferContents::allocateMemoryWithFlags(size_t size, InitializationPolicy policy, int flags, void*& data)
{
- if (s_adjustAmountOfExternalAllocatedMemoryFunction)
- s_adjustAmountOfExternalAllocatedMemoryFunction(static_cast<int>(size));
data = partitionAllocGenericFlags(WTF::Partitions::bufferPartition(), flags, size, WTF_HEAP_PROFILER_TYPE_NAME(ArrayBufferContents));
if (policy == ZeroInitialize && data)
memset(data, '\0', size);
@@ -119,8 +117,6 @@ void ArrayBufferContents::allocateMemoryOrNull(size_t size, InitializationPolicy
void ArrayBufferContents::freeMemory(void* data, size_t size)
{
Partitions::bufferFree(data);
- if (s_adjustAmountOfExternalAllocatedMemoryFunction)
- s_adjustAmountOfExternalAllocatedMemoryFunction(-static_cast<int>(size));
}
ArrayBufferContents::DataHolder::DataHolder()
@@ -131,6 +127,8 @@ ArrayBufferContents::DataHolder::DataHolder()
ArrayBufferContents::DataHolder::~DataHolder()
{
ArrayBufferContents::freeMemory(m_data, m_sizeInBytes);
+ if (s_adjustAmountOfExternalAllocatedMemoryFunction)
+ s_adjustAmountOfExternalAllocatedMemoryFunction(-static_cast<int>(m_sizeInBytes));
m_data = nullptr;
m_sizeInBytes = 0;
@@ -141,6 +139,8 @@ void ArrayBufferContents::DataHolder::allocateNew(unsigned sizeInBytes, SharingT
{
ASSERT(!m_data);
void* data = nullptr;
+ if (s_adjustAmountOfExternalAllocatedMemoryFunction)
sof 2016/05/17 21:05:04 What if allocateMemory() isn't able to allocate |s
Michael Lippautz 2016/05/18 08:05:09 Thanks, you are right. I was not aware that a fail
+ s_adjustAmountOfExternalAllocatedMemoryFunction(static_cast<int>(sizeInBytes));
allocateMemory(sizeInBytes, policy, data);
m_data = data;
m_sizeInBytes = data ? sizeInBytes : 0;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698