Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008 Apple 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 | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 138 // The below assignment will destroy the context, which will in turn notify messaging proxy. | 138 // The below assignment will destroy the context, which will in turn notify messaging proxy. |
| 139 // We cannot let any objects survive past thread exit, because no other thre ad will run GC or otherwise destroy them. | 139 // We cannot let any objects survive past thread exit, because no other thre ad will run GC or otherwise destroy them. |
| 140 // If Oilpan is enabled, we detach of the context/global scope, with the fin al heap cleanup below sweeping it out. | 140 // If Oilpan is enabled, we detach of the context/global scope, with the fin al heap cleanup below sweeping it out. |
| 141 #if ENABLE(OILPAN) | 141 #if ENABLE(OILPAN) |
| 142 m_workerGlobalScope->dispose(); | 142 m_workerGlobalScope->dispose(); |
| 143 #else | 143 #else |
| 144 ASSERT(m_workerGlobalScope->hasOneRef()); | 144 ASSERT(m_workerGlobalScope->hasOneRef()); |
| 145 #endif | 145 #endif |
| 146 m_workerGlobalScope = nullptr; | 146 m_workerGlobalScope = nullptr; |
| 147 | 147 |
| 148 // Detach the ThreadState, cleaning out the thread's heap by | |
| 149 // performing a final GC. The cleanup operation will at the end | |
| 150 // assert that the heap is empty, as any surviving objects will | |
| 151 // otherwise leak and never be destructed. It is important to | |
|
Vyacheslav Egorov (Google)
2014/03/18 14:17:46
This comment is a bit confusing.
It is correct t
Mads Ager (chromium)
2014/03/18 14:23:54
Yes, thanks Slava. Updated the comment.
| |
| 152 // detach while the thread is still valid. In particular, | |
| 153 // finalizers for objects in the heap for this thread will need to | |
| 154 // access thread local data. | |
| 148 ThreadState::detach(); | 155 ThreadState::detach(); |
| 149 | 156 |
| 157 // Notify the proxy that the WorkerGlobalScope has been disposed of. | |
| 158 // This can free this thread object, hence it must not be touched afterwards . | |
| 159 workerReportingProxy().workerGlobalScopeDestroyed(); | |
| 160 | |
| 150 // Clean up PlatformThreadData before WTF::WTFThreadData goes away! | 161 // Clean up PlatformThreadData before WTF::WTFThreadData goes away! |
| 151 PlatformThreadData::current().destroy(); | 162 PlatformThreadData::current().destroy(); |
| 152 | 163 |
| 153 // The thread object may be already destroyed from notification now, don't t ry to access "this". | 164 // The thread object may be already destroyed from notification now, don't t ry to access "this". |
| 154 detachThread(threadID); | 165 detachThread(threadID); |
| 155 } | 166 } |
| 156 | 167 |
| 157 void WorkerThread::runEventLoop() | 168 void WorkerThread::runEventLoop() |
| 158 { | 169 { |
| 159 // Does not return until terminated. | 170 // Does not return until terminated. |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 237 void WorkerThread::releaseFastMallocFreeMemoryInAllThreads() | 248 void WorkerThread::releaseFastMallocFreeMemoryInAllThreads() |
| 238 { | 249 { |
| 239 MutexLocker lock(threadSetMutex()); | 250 MutexLocker lock(threadSetMutex()); |
| 240 HashSet<WorkerThread*>& threads = workerThreads(); | 251 HashSet<WorkerThread*>& threads = workerThreads(); |
| 241 HashSet<WorkerThread*>::iterator end = threads.end(); | 252 HashSet<WorkerThread*>::iterator end = threads.end(); |
| 242 for (HashSet<WorkerThread*>::iterator it = threads.begin(); it != end; ++it) | 253 for (HashSet<WorkerThread*>::iterator it = threads.begin(); it != end; ++it) |
| 243 (*it)->runLoop().postTask(adoptPtr(new ReleaseFastMallocFreeMemoryTask)) ; | 254 (*it)->runLoop().postTask(adoptPtr(new ReleaseFastMallocFreeMemoryTask)) ; |
| 244 } | 255 } |
| 245 | 256 |
| 246 } // namespace WebCore | 257 } // namespace WebCore |
| OLD | NEW |