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

Side by Side Diff: sky/engine/core/script/dart_controller.cc

Issue 1047883002: gen_snapshot now generates two snapshot buffers, one for the vm isolate (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: update dart revision Created 5 years, 8 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
« no previous file with comments | « sky/engine/bindings/snapshot.cc.tmpl ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/config.h" 5 #include "sky/engine/config.h"
6 #include "sky/engine/core/script/dart_controller.h" 6 #include "sky/engine/core/script/dart_controller.h"
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/single_thread_task_runner.h" 10 #include "base/single_thread_task_runner.h"
(...skipping 28 matching lines...) Expand all
39 39
40 #if ENABLE(ASSERT) 40 #if ENABLE(ASSERT)
41 static const char* kCheckedModeArgs[] = { 41 static const char* kCheckedModeArgs[] = {
42 "--enable_asserts", 42 "--enable_asserts",
43 "--enable_type_checks", 43 "--enable_type_checks",
44 "--error_on_bad_type", 44 "--error_on_bad_type",
45 "--error_on_bad_override", 45 "--error_on_bad_override",
46 }; 46 };
47 #endif 47 #endif
48 48
49 extern const uint8_t* kDartSnapshotBuffer; 49 extern const uint8_t* kDartVmIsolateSnapshotBuffer;
50 extern const uint8_t* kDartIsolateSnapshotBuffer;
50 51
51 DartController::DartController() { 52 DartController::DartController() {
52 } 53 }
53 54
54 DartController::~DartController() { 55 DartController::~DartController() {
55 } 56 }
56 57
57 bool DartController::ImportChildLibraries(AbstractModule* module, 58 bool DartController::ImportChildLibraries(AbstractModule* module,
58 Dart_Handle library) { 59 Dart_Handle library) {
59 // If the document has never seen an <import> tag, it won't have an import 60 // If the document has never seen an <import> tag, it won't have an import
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 // TODO(rafaelw): Right now this only supports the creation of the handle 179 // TODO(rafaelw): Right now this only supports the creation of the handle
179 // watcher isolate. Presumably, we'll want application isolates to spawn their 180 // watcher isolate. Presumably, we'll want application isolates to spawn their
180 // own isolates. 181 // own isolates.
181 static Dart_Isolate IsolateCreateCallback(const char* script_uri, 182 static Dart_Isolate IsolateCreateCallback(const char* script_uri,
182 const char* main, 183 const char* main,
183 const char* package_root, 184 const char* package_root,
184 void* callback_data, 185 void* callback_data,
185 char** error) { 186 char** error) {
186 187
187 if (IsServiceIsolateURL(script_uri)) { 188 if (IsServiceIsolateURL(script_uri)) {
188 return Dart_CreateIsolate(script_uri, "main", kDartSnapshotBuffer, nullptr, 189 return Dart_CreateIsolate(script_uri, "main", kDartIsolateSnapshotBuffer,
189 error); 190 nullptr, error);
190 } 191 }
191 192
192 // Create & start the handle watcher isolate 193 // Create & start the handle watcher isolate
193 CHECK(kDartSnapshotBuffer); 194 CHECK(kDartIsolateSnapshotBuffer);
194 DartState* dart_state = new DartState(); 195 DartState* dart_state = new DartState();
195 Dart_Isolate isolate = Dart_CreateIsolate("sky:handle_watcher", "", 196 Dart_Isolate isolate = Dart_CreateIsolate("sky:handle_watcher", "",
196 kDartSnapshotBuffer, dart_state, error); 197 kDartIsolateSnapshotBuffer, dart_state, error);
197 CHECK(isolate) << error; 198 CHECK(isolate) << error;
198 dart_state->set_isolate(isolate); 199 dart_state->set_isolate(isolate);
199 200
200 CHECK(!LogIfError(Dart_SetLibraryTagHandler(LibraryTagHandler))); 201 CHECK(!LogIfError(Dart_SetLibraryTagHandler(LibraryTagHandler)));
201 202
202 { 203 {
203 DartApiScope apiScope; 204 DartApiScope apiScope;
204 Builtin::SetNativeResolver(Builtin::kBuiltinLibrary); 205 Builtin::SetNativeResolver(Builtin::kBuiltinLibrary);
205 Builtin::SetNativeResolver(Builtin::kMojoInternalLibrary); 206 Builtin::SetNativeResolver(Builtin::kMojoInternalLibrary);
206 } 207 }
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 0, 251 0,
251 nullptr))); 252 nullptr)));
252 253
253 // RunLoop until the handle watcher isolate is spun-up. 254 // RunLoop until the handle watcher isolate is spun-up.
254 CHECK(!LogIfError(Dart_RunLoop())); 255 CHECK(!LogIfError(Dart_RunLoop()));
255 handle_watcher_started = true; 256 handle_watcher_started = true;
256 } 257 }
257 258
258 void DartController::CreateIsolateFor(Document* document) { 259 void DartController::CreateIsolateFor(Document* document) {
259 DCHECK(document); 260 DCHECK(document);
260 CHECK(kDartSnapshotBuffer); 261 CHECK(kDartIsolateSnapshotBuffer);
261 char* error = nullptr; 262 char* error = nullptr;
262 dom_dart_state_ = adoptPtr(new DOMDartState(document)); 263 dom_dart_state_ = adoptPtr(new DOMDartState(document));
263 Dart_Isolate isolate = Dart_CreateIsolate( 264 Dart_Isolate isolate = Dart_CreateIsolate(
264 document->url().string().utf8().data(), "main", kDartSnapshotBuffer, 265 document->url().string().utf8().data(), "main", kDartIsolateSnapshotBuffer ,
265 static_cast<DartState*>(dom_dart_state_.get()), &error); 266 static_cast<DartState*>(dom_dart_state_.get()), &error);
266 Dart_SetMessageNotifyCallback(MessageNotifyCallback); 267 Dart_SetMessageNotifyCallback(MessageNotifyCallback);
267 CHECK(isolate) << error; 268 CHECK(isolate) << error;
268 dom_dart_state_->set_isolate(isolate); 269 dom_dart_state_->set_isolate(isolate);
269 Dart_SetGcCallbacks(DartGCPrologue, DartGCEpilogue); 270 Dart_SetGcCallbacks(DartGCPrologue, DartGCEpilogue);
270 CHECK(!LogIfError(Dart_SetLibraryTagHandler(LibraryTagHandler))); 271 CHECK(!LogIfError(Dart_SetLibraryTagHandler(LibraryTagHandler)));
271 272
272 { 273 {
273 DartApiScope apiScope; 274 DartApiScope apiScope;
274 275
(...skipping 22 matching lines...) Expand all
297 void DartController::InitVM() { 298 void DartController::InitVM() {
298 int argc = 0; 299 int argc = 0;
299 const char** argv = nullptr; 300 const char** argv = nullptr;
300 301
301 #if ENABLE(ASSERT) 302 #if ENABLE(ASSERT)
302 argc = arraysize(kCheckedModeArgs); 303 argc = arraysize(kCheckedModeArgs);
303 argv = kCheckedModeArgs; 304 argv = kCheckedModeArgs;
304 #endif 305 #endif
305 306
306 CHECK(Dart_SetVMFlags(argc, argv)); 307 CHECK(Dart_SetVMFlags(argc, argv));
307 CHECK(Dart_Initialize(IsolateCreateCallback, 308 CHECK(Dart_Initialize(kDartVmIsolateSnapshotBuffer,
309 IsolateCreateCallback,
308 nullptr, // Isolate interrupt callback. 310 nullptr, // Isolate interrupt callback.
309 UnhandledExceptionCallback, IsolateShutdownCallback, 311 UnhandledExceptionCallback, IsolateShutdownCallback,
310 // File IO callbacks. 312 // File IO callbacks.
311 nullptr, nullptr, nullptr, nullptr, nullptr)); 313 nullptr, nullptr, nullptr, nullptr, nullptr));
312 } 314 }
313 315
314 } // namespace blink 316 } // namespace blink
OLDNEW
« no previous file with comments | « sky/engine/bindings/snapshot.cc.tmpl ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698