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 |
(...skipping 23 matching lines...) Expand all Loading... | |
34 #include "bindings/core/v8/ScriptValue.h" | 34 #include "bindings/core/v8/ScriptValue.h" |
35 #include "bindings/core/v8/SourceLocation.h" | 35 #include "bindings/core/v8/SourceLocation.h" |
36 #include "bindings/core/v8/UseCounterCallback.h" | 36 #include "bindings/core/v8/UseCounterCallback.h" |
37 #include "bindings/core/v8/V8BindingForCore.h" | 37 #include "bindings/core/v8/V8BindingForCore.h" |
38 #include "bindings/core/v8/V8DOMException.h" | 38 #include "bindings/core/v8/V8DOMException.h" |
39 #include "bindings/core/v8/V8ErrorEvent.h" | 39 #include "bindings/core/v8/V8ErrorEvent.h" |
40 #include "bindings/core/v8/V8ErrorHandler.h" | 40 #include "bindings/core/v8/V8ErrorHandler.h" |
41 #include "bindings/core/v8/V8GCController.h" | 41 #include "bindings/core/v8/V8GCController.h" |
42 #include "bindings/core/v8/V8IdleTaskRunner.h" | 42 #include "bindings/core/v8/V8IdleTaskRunner.h" |
43 #include "bindings/core/v8/V8Location.h" | 43 #include "bindings/core/v8/V8Location.h" |
44 #include "bindings/core/v8/V8SnapshotCreator.h" | |
44 #include "bindings/core/v8/V8Window.h" | 45 #include "bindings/core/v8/V8Window.h" |
45 #include "bindings/core/v8/WorkerOrWorkletScriptController.h" | 46 #include "bindings/core/v8/WorkerOrWorkletScriptController.h" |
46 #include "core/dom/Document.h" | 47 #include "core/dom/Document.h" |
47 #include "core/dom/ExecutionContext.h" | 48 #include "core/dom/ExecutionContext.h" |
48 #include "core/frame/LocalDOMWindow.h" | 49 #include "core/frame/LocalDOMWindow.h" |
49 #include "core/frame/LocalFrame.h" | 50 #include "core/frame/LocalFrame.h" |
50 #include "core/frame/csp/ContentSecurityPolicy.h" | 51 #include "core/frame/csp/ContentSecurityPolicy.h" |
51 #include "core/inspector/ConsoleMessage.h" | 52 #include "core/inspector/ConsoleMessage.h" |
52 #include "core/inspector/MainThreadDebugger.h" | 53 #include "core/inspector/MainThreadDebugger.h" |
53 #include "core/workers/WorkerGlobalScope.h" | 54 #include "core/workers/WorkerGlobalScope.h" |
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
439 | 440 |
440 process_total += diff; | 441 process_total += diff; |
441 DCHECK_GE(process_total, 0) | 442 DCHECK_GE(process_total, 0) |
442 << "total amount = " << process_total << ", diff = " << diff; | 443 << "total amount = " << process_total << ", diff = " << diff; |
443 } | 444 } |
444 #endif | 445 #endif |
445 | 446 |
446 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(diff); | 447 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(diff); |
447 } | 448 } |
448 | 449 |
449 void V8Initializer::InitializeMainThread() { | 450 void V8Initializer::InitializeMainThread(intptr_t* table) { |
Yuki
2017/05/12 15:20:10
|table| doesn't make much sense.
v8_snapshot_exter
peria
2017/05/30 08:25:42
Acknowledged.
| |
450 DCHECK(IsMainThread()); | 451 DCHECK(IsMainThread()); |
451 | 452 |
452 WTF::ArrayBufferContents::Initialize(AdjustAmountOfExternalAllocatedMemory); | 453 WTF::ArrayBufferContents::Initialize(AdjustAmountOfExternalAllocatedMemory); |
453 | 454 |
454 DEFINE_STATIC_LOCAL(ArrayBufferAllocator, array_buffer_allocator, ()); | 455 DEFINE_STATIC_LOCAL(ArrayBufferAllocator, array_buffer_allocator, ()); |
455 auto v8_extras_mode = RuntimeEnabledFeatures::experimentalV8ExtrasEnabled() | 456 auto v8_extras_mode = RuntimeEnabledFeatures::experimentalV8ExtrasEnabled() |
456 ? gin::IsolateHolder::kStableAndExperimentalV8Extras | 457 ? gin::IsolateHolder::kStableAndExperimentalV8Extras |
457 : gin::IsolateHolder::kStableV8Extras; | 458 : gin::IsolateHolder::kStableV8Extras; |
458 gin::IsolateHolder::Initialize(gin::IsolateHolder::kNonStrictMode, | 459 gin::IsolateHolder::Initialize(gin::IsolateHolder::kNonStrictMode, |
459 v8_extras_mode, &array_buffer_allocator); | 460 v8_extras_mode, &array_buffer_allocator); |
460 | 461 |
461 // NOTE: Some threads (namely utility threads) don't have a scheduler. | 462 // NOTE: Some threads (namely utility threads) don't have a scheduler. |
462 WebScheduler* scheduler = Platform::Current()->CurrentThread()->Scheduler(); | 463 WebThread* thread = Platform::Current()->CurrentThread(); |
464 WebScheduler* scheduler = thread ? thread->Scheduler() : nullptr; | |
465 | |
463 // When timer task runner is used for PerIsolateData, GC tasks are getting | 466 // When timer task runner is used for PerIsolateData, GC tasks are getting |
464 // throttled and memory usage goes up. For now we're using loading task queue | 467 // throttled and memory usage goes up. For now we're using loading task queue |
465 // to prevent this. | 468 // to prevent this. |
466 // TODO(altimin): Consider switching to timerTaskRunner here. | 469 // TODO(altimin): Consider switching to timerTaskRunner here. |
467 v8::Isolate* isolate = V8PerIsolateData::Initialize( | 470 v8::Isolate* isolate = V8PerIsolateData::Initialize( |
468 scheduler ? scheduler->LoadingTaskRunner() | 471 scheduler ? scheduler->LoadingTaskRunner() |
469 : Platform::Current()->CurrentThread()->GetWebTaskRunner()); | 472 : thread ? thread->GetWebTaskRunner() : nullptr, |
473 table, V8SnapshotCreator::TakingSnapshot()); | |
470 | 474 |
471 InitializeV8Common(isolate); | 475 InitializeV8Common(isolate); |
472 | 476 |
473 isolate->SetOOMErrorHandler(ReportOOMErrorInMainThread); | 477 isolate->SetOOMErrorHandler(ReportOOMErrorInMainThread); |
474 isolate->SetFatalErrorHandler(ReportFatalErrorInMainThread); | 478 isolate->SetFatalErrorHandler(ReportFatalErrorInMainThread); |
475 isolate->AddMessageListenerWithErrorLevel( | 479 isolate->AddMessageListenerWithErrorLevel( |
476 MessageHandlerInMainThread, | 480 MessageHandlerInMainThread, |
477 v8::Isolate::kMessageError | v8::Isolate::kMessageWarning | | 481 v8::Isolate::kMessageError | v8::Isolate::kMessageWarning | |
478 v8::Isolate::kMessageInfo | v8::Isolate::kMessageDebug | | 482 v8::Isolate::kMessageInfo | v8::Isolate::kMessageDebug | |
479 v8::Isolate::kMessageLog); | 483 v8::Isolate::kMessageLog); |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
583 v8::Isolate::kMessageLog); | 587 v8::Isolate::kMessageLog); |
584 isolate->SetFatalErrorHandler(ReportFatalErrorInWorker); | 588 isolate->SetFatalErrorHandler(ReportFatalErrorInWorker); |
585 | 589 |
586 uint32_t here; | 590 uint32_t here; |
587 isolate->SetStackLimit(reinterpret_cast<uintptr_t>(&here) - | 591 isolate->SetStackLimit(reinterpret_cast<uintptr_t>(&here) - |
588 kWorkerMaxStackSize); | 592 kWorkerMaxStackSize); |
589 isolate->SetPromiseRejectCallback(PromiseRejectHandlerInWorker); | 593 isolate->SetPromiseRejectCallback(PromiseRejectHandlerInWorker); |
590 } | 594 } |
591 | 595 |
592 } // namespace blink | 596 } // namespace blink |
OLD | NEW |