| Index: runtime/bin/main.cc
|
| diff --git a/runtime/bin/main.cc b/runtime/bin/main.cc
|
| index 16b5d3358e9a6d906dd2f3d458fb3266699f44df..702a8a2f50ded29165b6549fbe47f8a8cb7bc8d0 100644
|
| --- a/runtime/bin/main.cc
|
| +++ b/runtime/bin/main.cc
|
| @@ -721,10 +721,7 @@ static Dart_Isolate CreateIsolateAndSetupHelper(const char* script_uri,
|
| *error = strdup(VmService::GetErrorMessage());
|
| return NULL;
|
| }
|
| - if (has_gen_precompiled_snapshot) {
|
| - result = Dart_Precompile();
|
| - CHECK_RESULT(result);
|
| - } else if (has_compile_all) {
|
| + if (has_compile_all) {
|
| result = Dart_CompileAll();
|
| CHECK_RESULT(result);
|
| }
|
| @@ -1042,7 +1039,9 @@ static void WriteSnapshotFile(const char* filename,
|
| File* file = File::Open(filename, File::kWriteTruncate);
|
| ASSERT(file != NULL);
|
| if (!file->WriteFully(buffer, size)) {
|
| - Log::PrintErr("Error: Failed to write snapshot file.\n\n");
|
| + ErrorExit(kErrorExitCode,
|
| + "Unable to open file %s for writing snapshot\n",
|
| + filename);
|
| }
|
| delete file;
|
| }
|
| @@ -1052,14 +1051,14 @@ static void ReadSnapshotFile(const char* filename,
|
| const uint8_t** buffer) {
|
| void* file = DartUtils::OpenFile(filename, false);
|
| if (file == NULL) {
|
| - Log::PrintErr("Error: Failed to open '%s'.\n\n", filename);
|
| - exit(kErrorExitCode);
|
| + ErrorExit(kErrorExitCode,
|
| + "Error: Unable to open file %s for reading snapshot\n", filename);
|
| }
|
| intptr_t len = -1;
|
| DartUtils::ReadFile(buffer, &len, file);
|
| if (*buffer == NULL || len == -1) {
|
| - Log::PrintErr("Error: Failed to read '%s'.\n\n", filename);
|
| - exit(kErrorExitCode);
|
| + ErrorExit(kErrorExitCode,
|
| + "Error: Unable to read snapshot file %s\n", filename);
|
| }
|
| DartUtils::CloseFile(file);
|
| }
|
| @@ -1068,13 +1067,13 @@ static void ReadSnapshotFile(const char* filename,
|
| static void* LoadLibrarySymbol(const char* libname, const char* symname) {
|
| void* library = Extensions::LoadExtensionLibrary(libname);
|
| if (library == NULL) {
|
| - Log::PrintErr("Error: Failed to load library '%s'.\n\n", libname);
|
| - exit(kErrorExitCode);
|
| + ErrorExit(kErrorExitCode,
|
| + "Error: Failed to load library '%s'\n", libname);
|
| }
|
| void* symbol = Extensions::ResolveSymbol(library, symname);
|
| if (symbol == NULL) {
|
| - Log::PrintErr("Failed to load symbol '%s'\n", symname);
|
| - exit(kErrorExitCode);
|
| + ErrorExit(kErrorExitCode,
|
| + "Error: Failed to load symbol '%s'\n", symname);
|
| }
|
| return symbol;
|
| }
|
| @@ -1283,53 +1282,55 @@ void main(int argc, char** argv) {
|
| WriteSnapshotFile(kPrecompiledInstructionsName,
|
| instructions_buffer,
|
| instructions_size);
|
| - } else if (has_compile_all) {
|
| - result = Dart_CompileAll();
|
| - DartExitOnError(result);
|
| - }
|
| -
|
| - if (Dart_IsNull(root_lib)) {
|
| - ErrorExit(kErrorExitCode,
|
| - "Unable to find root library for '%s'\n",
|
| - script_name);
|
| - }
|
| + } else {
|
| + if (has_compile_all) {
|
| + result = Dart_CompileAll();
|
| + DartExitOnError(result);
|
| + }
|
|
|
| - // The helper function _getMainClosure creates a closure for the main
|
| - // entry point which is either explicitly or implictly exported from the
|
| - // root library.
|
| - Dart_Handle main_closure = Dart_Invoke(
|
| - builtin_lib, Dart_NewStringFromCString("_getMainClosure"), 0, NULL);
|
| - DartExitOnError(main_closure);
|
| -
|
| - // Set debug breakpoint if specified on the command line before calling
|
| - // the main function.
|
| - if (breakpoint_at != NULL) {
|
| - result = SetBreakpoint(breakpoint_at, root_lib);
|
| - if (Dart_IsError(result)) {
|
| + if (Dart_IsNull(root_lib)) {
|
| ErrorExit(kErrorExitCode,
|
| - "Error setting breakpoint at '%s': %s\n",
|
| - breakpoint_at,
|
| - Dart_GetError(result));
|
| + "Unable to find root library for '%s'\n",
|
| + script_name);
|
| }
|
| - }
|
|
|
| - // Call _startIsolate in the isolate library to enable dispatching the
|
| - // initial startup message.
|
| - const intptr_t kNumIsolateArgs = 2;
|
| - Dart_Handle isolate_args[kNumIsolateArgs];
|
| - isolate_args[0] = main_closure; // entryPoint
|
| - isolate_args[1] = CreateRuntimeOptions(&dart_options); // args
|
| -
|
| - Dart_Handle isolate_lib = Dart_LookupLibrary(
|
| - Dart_NewStringFromCString("dart:isolate"));
|
| - result = Dart_Invoke(isolate_lib,
|
| - Dart_NewStringFromCString("_startMainIsolate"),
|
| - kNumIsolateArgs, isolate_args);
|
| - DartExitOnError(result);
|
| + // The helper function _getMainClosure creates a closure for the main
|
| + // entry point which is either explicitly or implictly exported from the
|
| + // root library.
|
| + Dart_Handle main_closure = Dart_Invoke(builtin_lib,
|
| + Dart_NewStringFromCString("_getMainClosure"), 0, NULL);
|
| + DartExitOnError(main_closure);
|
| +
|
| + // Set debug breakpoint if specified on the command line before calling
|
| + // the main function.
|
| + if (breakpoint_at != NULL) {
|
| + result = SetBreakpoint(breakpoint_at, root_lib);
|
| + if (Dart_IsError(result)) {
|
| + ErrorExit(kErrorExitCode,
|
| + "Error setting breakpoint at '%s': %s\n",
|
| + breakpoint_at,
|
| + Dart_GetError(result));
|
| + }
|
| + }
|
|
|
| - // Keep handling messages until the last active receive port is closed.
|
| - result = Dart_RunLoop();
|
| - DartExitOnError(result);
|
| + // Call _startIsolate in the isolate library to enable dispatching the
|
| + // initial startup message.
|
| + const intptr_t kNumIsolateArgs = 2;
|
| + Dart_Handle isolate_args[kNumIsolateArgs];
|
| + isolate_args[0] = main_closure; // entryPoint
|
| + isolate_args[1] = CreateRuntimeOptions(&dart_options); // args
|
| +
|
| + Dart_Handle isolate_lib =
|
| + Dart_LookupLibrary(Dart_NewStringFromCString("dart:isolate"));
|
| + result = Dart_Invoke(isolate_lib,
|
| + Dart_NewStringFromCString("_startMainIsolate"),
|
| + kNumIsolateArgs, isolate_args);
|
| + DartExitOnError(result);
|
| +
|
| + // Keep handling messages until the last active receive port is closed.
|
| + result = Dart_RunLoop();
|
| + DartExitOnError(result);
|
| + }
|
| }
|
|
|
| Dart_ExitScope();
|
|
|