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