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

Unified Diff: runtime/bin/process.cc

Issue 1275353005: VM thread shutdown. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Merge Created 5 years, 3 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/main.cc ('k') | runtime/bin/run_vm_tests.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/process.cc
diff --git a/runtime/bin/process.cc b/runtime/bin/process.cc
index 242ef1c055db971bcc41d2a26b25bd32bd1a0267..3c345b724ca1949168aef7f5d70593b72207f4ab 100644
--- a/runtime/bin/process.cc
+++ b/runtime/bin/process.cc
@@ -6,6 +6,7 @@
#include "bin/dbg_connection.h"
#include "bin/eventhandler.h"
#include "bin/io_buffer.h"
+#include "bin/log.h"
#include "bin/platform.h"
#include "bin/process.h"
#include "bin/socket.h"
@@ -16,6 +17,10 @@
namespace dart {
namespace bin {
+// Global flag that is used to indicate that the VM should do a clean
+// shutdown.
+bool do_vm_shutdown = true;
+
static const int kProcessIdNativeField = 0;
int Process::global_exit_code_ = 0;
@@ -36,9 +41,15 @@ static char** ExtractCStringList(Dart_Handle strings,
// Protect against user-defined list implementations that can have
// arbitrary length.
if (len < 0 || len > kMaxArgumentListLength) {
- DartUtils::SetIntegerField(status_handle, "_errorCode", 0);
- DartUtils::SetStringField(
+ result = DartUtils::SetIntegerField(status_handle, "_errorCode", 0);
+ if (Dart_IsError(result)) {
+ Dart_PropagateError(result);
+ }
+ result = DartUtils::SetStringField(
status_handle, "_errorMessage", "Max argument list length exceeded");
+ if (Dart_IsError(result)) {
+ Dart_PropagateError(result);
+ }
return NULL;
}
*length = len;
@@ -50,9 +61,15 @@ static char** ExtractCStringList(Dart_Handle strings,
Dart_PropagateError(arg);
}
if (!Dart_IsString(arg)) {
- DartUtils::SetIntegerField(status_handle, "_errorCode", 0);
- DartUtils::SetStringField(
+ result = DartUtils::SetIntegerField(status_handle, "_errorCode", 0);
+ if (Dart_IsError(result)) {
+ Dart_PropagateError(result);
+ }
+ result = DartUtils::SetStringField(
status_handle, "_errorMessage", error_msg);
+ if (Dart_IsError(result)) {
+ Dart_PropagateError(result);
+ }
delete[] string_args;
return NULL;
}
@@ -67,15 +84,22 @@ void FUNCTION_NAME(Process_Start)(Dart_NativeArguments args) {
intptr_t process_stdout;
intptr_t process_stderr;
intptr_t exit_event;
+ Dart_Handle result;
Dart_Handle status_handle = Dart_GetNativeArgument(args, 10);
Dart_Handle path_handle = Dart_GetNativeArgument(args, 1);
// The Dart code verifies that the path implements the String
// interface. However, only builtin Strings are handled by
// GetStringValue.
if (!Dart_IsString(path_handle)) {
- DartUtils::SetIntegerField(status_handle, "_errorCode", 0);
- DartUtils::SetStringField(
+ result = DartUtils::SetIntegerField(status_handle, "_errorCode", 0);
+ if (Dart_IsError(result)) {
+ Dart_PropagateError(result);
+ }
+ result = DartUtils::SetStringField(
status_handle, "_errorMessage", "Path must be a builtin string");
+ if (Dart_IsError(result)) {
+ Dart_PropagateError(result);
+ }
Dart_SetReturnValue(args, Dart_NewBoolean(false));
return;
}
@@ -98,10 +122,16 @@ void FUNCTION_NAME(Process_Start)(Dart_NativeArguments args) {
working_directory = DartUtils::GetStringValue(working_directory_handle);
} else if (!Dart_IsNull(working_directory_handle)) {
delete[] string_args;
- DartUtils::SetIntegerField(status_handle, "_errorCode", 0);
- DartUtils::SetStringField(
+ result = DartUtils::SetIntegerField(status_handle, "_errorCode", 0);
+ if (Dart_IsError(result)) {
+ Dart_PropagateError(result);
+ }
+ result = DartUtils::SetStringField(
status_handle, "_errorMessage",
"WorkingDirectory must be a builtin string");
+ if (Dart_IsError(result)) {
+ Dart_PropagateError(result);
+ }
Dart_SetReturnValue(args, Dart_NewBoolean(false));
return;
}
@@ -153,13 +183,19 @@ void FUNCTION_NAME(Process_Start)(Dart_NativeArguments args) {
}
Process::SetProcessIdNativeField(process, pid);
} else {
- DartUtils::SetIntegerField(
+ result = DartUtils::SetIntegerField(
status_handle, "_errorCode", error_code);
- DartUtils::SetStringField(
+ if (Dart_IsError(result)) {
+ Dart_PropagateError(result);
+ }
+ result = DartUtils::SetStringField(
status_handle,
"_errorMessage",
os_error_message != NULL ? os_error_message
: "Cannot get error message");
+ if (Dart_IsError(result)) {
+ Dart_PropagateError(result);
+ }
}
delete[] string_args;
delete[] string_environment;
@@ -218,11 +254,17 @@ void FUNCTION_NAME(Process_Exit)(Dart_NativeArguments args) {
int64_t status = 0;
// Ignore result if passing invalid argument and just exit 0.
DartUtils::GetInt64Value(Dart_GetNativeArgument(args, 0), &status);
- Dart_ExitIsolate();
- Dart_Cleanup();
- DebuggerConnectionHandler::StopHandler();
- // TODO(zra): Stop the EventHandler once thread shutdown is enabled.
- // EventHandler::Stop();
+ Dart_ShutdownIsolate();
+ Process::TerminateExitCodeHandler();
+ char* error = Dart_Cleanup();
+ if (error != NULL) {
+ Log::PrintErr("VM cleanup failed: %s\n", error);
+ free(error);
+ }
+ if (do_vm_shutdown) {
+ DebuggerConnectionHandler::StopHandler();
+ EventHandler::Stop();
+ }
exit(static_cast<int>(status));
}
« no previous file with comments | « runtime/bin/main.cc ('k') | runtime/bin/run_vm_tests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698