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

Unified Diff: runtime/bin/gen_snapshot.cc

Issue 1405183002: Bring up the service isolate and use it for package resolution in gen_snapshot (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 2 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
« no previous file with comments | « runtime/bin/dartutils.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/gen_snapshot.cc
diff --git a/runtime/bin/gen_snapshot.cc b/runtime/bin/gen_snapshot.cc
index 72ee0f1ba066d92b99ebf46e4cfad77ff65a4877..bb6d4f8502e425ff0748b4f84f39ead591311132 100644
--- a/runtime/bin/gen_snapshot.cc
+++ b/runtime/bin/gen_snapshot.cc
@@ -13,9 +13,11 @@
#include "bin/builtin.h"
#include "bin/dartutils.h"
+#include "bin/eventhandler.h"
#include "bin/file.h"
#include "bin/log.h"
#include "bin/thread.h"
+#include "bin/vmservice_impl.h"
#include "platform/globals.h"
@@ -515,6 +517,52 @@ static void SetupForGenericSnapshotCreation() {
}
+static Dart_Isolate CreateServiceIsolate(const char* script_uri,
+ const char* main,
+ const char* package_root,
+ const char** package_map,
+ Dart_IsolateFlags* flags,
+ void* data,
+ char** error) {
+ Dart_Isolate isolate = NULL;
+ isolate = Dart_CreateIsolate(script_uri,
+ main,
+ NULL,
+ NULL,
+ NULL,
+ error);
+
+ if (isolate == NULL) {
+ Log::PrintErr("Error: Could not create service isolate");
+ return NULL;
+ }
+
+ Dart_EnterScope();
+ if (!Dart_IsServiceIsolate(isolate)) {
+ Log::PrintErr("Error: We only expect to create the service isolate");
+ return NULL;
+ }
+ Dart_Handle result = Dart_SetLibraryTagHandler(DartUtils::LibraryTagHandler);
+ // Setup the native resolver.
+ Builtin::LoadAndCheckLibrary(Builtin::kBuiltinLibrary);
+ Builtin::LoadAndCheckLibrary(Builtin::kIOLibrary);
+ if (Dart_IsError(result)) {
+ Log::PrintErr("Error: Could not set tag handler for service isolate");
+ return NULL;
+ }
+ CHECK_RESULT(result);
+ ASSERT(Dart_IsServiceIsolate(isolate));
+ // Load embedder specific bits and return. Will not start http server.
+ if (!VmService::Setup("127.0.0.1", -1)) {
+ *error = strdup(VmService::GetErrorMessage());
+ return NULL;
+ }
+ Dart_ExitScope();
+ Dart_ExitIsolate();
+ return isolate;
+}
+
+
int main(int argc, char** argv) {
const int EXTRA_VM_ARGUMENTS = 2;
CommandLineOptions vm_options(argc + EXTRA_VM_ARGUMENTS);
@@ -534,6 +582,8 @@ int main(int argc, char** argv) {
Thread::InitOnce();
DartUtils::SetOriginalWorkingDirectory();
+ // Start event handler.
+ EventHandler::Start();
vm_options.AddArgument("--load_deferred_eagerly");
// Workaround until issue 21620 is fixed.
@@ -544,8 +594,13 @@ int main(int argc, char** argv) {
// Initialize the Dart VM.
// Note: We don't expect isolates to be created from dart code during
// snapshot generation.
- char* error = Dart_Initialize(NULL, NULL,
- NULL, NULL, NULL, NULL,
+ char* error = Dart_Initialize(
+ NULL,
+ NULL,
+ CreateServiceIsolate,
+ NULL,
+ NULL,
+ NULL,
DartUtils::OpenFile,
DartUtils::ReadFile,
DartUtils::WriteFile,
@@ -631,6 +686,7 @@ int main(int argc, char** argv) {
SetupForGenericSnapshotCreation();
CreateAndWriteSnapshot();
}
+ EventHandler::Stop();
return 0;
}
« no previous file with comments | « runtime/bin/dartutils.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698