mirror of
https://github.com/dart-lang/sdk
synced 2024-10-06 14:39:38 +00:00
[vm/concurrency] Remove code duplication in isolate shutdown code
We have currently two ways to shut down isolates from the outside: * An embedder shuts down an embedder-owned isolate via `Dart_ShutdownIsolate()`. * An `Isolate.spawn()`ed isolate finishes the VM-owned message loop and VM shuts it down. The second mechanism uses almost the same as the first, but slightly different. This CL makes us change the second one to call our normal `Dart_ShutdownIsolate()`. Approved failures that got revealed by moving canonicalization check to all isolate shutdowns, see Issue https://github.com/dart-lang/sdk/issues/44141 Issue https://github.com/dart-lang/sdk/issues/36097 Issue https://github.com/dart-lang/sdk/issues/44088 Change-Id: I58af0e9ae73842545e21edad23c106ea59b176b3 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/170984 Reviewed-by: Ryan Macnak <rmacnak@google.com> Commit-Queue: Martin Kustermann <kustermann@google.com>
This commit is contained in:
parent
93d74d6aad
commit
ea9a4b1a78
|
@ -1590,6 +1590,9 @@ DART_EXPORT void Dart_ShutdownIsolate() {
|
|||
{
|
||||
StackZone zone(T);
|
||||
HandleScope handle_scope(T);
|
||||
#if defined(DEBUG)
|
||||
I->ValidateConstants();
|
||||
#endif
|
||||
Dart::RunShutdownCallback();
|
||||
}
|
||||
Dart::ShutdownIsolate();
|
||||
|
|
|
@ -2400,27 +2400,8 @@ static MessageHandler::MessageStatus RunIsolate(uword parameter) {
|
|||
}
|
||||
|
||||
static void ShutdownIsolate(uword parameter) {
|
||||
Isolate* isolate = reinterpret_cast<Isolate*>(parameter);
|
||||
{
|
||||
// Print the error if there is one. This may execute dart code to
|
||||
// print the exception object, so we need to use a StartIsolateScope.
|
||||
StartIsolateScope start_scope(isolate);
|
||||
Thread* thread = Thread::Current();
|
||||
ASSERT(thread->isolate() == isolate);
|
||||
|
||||
// We must wait for any outstanding spawn calls to complete before
|
||||
// running the shutdown callback.
|
||||
isolate->WaitForOutstandingSpawns();
|
||||
|
||||
StackZone zone(thread);
|
||||
HandleScope handle_scope(thread);
|
||||
#if defined(DEBUG)
|
||||
isolate->ValidateConstants();
|
||||
#endif // defined(DEBUG)
|
||||
Dart::RunShutdownCallback();
|
||||
}
|
||||
// Shut the isolate down.
|
||||
Dart::ShutdownIsolate(isolate);
|
||||
Dart_EnterIsolate(reinterpret_cast<Dart_Isolate>(parameter));
|
||||
Dart_ShutdownIsolate();
|
||||
}
|
||||
|
||||
void Isolate::SetStickyError(ErrorPtr sticky_error) {
|
||||
|
|
Loading…
Reference in a new issue