OLD | NEW |
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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 #include "public/platform/WebProcessMemoryDump.h" | 44 #include "public/platform/WebProcessMemoryDump.h" |
45 #include "wtf/Assertions.h" | 45 #include "wtf/Assertions.h" |
46 #include "wtf/DataLog.h" | 46 #include "wtf/DataLog.h" |
47 #include "wtf/LeakAnnotations.h" | 47 #include "wtf/LeakAnnotations.h" |
48 #include "wtf/MainThread.h" | 48 #include "wtf/MainThread.h" |
49 #include "wtf/Partitions.h" | 49 #include "wtf/Partitions.h" |
50 | 50 |
51 namespace blink { | 51 namespace blink { |
52 | 52 |
53 class GCForbiddenScope final { | 53 class GCForbiddenScope final { |
| 54 DISALLOW_NEW(); |
54 public: | 55 public: |
55 explicit GCForbiddenScope(ThreadState* state) | 56 explicit GCForbiddenScope(ThreadState* state) |
56 : m_state(state) | 57 : m_state(state) |
57 { | 58 { |
58 // Prevent nested collectGarbage() invocations. | 59 // Prevent nested collectGarbage() invocations. |
59 m_state->enterGCForbiddenScope(); | 60 m_state->enterGCForbiddenScope(); |
60 } | 61 } |
61 | 62 |
62 ~GCForbiddenScope() | 63 ~GCForbiddenScope() |
63 { | 64 { |
64 m_state->leaveGCForbiddenScope(); | 65 m_state->leaveGCForbiddenScope(); |
65 } | 66 } |
66 | 67 |
67 private: | 68 private: |
68 ThreadState* m_state; | 69 ThreadState* m_state; |
69 }; | 70 }; |
70 | 71 |
71 class GCScope final { | 72 class GCScope final { |
| 73 STACK_ALLOCATED(); |
72 public: | 74 public: |
73 GCScope(ThreadState* state, BlinkGC::StackState stackState, BlinkGC::GCType
gcType) | 75 GCScope(ThreadState* state, BlinkGC::StackState stackState, BlinkGC::GCType
gcType) |
74 : m_state(state) | 76 : m_state(state) |
75 , m_gcForbiddenScope(state) | 77 , m_gcForbiddenScope(state) |
76 { | 78 { |
77 ASSERT(m_state->checkThread()); | 79 ASSERT(m_state->checkThread()); |
78 | 80 |
79 switch (gcType) { | 81 switch (gcType) { |
80 case BlinkGC::GCWithSweep: | 82 case BlinkGC::GCWithSweep: |
81 case BlinkGC::GCWithoutSweep: | 83 case BlinkGC::GCWithoutSweep: |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 Visitor* visitor() const { return m_visitor.get(); } | 122 Visitor* visitor() const { return m_visitor.get(); } |
121 | 123 |
122 private: | 124 private: |
123 ThreadState* m_state; | 125 ThreadState* m_state; |
124 // See ThreadState::runScheduledGC() why we need to already be in a | 126 // See ThreadState::runScheduledGC() why we need to already be in a |
125 // GCForbiddenScope before any safe point is entered. | 127 // GCForbiddenScope before any safe point is entered. |
126 GCForbiddenScope m_gcForbiddenScope; | 128 GCForbiddenScope m_gcForbiddenScope; |
127 OwnPtr<Visitor> m_visitor; | 129 OwnPtr<Visitor> m_visitor; |
128 }; | 130 }; |
129 | 131 |
130 class ResumeThreadScope { | 132 class ResumeThreadScope final { |
| 133 STACK_ALLOCATED(); |
131 public: | 134 public: |
132 explicit ResumeThreadScope(BlinkGC::GCType gcType) | 135 explicit ResumeThreadScope(BlinkGC::GCType gcType) |
133 : m_resumeThreads(gcType != BlinkGC::ThreadTerminationGC) | 136 : m_resumeThreads(gcType != BlinkGC::ThreadTerminationGC) |
134 { | 137 { |
135 } | 138 } |
136 ~ResumeThreadScope() | 139 ~ResumeThreadScope() |
137 { | 140 { |
138 // Only cleanup if we parked all threads in which case the GC happened | 141 // Only cleanup if we parked all threads in which case the GC happened |
139 // and we need to resume the other threads. | 142 // and we need to resume the other threads. |
140 if (m_resumeThreads) | 143 if (m_resumeThreads) |
141 ThreadState::resumeThreads(); | 144 ThreadState::resumeThreads(); |
142 } | 145 } |
143 private: | 146 private: |
144 bool m_resumeThreads; | 147 bool m_resumeThreads; |
145 }; | 148 }; |
146 | 149 |
147 void Heap::flushHeapDoesNotContainCache() | 150 void Heap::flushHeapDoesNotContainCache() |
148 { | 151 { |
149 s_heapDoesNotContainCache->flush(); | 152 s_heapDoesNotContainCache->flush(); |
150 } | 153 } |
151 | 154 |
152 void Heap::init() | 155 void Heap::init() |
153 { | 156 { |
154 ThreadState::init(); | 157 ThreadState::init(); |
155 s_markingStack = new CallbackStack(); | 158 s_markingStack = new CallbackStack(); |
156 s_postMarkingCallbackStack = new CallbackStack(); | 159 s_postMarkingCallbackStack = new CallbackStack(); |
157 s_globalWeakCallbackStack = new CallbackStack(); | 160 s_globalWeakCallbackStack = new CallbackStack(); |
158 s_ephemeronStack = new CallbackStack(); | 161 s_ephemeronStack = new CallbackStack(); |
159 s_heapDoesNotContainCache = new HeapDoesNotContainCache(); | 162 s_heapDoesNotContainCache = HeapDoesNotContainCache::create(); |
160 s_freePagePool = new FreePagePool(); | 163 s_freePagePool = new FreePagePool(); |
161 s_orphanedPagePool = new OrphanedPagePool(); | 164 s_orphanedPagePool = new OrphanedPagePool(); |
162 s_allocatedSpace = 0; | 165 s_allocatedSpace = 0; |
163 s_allocatedObjectSize = 0; | 166 s_allocatedObjectSize = 0; |
164 s_objectSizeAtLastGC = 0; | 167 s_objectSizeAtLastGC = 0; |
165 s_markedObjectSize = 0; | 168 s_markedObjectSize = 0; |
166 s_markedObjectSizeAtLastCompleteSweep = 0; | 169 s_markedObjectSizeAtLastCompleteSweep = 0; |
167 s_wrapperCount = 0; | 170 s_wrapperCount = 0; |
168 s_wrapperCountAtLastGC = 0; | 171 s_wrapperCountAtLastGC = 0; |
169 s_collectedWrapperCount = 0; | 172 s_collectedWrapperCount = 0; |
(...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
711 size_t Heap::s_wrapperCount = 0; | 714 size_t Heap::s_wrapperCount = 0; |
712 size_t Heap::s_wrapperCountAtLastGC = 0; | 715 size_t Heap::s_wrapperCountAtLastGC = 0; |
713 size_t Heap::s_collectedWrapperCount = 0; | 716 size_t Heap::s_collectedWrapperCount = 0; |
714 size_t Heap::s_partitionAllocSizeAtLastGC = 0; | 717 size_t Heap::s_partitionAllocSizeAtLastGC = 0; |
715 double Heap::s_estimatedMarkingTimePerByte = 0.0; | 718 double Heap::s_estimatedMarkingTimePerByte = 0.0; |
716 #if ENABLE(ASSERT) | 719 #if ENABLE(ASSERT) |
717 uint16_t Heap::s_gcGeneration = 0; | 720 uint16_t Heap::s_gcGeneration = 0; |
718 #endif | 721 #endif |
719 | 722 |
720 } // namespace blink | 723 } // namespace blink |
OLD | NEW |