OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009, 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2009, 2012 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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 , m_workerGlobalScope(workerGlobalScope) | 63 , m_workerGlobalScope(workerGlobalScope) |
64 , m_executionForbidden(false) | 64 , m_executionForbidden(false) |
65 , m_executionScheduledToTerminate(false) | 65 , m_executionScheduledToTerminate(false) |
66 { | 66 { |
67 m_isolate->Enter(); | 67 m_isolate->Enter(); |
68 V8Initializer::initializeWorker(m_isolate); | 68 V8Initializer::initializeWorker(m_isolate); |
69 v8::V8::Initialize(); | 69 v8::V8::Initialize(); |
70 V8PerIsolateData::ensureInitialized(m_isolate); | 70 V8PerIsolateData::ensureInitialized(m_isolate); |
71 m_world = DOMWrapperWorld::create(WorkerWorldId); | 71 m_world = DOMWrapperWorld::create(WorkerWorldId); |
72 m_interruptor = adoptPtr(new V8IsolateInterruptor(m_isolate)); | 72 m_interruptor = adoptPtr(new V8IsolateInterruptor(m_isolate)); |
| 73 |
| 74 // FIXME: Calling v8::Context::New in ensureDomInJsContext() later may |
| 75 // fail in certain cases and lead to a crash. |
| 76 // Since the main thread may call scheduleExecutionTermination at arbitrary |
| 77 // timing, calling v8::Context::New in the worker thread may fail and |
| 78 // result in a crash. |
| 79 // We need these statements here to prevent that. |
| 80 v8::HandleScope handleScope(m_isolate); |
| 81 V8PerIsolateData::from(m_isolate)->ensureDomInJSContext(); |
| 82 |
73 ThreadState::current()->addInterruptor(m_interruptor.get()); | 83 ThreadState::current()->addInterruptor(m_interruptor.get()); |
74 } | 84 } |
75 | 85 |
76 // We need to postpone V8 Isolate destruction until the very end of | 86 // We need to postpone V8 Isolate destruction until the very end of |
77 // worker thread finalization when all objects on the worker heap | 87 // worker thread finalization when all objects on the worker heap |
78 // are destroyed. | 88 // are destroyed. |
79 class IsolateCleanupTask : public ThreadState::CleanupTask { | 89 class IsolateCleanupTask : public ThreadState::CleanupTask { |
80 public: | 90 public: |
81 static PassOwnPtr<IsolateCleanupTask> create(v8::Isolate* isolate) | 91 static PassOwnPtr<IsolateCleanupTask> create(v8::Isolate* isolate) |
82 { | 92 { |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 m_disableEvalPending = errorMessage; | 268 m_disableEvalPending = errorMessage; |
259 } | 269 } |
260 | 270 |
261 void WorkerScriptController::rethrowExceptionFromImportedScript(PassRefPtrWillBe
RawPtr<ErrorEvent> errorEvent) | 271 void WorkerScriptController::rethrowExceptionFromImportedScript(PassRefPtrWillBe
RawPtr<ErrorEvent> errorEvent) |
262 { | 272 { |
263 m_errorEventFromImportedScript = errorEvent; | 273 m_errorEventFromImportedScript = errorEvent; |
264 throwError(V8ThrowException::createError(v8GeneralError, m_errorEventFromImp
ortedScript->message(), m_isolate), m_isolate); | 274 throwError(V8ThrowException::createError(v8GeneralError, m_errorEventFromImp
ortedScript->message(), m_isolate), m_isolate); |
265 } | 275 } |
266 | 276 |
267 } // namespace WebCore | 277 } // namespace WebCore |
OLD | NEW |