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

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/V8Initializer.cpp

Issue 2687943004: Abstract out ThreadDebugger from V8PerIsolateData (Closed)
Patch Set: Initialize HiddenValue and PrivateProperty in V8Initializer Created 3 years, 10 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
OLDNEW
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 "bindings/core/v8/V8Initializer.h" 26 #include "bindings/core/v8/V8Initializer.h"
27 27
28 #include <v8-debug.h>
29 #include <v8-profiler.h>
30 #include <memory>
28 #include "bindings/core/v8/DOMWrapperWorld.h" 31 #include "bindings/core/v8/DOMWrapperWorld.h"
29 #include "bindings/core/v8/RejectedPromises.h" 32 #include "bindings/core/v8/RejectedPromises.h"
30 #include "bindings/core/v8/RetainedDOMInfo.h" 33 #include "bindings/core/v8/RetainedDOMInfo.h"
31 #include "bindings/core/v8/ScriptController.h" 34 #include "bindings/core/v8/ScriptController.h"
32 #include "bindings/core/v8/ScriptValue.h" 35 #include "bindings/core/v8/ScriptValue.h"
33 #include "bindings/core/v8/ScriptWrappableVisitor.h" 36 #include "bindings/core/v8/ScriptWrappableVisitor.h"
34 #include "bindings/core/v8/SourceLocation.h" 37 #include "bindings/core/v8/SourceLocation.h"
35 #include "bindings/core/v8/V8Binding.h" 38 #include "bindings/core/v8/V8Binding.h"
36 #include "bindings/core/v8/V8DOMException.h" 39 #include "bindings/core/v8/V8DOMException.h"
37 #include "bindings/core/v8/V8ErrorEvent.h" 40 #include "bindings/core/v8/V8ErrorEvent.h"
38 #include "bindings/core/v8/V8ErrorHandler.h" 41 #include "bindings/core/v8/V8ErrorHandler.h"
39 #include "bindings/core/v8/V8GCController.h" 42 #include "bindings/core/v8/V8GCController.h"
43 #include "bindings/core/v8/V8HiddenValue.h"
40 #include "bindings/core/v8/V8IdleTaskRunner.h" 44 #include "bindings/core/v8/V8IdleTaskRunner.h"
41 #include "bindings/core/v8/V8Location.h" 45 #include "bindings/core/v8/V8Location.h"
42 #include "bindings/core/v8/V8PerContextData.h" 46 #include "bindings/core/v8/V8PerContextData.h"
43 #include "bindings/core/v8/V8PrivateProperty.h" 47 #include "bindings/core/v8/V8PrivateProperty.h"
44 #include "bindings/core/v8/V8Window.h" 48 #include "bindings/core/v8/V8Window.h"
45 #include "bindings/core/v8/WorkerOrWorkletScriptController.h" 49 #include "bindings/core/v8/WorkerOrWorkletScriptController.h"
46 #include "core/dom/Document.h" 50 #include "core/dom/Document.h"
47 #include "core/frame/LocalDOMWindow.h" 51 #include "core/frame/LocalDOMWindow.h"
48 #include "core/frame/LocalFrame.h" 52 #include "core/frame/LocalFrame.h"
49 #include "core/frame/csp/ContentSecurityPolicy.h" 53 #include "core/frame/csp/ContentSecurityPolicy.h"
50 #include "core/inspector/ConsoleMessage.h" 54 #include "core/inspector/ConsoleMessage.h"
51 #include "core/inspector/MainThreadDebugger.h" 55 #include "core/inspector/MainThreadDebugger.h"
52 #include "core/workers/WorkerGlobalScope.h" 56 #include "core/workers/WorkerGlobalScope.h"
53 #include "platform/EventDispatchForbiddenScope.h" 57 #include "platform/EventDispatchForbiddenScope.h"
54 #include "platform/RuntimeEnabledFeatures.h" 58 #include "platform/RuntimeEnabledFeatures.h"
55 #include "platform/instrumentation/tracing/TraceEvent.h" 59 #include "platform/instrumentation/tracing/TraceEvent.h"
56 #include "platform/loader/fetch/AccessControlStatus.h" 60 #include "platform/loader/fetch/AccessControlStatus.h"
57 #include "public/platform/Platform.h" 61 #include "public/platform/Platform.h"
58 #include "public/platform/WebScheduler.h" 62 #include "public/platform/WebScheduler.h"
59 #include "public/platform/WebThread.h" 63 #include "public/platform/WebThread.h"
60 #include "wtf/AddressSanitizer.h" 64 #include "wtf/AddressSanitizer.h"
61 #include "wtf/PtrUtil.h" 65 #include "wtf/PtrUtil.h"
62 #include "wtf/RefPtr.h" 66 #include "wtf/RefPtr.h"
63 #include "wtf/text/WTFString.h" 67 #include "wtf/text/WTFString.h"
64 #include "wtf/typed_arrays/ArrayBufferContents.h" 68 #include "wtf/typed_arrays/ArrayBufferContents.h"
65 #include <memory>
66 #include <v8-debug.h>
67 #include <v8-profiler.h>
68 69
69 namespace blink { 70 namespace blink {
70 71
71 static Frame* findFrame(v8::Isolate* isolate, 72 static Frame* findFrame(v8::Isolate* isolate,
72 v8::Local<v8::Object> host, 73 v8::Local<v8::Object> host,
73 v8::Local<v8::Value> data) { 74 v8::Local<v8::Value> data) {
74 const WrapperTypeInfo* type = WrapperTypeInfo::unwrap(data); 75 const WrapperTypeInfo* type = WrapperTypeInfo::unwrap(data);
75 76
76 if (V8Window::wrapperTypeInfo.equals(type)) { 77 if (V8Window::wrapperTypeInfo.equals(type)) {
77 v8::Local<v8::Object> windowWrapper = 78 v8::Local<v8::Object> windowWrapper =
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 ContentSecurityPolicy::WillThrowException); 317 ContentSecurityPolicy::WillThrowException);
317 } 318 }
318 return false; 319 return false;
319 } 320 }
320 321
321 static void initializeV8Common(v8::Isolate* isolate) { 322 static void initializeV8Common(v8::Isolate* isolate) {
322 isolate->AddGCPrologueCallback(V8GCController::gcPrologue); 323 isolate->AddGCPrologueCallback(V8GCController::gcPrologue);
323 isolate->AddGCEpilogueCallback(V8GCController::gcEpilogue); 324 isolate->AddGCEpilogueCallback(V8GCController::gcEpilogue);
324 std::unique_ptr<ScriptWrappableVisitor> visitor( 325 std::unique_ptr<ScriptWrappableVisitor> visitor(
325 new ScriptWrappableVisitor(isolate)); 326 new ScriptWrappableVisitor(isolate));
326 V8PerIsolateData::from(isolate)->setScriptWrappableVisitor( 327 V8PerIsolateData* isolateData = V8PerIsolateData::from(isolate);
327 std::move(visitor)); 328 isolateData->setScriptWrappableVisitor(std::move(visitor));
328 isolate->SetEmbedderHeapTracer( 329 isolate->SetEmbedderHeapTracer(
329 V8PerIsolateData::from(isolate)->scriptWrappableVisitor()); 330 V8PerIsolateData::from(isolate)->scriptWrappableVisitor());
330 331
331 v8::Debug::SetLiveEditEnabled(isolate, false); 332 v8::Debug::SetLiveEditEnabled(isolate, false);
332 333
333 isolate->SetMicrotasksPolicy(v8::MicrotasksPolicy::kScoped); 334 isolate->SetMicrotasksPolicy(v8::MicrotasksPolicy::kScoped);
335
336 V8HiddenValue::initialize(isolate);
337 V8PrivateProperty::initialize(isolate);
334 } 338 }
335 339
336 namespace { 340 namespace {
337 341
338 class ArrayBufferAllocator : public v8::ArrayBuffer::Allocator { 342 class ArrayBufferAllocator : public v8::ArrayBuffer::Allocator {
339 // Allocate() methods return null to signal allocation failure to V8, which 343 // Allocate() methods return null to signal allocation failure to V8, which
340 // should respond by throwing a RangeError, per 344 // should respond by throwing a RangeError, per
341 // http://www.ecma-international.org/ecma-262/6.0/#sec-createbytedatablock. 345 // http://www.ecma-international.org/ecma-262/6.0/#sec-createbytedatablock.
342 void* Allocate(size_t size) override { 346 void* Allocate(size_t size) override {
343 void* data; 347 void* data;
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 } 430 }
427 431
428 ASSERT(ThreadState::mainThreadState()); 432 ASSERT(ThreadState::mainThreadState());
429 ThreadState::mainThreadState()->addInterruptor( 433 ThreadState::mainThreadState()->addInterruptor(
430 WTF::makeUnique<V8IsolateInterruptor>(isolate)); 434 WTF::makeUnique<V8IsolateInterruptor>(isolate));
431 ThreadState::mainThreadState()->registerTraceDOMWrappers( 435 ThreadState::mainThreadState()->registerTraceDOMWrappers(
432 isolate, V8GCController::traceDOMWrappers, 436 isolate, V8GCController::traceDOMWrappers,
433 ScriptWrappableVisitor::invalidateDeadObjectsInMarkingDeque, 437 ScriptWrappableVisitor::invalidateDeadObjectsInMarkingDeque,
434 ScriptWrappableVisitor::performCleanup); 438 ScriptWrappableVisitor::performCleanup);
435 439
436 V8PerIsolateData::from(isolate)->setThreadDebugger( 440 ThreadDebugger::setThreadDebugger(isolate, new MainThreadDebugger(isolate));
jbroman 2017/02/15 02:25:23 This looks like it was more or less fine as-is. I'
adithyas 2017/02/15 18:12:12 I thought it was weird having a getter and setter
437 WTF::makeUnique<MainThreadDebugger>(isolate));
438 } 441 }
439 442
440 static void reportFatalErrorInWorker(const char* location, 443 static void reportFatalErrorInWorker(const char* location,
441 const char* message) { 444 const char* message) {
442 // FIXME: We temporarily deal with V8 internal error situations such as 445 // FIXME: We temporarily deal with V8 internal error situations such as
443 // out-of-memory by crashing the worker. 446 // out-of-memory by crashing the worker.
444 CRASH(); 447 CRASH();
445 } 448 }
446 449
447 static void messageHandlerInWorker(v8::Local<v8::Message> message, 450 static void messageHandlerInWorker(v8::Local<v8::Message> message,
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 v8::Isolate::kMessageLog); 516 v8::Isolate::kMessageLog);
514 isolate->SetFatalErrorHandler(reportFatalErrorInWorker); 517 isolate->SetFatalErrorHandler(reportFatalErrorInWorker);
515 518
516 uint32_t here; 519 uint32_t here;
517 isolate->SetStackLimit(reinterpret_cast<uintptr_t>(&here) - 520 isolate->SetStackLimit(reinterpret_cast<uintptr_t>(&here) -
518 kWorkerMaxStackSize); 521 kWorkerMaxStackSize);
519 isolate->SetPromiseRejectCallback(promiseRejectHandlerInWorker); 522 isolate->SetPromiseRejectCallback(promiseRejectHandlerInWorker);
520 } 523 }
521 524
522 } // namespace blink 525 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698