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

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

Issue 429453010: Drop V8RecursionScope dependency on ExecutionContext (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Factor out microtask fix/tests Created 6 years, 3 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 | Annotate | Revision Log
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 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 InspectorInstrumentation::willEvaluateWorkerScript(workerGlobalScope(), star tMode); 279 InspectorInstrumentation::willEvaluateWorkerScript(workerGlobalScope(), star tMode);
280 script->evaluate(ScriptSourceCode(sourceCode, scriptURL)); 280 script->evaluate(ScriptSourceCode(sourceCode, scriptURL));
281 281
282 postInitialize(); 282 postInitialize();
283 283
284 postDelayedTask(createSameThreadTask(&WorkerThread::idleHandler, this), kSho rtIdleHandlerDelayMs); 284 postDelayedTask(createSameThreadTask(&WorkerThread::idleHandler, this), kSho rtIdleHandlerDelayMs);
285 } 285 }
286 286
287 void WorkerThread::cleanup() 287 void WorkerThread::cleanup()
288 { 288 {
289
290 // This should be called before we start the shutdown procedure. 289 // This should be called before we start the shutdown procedure.
291 workerReportingProxy().willDestroyWorkerGlobalScope(); 290 workerReportingProxy().willDestroyWorkerGlobalScope();
292 291
293 // The below assignment will destroy the context, which will in turn notify messaging proxy. 292 // The below assignment will destroy the context, which will in turn notify messaging proxy.
294 // We cannot let any objects survive past thread exit, because no other thre ad will run GC or otherwise destroy them. 293 // We cannot let any objects survive past thread exit, because no other thre ad will run GC or otherwise destroy them.
295 // If Oilpan is enabled, we detach of the context/global scope, with the fin al heap cleanup below sweeping it out. 294 // If Oilpan is enabled, we detach of the context/global scope, with the fin al heap cleanup below sweeping it out.
296 #if !ENABLE(OILPAN) 295 #if !ENABLE(OILPAN)
297 ASSERT(m_workerGlobalScope->hasOneRef()); 296 ASSERT(m_workerGlobalScope->hasOneRef());
298 #endif 297 #endif
299 m_workerGlobalScope->dispose(); 298 m_workerGlobalScope->dispose();
haraken 2014/09/11 01:18:54 I think you can call willBeDestroyed here (between
jsbell 2014/09/11 22:14:52 Agreed, doing it here in cleanup() would be better
300 m_workerGlobalScope = nullptr; 299 m_workerGlobalScope = nullptr;
301 300
haraken 2014/09/11 01:18:54 I think you can call willBeDestroyed here.
302 ThreadState::current()->removeInterruptor(m_messageLoopInterruptor.get()); 301 ThreadState::current()->removeInterruptor(m_messageLoopInterruptor.get());
303 302
304 // Detach the ThreadState, cleaning out the thread's heap by 303 // Detach the ThreadState, cleaning out the thread's heap by
305 // performing a final GC. The cleanup operation will at the end 304 // performing a final GC. The cleanup operation will at the end
306 // assert that the heap is empty. If the heap does not become 305 // assert that the heap is empty. If the heap does not become
307 // empty, there are still pointers into the heap and those 306 // empty, there are still pointers into the heap and those
308 // pointers will be dangling after thread termination because we 307 // pointers will be dangling after thread termination because we
309 // are destroying the heap. It is important to detach while the 308 // are destroying the heap. It is important to detach while the
310 // thread is still valid. In particular, finalizers for objects in 309 // thread is still valid. In particular, finalizers for objects in
311 // the heap for this thread will need to access thread local data. 310 // the heap for this thread will need to access thread local data.
(...skipping 18 matching lines...) Expand all
330 class WorkerThreadShutdownFinishTask : public ExecutionContextTask { 329 class WorkerThreadShutdownFinishTask : public ExecutionContextTask {
331 public: 330 public:
332 static PassOwnPtr<WorkerThreadShutdownFinishTask> create() 331 static PassOwnPtr<WorkerThreadShutdownFinishTask> create()
333 { 332 {
334 return adoptPtr(new WorkerThreadShutdownFinishTask()); 333 return adoptPtr(new WorkerThreadShutdownFinishTask());
335 } 334 }
336 335
337 virtual void performTask(ExecutionContext *context) 336 virtual void performTask(ExecutionContext *context)
338 { 337 {
339 WorkerGlobalScope* workerGlobalScope = toWorkerGlobalScope(context); 338 WorkerGlobalScope* workerGlobalScope = toWorkerGlobalScope(context);
339
340 V8PerIsolateData::willBeDestroyed(workerGlobalScope->script()->isolate() );
haraken 2014/09/11 01:18:54 Can we call this in WorkerThread::cleanup()? We wa
340 workerGlobalScope->clearInspector(); 341 workerGlobalScope->clearInspector();
341 // It's not safe to call clearScript until all the cleanup tasks posted by functions initiated by WorkerThreadShutdownStartTask have completed. 342 // It's not safe to call clearScript until all the cleanup tasks posted by functions initiated by WorkerThreadShutdownStartTask have completed.
342 workerGlobalScope->clearScript(); 343 workerGlobalScope->clearScript();
343 workerGlobalScope->thread()->m_thread->postTask(new Task(WTF::bind(&Work erThread::cleanup, workerGlobalScope->thread()))); 344 workerGlobalScope->thread()->m_thread->postTask(new Task(WTF::bind(&Work erThread::cleanup, workerGlobalScope->thread())));
344 } 345 }
345 346
346 virtual bool isCleanupTask() const { return true; } 347 virtual bool isCleanupTask() const { return true; }
347 }; 348 };
348 349
349 class WorkerThreadShutdownStartTask : public ExecutionContextTask { 350 class WorkerThreadShutdownStartTask : public ExecutionContextTask {
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 InspectorInstrumentation::didLeaveNestedRunLoop(m_workerGlobalScope.get()); 491 InspectorInstrumentation::didLeaveNestedRunLoop(m_workerGlobalScope.get());
491 } 492 }
492 493
493 void WorkerThread::setWorkerInspectorController(WorkerInspectorController* worke rInspectorController) 494 void WorkerThread::setWorkerInspectorController(WorkerInspectorController* worke rInspectorController)
494 { 495 {
495 MutexLocker locker(m_workerInspectorControllerMutex); 496 MutexLocker locker(m_workerInspectorControllerMutex);
496 m_workerInspectorController = workerInspectorController; 497 m_workerInspectorController = workerInspectorController;
497 } 498 }
498 499
499 } // namespace blink 500 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698