| 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)
|
|
|