Chromium Code Reviews| Index: mojo/dart/embedder/dart_controller.cc |
| diff --git a/mojo/dart/embedder/dart_controller.cc b/mojo/dart/embedder/dart_controller.cc |
| index 12881e2ce8958395f8d5a7119ce8e38e1793857f..b69ccf2c69602af8779dbcb12c78081c7ee07cec 100644 |
| --- a/mojo/dart/embedder/dart_controller.cc |
| +++ b/mojo/dart/embedder/dart_controller.cc |
| @@ -371,7 +371,7 @@ void DartController::InitVmIfNeeded(Dart_EntropySource entropy, |
| return; |
| } |
| - const int kNumArgs = arguments_count + 1; |
| + const int kNumArgs = arguments_count + 2; |
| const char* args[kNumArgs]; |
| // TODO(zra): Fix Dart VM Shutdown race. |
| @@ -383,8 +383,10 @@ void DartController::InitVmIfNeeded(Dart_EntropySource entropy, |
| // that isn't there anymore. |
| args[0] = "--worker-timeout-millis=0"; |
| + args[1] = "--print-stacktrace-at-throw"; |
| + |
| for (int i = 0; i < arguments_count; ++i) { |
| - args[i + 1] = arguments[i]; |
| + args[i + 2] = arguments[i]; |
| } |
| bool result = Dart_SetVMFlags(kNumArgs, args); |
| @@ -420,17 +422,10 @@ bool DartController::RunDartScript(const DartControllerConfig& config) { |
| Dart_Handle result; |
| Dart_EnterScope(); |
| - Dart_Handle root_lib = Dart_RootLibrary(); |
| - DART_CHECK_VALID(root_lib); |
| - |
| - Dart_Handle builtin_lib = |
| - Builtin::LoadAndCheckLibrary(Builtin::kBuiltinLibrary); |
| - DART_CHECK_VALID(builtin_lib); |
| + // Start the MojoHandleWatcher. |
| Dart_Handle mojo_core_lib = |
| Builtin::LoadAndCheckLibrary(Builtin::kMojoCoreLibrary); |
| DART_CHECK_VALID(mojo_core_lib); |
| - |
| - // Start the MojoHandleWatcher. |
| Dart_Handle handle_watcher_type = Dart_GetType( |
| mojo_core_lib, |
| Dart_NewStringFromCString("MojoHandleWatcher"), |
| @@ -448,6 +443,12 @@ bool DartController::RunDartScript(const DartControllerConfig& config) { |
| result = Dart_RunLoop(); |
| DART_CHECK_VALID(result); |
| + // Load the root library into the builtin library so that main can be found. |
| + Dart_Handle builtin_lib = |
| + Builtin::LoadAndCheckLibrary(Builtin::kBuiltinLibrary); |
| + DART_CHECK_VALID(builtin_lib); |
| + Dart_Handle root_lib = Dart_RootLibrary(); |
| + DART_CHECK_VALID(root_lib); |
| result = Dart_LibraryImportLibrary(builtin_lib, root_lib, Dart_Null()); |
| DART_CHECK_VALID(result); |
| @@ -468,9 +469,14 @@ bool DartController::RunDartScript(const DartControllerConfig& config) { |
| const intptr_t kNumIsolateArgs = 2; |
| Dart_Handle isolate_args[kNumIsolateArgs]; |
| isolate_args[0] = main_closure; // entryPoint |
| - isolate_args[1] = Dart_NewList(1); // args |
| + isolate_args[1] = Dart_NewList(2); // args |
| DART_CHECK_VALID(isolate_args[1]); |
| + |
| + Dart_Handle script_uri = Dart_NewStringFromUTF8( |
| + reinterpret_cast<const uint8_t*>(config.script_uri.data()), |
| + config.script_uri.length()); |
| Dart_ListSetAt(isolate_args[1], 0, Dart_NewInteger(config.handle)); |
| + Dart_ListSetAt(isolate_args[1], 1, script_uri); |
|
abarth-chromium
2015/01/16 05:43:43
We need a better way to solve this problem, but th
zra
2015/01/16 17:54:51
Acknowledged.
|
| Dart_Handle isolate_lib = |
| Dart_LookupLibrary(Dart_NewStringFromCString(kIsolateLibURL)); |