Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 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 | 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 |
| 11 * documentation and/or other materials provided with the distribution. | 11 * documentation and/or other materials provided with the distribution. |
| 12 * | 12 * |
| 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' | 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' |
| 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, |
| 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS | 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS |
| 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
| 23 * THE POSSIBILITY OF SUCH DAMAGE. | 23 * THE POSSIBILITY OF SUCH DAMAGE. |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 #include "config.h" | 26 #include "config.h" |
| 27 #include "bindings/core/v8/V8Initializer.h" | 27 #include "bindings/core/v8/V8Initializer.h" |
| 28 | 28 |
| 29 #include "bindings/core/v8/DOMWrapperWorld.h" | 29 #include "bindings/core/v8/DOMWrapperWorld.h" |
| 30 #include "bindings/core/v8/RejectedPromises.h" | |
| 30 #include "bindings/core/v8/ScriptCallStackFactory.h" | 31 #include "bindings/core/v8/ScriptCallStackFactory.h" |
| 31 #include "bindings/core/v8/ScriptController.h" | 32 #include "bindings/core/v8/ScriptController.h" |
| 32 #include "bindings/core/v8/ScriptProfiler.h" | 33 #include "bindings/core/v8/ScriptProfiler.h" |
| 33 #include "bindings/core/v8/ScriptValue.h" | 34 #include "bindings/core/v8/ScriptValue.h" |
| 34 #include "bindings/core/v8/V8Binding.h" | 35 #include "bindings/core/v8/V8Binding.h" |
| 35 #include "bindings/core/v8/V8DOMException.h" | 36 #include "bindings/core/v8/V8DOMException.h" |
| 36 #include "bindings/core/v8/V8ErrorEvent.h" | 37 #include "bindings/core/v8/V8ErrorEvent.h" |
| 37 #include "bindings/core/v8/V8ErrorHandler.h" | 38 #include "bindings/core/v8/V8ErrorHandler.h" |
| 38 #include "bindings/core/v8/V8GCController.h" | 39 #include "bindings/core/v8/V8GCController.h" |
| 39 #include "bindings/core/v8/V8History.h" | 40 #include "bindings/core/v8/V8History.h" |
| 40 #include "bindings/core/v8/V8Location.h" | 41 #include "bindings/core/v8/V8Location.h" |
| 41 #include "bindings/core/v8/V8PerContextData.h" | 42 #include "bindings/core/v8/V8PerContextData.h" |
| 42 #include "bindings/core/v8/V8Window.h" | 43 #include "bindings/core/v8/V8Window.h" |
| 44 #include "bindings/core/v8/WorkerScriptController.h" | |
| 43 #include "core/dom/Document.h" | 45 #include "core/dom/Document.h" |
| 44 #include "core/dom/ExceptionCode.h" | 46 #include "core/dom/ExceptionCode.h" |
| 45 #include "core/fetch/AccessControlStatus.h" | 47 #include "core/fetch/AccessControlStatus.h" |
| 46 #include "core/frame/ConsoleTypes.h" | 48 #include "core/frame/ConsoleTypes.h" |
| 47 #include "core/frame/LocalDOMWindow.h" | 49 #include "core/frame/LocalDOMWindow.h" |
| 48 #include "core/frame/LocalFrame.h" | 50 #include "core/frame/LocalFrame.h" |
| 49 #include "core/frame/csp/ContentSecurityPolicy.h" | 51 #include "core/frame/csp/ContentSecurityPolicy.h" |
| 50 #include "core/inspector/ConsoleMessage.h" | |
| 51 #include "core/inspector/ScriptArguments.h" | 52 #include "core/inspector/ScriptArguments.h" |
| 52 #include "core/inspector/ScriptCallStack.h" | 53 #include "core/inspector/ScriptCallStack.h" |
| 54 #include "core/workers/WorkerGlobalScope.h" | |
| 53 #include "platform/EventDispatchForbiddenScope.h" | 55 #include "platform/EventDispatchForbiddenScope.h" |
| 54 #include "platform/RuntimeEnabledFeatures.h" | 56 #include "platform/RuntimeEnabledFeatures.h" |
| 55 #include "platform/TraceEvent.h" | 57 #include "platform/TraceEvent.h" |
| 56 #include "platform/heap/AddressSanitizer.h" | 58 #include "platform/heap/AddressSanitizer.h" |
| 57 #include "platform/scheduler/Scheduler.h" | 59 #include "platform/scheduler/Scheduler.h" |
| 58 #include "public/platform/Platform.h" | 60 #include "public/platform/Platform.h" |
| 59 #include "wtf/ArrayBufferContents.h" | 61 #include "wtf/ArrayBufferContents.h" |
| 60 #include "wtf/RefPtr.h" | 62 #include "wtf/RefPtr.h" |
| 61 #include "wtf/ThreadSpecific.h" | |
| 62 #include "wtf/text/WTFString.h" | 63 #include "wtf/text/WTFString.h" |
| 63 #include <v8-debug.h> | 64 #include <v8-debug.h> |
| 64 | 65 |
| 65 namespace blink { | 66 namespace blink { |
| 66 | 67 |
| 67 static Frame* findFrame(v8::Local<v8::Object> host, v8::Local<v8::Value> data, v 8::Isolate* isolate) | 68 static Frame* findFrame(v8::Local<v8::Object> host, v8::Local<v8::Value> data, v 8::Isolate* isolate) |
| 68 { | 69 { |
| 69 const WrapperTypeInfo* type = WrapperTypeInfo::unwrap(data); | 70 const WrapperTypeInfo* type = WrapperTypeInfo::unwrap(data); |
| 70 | 71 |
| 71 if (V8Window::wrapperTypeInfo.equals(type)) { | 72 if (V8Window::wrapperTypeInfo.equals(type)) { |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 178 // in user's scripts). | 179 // in user's scripts). |
| 179 EventDispatchForbiddenScope::AllowUserAgentEvents allowUserAgentEvents; | 180 EventDispatchForbiddenScope::AllowUserAgentEvents allowUserAgentEvents; |
| 180 enteredWindow->document()->reportException(event.release(), scriptId, ca llStack, corsStatus); | 181 enteredWindow->document()->reportException(event.release(), scriptId, ca llStack, corsStatus); |
| 181 } else { | 182 } else { |
| 182 enteredWindow->document()->reportException(event.release(), scriptId, ca llStack, corsStatus); | 183 enteredWindow->document()->reportException(event.release(), scriptId, ca llStack, corsStatus); |
| 183 } | 184 } |
| 184 } | 185 } |
| 185 | 186 |
| 186 namespace { | 187 namespace { |
| 187 | 188 |
| 188 class PromiseRejectMessage { | 189 static RejectedPromises& rejectedPromisesOnMainThread() |
| 189 ALLOW_ONLY_INLINE_ALLOCATION(); | 190 { |
| 190 public: | 191 ASSERT(isMainThread()); |
| 191 PromiseRejectMessage(const ScriptValue& promise, const ScriptValue& exceptio n, const String& errorMessage, const String& resourceName, int scriptId, int lin eNumber, int columnNumber, PassRefPtrWillBeRawPtr<ScriptCallStack> callStack) | 192 DEFINE_STATIC_LOCAL(OwnPtrWillBePersistent<RejectedPromises>, rejectedPromis es, (adoptPtrWillBeNoop (new RejectedPromises()))); |
|
haraken
2015/02/08 01:53:55
Nit: Unnecessary space after Noop.
sof
2015/02/08 07:26:47
Removed
| |
| 192 : m_promise(promise) | 193 return *rejectedPromises; |
| 193 , m_exception(exception) | 194 } |
| 194 , m_errorMessage(errorMessage) | |
| 195 , m_resourceName(resourceName) | |
| 196 , m_scriptId(scriptId) | |
| 197 , m_lineNumber(lineNumber) | |
| 198 , m_columnNumber(columnNumber) | |
| 199 , m_callStack(callStack) | |
| 200 { | |
| 201 } | |
| 202 | |
| 203 void trace(Visitor* visitor) | |
| 204 { | |
| 205 visitor->trace(m_callStack); | |
| 206 } | |
| 207 | |
| 208 const ScriptValue m_promise; | |
| 209 const ScriptValue m_exception; | |
| 210 const String m_errorMessage; | |
| 211 const String m_resourceName; | |
| 212 const int m_scriptId; | |
| 213 const int m_lineNumber; | |
| 214 const int m_columnNumber; | |
| 215 const RefPtrWillBeMember<ScriptCallStack> m_callStack; | |
| 216 }; | |
| 217 | |
| 218 class ArrayBufferAllocator : public v8::ArrayBuffer::Allocator { | |
| 219 virtual void* Allocate(size_t size) override | |
| 220 { | |
| 221 void* data; | |
| 222 WTF::ArrayBufferContents::allocateMemory(size, WTF::ArrayBufferContents: :ZeroInitialize, data); | |
| 223 return data; | |
| 224 } | |
| 225 | |
| 226 virtual void* AllocateUninitialized(size_t size) override | |
| 227 { | |
| 228 void* data; | |
| 229 WTF::ArrayBufferContents::allocateMemory(size, WTF::ArrayBufferContents: :DontInitialize, data); | |
| 230 return data; | |
| 231 } | |
| 232 | |
| 233 virtual void Free(void* data, size_t size) override | |
| 234 { | |
| 235 WTF::ArrayBufferContents::freeMemory(data, size); | |
| 236 } | |
| 237 }; | |
| 238 | 195 |
| 239 } // namespace | 196 } // namespace |
| 240 | 197 |
| 241 typedef Deque<PromiseRejectMessage> PromiseRejectMessageQueue; | 198 void V8Initializer::reportRejectedPromisesOnMainThread() |
| 242 | |
| 243 static PromiseRejectMessageQueue& promiseRejectMessageQueue() | |
| 244 { | 199 { |
| 245 AtomicallyInitializedStaticReference(ThreadSpecific<PromiseRejectMessageQueu e>, queue, new ThreadSpecific<PromiseRejectMessageQueue>); | 200 rejectedPromisesOnMainThread().processQueue(); |
| 246 return *queue; | |
| 247 } | |
| 248 | |
| 249 void V8Initializer::reportRejectedPromises() | |
| 250 { | |
| 251 PromiseRejectMessageQueue& queue = promiseRejectMessageQueue(); | |
| 252 while (!queue.isEmpty()) { | |
| 253 PromiseRejectMessage message = queue.takeFirst(); | |
| 254 ScriptState* scriptState = message.m_promise.scriptState(); | |
| 255 if (!scriptState->contextIsValid()) | |
| 256 continue; | |
| 257 // If execution termination has been triggered, quietly bail out. | |
| 258 if (v8::V8::IsExecutionTerminating(scriptState->isolate())) | |
| 259 continue; | |
| 260 ExecutionContext* executionContext = scriptState->executionContext(); | |
| 261 if (!executionContext) | |
| 262 continue; | |
| 263 | |
| 264 ScriptState::Scope scope(scriptState); | |
| 265 | |
| 266 ASSERT(!message.m_promise.isEmpty()); | |
| 267 v8::Handle<v8::Value> value = message.m_promise.v8Value(); | |
| 268 ASSERT(!value.IsEmpty() && value->IsPromise()); | |
| 269 if (v8::Handle<v8::Promise>::Cast(value)->HasHandler()) | |
| 270 continue; | |
| 271 | |
| 272 const String errorMessage = "Uncaught (in promise)"; | |
| 273 Vector<ScriptValue> args; | |
| 274 args.append(ScriptValue(scriptState, v8String(scriptState->isolate(), er rorMessage))); | |
| 275 args.append(message.m_exception); | |
| 276 RefPtrWillBeRawPtr<ScriptArguments> arguments = ScriptArguments::create( scriptState, args); | |
| 277 | |
| 278 String embedderErrorMessage = message.m_errorMessage; | |
| 279 if (embedderErrorMessage.isEmpty()) { | |
| 280 embedderErrorMessage = errorMessage; | |
| 281 } else { | |
| 282 if (embedderErrorMessage.startsWith("Uncaught ")) | |
| 283 embedderErrorMessage.insert(" (in promise)", 8); | |
| 284 } | |
| 285 | |
| 286 RefPtrWillBeRawPtr<ConsoleMessage> consoleMessage = ConsoleMessage::crea te(JSMessageSource, ErrorMessageLevel, embedderErrorMessage, message.m_resourceN ame, message.m_lineNumber, message.m_columnNumber); | |
| 287 consoleMessage->setScriptArguments(arguments); | |
| 288 consoleMessage->setCallStack(message.m_callStack); | |
| 289 consoleMessage->setScriptId(message.m_scriptId); | |
| 290 executionContext->addConsoleMessage(consoleMessage.release()); | |
| 291 } | |
| 292 } | 201 } |
| 293 | 202 |
| 294 static void promiseRejectHandlerInMainThread(v8::PromiseRejectMessage data) | 203 static void promiseRejectHandlerInMainThread(v8::PromiseRejectMessage data) |
| 295 { | 204 { |
| 296 ASSERT(isMainThread()); | 205 ASSERT(isMainThread()); |
| 297 | 206 |
| 298 if (data.GetEvent() != v8::kPromiseRejectWithNoHandler) | 207 if (data.GetEvent() != v8::kPromiseRejectWithNoHandler) |
| 299 return; | 208 return; |
| 300 | 209 |
| 301 // It's possible that promiseRejectHandlerInMainThread() is invoked while we 're initializing a window. | 210 // It's possible that promiseRejectHandlerInMainThread() is invoked while we 're initializing a window. |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 348 } else if (!exception.IsEmpty() && exception->IsInt32()) { | 257 } else if (!exception.IsEmpty() && exception->IsInt32()) { |
| 349 // For Smi's the message would be empty. | 258 // For Smi's the message would be empty. |
| 350 errorMessage = "Uncaught " + String::number(exception.As<v8::Integer>()- >Value()); | 259 errorMessage = "Uncaught " + String::number(exception.As<v8::Integer>()- >Value()); |
| 351 } | 260 } |
| 352 | 261 |
| 353 String messageForConsole = extractMessageForConsole(data.GetValue()); | 262 String messageForConsole = extractMessageForConsole(data.GetValue()); |
| 354 if (!messageForConsole.isEmpty()) | 263 if (!messageForConsole.isEmpty()) |
| 355 errorMessage = "Uncaught " + messageForConsole; | 264 errorMessage = "Uncaught " + messageForConsole; |
| 356 | 265 |
| 357 ScriptState* scriptState = ScriptState::from(context); | 266 ScriptState* scriptState = ScriptState::from(context); |
| 358 promiseRejectMessageQueue().append(PromiseRejectMessage(ScriptValue(scriptSt ate, promise), ScriptValue(scriptState, data.GetValue()), errorMessage, resource Name, scriptId, lineNumber, columnNumber, callStack)); | 267 rejectedPromisesOnMainThread().add(scriptState, data, errorMessage, resource Name, scriptId, lineNumber, columnNumber, callStack); |
| 359 } | 268 } |
| 360 | 269 |
| 361 static void promiseRejectHandlerInWorker(v8::PromiseRejectMessage data) | 270 static void promiseRejectHandlerInWorker(v8::PromiseRejectMessage data) |
| 362 { | 271 { |
| 363 if (data.GetEvent() != v8::kPromiseRejectWithNoHandler) | 272 if (data.GetEvent() != v8::kPromiseRejectWithNoHandler) |
| 364 return; | 273 return; |
| 365 | 274 |
| 366 v8::Handle<v8::Promise> promise = data.GetPromise(); | 275 v8::Handle<v8::Promise> promise = data.GetPromise(); |
| 367 | 276 |
| 368 // Bail out if called during context initialization. | 277 // Bail out if called during context initialization. |
| 369 v8::Isolate* isolate = promise->GetIsolate(); | 278 v8::Isolate* isolate = promise->GetIsolate(); |
| 370 v8::Handle<v8::Context> context = isolate->GetCurrentContext(); | 279 v8::Handle<v8::Context> context = isolate->GetCurrentContext(); |
| 371 if (context.IsEmpty()) | 280 if (context.IsEmpty()) |
| 372 return; | 281 return; |
| 373 | 282 |
| 283 ScriptState* scriptState = ScriptState::from(context); | |
|
haraken
2015/02/08 01:53:54
Slightly better:
ScriptState* scriptState = Scrip
sof
2015/02/08 07:26:47
That looks a bit tidier, thanks. Switched.
| |
| 284 ExecutionContext* executionContext = scriptState->executionContext(); | |
| 285 if (!executionContext) | |
| 286 return; | |
| 287 | |
| 288 ASSERT(executionContext->isWorkerGlobalScope()); | |
| 289 WorkerScriptController* scriptController = toWorkerGlobalScope(executionCont ext)->script(); | |
| 290 ASSERT(scriptController); | |
| 291 | |
| 374 int scriptId = 0; | 292 int scriptId = 0; |
| 375 int lineNumber = 0; | 293 int lineNumber = 0; |
| 376 int columnNumber = 0; | 294 int columnNumber = 0; |
| 377 String resourceName; | 295 String resourceName; |
| 378 String errorMessage; | 296 String errorMessage; |
| 379 | 297 |
| 380 v8::Handle<v8::Message> message = v8::Exception::CreateMessage(data.GetValue ()); | 298 v8::Handle<v8::Message> message = v8::Exception::CreateMessage(data.GetValue ()); |
| 381 if (!message.IsEmpty()) { | 299 if (!message.IsEmpty()) { |
| 382 TOSTRING_VOID(V8StringResource<>, resourceName, message->GetScriptOrigin ().ResourceName()); | 300 TOSTRING_VOID(V8StringResource<>, resourceName, message->GetScriptOrigin ().ResourceName()); |
| 383 scriptId = message->GetScriptOrigin().ScriptID()->Value(); | 301 scriptId = message->GetScriptOrigin().ScriptID()->Value(); |
| 384 lineNumber = message->GetLineNumber(); | 302 lineNumber = message->GetLineNumber(); |
| 385 columnNumber = message->GetStartColumn() + 1; | 303 columnNumber = message->GetStartColumn() + 1; |
| 386 errorMessage = toCoreString(message->Get()); | 304 errorMessage = toCoreString(message->Get()); |
| 387 } | 305 } |
| 388 | 306 scriptController->rejectedPromises()->add(scriptState, data, errorMessage, r esourceName, scriptId, lineNumber, columnNumber, nullptr); |
| 389 ScriptState* scriptState = ScriptState::from(context); | |
| 390 promiseRejectMessageQueue().append(PromiseRejectMessage(ScriptValue(scriptSt ate, promise), ScriptValue(scriptState, data.GetValue()), errorMessage, resource Name, scriptId, lineNumber, columnNumber, nullptr)); | |
| 391 } | 307 } |
| 392 | 308 |
| 393 static void failedAccessCheckCallbackInMainThread(v8::Local<v8::Object> host, v8 ::AccessType type, v8::Local<v8::Value> data) | 309 static void failedAccessCheckCallbackInMainThread(v8::Local<v8::Object> host, v8 ::AccessType type, v8::Local<v8::Value> data) |
| 394 { | 310 { |
| 395 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 311 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
| 396 Frame* target = findFrame(host, data, isolate); | 312 Frame* target = findFrame(host, data, isolate); |
| 397 if (!target) | 313 if (!target) |
| 398 return; | 314 return; |
| 399 DOMWindow* targetWindow = target->domWindow(); | 315 DOMWindow* targetWindow = target->domWindow(); |
| 400 | 316 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 450 static void initializeV8Common(v8::Isolate* isolate) | 366 static void initializeV8Common(v8::Isolate* isolate) |
| 451 { | 367 { |
| 452 v8::V8::AddGCPrologueCallback(V8GCController::gcPrologue); | 368 v8::V8::AddGCPrologueCallback(V8GCController::gcPrologue); |
| 453 v8::V8::AddGCEpilogueCallback(V8GCController::gcEpilogue); | 369 v8::V8::AddGCEpilogueCallback(V8GCController::gcEpilogue); |
| 454 | 370 |
| 455 v8::Debug::SetLiveEditEnabled(isolate, false); | 371 v8::Debug::SetLiveEditEnabled(isolate, false); |
| 456 | 372 |
| 457 isolate->SetAutorunMicrotasks(false); | 373 isolate->SetAutorunMicrotasks(false); |
| 458 } | 374 } |
| 459 | 375 |
| 376 namespace { | |
| 377 | |
| 378 class ArrayBufferAllocator : public v8::ArrayBuffer::Allocator { | |
| 379 virtual void* Allocate(size_t size) override | |
| 380 { | |
| 381 void* data; | |
| 382 WTF::ArrayBufferContents::allocateMemory(size, WTF::ArrayBufferContents: :ZeroInitialize, data); | |
| 383 return data; | |
| 384 } | |
| 385 | |
| 386 virtual void* AllocateUninitialized(size_t size) override | |
| 387 { | |
| 388 void* data; | |
| 389 WTF::ArrayBufferContents::allocateMemory(size, WTF::ArrayBufferContents: :DontInitialize, data); | |
| 390 return data; | |
| 391 } | |
| 392 | |
| 393 virtual void Free(void* data, size_t size) override | |
| 394 { | |
| 395 WTF::ArrayBufferContents::freeMemory(data, size); | |
| 396 } | |
| 397 }; | |
| 398 | |
| 399 } // namespace | |
| 400 | |
| 460 void V8Initializer::initializeMainThreadIfNeeded() | 401 void V8Initializer::initializeMainThreadIfNeeded() |
| 461 { | 402 { |
| 462 ASSERT(isMainThread()); | 403 ASSERT(isMainThread()); |
| 463 | 404 |
| 464 static bool initialized = false; | 405 static bool initialized = false; |
| 465 if (initialized) | 406 if (initialized) |
| 466 return; | 407 return; |
| 467 initialized = true; | 408 initialized = true; |
| 468 | 409 |
| 469 DEFINE_STATIC_LOCAL(ArrayBufferAllocator, arrayBufferAllocator, ()); | 410 DEFINE_STATIC_LOCAL(ArrayBufferAllocator, arrayBufferAllocator, ()); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 536 | 477 |
| 537 v8::V8::AddMessageListener(messageHandlerInWorker); | 478 v8::V8::AddMessageListener(messageHandlerInWorker); |
| 538 v8::V8::SetFatalErrorHandler(reportFatalErrorInWorker); | 479 v8::V8::SetFatalErrorHandler(reportFatalErrorInWorker); |
| 539 | 480 |
| 540 uint32_t here; | 481 uint32_t here; |
| 541 isolate->SetStackLimit(reinterpret_cast<uintptr_t>(&here - kWorkerMaxStackSi ze / sizeof(uint32_t*))); | 482 isolate->SetStackLimit(reinterpret_cast<uintptr_t>(&here - kWorkerMaxStackSi ze / sizeof(uint32_t*))); |
| 542 isolate->SetPromiseRejectCallback(promiseRejectHandlerInWorker); | 483 isolate->SetPromiseRejectCallback(promiseRejectHandlerInWorker); |
| 543 } | 484 } |
| 544 | 485 |
| 545 } // namespace blink | 486 } // namespace blink |
| OLD | NEW |