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

Unified Diff: third_party/WebKit/Source/platform/heap/ThreadState.cpp

Issue 1670463002: [Oilpan] Unify memory usage reporters of Oilpan (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix nits Created 4 years, 10 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/platform/heap/ThreadState.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/platform/heap/ThreadState.cpp
diff --git a/third_party/WebKit/Source/platform/heap/ThreadState.cpp b/third_party/WebKit/Source/platform/heap/ThreadState.cpp
index 2b953d83646578b3e9c5c7f0e7d59d4642783a4a..726628115d97279e436cccede71085cefc1924c9 100644
--- a/third_party/WebKit/Source/platform/heap/ThreadState.cpp
+++ b/third_party/WebKit/Source/platform/heap/ThreadState.cpp
@@ -63,6 +63,8 @@
#include <pthread_np.h>
#endif
+#include <v8.h>
+
namespace blink {
WTF::ThreadSpecific<ThreadState*>* ThreadState::s_threadSpecific = nullptr;
@@ -98,6 +100,7 @@ ThreadState::ThreadState()
, m_gcMixinMarker(nullptr)
, m_shouldFlushHeapDoesNotContainCache(false)
, m_gcState(NoGCScheduled)
+ , m_isolate(nullptr)
, m_traceDOMWrappers(nullptr)
#if defined(ADDRESS_SANITIZER)
, m_asanFakeStack(__asan_get_current_fake_stack())
@@ -105,6 +108,9 @@ ThreadState::ThreadState()
#if defined(LEAK_SANITIZER)
, m_disabledStaticPersistentsRegistration(0)
#endif
+ , m_allocatedObjectSize(0)
+ , m_markedObjectSize(0)
+ , m_reportedMemoryToV8(0)
{
ASSERT(checkThread());
ASSERT(!**s_threadSpecific);
@@ -689,6 +695,8 @@ void ThreadState::scheduleGCIfNeeded()
return;
ASSERT(!sweepForbidden());
+ reportMemoryToV8();
+
if (shouldForceMemoryPressureGC()) {
completeSweep();
if (shouldForceMemoryPressureGC()) {
@@ -1248,6 +1256,41 @@ void ThreadState::leaveSafePoint(SafePointAwareMutexLocker* locker)
preSweep();
}
+void ThreadState::reportMemoryToV8()
+{
+ if (!m_isolate)
+ return;
+
+ size_t currentHeapSize = m_allocatedObjectSize + m_markedObjectSize;
+ int64_t diff = static_cast<int64_t>(currentHeapSize) - static_cast<int64_t>(m_reportedMemoryToV8);
+ m_isolate->AdjustAmountOfExternalAllocatedMemory(diff);
+ m_reportedMemoryToV8 = currentHeapSize;
+}
+
+void ThreadState::resetHeapCounters()
+{
+ m_allocatedObjectSize = 0;
+ m_markedObjectSize = 0;
+}
+
+void ThreadState::increaseAllocatedObjectSize(size_t delta)
+{
+ m_allocatedObjectSize += delta;
+ Heap::increaseAllocatedObjectSize(delta);
+}
+
+void ThreadState::decreaseAllocatedObjectSize(size_t delta)
+{
+ m_allocatedObjectSize -= delta;
+ Heap::decreaseAllocatedObjectSize(delta);
+}
+
+void ThreadState::increaseMarkedObjectSize(size_t delta)
+{
+ m_markedObjectSize += delta;
+ Heap::increaseMarkedObjectSize(delta);
+}
+
void ThreadState::copyStackUntilSafePointScope()
{
if (!m_safePointScopeMarker || m_stackState == BlinkGC::NoHeapPointersOnStack)
« no previous file with comments | « third_party/WebKit/Source/platform/heap/ThreadState.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698