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

Unified Diff: mojo/dart/dart_snapshotter/vm.cc

Issue 1273743005: Dart: Adds a program to create snapshots of Mojo apps. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: mojo/dart/dart_snapshotter/vm.cc
diff --git a/mojo/dart/dart_snapshotter/vm.cc b/mojo/dart/dart_snapshotter/vm.cc
new file mode 100644
index 0000000000000000000000000000000000000000..52b77f085069cef8f9034b25949f7c4f8154acaf
--- /dev/null
+++ b/mojo/dart/dart_snapshotter/vm.cc
@@ -0,0 +1,42 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "mojo/dart/dart_snapshotter/vm.h"
+
+#include "base/logging.h"
+#include "mojo/dart/dart_snapshotter/loader.h"
+#include "tonic/dart_error.h"
+#include "tonic/dart_state.h"
+
+namespace mojo {
+namespace dart {
+extern const uint8_t* vm_isolate_snapshot_buffer;
+extern const uint8_t* isolate_snapshot_buffer;
+}
+}
+
+static const char* kDartArgs[] = {
+ "--enable_mirrors=false",
+};
+
+void InitDartVM() {
+ CHECK(Dart_SetVMFlags(arraysize(kDartArgs), kDartArgs));
+ CHECK(Dart_Initialize(mojo::dart::vm_isolate_snapshot_buffer, nullptr,
+ nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
+ nullptr, nullptr));
+}
+
+Dart_Isolate CreateDartIsolate() {
+ CHECK(mojo::dart::isolate_snapshot_buffer);
+ char* error = nullptr;
+ Dart_Isolate isolate = Dart_CreateIsolate("dart:snapshot", "main",
Cutch 2015/08/11 14:18:06 Does this "dart:" url make it into the program tha
zra 2015/08/11 17:03:21 This string is only used for debug messages, and d
+ mojo::dart::isolate_snapshot_buffer,
+ nullptr, nullptr, &error);
+
+ CHECK(isolate) << error;
+ CHECK(!tonic::LogIfError(Dart_SetLibraryTagHandler(HandleLibraryTag)));
+
+ Dart_ExitIsolate();
+ return isolate;
+}

Powered by Google App Engine
This is Rietveld 408576698