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

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

Issue 2741793003: Accurate transfer of SerializedScriptValue allocation costs. (Closed)
Patch Set: sanity check diff adjustments Created 3 years, 9 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 | « third_party/WebKit/Source/wtf/typed_arrays/ArrayBufferContents.h ('k') | 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 8dc7707fafd625e7a34163a788324da05a4f00a5..4ae02962fe3b376c0a59b494567543efe7d4aad4 100644
--- a/third_party/WebKit/Source/wtf/typed_arrays/ArrayBufferContents.cpp
+++ b/third_party/WebKit/Source/wtf/typed_arrays/ArrayBufferContents.cpp
@@ -135,10 +135,14 @@ ArrayBufferContents::DataHandle ArrayBufferContents::createDataHandle(
}
ArrayBufferContents::DataHolder::DataHolder()
- : m_data(nullptr, freeMemory), m_sizeInBytes(0), m_isShared(NotShared) {}
+ : m_data(nullptr, freeMemory),
+ m_sizeInBytes(0),
+ m_isShared(NotShared),
+ m_hasRegisteredExternalAllocation(false) {}
ArrayBufferContents::DataHolder::~DataHolder() {
- adjustAmountOfExternalAllocatedMemory(-static_cast<int64_t>(m_sizeInBytes));
+ if (m_hasRegisteredExternalAllocation)
+ adjustAmountOfExternalAllocatedMemory(-static_cast<int64_t>(m_sizeInBytes));
m_data.reset();
m_sizeInBytes = 0;
@@ -150,6 +154,7 @@ void ArrayBufferContents::DataHolder::allocateNew(unsigned sizeInBytes,
InitializationPolicy policy) {
DCHECK(!m_data);
DCHECK_EQ(m_sizeInBytes, 0u);
+ DCHECK(!m_hasRegisteredExternalAllocation);
m_data = createDataHandle(sizeInBytes, policy);
if (!m_data)
@@ -166,6 +171,7 @@ void ArrayBufferContents::DataHolder::adopt(DataHandle data,
SharingType isShared) {
DCHECK(!m_data);
DCHECK_EQ(m_sizeInBytes, 0u);
+ DCHECK(!m_hasRegisteredExternalAllocation);
m_data = std::move(data);
m_sizeInBytes = sizeInBytes;
@@ -177,6 +183,7 @@ void ArrayBufferContents::DataHolder::adopt(DataHandle data,
void ArrayBufferContents::DataHolder::copyMemoryFrom(const DataHolder& source) {
DCHECK(!m_data);
DCHECK_EQ(m_sizeInBytes, 0u);
+ DCHECK(!m_hasRegisteredExternalAllocation);
m_data = createDataHandle(source.sizeInBytes(), DontInitialize);
if (!m_data)
@@ -188,4 +195,17 @@ void ArrayBufferContents::DataHolder::copyMemoryFrom(const DataHolder& source) {
adjustAmountOfExternalAllocatedMemory(m_sizeInBytes);
}
+void ArrayBufferContents::DataHolder::
+ registerExternalAllocationWithCurrentContext() {
+ DCHECK(!m_hasRegisteredExternalAllocation);
+ adjustAmountOfExternalAllocatedMemory(static_cast<int64_t>(m_sizeInBytes));
+}
+
+void ArrayBufferContents::DataHolder::
+ unregisterExternalAllocationWithCurrentContext() {
+ if (!m_hasRegisteredExternalAllocation)
+ return;
+ adjustAmountOfExternalAllocatedMemory(-static_cast<int64_t>(m_sizeInBytes));
+}
+
} // namespace WTF
« no previous file with comments | « third_party/WebKit/Source/wtf/typed_arrays/ArrayBufferContents.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698