OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "sky/engine/core/script/dart_init.h" | 5 #include "sky/engine/core/script/dart_init.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
10 #include "base/trace_event/trace_event.h" | 10 #include "base/trace_event/trace_event.h" |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 | 66 |
67 namespace { | 67 namespace { |
68 | 68 |
69 void CreateEmptyRootLibraryIfNeeded() { | 69 void CreateEmptyRootLibraryIfNeeded() { |
70 if (Dart_IsNull(Dart_RootLibrary())) { | 70 if (Dart_IsNull(Dart_RootLibrary())) { |
71 Dart_LoadScript(Dart_NewStringFromCString("dart:empty"), Dart_EmptyString(), | 71 Dart_LoadScript(Dart_NewStringFromCString("dart:empty"), Dart_EmptyString(), |
72 0, 0); | 72 0, 0); |
73 } | 73 } |
74 } | 74 } |
75 | 75 |
| 76 static const char* kDartArgs[] = { |
| 77 "--enable_mirrors=false", |
76 #if ENABLE(DART_STRICT) | 78 #if ENABLE(DART_STRICT) |
77 static const char* kCheckedModeArgs[] = {"--enable_asserts", | 79 "--enable_asserts", |
78 "--enable_type_checks", | 80 "--enable_type_checks", |
79 "--error_on_bad_type", | 81 "--error_on_bad_type", |
80 "--error_on_bad_override", | 82 "--error_on_bad_override", |
81 #if WTF_OS_IOS | 83 #if WTF_OS_IOS |
82 "--no-profile" | 84 "--no-profile" |
| 85 #endif |
83 #endif | 86 #endif |
84 }; | 87 }; |
85 #endif | |
86 | 88 |
87 void UnhandledExceptionCallback(Dart_Handle error) { | 89 void UnhandledExceptionCallback(Dart_Handle error) { |
88 LOG(ERROR) << Dart_GetError(error); | 90 LOG(ERROR) << Dart_GetError(error); |
89 } | 91 } |
90 | 92 |
91 void IsolateShutdownCallback(void* callback_data) { | 93 void IsolateShutdownCallback(void* callback_data) { |
92 // TODO(dart) | 94 // TODO(dart) |
93 } | 95 } |
94 | 96 |
95 bool IsServiceIsolateURL(const char* url_name) { | 97 bool IsServiceIsolateURL(const char* url_name) { |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 | 163 |
162 Dart_ExitIsolate(); | 164 Dart_ExitIsolate(); |
163 | 165 |
164 CHECK(Dart_IsolateMakeRunnable(isolate)); | 166 CHECK(Dart_IsolateMakeRunnable(isolate)); |
165 return isolate; | 167 return isolate; |
166 } | 168 } |
167 | 169 |
168 } // namespace | 170 } // namespace |
169 | 171 |
170 void InitDartVM() { | 172 void InitDartVM() { |
171 int argc = 0; | |
172 const char** argv = nullptr; | |
173 | |
174 #if ENABLE(DART_STRICT) | |
175 argc = arraysize(kCheckedModeArgs); | |
176 argv = kCheckedModeArgs; | |
177 #endif | |
178 | |
179 dart::bin::BootstrapDartIo(); | 173 dart::bin::BootstrapDartIo(); |
180 | 174 |
181 CHECK(Dart_SetVMFlags(argc, argv)); | 175 CHECK(Dart_SetVMFlags(arraysize(kDartArgs), kDartArgs)); |
182 // This should be called before calling Dart_Initialize. | 176 // This should be called before calling Dart_Initialize. |
183 DartDebugger::InitDebugger(); | 177 DartDebugger::InitDebugger(); |
184 CHECK(Dart_Initialize(kDartVmIsolateSnapshotBuffer, | 178 CHECK(Dart_Initialize(kDartVmIsolateSnapshotBuffer, |
185 IsolateCreateCallback, | 179 IsolateCreateCallback, |
186 nullptr, // Isolate interrupt callback. | 180 nullptr, // Isolate interrupt callback. |
187 UnhandledExceptionCallback, IsolateShutdownCallback, | 181 UnhandledExceptionCallback, IsolateShutdownCallback, |
188 // File IO callbacks. | 182 // File IO callbacks. |
189 nullptr, nullptr, nullptr, nullptr, nullptr)); | 183 nullptr, nullptr, nullptr, nullptr, nullptr)); |
190 // Wait for load port- ensures handle watcher and service isolates are | 184 // Wait for load port- ensures handle watcher and service isolates are |
191 // running. | 185 // running. |
192 Dart_ServiceWaitForLoadPort(); | 186 Dart_ServiceWaitForLoadPort(); |
193 } | 187 } |
194 | 188 |
195 } // namespace blink | 189 } // namespace blink |
OLD | NEW |