Skip to content

Commit a4adbff

Browse files
committed
Remove legacy restart code
Also fixes #29092 by threading Error objects back to the message handler. BUG= [email protected], [email protected] Review-Url: https://codereview.chromium.org/2759533002 .
1 parent ee7fe44 commit a4adbff

21 files changed

+71
-162
lines changed

runtime/bin/error_exit.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ static const int kApiErrorExitCode = 253;
1616
static const int kCompilationErrorExitCode = 254;
1717
// Exit code indicating an unhandled error that is not a compilation error.
1818
static const int kErrorExitCode = 255;
19-
// Exit code indicating a vm restart request. Never returned to the user.
20-
static const int kRestartRequestExitCode = 1000;
2119

2220
void ErrorExit(int exit_code, const char* format, ...);
2321

runtime/bin/gen_snapshot.cc

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ static const int kApiErrorExitCode = 253;
3737
static const int kCompilationErrorExitCode = 254;
3838
// Exit code indicating an unhandled error that is not a compilation error.
3939
static const int kErrorExitCode = 255;
40-
// Exit code indicating a vm restart request. Never returned to the user.
41-
static const int kRestartRequestExitCode = 1000;
4240

4341
#define CHECK_RESULT(result) \
4442
if (Dart_IsError(result)) { \
@@ -48,8 +46,6 @@ static const int kRestartRequestExitCode = 1000;
4846
exit_code = kCompilationErrorExitCode; \
4947
} else if (Dart_IsApiError(result)) { \
5048
exit_code = kApiErrorExitCode; \
51-
} else if (Dart_IsVMRestartRequest(result)) { \
52-
exit_code = kRestartRequestExitCode; \
5349
} else { \
5450
exit_code = kErrorExitCode; \
5551
} \

runtime/bin/main.cc

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -761,8 +761,6 @@ static Dart_Handle EnvironmentCallback(Dart_Handle name) {
761761
*exit_code = kCompilationErrorExitCode; \
762762
} else if (Dart_IsApiError(result)) { \
763763
*exit_code = kApiErrorExitCode; \
764-
} else if (Dart_IsVMRestartRequest(result)) { \
765-
*exit_code = kRestartRequestExitCode; \
766764
} else { \
767765
*exit_code = kErrorExitCode; \
768766
} \
@@ -1215,11 +1213,6 @@ static void GenerateAppAOTSnapshot() {
12151213

12161214
#define CHECK_RESULT(result) \
12171215
if (Dart_IsError(result)) { \
1218-
if (Dart_IsVMRestartRequest(result)) { \
1219-
Dart_ExitScope(); \
1220-
Dart_ShutdownIsolate(); \
1221-
return true; \
1222-
} \
12231216
const int exit_code = Dart_IsCompilationError(result) \
12241217
? kCompilationErrorExitCode \
12251218
: kErrorExitCode; \
@@ -1253,10 +1246,6 @@ bool RunMainIsolate(const char* script_name, CommandLineOptions* dart_options) {
12531246
commandline_packages_file, NULL, &error, &exit_code);
12541247
if (isolate == NULL) {
12551248
delete[] isolate_name;
1256-
if (exit_code == kRestartRequestExitCode) {
1257-
free(error);
1258-
return true;
1259-
}
12601249
Log::PrintErr("%s\n", error);
12611250
free(error);
12621251
error = NULL;
@@ -1411,8 +1400,7 @@ bool RunMainIsolate(const char* script_name, CommandLineOptions* dart_options) {
14111400
result = Dart_RunLoop();
14121401
// Generate an app snapshot after execution if specified.
14131402
if (gen_snapshot_kind == kAppJIT) {
1414-
if (!Dart_IsCompilationError(result) &&
1415-
!Dart_IsVMRestartRequest(result)) {
1403+
if (!Dart_IsCompilationError(result)) {
14161404
Snapshot::GenerateAppJIT(snapshot_filename);
14171405
}
14181406
}

runtime/include/dart_api.h

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,7 @@ typedef struct _Dart_Isolate* Dart_Isolate;
132132
* occur in any function which triggers the execution of Dart code.
133133
*
134134
* - Fatal error handles are produced when the system wants to shut
135-
* down the current isolate. Sometimes a fatal error may be a
136-
* restart request (see Dart_IsRestartRequest). If the embedder does
137-
* not support restarting the VM, then this should be treated as a
138-
* normal fatal error.
135+
* down the current isolate.
139136
*
140137
* --- Propagating errors ---
141138
*
@@ -311,17 +308,6 @@ DART_EXPORT bool Dart_IsCompilationError(Dart_Handle handle);
311308
*/
312309
DART_EXPORT bool Dart_IsFatalError(Dart_Handle handle);
313310

314-
/**
315-
* Is this error a request to restart the VM?
316-
*
317-
* If an embedder chooses to support restarting the VM from tools
318-
* (such as a debugger), then this function is used to distinguish
319-
* restart requests from other fatal errors.
320-
*
321-
* Requires there to be a current isolate.
322-
*/
323-
DART_EXPORT bool Dart_IsVMRestartRequest(Dart_Handle handle);
324-
325311
/**
326312
* Gets the error message from an error handle.
327313
*

runtime/lib/vmservice.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ DEFINE_NATIVE_ENTRY(VMService_SendIsolateServiceMessage, 2) {
122122
DEFINE_NATIVE_ENTRY(VMService_SendRootServiceMessage, 1) {
123123
GET_NON_NULL_NATIVE_ARGUMENT(Array, message, arguments->NativeArgAt(0));
124124
if (FLAG_support_service) {
125-
Service::HandleRootMessage(message);
125+
return Service::HandleRootMessage(message);
126126
}
127127
return Object::null();
128128
}
@@ -131,7 +131,7 @@ DEFINE_NATIVE_ENTRY(VMService_SendRootServiceMessage, 1) {
131131
DEFINE_NATIVE_ENTRY(VMService_SendObjectRootServiceMessage, 1) {
132132
GET_NON_NULL_NATIVE_ARGUMENT(Array, message, arguments->NativeArgAt(0));
133133
if (FLAG_support_service) {
134-
Service::HandleObjectRootMessage(message);
134+
return Service::HandleObjectRootMessage(message);
135135
}
136136
return Object::null();
137137
}

runtime/observatory/lib/src/elements/debugger.dart

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1242,39 +1242,12 @@ class VmNameCommand extends DebuggerCommand {
12421242
'Syntax: vm name <name>\n';
12431243
}
12441244

1245-
class VmRestartCommand extends DebuggerCommand {
1246-
VmRestartCommand(Debugger debugger) : super(debugger, 'restart', []);
1247-
1248-
Future handleModalInput(String line) async {
1249-
if (line == 'yes') {
1250-
debugger.console.printRed('Restarting VM...');
1251-
await debugger.vm.restart();
1252-
debugger.input.exitMode();
1253-
} else if (line == 'no') {
1254-
debugger.console.printRed('VM restart canceled.');
1255-
debugger.input.exitMode();
1256-
} else {
1257-
debugger.console.printRed("Please type 'yes' or 'no'");
1258-
}
1259-
}
1260-
1261-
Future run(List<String> args) async {
1262-
debugger.input.enterMode('Restart vm? (yes/no)', handleModalInput);
1263-
}
1264-
1265-
String helpShort = 'Restart a Dart virtual machine';
1266-
1267-
String helpLong = 'Restart a Dart virtual machine.\n'
1268-
'\n'
1269-
'Syntax: vm restart\n';
1270-
}
12711245

12721246
class VmCommand extends DebuggerCommand {
12731247
VmCommand(Debugger debugger)
12741248
: super(debugger, 'vm', [
12751249
new VmListCommand(debugger),
12761250
new VmNameCommand(debugger),
1277-
new VmRestartCommand(debugger),
12781251
]);
12791252

12801253
Future run(List<String> args) async {

runtime/observatory/lib/src/service/object.dart

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -853,10 +853,6 @@ abstract class VM extends ServiceObjectOwner implements M.VM {
853853
}
854854
}
855855

856-
Future restart() {
857-
return invokeRpc('_restartVM', {});
858-
}
859-
860856
Future<Map> _fetchDirect({int count: kDefaultFieldLimit}) async {
861857
if (!loaded) {
862858
// The vm service relies on these events to keep the VM and

runtime/observatory/tests/service/service.status

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@ evaluate_activation_test/scope: RuntimeError # http://dartbug.com/20047
2727
debugger_location_second_test: Pass, Slow
2828
debugger_location_test: Pass, Slow
2929

30-
# Can be slow in debug mode, as well.
31-
vm_restart_test: Pass, Slow
32-
3330
# These tests are slow on simulators.
3431
[ $arch == simarm || $arch == simmips || $arch == simarm64 ]
3532
*: Pass, Slow
@@ -64,7 +61,6 @@ evaluate_activation_test/scope: RuntimeError # Issue 27806
6461
get_object_rpc_test: RuntimeError # Issue 27806
6562
get_source_report_test: RuntimeError # Issue 27806
6663
set_name_rpc_test: RuntimeError # Issue 27806
67-
vm_restart_test: CompileTimeError # Issue 27806
6864

6965
debugger_location_second_test: Skip # Issue 28180
7066

runtime/observatory/tests/service/service_kernel.status

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ library_dependency_test: RuntimeError # There are no imports and exports in kern
2020
# 'VMServiceIO_Shutdown' (0 arguments) cannot be found
2121
# because of '--compile_all'
2222
capture_stdio_test: CompileTimeError
23-
vm_restart_test: CompileTimeError
2423
address_mapper_test: CompileTimeError
2524

2625
###

runtime/vm/dart_api_impl.cc

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -809,13 +809,6 @@ DART_EXPORT bool Dart_IsFatalError(Dart_Handle object) {
809809
}
810810

811811

812-
DART_EXPORT bool Dart_IsVMRestartRequest(Dart_Handle handle) {
813-
DARTSCOPE(Thread::Current());
814-
const Object& obj = Object::Handle(Z, Api::UnwrapHandle(handle));
815-
return (obj.IsUnwindError() && UnwindError::Cast(obj).is_vm_restart());
816-
}
817-
818-
819812
DART_EXPORT const char* Dart_GetError(Dart_Handle handle) {
820813
API_TIMELINE_DURATION;
821814
DARTSCOPE(Thread::Current());

runtime/vm/isolate.cc

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -314,8 +314,7 @@ RawError* IsolateMessageHandler::HandleLibMessage(const Array& message) {
314314
break;
315315
}
316316
case Isolate::kKillMsg:
317-
case Isolate::kInternalKillMsg:
318-
case Isolate::kVMRestartMsg: {
317+
case Isolate::kInternalKillMsg: {
319318
// [ OOB, kKillMsg, terminate capability, priority ]
320319
if (message.Length() != 4) return Error::null();
321320
Object& obj = Object::Handle(zone, message.At(3));
@@ -336,16 +335,6 @@ RawError* IsolateMessageHandler::HandleLibMessage(const Array& message) {
336335
const String& msg =
337336
String::Handle(String::New("isolate terminated by vm"));
338337
return UnwindError::New(msg);
339-
} else if (msg_type == Isolate::kVMRestartMsg) {
340-
// If this is the main isolate, this request to restart
341-
// will be caught and handled in the embedder. Otherwise
342-
// this unwind error will cause the isolate to exit.
343-
const String& msg = String::Handle(
344-
String::New("isolate terminated for vm restart"));
345-
const UnwindError& error =
346-
UnwindError::Handle(UnwindError::New(msg));
347-
error.set_is_vm_restart(true);
348-
return error.raw();
349338
} else {
350339
UNREACHABLE();
351340
}
@@ -531,7 +520,11 @@ MessageHandler::MessageStatus IsolateMessageHandler::HandleMessage(
531520
switch (Smi::Cast(oob_tag).Value()) {
532521
case Message::kServiceOOBMsg: {
533522
if (FLAG_support_service) {
534-
Service::HandleIsolateMessage(I, oob_msg);
523+
const Error& error =
524+
Error::Handle(Service::HandleIsolateMessage(I, oob_msg));
525+
if (!error.IsNull()) {
526+
status = ProcessUnhandledException(error);
527+
}
535528
} else {
536529
UNREACHABLE();
537530
}
@@ -650,11 +643,7 @@ static MessageHandler::MessageStatus StoreError(Thread* thread,
650643
if (error.IsUnwindError()) {
651644
const UnwindError& unwind = UnwindError::Cast(error);
652645
if (!unwind.is_user_initiated()) {
653-
if (unwind.is_vm_restart()) {
654-
return MessageHandler::kRestart;
655-
} else {
656-
return MessageHandler::kShutdown;
657-
}
646+
return MessageHandler::kShutdown;
658647
}
659648
}
660649
return MessageHandler::kError;
@@ -1033,18 +1022,24 @@ bool Isolate::IsPaused() const {
10331022
}
10341023

10351024

1036-
void Isolate::PausePostRequest() {
1025+
RawError* Isolate::PausePostRequest() {
10371026
if (!FLAG_support_debugger) {
1038-
return;
1027+
return Error::null();
10391028
}
10401029
if (debugger_ == NULL) {
1041-
return;
1030+
return Error::null();
10421031
}
10431032
ASSERT(!IsPaused());
10441033
const Error& error = Error::Handle(debugger_->PausePostRequest());
10451034
if (!error.IsNull()) {
1046-
Exceptions::PropagateError(error);
1035+
if (Thread::Current()->top_exit_frame_info() == 0) {
1036+
return error.raw();
1037+
} else {
1038+
Exceptions::PropagateError(error);
1039+
UNREACHABLE();
1040+
}
10471041
}
1042+
return Error::null();
10481043
}
10491044

10501045

runtime/vm/isolate.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,6 @@ class Isolate : public BaseIsolate {
163163
// Internal message ids.
164164
kInterruptMsg = 10, // Break in the debugger.
165165
kInternalKillMsg = 11, // Like kill, but does not run exit listeners, etc.
166-
kVMRestartMsg = 12, // Sent to isolates when vm is restarting.
167166
};
168167
// The different Isolate API message priorities for ping and kill messages.
169168
enum LibMsgPriority {
@@ -530,7 +529,7 @@ class Isolate : public BaseIsolate {
530529
should_pause_post_service_request_ = should_pause_post_service_request;
531530
}
532531

533-
void PausePostRequest();
532+
RawError* PausePostRequest();
534533

535534
uword user_tag() const { return user_tag_; }
536535
static intptr_t user_tag_offset() { return OFFSET_OF(Isolate, user_tag_); }

runtime/vm/isolate_reload.cc

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -635,17 +635,18 @@ void IsolateReloadContext::Reload(bool force_reload,
635635
TIR_Print("---- EXITED TAG HANDLER\n");
636636

637637
if (result.IsUnwindError()) {
638-
// We can only propagate errors when there are Dart frames on the stack.
639-
// TODO(johnmccutchan): Fix dartbug.com/29092.
640638
if (thread->top_exit_frame_info() == 0) {
641-
FATAL(
642-
"Got an Unwind Error in the middle of a reload. "
643-
"http://dartbug.com/29092");
639+
// We can only propagate errors when there are Dart frames on the stack.
640+
// In this case there are no Dart frames on the stack and we set the
641+
// thread's sticky error. This error will be returned to the message
642+
// handler.
643+
thread->set_sticky_error(Error::Cast(result));
644+
} else {
645+
// If the tag handler returns with an UnwindError error, propagate it and
646+
// give up.
647+
Exceptions::PropagateError(Error::Cast(result));
648+
UNREACHABLE();
644649
}
645-
// If the tag handler returns with an UnwindError error, propagate it and
646-
// give up.
647-
Exceptions::PropagateError(Error::Cast(result));
648-
UNREACHABLE();
649650
}
650651

651652
// Other errors (e.g. a parse error) are captured by the reload system.

runtime/vm/object.cc

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15406,7 +15406,6 @@ RawUnwindError* UnwindError::New(const String& message, Heap::Space space) {
1540615406
}
1540715407
result.set_message(message);
1540815408
result.set_is_user_initiated(false);
15409-
result.set_is_vm_restart(false);
1541015409
return result.raw();
1541115410
}
1541215411

@@ -15421,11 +15420,6 @@ void UnwindError::set_is_user_initiated(bool value) const {
1542115420
}
1542215421

1542315422

15424-
void UnwindError::set_is_vm_restart(bool value) const {
15425-
StoreNonPointer(&raw_ptr()->is_vm_restart_, value);
15426-
}
15427-
15428-
1542915423
const char* UnwindError::ToErrorCString() const {
1543015424
const String& msg_str = String::Handle(message());
1543115425
return msg_str.ToCString();

runtime/vm/object.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5421,9 +5421,6 @@ class UnwindError : public Error {
54215421
bool is_user_initiated() const { return raw_ptr()->is_user_initiated_; }
54225422
void set_is_user_initiated(bool value) const;
54235423

5424-
bool is_vm_restart() const { return raw_ptr()->is_vm_restart_; }
5425-
void set_is_vm_restart(bool value) const;
5426-
54275424
RawString* message() const { return raw_ptr()->message_; }
54285425

54295426
static intptr_t InstanceSize() {

runtime/vm/object_service.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -997,7 +997,6 @@ void UnwindError::PrintJSONImpl(JSONStream* stream, bool ref) const {
997997
jsobj.AddServiceId(*this);
998998
jsobj.AddProperty("message", ToErrorCString());
999999
jsobj.AddProperty("_is_user_initiated", is_user_initiated());
1000-
jsobj.AddProperty("_is_vm_restart", is_vm_restart());
10011000
}
10021001

10031002

runtime/vm/raw_object.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1629,7 +1629,6 @@ class RawUnwindError : public RawError {
16291629
RawString* message_;
16301630
RawObject** to() { return reinterpret_cast<RawObject**>(&ptr()->message_); }
16311631
bool is_user_initiated_;
1632-
bool is_vm_restart_;
16331632
};
16341633

16351634

0 commit comments

Comments
 (0)