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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 | 83 |
84 RecursiveMutex& ThreadState::threadAttachMutex() | 84 RecursiveMutex& ThreadState::threadAttachMutex() |
85 { | 85 { |
86 AtomicallyInitializedStaticReference(RecursiveMutex, mutex, (new RecursiveMu
tex)); | 86 AtomicallyInitializedStaticReference(RecursiveMutex, mutex, (new RecursiveMu
tex)); |
87 return mutex; | 87 return mutex; |
88 } | 88 } |
89 | 89 |
90 ThreadState::ThreadState() | 90 ThreadState::ThreadState() |
91 : m_thread(currentThread()) | 91 : m_thread(currentThread()) |
92 , m_persistentRegion(adoptPtr(new PersistentRegion())) | 92 , m_persistentRegion(adoptPtr(new PersistentRegion())) |
93 #if OS(WIN) && COMPILER(MSVC) | |
94 , m_threadStackSize(0) | |
95 #endif | |
96 , m_startOfStack(reinterpret_cast<intptr_t*>(StackFrameDepth::getStackStart(
))) | 93 , m_startOfStack(reinterpret_cast<intptr_t*>(StackFrameDepth::getStackStart(
))) |
97 , m_endOfStack(reinterpret_cast<intptr_t*>(StackFrameDepth::getStackStart())
) | 94 , m_endOfStack(reinterpret_cast<intptr_t*>(StackFrameDepth::getStackStart())
) |
98 , m_safePointScopeMarker(nullptr) | 95 , m_safePointScopeMarker(nullptr) |
99 , m_atSafePoint(false) | 96 , m_atSafePoint(false) |
100 , m_interruptors() | 97 , m_interruptors() |
101 , m_sweepForbidden(false) | 98 , m_sweepForbidden(false) |
102 , m_noAllocationCount(0) | 99 , m_noAllocationCount(0) |
103 , m_gcForbiddenCount(0) | 100 , m_gcForbiddenCount(0) |
104 , m_vectorBackingHeapIndex(BlinkGC::Vector1HeapIndex) | 101 , m_vectorBackingHeapIndex(BlinkGC::Vector1HeapIndex) |
105 , m_currentHeapAges(0) | 102 , m_currentHeapAges(0) |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 } | 155 } |
159 | 156 |
160 void ThreadState::shutdown() | 157 void ThreadState::shutdown() |
161 { | 158 { |
162 delete s_safePointBarrier; | 159 delete s_safePointBarrier; |
163 s_safePointBarrier = nullptr; | 160 s_safePointBarrier = nullptr; |
164 | 161 |
165 // Thread-local storage shouldn't be disposed, so we don't call ~ThreadSpeci
fic(). | 162 // Thread-local storage shouldn't be disposed, so we don't call ~ThreadSpeci
fic(). |
166 } | 163 } |
167 | 164 |
168 #if OS(WIN) && COMPILER(MSVC) | |
169 size_t ThreadState::threadStackSize() | |
170 { | |
171 if (m_threadStackSize) | |
172 return m_threadStackSize; | |
173 | |
174 // Notice that we cannot use the TIB's StackLimit for the stack end, as it | |
175 // tracks the end of the committed range. We're after the end of the reserve
d | |
176 // stack area (most of which will be uncommitted, most times.) | |
177 MEMORY_BASIC_INFORMATION stackInfo; | |
178 memset(&stackInfo, 0, sizeof(MEMORY_BASIC_INFORMATION)); | |
179 size_t resultSize = VirtualQuery(&stackInfo, &stackInfo, sizeof(MEMORY_BASIC
_INFORMATION)); | |
180 ASSERT_UNUSED(resultSize, resultSize >= sizeof(MEMORY_BASIC_INFORMATION)); | |
181 Address stackEnd = reinterpret_cast<Address>(stackInfo.AllocationBase); | |
182 | |
183 Address stackStart = reinterpret_cast<Address>(StackFrameDepth::getStackStar
t()); | |
184 RELEASE_ASSERT(stackStart && stackStart > stackEnd); | |
185 m_threadStackSize = static_cast<size_t>(stackStart - stackEnd); | |
186 return m_threadStackSize; | |
187 } | |
188 #endif | |
189 | |
190 void ThreadState::attachMainThread() | 165 void ThreadState::attachMainThread() |
191 { | 166 { |
192 RELEASE_ASSERT(!Heap::s_shutdownCalled); | 167 RELEASE_ASSERT(!Heap::s_shutdownCalled); |
193 MutexLocker locker(threadAttachMutex()); | 168 MutexLocker locker(threadAttachMutex()); |
194 ThreadState* state = new(s_mainThreadStateStorage) ThreadState(); | 169 ThreadState* state = new(s_mainThreadStateStorage) ThreadState(); |
195 attachedThreads().add(state); | 170 attachedThreads().add(state); |
196 } | 171 } |
197 | 172 |
198 void ThreadState::detachMainThread() | 173 void ThreadState::detachMainThread() |
199 { | 174 { |
(...skipping 1481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1681 json->beginArray(it->key.ascii().data()); | 1656 json->beginArray(it->key.ascii().data()); |
1682 for (size_t age = 0; age <= maxHeapObjectAge; ++age) | 1657 for (size_t age = 0; age <= maxHeapObjectAge; ++age) |
1683 json->pushInteger(it->value.ages[age]); | 1658 json->pushInteger(it->value.ages[age]); |
1684 json->endArray(); | 1659 json->endArray(); |
1685 } | 1660 } |
1686 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(TRACE_DISABLED_BY_DEFAULT("blink_gc"), s
tatsName, this, json.release()); | 1661 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(TRACE_DISABLED_BY_DEFAULT("blink_gc"), s
tatsName, this, json.release()); |
1687 } | 1662 } |
1688 #endif | 1663 #endif |
1689 | 1664 |
1690 } // namespace blink | 1665 } // namespace blink |
OLD | NEW |