Chromium Code Reviews| 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 9de5549437e8814087cb2df86d36621584ab65f4..c7c50de110f1f59a35fbc57239a556877cfa736e 100644 |
| --- a/third_party/WebKit/Source/platform/heap/ThreadState.cpp |
| +++ b/third_party/WebKit/Source/platform/heap/ThreadState.cpp |
| @@ -62,6 +62,8 @@ |
| #include <pthread_np.h> |
| #endif |
| +#include <v8.h> |
| + |
| namespace blink { |
| WTF::ThreadSpecific<ThreadState*>* ThreadState::s_threadSpecific = nullptr; |
| @@ -97,6 +99,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()) |
| @@ -104,6 +107,9 @@ ThreadState::ThreadState() |
| #if defined(LEAK_SANITIZER) |
| , m_disabledStaticPersistentsRegistration(0) |
| #endif |
| + , m_allocatedObjectSize(0) |
| + , m_markedObjectSize(0) |
| + , m_prevReportedSize(0) |
| { |
| ASSERT(checkThread()); |
| ASSERT(!**s_threadSpecific); |
| @@ -698,6 +704,8 @@ void ThreadState::scheduleGCIfNeeded() |
| return; |
| ASSERT(!sweepForbidden()); |
| + adjustAmountOfMemory(); |
|
haraken
2016/02/12 09:30:54
adjustAmountOfMemory => reportMemoryToV8 ?
peria
2016/02/15 04:16:59
Done.
|
| + |
| if (shouldForceMemoryPressureGC()) { |
| completeSweep(); |
| if (shouldForceMemoryPressureGC()) { |
| @@ -1251,6 +1259,46 @@ void ThreadState::leaveSafePoint(SafePointAwareMutexLocker* locker) |
| preSweep(); |
| } |
| +void ThreadState::adjustAmountOfMemory() |
| +{ |
| + if (!m_isolate) |
| + return; |
| + |
| + size_t currentHeapSize = heapSize(); |
|
haraken
2016/02/12 09:30:54
size_t currentHeapSize = m_allocatedObjectSize + m
peria
2016/02/15 04:16:59
Done.
|
| + int64_t diff = static_cast<int64_t>(currentHeapSize) - static_cast<int64_t>(m_prevReportedSize); |
| + m_isolate->AdjustAmountOfExternalAllocatedMemory(diff); |
| + m_prevReportedSize = currentHeapSize; |
|
haraken
2016/02/12 09:30:54
m_prevReportedSize => m_reportedMemoryToV8 ?
peria
2016/02/15 04:16:59
Done.
|
| +} |
| + |
| +void ThreadState::resetHeapSizes() |
| +{ |
| + m_allocatedObjectSize = 0; |
| + m_markedObjectSize = 0; |
| +} |
| + |
| +size_t ThreadState::heapSize() |
|
haraken
2016/02/12 09:30:54
This method won't be needed.
peria
2016/02/15 04:16:59
Done.
|
| +{ |
| + return allocatedObjectSize() + markedObjectSize(); |
| +} |
| + |
| +void ThreadState::increaseAllocatedObjectSize(size_t delta) |
| +{ |
| + atomicAdd(&m_allocatedObjectSize, delta); |
| + Heap::increaseAllocatedObjectSize(delta); |
| +} |
| + |
| +void ThreadState::decreaseAllocatedObjectSize(size_t delta) |
| +{ |
| + atomicSubtract(&m_allocatedObjectSize, delta); |
| + Heap::decreaseAllocatedObjectSize(delta); |
| +} |
| + |
| +void ThreadState::increaseMarkedObjectSize(size_t delta) |
| +{ |
| + atomicAdd(&m_markedObjectSize, delta); |
| + Heap::increaseMarkedObjectSize(delta); |
| +} |
| + |
| void ThreadState::copyStackUntilSafePointScope() |
| { |
| if (!m_safePointScopeMarker || m_stackState == BlinkGC::NoHeapPointersOnStack) |