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 | |
adamk
2014/03/31 15:27:37
What circumstances? What do the crashes look like
| |
75 // fail in certain cases and lead to a crash. | |
76 // We need these statements here to prevent that. | |
77 v8::HandleScope handleScope(m_isolate); | |
78 V8PerIsolateData::from(m_isolate)->ensureDomInJSContext(); | |
79 | |
73 ThreadState::current()->addInterruptor(m_interruptor.get()); | 80 ThreadState::current()->addInterruptor(m_interruptor.get()); |
74 } | 81 } |
75 | 82 |
76 // We need to postpone V8 Isolate destruction until the very end of | 83 // We need to postpone V8 Isolate destruction until the very end of |
77 // worker thread finalization when all objects on the worker heap | 84 // worker thread finalization when all objects on the worker heap |
78 // are destroyed. | 85 // are destroyed. |
79 class IsolateCleanupTask : public ThreadState::CleanupTask { | 86 class IsolateCleanupTask : public ThreadState::CleanupTask { |
80 public: | 87 public: |
81 static PassOwnPtr<IsolateCleanupTask> create(v8::Isolate* isolate) | 88 static PassOwnPtr<IsolateCleanupTask> create(v8::Isolate* isolate) |
82 { | 89 { |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
257 m_disableEvalPending = errorMessage; | 264 m_disableEvalPending = errorMessage; |
258 } | 265 } |
259 | 266 |
260 void WorkerScriptController::rethrowExceptionFromImportedScript(PassRefPtr<Error Event> errorEvent) | 267 void WorkerScriptController::rethrowExceptionFromImportedScript(PassRefPtr<Error Event> errorEvent) |
261 { | 268 { |
262 m_errorEventFromImportedScript = errorEvent; | 269 m_errorEventFromImportedScript = errorEvent; |
263 throwError(V8ThrowException::createError(v8GeneralError, m_errorEventFromImp ortedScript->message(), m_isolate), m_isolate); | 270 throwError(V8ThrowException::createError(v8GeneralError, m_errorEventFromImp ortedScript->message(), m_isolate), m_isolate); |
264 } | 271 } |
265 | 272 |
266 } // namespace WebCore | 273 } // namespace WebCore |
OLD | NEW |