[vm] Ensure IMMEDIATE operations on Isolate.current take effect before returning to Dart code.

Change-Id: I18ced559a9eb0d4c93d98f82014892a15667d608
Reviewed-on: https://dart-review.googlesource.com/5600
Reviewed-by: Zach Anderson <zra@google.com>
This commit is contained in:
Ryan Macnak 2017-09-14 16:53:34 +00:00
parent fe2e114e8e
commit ad7780d5c3
2 changed files with 42 additions and 0 deletions

View file

@ -447,6 +447,15 @@ DEFINE_NATIVE_ENTRY(Isolate_sendOOB, 2) {
PortMap::PostMessage(new Message(port.Id(), data, writer.BytesWritten(),
Message::kOOBPriority));
// Drain interrupts before running so any IMMEDIATE operations on the current
// isolate happen synchronously.
const Error& error = Error::Handle(thread->HandleInterrupts());
if (!error.IsNull()) {
Exceptions::PropagateError(error);
UNREACHABLE();
}
return Object::null();
}

View file

@ -0,0 +1,33 @@
// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import "dart:isolate";
import "dart:io";
void main(List<String> args) {
if (args.contains("--child")) {
new RawReceivePort(); // Hang if not killed.
Isolate.current.kill(priority: Isolate.IMMEDIATE);
// No intervening call.
throw "QQQ Should not be reached";
} else {
var exec = Platform.resolvedExecutable;
var args = new List();
args.addAll(Platform.executableArguments);
args.add(Platform.script.toFilePath());
args.add("--child");
var result = Process.runSync(exec, args);
if (result.exitCode != 255) {
throw "Wrong exit code: ${result.exitCode}";
}
if (result.stderr.contains("QQQ Should not be reached")) {
print(result.stderr);
throw "Not killed synchronously";
}
if (!result.stderr.contains("isolate terminated by Isolate.kill")) {
print(result.stderr);
throw "Missing killed message";
}
}
}