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

Side by Side Diff: Source/core/workers/WorkerThread.cpp

Issue 177073004: Oilpan: move core/workers to oilpan's heap. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 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) 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 #include "public/platform/Platform.h" 42 #include "public/platform/Platform.h"
43 #include "public/platform/WebWaitableEvent.h" 43 #include "public/platform/WebWaitableEvent.h"
44 #include "public/platform/WebWorkerRunLoop.h" 44 #include "public/platform/WebWorkerRunLoop.h"
45 #include "wtf/Noncopyable.h" 45 #include "wtf/Noncopyable.h"
46 #include "wtf/text/WTFString.h" 46 #include "wtf/text/WTFString.h"
47 47
48 #include <utility> 48 #include <utility>
49 49
50 namespace WebCore { 50 namespace WebCore {
51 51
52 DEFINE_GC_INFO(WorkerThread);
53
52 static Mutex& threadSetMutex() 54 static Mutex& threadSetMutex()
53 { 55 {
54 AtomicallyInitializedStatic(Mutex&, mutex = *new Mutex); 56 AtomicallyInitializedStatic(Mutex&, mutex = *new Mutex);
55 return mutex; 57 return mutex;
56 } 58 }
57 59
58 static HashSet<WorkerThread*>& workerThreads() 60 static HashSet<WorkerThread*>& workerThreads()
59 { 61 {
60 DEFINE_STATIC_LOCAL(HashSet<WorkerThread*>, threads, ()); 62 DEFINE_STATIC_LOCAL(HashSet<WorkerThread*>, threads, ());
61 return threads; 63 return threads;
62 } 64 }
63 65
64 unsigned WorkerThread::workerThreadCount() 66 unsigned WorkerThread::workerThreadCount()
65 { 67 {
66 MutexLocker lock(threadSetMutex()); 68 MutexLocker lock(threadSetMutex());
67 return workerThreads().size(); 69 return workerThreads().size();
68 } 70 }
69 71
70 WorkerThread::WorkerThread(WorkerLoaderProxy& workerLoaderProxy, WorkerReporting Proxy& workerReportingProxy, PassOwnPtr<WorkerThreadStartupData> startupData) 72 WorkerThread::WorkerThread(WorkerLoaderProxy& workerLoaderProxy, WorkerReporting Proxy& workerReportingProxy, PassOwnPtrWillBeRawPtr<WorkerThreadStartupData> sta rtupData)
71 : m_threadID(0) 73 : m_threadID(0)
72 , m_workerLoaderProxy(workerLoaderProxy) 74 , m_workerLoaderProxy(workerLoaderProxy)
73 , m_workerReportingProxy(workerReportingProxy) 75 , m_workerReportingProxy(workerReportingProxy)
74 , m_startupData(startupData) 76 , m_startupData(startupData)
75 , m_notificationClient(0) 77 , m_notificationClient(0)
76 , m_shutdownEvent(adoptPtr(blink::Platform::current()->createWaitableEvent() )) 78 , m_shutdownEvent(adoptPtr(blink::Platform::current()->createWaitableEvent() ))
77 { 79 {
78 MutexLocker lock(threadSetMutex()); 80 MutexLocker lock(threadSetMutex());
79 workerThreads().add(this); 81 workerThreads().add(this);
80 } 82 }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 m_workerReportingProxy.workerGlobalScopeStarted(m_workerGlobalScope.get()); 131 m_workerReportingProxy.workerGlobalScopeStarted(m_workerGlobalScope.get());
130 132
131 WorkerScriptController* script = m_workerGlobalScope->script(); 133 WorkerScriptController* script = m_workerGlobalScope->script();
132 InspectorInstrumentation::willEvaluateWorkerScript(workerGlobalScope(), star tMode); 134 InspectorInstrumentation::willEvaluateWorkerScript(workerGlobalScope(), star tMode);
133 script->evaluate(ScriptSourceCode(sourceCode, scriptURL)); 135 script->evaluate(ScriptSourceCode(sourceCode, scriptURL));
134 136
135 runEventLoop(); 137 runEventLoop();
136 138
137 ThreadIdentifier threadID = m_threadID; 139 ThreadIdentifier threadID = m_threadID;
138 140
141 #if !ENABLE(OILPAN)
139 ASSERT(m_workerGlobalScope->hasOneRef()); 142 ASSERT(m_workerGlobalScope->hasOneRef());
143 #endif
140 144
141 // The below assignment will destroy the context, which will in turn notify messaging proxy. 145 // The below assignment will destroy the context, which will in turn notify messaging proxy.
142 // We cannot let any objects survive past thread exit, because no other thre ad will run GC or otherwise destroy them. 146 // We cannot let any objects survive past thread exit, because no other thre ad will run GC or otherwise destroy them.
143 m_workerGlobalScope = nullptr; 147 m_workerGlobalScope = nullptr;
144 148
145 // Cleanup thread heap which causes all objects to be finalized. 149 // Cleanup thread heap which causes all objects to be finalized.
146 // After this call thread heap must be empty. 150 // After this call thread heap must be empty.
147 ThreadState::current()->cleanup(); 151 ThreadState::current()->cleanup();
148 152
149 // Clean up PlatformThreadData before WTF::WTFThreadData goes away! 153 // Clean up PlatformThreadData before WTF::WTFThreadData goes away!
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 250
247 void WorkerThread::releaseFastMallocFreeMemoryInAllThreads() 251 void WorkerThread::releaseFastMallocFreeMemoryInAllThreads()
248 { 252 {
249 MutexLocker lock(threadSetMutex()); 253 MutexLocker lock(threadSetMutex());
250 HashSet<WorkerThread*>& threads = workerThreads(); 254 HashSet<WorkerThread*>& threads = workerThreads();
251 HashSet<WorkerThread*>::iterator end = threads.end(); 255 HashSet<WorkerThread*>::iterator end = threads.end();
252 for (HashSet<WorkerThread*>::iterator it = threads.begin(); it != end; ++it) 256 for (HashSet<WorkerThread*>::iterator it = threads.begin(); it != end; ++it)
253 (*it)->runLoop().postTask(adoptPtr(new ReleaseFastMallocFreeMemoryTask)) ; 257 (*it)->runLoop().postTask(adoptPtr(new ReleaseFastMallocFreeMemoryTask)) ;
254 } 258 }
255 259
260 void WorkerThread::trace(Visitor* visitor)
261 {
262 visitor->trace(m_workerGlobalScope);
263 visitor->trace(m_startupData);
264 }
265
256 } // namespace WebCore 266 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698