| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "mojo/dart/dart_snapshotter/vm.h" | |
| 6 | |
| 7 #include "base/logging.h" | |
| 8 #include "tonic/dart_error.h" | |
| 9 #include "tonic/dart_state.h" | |
| 10 | |
| 11 namespace mojo { | |
| 12 namespace dart { | |
| 13 extern const uint8_t* vm_isolate_snapshot_buffer; | |
| 14 extern const uint8_t* isolate_snapshot_buffer; | |
| 15 } | |
| 16 } | |
| 17 | |
| 18 static const char* kDartArgs[] = { | |
| 19 "--enable_mirrors=false", | |
| 20 }; | |
| 21 | |
| 22 void InitDartVM() { | |
| 23 CHECK(Dart_SetVMFlags(arraysize(kDartArgs), kDartArgs)); | |
| 24 CHECK(Dart_Initialize(mojo::dart::vm_isolate_snapshot_buffer, nullptr, | |
| 25 nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, | |
| 26 nullptr, nullptr, nullptr, nullptr) == nullptr); | |
| 27 } | |
| 28 | |
| 29 Dart_Isolate CreateDartIsolate() { | |
| 30 CHECK(mojo::dart::isolate_snapshot_buffer); | |
| 31 char* error = nullptr; | |
| 32 auto isolate_data = new SnapshotterDartState(); | |
| 33 CHECK(isolate_data != nullptr); | |
| 34 Dart_Isolate isolate = Dart_CreateIsolate("dart:snapshot", | |
| 35 "main", | |
| 36 mojo::dart::isolate_snapshot_buffer, | |
| 37 nullptr, | |
| 38 isolate_data, | |
| 39 &error); | |
| 40 CHECK(isolate) << error; | |
| 41 Dart_ExitIsolate(); | |
| 42 isolate_data->SetIsolate(isolate); | |
| 43 return isolate; | |
| 44 } | |
| OLD | NEW |