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

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

Issue 875503003: Allow Oilpan heap objects account for their external allocations. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Have conservative GC take prio over scheduled GC when urgent GCing Created 5 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 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 991 matching lines...) Expand 10 before | Expand all | Expand 10 after
1002 } 1002 }
1003 1003
1004 static void increaseAllocatedObjectSize(size_t delta) { atomicAdd(&s_allocat edObjectSize, static_cast<long>(delta)); } 1004 static void increaseAllocatedObjectSize(size_t delta) { atomicAdd(&s_allocat edObjectSize, static_cast<long>(delta)); }
1005 static void decreaseAllocatedObjectSize(size_t delta) { atomicSubtract(&s_al locatedObjectSize, static_cast<long>(delta)); } 1005 static void decreaseAllocatedObjectSize(size_t delta) { atomicSubtract(&s_al locatedObjectSize, static_cast<long>(delta)); }
1006 static size_t allocatedObjectSize() { return acquireLoad(&s_allocatedObjectS ize); } 1006 static size_t allocatedObjectSize() { return acquireLoad(&s_allocatedObjectS ize); }
1007 static void increaseMarkedObjectSize(size_t delta) { atomicAdd(&s_markedObje ctSize, static_cast<long>(delta)); } 1007 static void increaseMarkedObjectSize(size_t delta) { atomicAdd(&s_markedObje ctSize, static_cast<long>(delta)); }
1008 static size_t markedObjectSize() { return acquireLoad(&s_markedObjectSize); } 1008 static size_t markedObjectSize() { return acquireLoad(&s_markedObjectSize); }
1009 static void increaseAllocatedSpace(size_t delta) { atomicAdd(&s_allocatedSpa ce, static_cast<long>(delta)); } 1009 static void increaseAllocatedSpace(size_t delta) { atomicAdd(&s_allocatedSpa ce, static_cast<long>(delta)); }
1010 static void decreaseAllocatedSpace(size_t delta) { atomicSubtract(&s_allocat edSpace, static_cast<long>(delta)); } 1010 static void decreaseAllocatedSpace(size_t delta) { atomicSubtract(&s_allocat edSpace, static_cast<long>(delta)); }
1011 static size_t allocatedSpace() { return acquireLoad(&s_allocatedSpace); } 1011 static size_t allocatedSpace() { return acquireLoad(&s_allocatedSpace); }
1012
1012 static double estimatedMarkingTime(); 1013 static double estimatedMarkingTime();
1013 1014
1015 // On object allocation, register its externally allocated memory.
1016 static void increaseExternallyAllocatedBytes(size_t);
1017 static size_t externallyAllocatedBytes() { return acquireLoad(&s_externallyA llocatedBytes); }
1018
1019 // On object tracing, register its externally allocated memory (as still liv e.)
1020 static void increaseExternallyAllocatedBytesAlive(size_t delta)
1021 {
1022 ASSERT(ThreadState::current()->isInGC());
1023 s_externallyAllocatedBytesAlive += delta;
1024 }
1025 static size_t externallyAllocatedBytesAlive() { return s_externallyAllocated BytesAlive; }
1026
1027 static void requestUrgentGC() { releaseStore(&s_requestedUrgentGC, 1); }
1028 static void clearUrgentGC() { releaseStore(&s_requestedUrgentGC, 0); }
1029 static bool isGCUrgentlyRequested() { return acquireLoad(&s_requestedUrgentG C); }
1030
1014 private: 1031 private:
1015 // A RegionTree is a simple binary search tree of PageMemoryRegions sorted 1032 // A RegionTree is a simple binary search tree of PageMemoryRegions sorted
1016 // by base addresses. 1033 // by base addresses.
1017 class RegionTree { 1034 class RegionTree {
1018 public: 1035 public:
1019 explicit RegionTree(PageMemoryRegion* region) : m_region(region), m_left (nullptr), m_right(nullptr) { } 1036 explicit RegionTree(PageMemoryRegion* region) : m_region(region), m_left (nullptr), m_right(nullptr) { }
1020 ~RegionTree() 1037 ~RegionTree()
1021 { 1038 {
1022 delete m_left; 1039 delete m_left;
1023 delete m_right; 1040 delete m_right;
1024 } 1041 }
1025 PageMemoryRegion* lookup(Address); 1042 PageMemoryRegion* lookup(Address);
1026 static void add(RegionTree*, RegionTree**); 1043 static void add(RegionTree*, RegionTree**);
1027 static void remove(PageMemoryRegion*, RegionTree**); 1044 static void remove(PageMemoryRegion*, RegionTree**);
1028 private: 1045 private:
1029 PageMemoryRegion* m_region; 1046 PageMemoryRegion* m_region;
1030 RegionTree* m_left; 1047 RegionTree* m_left;
1031 RegionTree* m_right; 1048 RegionTree* m_right;
1032 }; 1049 };
1033 1050
1034 static void resetAllocatedObjectSize() { ASSERT(ThreadState::current()->isIn GC()); s_allocatedObjectSize = 0; } 1051 // Reset counters that track live and allocated-since-last-GC sizes.
1035 static void resetMarkedObjectSize() { ASSERT(ThreadState::current()->isInGC( )); s_markedObjectSize = 0; } 1052 static void resetHeapCounters();
1036 1053
1037 static Visitor* s_markingVisitor; 1054 static Visitor* s_markingVisitor;
1038 static CallbackStack* s_markingStack; 1055 static CallbackStack* s_markingStack;
1039 static CallbackStack* s_postMarkingCallbackStack; 1056 static CallbackStack* s_postMarkingCallbackStack;
1040 static CallbackStack* s_weakCallbackStack; 1057 static CallbackStack* s_weakCallbackStack;
1041 static CallbackStack* s_ephemeronStack; 1058 static CallbackStack* s_ephemeronStack;
1042 static HeapDoesNotContainCache* s_heapDoesNotContainCache; 1059 static HeapDoesNotContainCache* s_heapDoesNotContainCache;
1043 static bool s_shutdownCalled; 1060 static bool s_shutdownCalled;
1044 static bool s_lastGCWasConservative; 1061 static bool s_lastGCWasConservative;
1045 static FreePagePool* s_freePagePool; 1062 static FreePagePool* s_freePagePool;
1046 static OrphanedPagePool* s_orphanedPagePool; 1063 static OrphanedPagePool* s_orphanedPagePool;
1047 static RegionTree* s_regionTree; 1064 static RegionTree* s_regionTree;
1048 static size_t s_allocatedSpace; 1065 static size_t s_allocatedSpace;
1049 static size_t s_allocatedObjectSize; 1066 static size_t s_allocatedObjectSize;
1050 static size_t s_markedObjectSize; 1067 static size_t s_markedObjectSize;
1068 static size_t s_externallyAllocatedBytes;
1069 static size_t s_externallyAllocatedBytesAlive;
1070 static unsigned s_requestedUrgentGC;
1071
1051 friend class ThreadState; 1072 friend class ThreadState;
1052 }; 1073 };
1053 1074
1054 // Base class for objects allocated in the Blink garbage-collected heap. 1075 // Base class for objects allocated in the Blink garbage-collected heap.
1055 // 1076 //
1056 // Defines a 'new' operator that allocates the memory in the heap. 'delete' 1077 // Defines a 'new' operator that allocates the memory in the heap. 'delete'
1057 // should not be called on objects that inherit from GarbageCollected. 1078 // should not be called on objects that inherit from GarbageCollected.
1058 // 1079 //
1059 // Instances of GarbageCollected will *NOT* get finalized. Their destructor 1080 // Instances of GarbageCollected will *NOT* get finalized. Their destructor
1060 // will not be called. Therefore, only classes that have trivial destructors 1081 // will not be called. Therefore, only classes that have trivial destructors
(...skipping 1401 matching lines...) Expand 10 before | Expand all | Expand 10 after
2462 template<typename T, size_t inlineCapacity> 2483 template<typename T, size_t inlineCapacity>
2463 struct GCInfoTrait<HeapVector<T, inlineCapacity>> : public GCInfoTrait<Vector<T, inlineCapacity, HeapAllocator>> { }; 2484 struct GCInfoTrait<HeapVector<T, inlineCapacity>> : public GCInfoTrait<Vector<T, inlineCapacity, HeapAllocator>> { };
2464 template<typename T, size_t inlineCapacity> 2485 template<typename T, size_t inlineCapacity>
2465 struct GCInfoTrait<HeapDeque<T, inlineCapacity>> : public GCInfoTrait<Deque<T, i nlineCapacity, HeapAllocator>> { }; 2486 struct GCInfoTrait<HeapDeque<T, inlineCapacity>> : public GCInfoTrait<Deque<T, i nlineCapacity, HeapAllocator>> { };
2466 template<typename T, typename U, typename V> 2487 template<typename T, typename U, typename V>
2467 struct GCInfoTrait<HeapHashCountedSet<T, U, V>> : public GCInfoTrait<HashCounted Set<T, U, V, HeapAllocator>> { }; 2488 struct GCInfoTrait<HeapHashCountedSet<T, U, V>> : public GCInfoTrait<HashCounted Set<T, U, V, HeapAllocator>> { };
2468 2489
2469 } // namespace blink 2490 } // namespace blink
2470 2491
2471 #endif // Heap_h 2492 #endif // Heap_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698