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

Side by Side Diff: third_party/WebKit/Source/platform/heap/Heap.h

Issue 1840103004: Introduce ThreadHeapStats (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 122
123 private: 123 private:
124 static bool s_isLowEndDevice; 124 static bool s_isLowEndDevice;
125 static size_t s_totalAllocatedSpace; 125 static size_t s_totalAllocatedSpace;
126 static size_t s_totalAllocatedObjectSize; 126 static size_t s_totalAllocatedObjectSize;
127 static size_t s_totalMarkedObjectSize; 127 static size_t s_totalMarkedObjectSize;
128 128
129 friend class ThreadState; 129 friend class ThreadState;
130 }; 130 };
131 131
132 // Stats for the heap.
133 class ThreadHeapStats {
134 USING_FAST_MALLOC(ThreadHeapStats);
135 public:
136 ThreadHeapStats();
137 void setMarkedObjectSizeAtLastCompleteSweep(size_t size) { releaseStore(&m_m arkedObjectSizeAtLastCompleteSweep, size); }
138 size_t markedObjectSizeAtLastCompleteSweep() { return acquireLoad(&m_markedO bjectSizeAtLastCompleteSweep); }
139 void increaseAllocatedObjectSize(size_t delta);
140 void decreaseAllocatedObjectSize(size_t delta);
141 size_t allocatedObjectSize() { return acquireLoad(&m_allocatedObjectSize); }
142 void increaseMarkedObjectSize(size_t delta);
143 size_t markedObjectSize() { return acquireLoad(&m_markedObjectSize); }
144 void increaseAllocatedSpace(size_t delta);
145 void decreaseAllocatedSpace(size_t delta);
146 size_t allocatedSpace() { return acquireLoad(&m_allocatedSpace); }
147 size_t objectSizeAtLastGC() { return acquireLoad(&m_objectSizeAtLastGC); }
148 void increaseWrapperCount(size_t delta) { atomicAdd(&m_wrapperCount, static_ cast<long>(delta)); }
149 void decreaseWrapperCount(size_t delta) { atomicSubtract(&m_wrapperCount, st atic_cast<long>(delta)); }
150 size_t wrapperCount() { return acquireLoad(&m_wrapperCount); }
151 size_t wrapperCountAtLastGC() { return acquireLoad(&m_wrapperCountAtLastGC); }
152 void increaseCollectedWrapperCount(size_t delta) { atomicAdd(&m_collectedWra pperCount, static_cast<long>(delta)); }
153 size_t collectedWrapperCount() { return acquireLoad(&m_collectedWrapperCount ); }
154 size_t partitionAllocSizeAtLastGC() { return acquireLoad(&m_partitionAllocSi zeAtLastGC); }
155 void setEstimatedMarkingTimePerByte(double estimatedMarkingTimePerByte) { m_ estimatedMarkingTimePerByte = estimatedMarkingTimePerByte; }
156 double estimatedMarkingTimePerByte() const { return m_estimatedMarkingTimePe rByte; }
157 double estimatedMarkingTime();
158 void reset();
159
160 private:
161 size_t m_allocatedSpace;
162 size_t m_allocatedObjectSize;
163 size_t m_objectSizeAtLastGC;
164 size_t m_markedObjectSize;
165 size_t m_markedObjectSizeAtLastCompleteSweep;
166 size_t m_wrapperCount;
167 size_t m_wrapperCountAtLastGC;
168 size_t m_collectedWrapperCount;
169 size_t m_partitionAllocSizeAtLastGC;
170 double m_estimatedMarkingTimePerByte;
171 };
172
132 class PLATFORM_EXPORT Heap { 173 class PLATFORM_EXPORT Heap {
133 STATIC_ONLY(Heap); 174 STATIC_ONLY(Heap);
134 public: 175 public:
135 static void init(); 176 static void init();
136 static void shutdown(); 177 static void shutdown();
137 178
138 #if ENABLE(ASSERT) 179 #if ENABLE(ASSERT)
139 static BasePage* findPageFromAddress(Address); 180 static BasePage* findPageFromAddress(Address);
140 static BasePage* findPageFromAddress(const void* pointer) { return findPageF romAddress(reinterpret_cast<Address>(const_cast<void*>(pointer))); } 181 static BasePage* findPageFromAddress(const void* pointer) { return findPageF romAddress(reinterpret_cast<Address>(const_cast<void*>(pointer))); }
141 #endif 182 #endif
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 static const GCInfo* gcInfo(size_t gcInfoIndex) 329 static const GCInfo* gcInfo(size_t gcInfoIndex)
289 { 330 {
290 ASSERT(gcInfoIndex >= 1); 331 ASSERT(gcInfoIndex >= 1);
291 ASSERT(gcInfoIndex < GCInfoTable::maxIndex); 332 ASSERT(gcInfoIndex < GCInfoTable::maxIndex);
292 ASSERT(s_gcInfoTable); 333 ASSERT(s_gcInfoTable);
293 const GCInfo* info = s_gcInfoTable[gcInfoIndex]; 334 const GCInfo* info = s_gcInfoTable[gcInfoIndex];
294 ASSERT(info); 335 ASSERT(info);
295 return info; 336 return info;
296 } 337 }
297 338
298 static void setMarkedObjectSizeAtLastCompleteSweep(size_t size) { releaseSto re(&s_markedObjectSizeAtLastCompleteSweep, size); } 339 static ThreadHeapStats& heapStats();
299 static size_t markedObjectSizeAtLastCompleteSweep() { return acquireLoad(&s_ markedObjectSizeAtLastCompleteSweep); }
300 static void increaseAllocatedObjectSize(size_t delta)
301 {
302 atomicAdd(&s_allocatedObjectSize, static_cast<long>(delta));
303 ProcessHeap::increaseTotalAllocatedObjectSize(delta);
304 }
305 static void decreaseAllocatedObjectSize(size_t delta)
306 {
307 atomicSubtract(&s_allocatedObjectSize, static_cast<long>(delta));
308 ProcessHeap::decreaseTotalAllocatedObjectSize(delta);
309 }
310 static size_t allocatedObjectSize() { return acquireLoad(&s_allocatedObjectS ize); }
311 static void increaseMarkedObjectSize(size_t delta)
312 {
313 atomicAdd(&s_markedObjectSize, static_cast<long>(delta));
314 ProcessHeap::increaseTotalMarkedObjectSize(delta);
315 }
316 static size_t markedObjectSize() { return acquireLoad(&s_markedObjectSize); }
317 static void increaseAllocatedSpace(size_t delta)
318 {
319 atomicAdd(&s_allocatedSpace, static_cast<long>(delta));
320 ProcessHeap::increaseTotalAllocatedSpace(delta);
321 }
322 static void decreaseAllocatedSpace(size_t delta)
323 {
324 atomicSubtract(&s_allocatedSpace, static_cast<long>(delta));
325 ProcessHeap::decreaseTotalAllocatedSpace(delta);
326 }
327 static size_t allocatedSpace() { return acquireLoad(&s_allocatedSpace); }
328 static size_t objectSizeAtLastGC() { return acquireLoad(&s_objectSizeAtLastG C); }
329 static void increaseWrapperCount(size_t delta) { atomicAdd(&s_wrapperCount, static_cast<long>(delta)); }
330 static void decreaseWrapperCount(size_t delta) { atomicSubtract(&s_wrapperCo unt, static_cast<long>(delta)); }
331 static size_t wrapperCount() { return acquireLoad(&s_wrapperCount); }
332 static size_t wrapperCountAtLastGC() { return acquireLoad(&s_wrapperCountAtL astGC); }
333 static void increaseCollectedWrapperCount(size_t delta) { atomicAdd(&s_colle ctedWrapperCount, static_cast<long>(delta)); }
334 static size_t collectedWrapperCount() { return acquireLoad(&s_collectedWrapp erCount); }
335 static size_t partitionAllocSizeAtLastGC() { return acquireLoad(&s_partition AllocSizeAtLastGC); }
336 340
337 static double estimatedMarkingTime(); 341 static double estimatedMarkingTime();
338 static void reportMemoryUsageHistogram(); 342 static void reportMemoryUsageHistogram();
339 static void reportMemoryUsageForTracing(); 343 static void reportMemoryUsageForTracing();
340 static BlinkGC::GCReason lastGCReason() { return s_lastGCReason; } 344 static BlinkGC::GCReason lastGCReason() { return s_lastGCReason; }
341 345
342 private: 346 private:
343 // Reset counters that track live and allocated-since-last-GC sizes. 347 // Reset counters that track live and allocated-since-last-GC sizes.
344 static void resetHeapCounters(); 348 static void resetHeapCounters();
345 349
346 static int arenaIndexForObjectSize(size_t); 350 static int arenaIndexForObjectSize(size_t);
347 static bool isNormalArenaIndex(int); 351 static bool isNormalArenaIndex(int);
348 352
349 static void decommitCallbackStacks(); 353 static void decommitCallbackStacks();
350 354
351 static CallbackStack* s_markingStack; 355 static CallbackStack* s_markingStack;
352 static CallbackStack* s_postMarkingCallbackStack; 356 static CallbackStack* s_postMarkingCallbackStack;
353 static CallbackStack* s_globalWeakCallbackStack; 357 static CallbackStack* s_globalWeakCallbackStack;
354 static CallbackStack* s_ephemeronStack; 358 static CallbackStack* s_ephemeronStack;
355 static HeapDoesNotContainCache* s_heapDoesNotContainCache; 359 static HeapDoesNotContainCache* s_heapDoesNotContainCache;
356 static FreePagePool* s_freePagePool; 360 static FreePagePool* s_freePagePool;
357 static OrphanedPagePool* s_orphanedPagePool; 361 static OrphanedPagePool* s_orphanedPagePool;
358 static size_t s_allocatedSpace;
359 static size_t s_allocatedObjectSize;
360 static size_t s_objectSizeAtLastGC;
361 static size_t s_markedObjectSize;
362 static size_t s_markedObjectSizeAtLastCompleteSweep;
363 static size_t s_wrapperCount;
364 static size_t s_wrapperCountAtLastGC;
365 static size_t s_collectedWrapperCount;
366 static size_t s_partitionAllocSizeAtLastGC;
367 static double s_estimatedMarkingTimePerByte;
368 static BlinkGC::GCReason s_lastGCReason; 362 static BlinkGC::GCReason s_lastGCReason;
369 363
370 friend class ThreadState; 364 friend class ThreadState;
371 }; 365 };
372 366
373 template<typename T> 367 template<typename T>
374 struct IsEagerlyFinalizedType { 368 struct IsEagerlyFinalizedType {
375 STATIC_ONLY(IsEagerlyFinalizedType); 369 STATIC_ONLY(IsEagerlyFinalizedType);
376 private: 370 private:
377 typedef char YesType; 371 typedef char YesType;
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
565 void VisitorHelper<Derived>::handleWeakCell(Visitor* self, void* object) 559 void VisitorHelper<Derived>::handleWeakCell(Visitor* self, void* object)
566 { 560 {
567 T** cell = reinterpret_cast<T**>(object); 561 T** cell = reinterpret_cast<T**>(object);
568 if (*cell && !ObjectAliveTrait<T>::isHeapObjectAlive(*cell)) 562 if (*cell && !ObjectAliveTrait<T>::isHeapObjectAlive(*cell))
569 *cell = nullptr; 563 *cell = nullptr;
570 } 564 }
571 565
572 } // namespace blink 566 } // namespace blink
573 567
574 #endif // Heap_h 568 #endif // Heap_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/bindings/core/v8/WrapperTypeInfo.h ('k') | third_party/WebKit/Source/platform/heap/Heap.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698