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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 130 m_workerReportingProxy.workerGlobalScopeStarted(m_workerGlobalScope.get()); | 130 m_workerReportingProxy.workerGlobalScopeStarted(m_workerGlobalScope.get()); |
| 131 | 131 |
| 132 WorkerScriptController* script = m_workerGlobalScope->script(); | 132 WorkerScriptController* script = m_workerGlobalScope->script(); |
| 133 InspectorInstrumentation::willEvaluateWorkerScript(workerGlobalScope(), star tMode); | 133 InspectorInstrumentation::willEvaluateWorkerScript(workerGlobalScope(), star tMode); |
| 134 script->evaluate(ScriptSourceCode(sourceCode, scriptURL)); | 134 script->evaluate(ScriptSourceCode(sourceCode, scriptURL)); |
| 135 | 135 |
| 136 runEventLoop(); | 136 runEventLoop(); |
| 137 | 137 |
| 138 ThreadIdentifier threadID = m_threadID; | 138 ThreadIdentifier threadID = m_threadID; |
| 139 | 139 |
| 140 // We need to collect all garbage before checking that the WorkerThread has the last reference | |
| 141 // to the WorkerGlobalScope. We don't need to call V8's GC because all wrapp ers of the worker thread | |
| 142 // are stored in DOMWrapperMap (i.e., no wrappers of the worker thread are s tored in ScriptWrappable) | |
| 143 // and they are already cleared out in ~WorkerScriptController(). In short, we just need to call | |
| 144 // oilpan's GC to collect all garbage. | |
| 145 Heap::collectAllGarbage(ThreadState::NoHeapPointersOnStack); | |
|
haraken
2014/03/05 05:08:35
Actually, I'll remove this code soon because the f
Mads Ager (chromium)
2014/03/05 07:40:34
We should just #ifdef out the ASSERT now so we don
haraken
2014/03/05 08:50:26
Done.
| |
| 140 ASSERT(m_workerGlobalScope->hasOneRef()); | 146 ASSERT(m_workerGlobalScope->hasOneRef()); |
| 141 | 147 |
| 142 // The below assignment will destroy the context, which will in turn notify messaging proxy. | 148 // The below assignment will destroy the context, which will in turn notify messaging proxy. |
| 143 // We cannot let any objects survive past thread exit, because no other thre ad will run GC or otherwise destroy them. | 149 // We cannot let any objects survive past thread exit, because no other thre ad will run GC or otherwise destroy them. |
| 144 m_workerGlobalScope = nullptr; | 150 m_workerGlobalScope = nullptr; |
| 145 | 151 |
| 146 // Cleanup thread heap which causes all objects to be finalized. | 152 ThreadState::detach(); |
| 147 // After this call thread heap must be empty. | |
| 148 ThreadState::current()->cleanup(); | |
| 149 | 153 |
| 150 // Clean up PlatformThreadData before WTF::WTFThreadData goes away! | 154 // Clean up PlatformThreadData before WTF::WTFThreadData goes away! |
| 151 PlatformThreadData::current().destroy(); | 155 PlatformThreadData::current().destroy(); |
| 152 | 156 |
| 153 // The thread object may be already destroyed from notification now, don't t ry to access "this". | 157 // The thread object may be already destroyed from notification now, don't t ry to access "this". |
| 154 detachThread(threadID); | 158 detachThread(threadID); |
| 155 | |
| 156 ThreadState::detach(); | |
| 157 } | 159 } |
| 158 | 160 |
| 159 void WorkerThread::runEventLoop() | 161 void WorkerThread::runEventLoop() |
| 160 { | 162 { |
| 161 // Does not return until terminated. | 163 // Does not return until terminated. |
| 162 m_runLoop.run(); | 164 m_runLoop.run(); |
| 163 } | 165 } |
| 164 | 166 |
| 165 class WorkerThreadShutdownFinishTask : public ExecutionContextTask { | 167 class WorkerThreadShutdownFinishTask : public ExecutionContextTask { |
| 166 public: | 168 public: |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 248 void WorkerThread::releaseFastMallocFreeMemoryInAllThreads() | 250 void WorkerThread::releaseFastMallocFreeMemoryInAllThreads() |
| 249 { | 251 { |
| 250 MutexLocker lock(threadSetMutex()); | 252 MutexLocker lock(threadSetMutex()); |
| 251 HashSet<WorkerThread*>& threads = workerThreads(); | 253 HashSet<WorkerThread*>& threads = workerThreads(); |
| 252 HashSet<WorkerThread*>::iterator end = threads.end(); | 254 HashSet<WorkerThread*>::iterator end = threads.end(); |
| 253 for (HashSet<WorkerThread*>::iterator it = threads.begin(); it != end; ++it) | 255 for (HashSet<WorkerThread*>::iterator it = threads.begin(); it != end; ++it) |
| 254 (*it)->runLoop().postTask(adoptPtr(new ReleaseFastMallocFreeMemoryTask)) ; | 256 (*it)->runLoop().postTask(adoptPtr(new ReleaseFastMallocFreeMemoryTask)) ; |
| 255 } | 257 } |
| 256 | 258 |
| 257 } // namespace WebCore | 259 } // namespace WebCore |
| OLD | NEW |