Skip to content

Commit

Permalink
Remove dartk and DFE workers support from testing scripts and kernel-…
Browse files Browse the repository at this point in the history
…service.

We only support running -c dark and -c dartkp configuration through Kernel isolate and fasta in non-batch mode.

R=kustermann@google.com
BUG=

Review-Url: https://codereview.chromium.org/2721543003 .
  • Loading branch information
mraleph committed Feb 27, 2017
1 parent c0404e4 commit b026aed
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 347 deletions.
54 changes: 8 additions & 46 deletions tools/testing/dart/compiler_configuration.dart
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@ abstract class CompilerConfiguration {
bool useFastStartup = configuration['fast_startup'];
bool useKernelInDart2js = configuration['dart2js_with_kernel'];
bool verifyKernel = configuration['verify-ir'];
bool useDFE = !configuration['noDFE'];
bool useFasta = !configuration['noUseFasta'];
bool treeShake = !configuration['no-tree-shake'];

switch (compiler) {
Expand Down Expand Up @@ -104,46 +102,22 @@ abstract class CompilerConfiguration {
useBlobs: useBlobs,
isAndroid: configuration['system'] == 'android');
case 'dartk':
if (!useDFE) {
return ComposedCompilerConfiguration.createDartKConfiguration(
isChecked: isChecked,
isHostChecked: isHostChecked,
useSdk: useSdk,
verify: verifyKernel,
strong: isStrong,
treeShake: treeShake);
}

return new NoneCompilerConfiguration(
isDebug: isDebug,
isChecked: isChecked,
isHostChecked: isHostChecked,
useSdk: useSdk,
hotReload: hotReload,
hotReloadRollback: hotReloadRollback,
dfeMode: useFasta ? DFEMode.Fasta : DFEMode.DartK);

useDFE: true);
case 'dartkp':
if (!useDFE) {
return ComposedCompilerConfiguration.createDartKPConfiguration(
isChecked: isChecked,
isHostChecked: isHostChecked,
arch: configuration['arch'],
useBlobs: useBlobs,
isAndroid: configuration['system'] == 'android',
useSdk: useSdk,
verify: verifyKernel,
strong: isStrong,
treeShake: treeShake);
}
return new PrecompilerCompilerConfiguration(
isDebug: isDebug,
isChecked: isChecked,
arch: configuration['arch'],
useBlobs: useBlobs,
isAndroid: configuration['system'] == 'android',
dfeMode: useFasta ? DFEMode.Fasta : DFEMode.DartK);

useDFE: true);
case 'none':
return new NoneCompilerConfiguration(
isDebug: isDebug,
Expand Down Expand Up @@ -210,23 +184,17 @@ abstract class CompilerConfiguration {
}
}

enum DFEMode {
None,
DartK,
Fasta
}

/// The "none" compiler.
class NoneCompilerConfiguration extends CompilerConfiguration {
final bool hotReload;
final bool hotReloadRollback;
final DFEMode dfeMode;
final bool useDFE;

NoneCompilerConfiguration(
{bool isDebug, bool isChecked, bool isHostChecked, bool useSdk,
bool this.hotReload,
bool this.hotReloadRollback,
DFEMode this.dfeMode: DFEMode.None})
this.useDFE: false})
: super._subclass(
isDebug: isDebug,
isChecked: isChecked,
Expand All @@ -244,12 +212,9 @@ class NoneCompilerConfiguration extends CompilerConfiguration {
List<String> originalArguments,
CommandArtifact artifact) {
List<String> args = [];
if (dfeMode != DFEMode.None) {
if (useDFE) {
args.add('--dfe=utils/kernel-service/kernel-service.dart');
}
if (dfeMode == DFEMode.Fasta) {
args.add('-DDFE_USE_FASTA=true');
}
if (isChecked) {
args.add('--enable_asserts');
args.add('--enable_type_checks');
Expand Down Expand Up @@ -613,10 +578,10 @@ class PrecompilerCompilerConfiguration extends CompilerConfiguration {
final String arch;
final bool useBlobs;
final bool isAndroid;
final DFEMode dfeMode;
final bool useDFE;

PrecompilerCompilerConfiguration({bool isDebug, bool isChecked,
this.arch, this.useBlobs, this.isAndroid, this.dfeMode: DFEMode.None})
this.arch, this.useBlobs, this.isAndroid, this.useDFE: false})
: super._subclass(isDebug: isDebug, isChecked: isChecked);

int computeTimeoutMultiplier() {
Expand Down Expand Up @@ -657,12 +622,9 @@ class PrecompilerCompilerConfiguration extends CompilerConfiguration {
exec = "$buildDir/dart_bootstrap";
}
var args = new List();
if (dfeMode != DFEMode.None) {
if (useDFE) {
args.add('--dfe=utils/kernel-service/kernel-service.dart');
}
if (dfeMode == DFEMode.Fasta) {
args.add('-DDFE_USE_FASTA=true');
}
args.add("--snapshot-kind=app-aot");
if (useBlobs) {
args.add("--snapshot=$tempDir/out.aotsnapshot");
Expand Down
5 changes: 1 addition & 4 deletions tools/testing/dart/runtime_configuration.dart
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,6 @@ class StandaloneDartRuntimeConfiguration extends DartVmRuntimeConfiguration {
CommandArtifact artifact,
List<String> arguments,
Map<String, String> environmentOverrides) {
final bool needsDFERunner = suite.configuration['compiler'] == 'dartk' &&
suite.configuration['noUseFasta'] &&
!suite.configuration['noBatch'];
String script = artifact.filename;
String type = artifact.mimeType;
if (script != null &&
Expand All @@ -239,7 +236,7 @@ class StandaloneDartRuntimeConfiguration extends DartVmRuntimeConfiguration {
}
String executable = suite.dartVmBinaryFileName;
return <Command>[
commandBuilder.getVmCommand(executable, arguments, environmentOverrides, needsDFERunner: needsDFERunner)
commandBuilder.getVmCommand(executable, arguments, environmentOverrides)
];
}
}
Expand Down
6 changes: 0 additions & 6 deletions tools/testing/dart/test_options.dart
Original file line number Diff line number Diff line change
Expand Up @@ -300,12 +300,6 @@ class TestOptionsParser {
new _TestOptionSpecification(
'no-tree-shake', 'Disable kernel IR tree shaking', ['--no-tree-shake'], [], false,
type: 'bool'),
new _TestOptionSpecification(
'noDFE', 'Do not use Kernel Isolate', ['--no-dfe'], [], false,
type: 'bool'),
new _TestOptionSpecification(
'noUseFasta', 'Use Fasta in Kernel Isolate', ['--no-use-fasta'], [], false,
type: 'bool'),
new _TestOptionSpecification(
'list', 'List tests only, do not run them', ['--list'], [], false,
type: 'bool'),
Expand Down
139 changes: 4 additions & 135 deletions tools/testing/dart/test_runner.dart
Original file line number Diff line number Diff line change
Expand Up @@ -364,25 +364,14 @@ class AnalysisCommand extends ProcessCommand {
}

class VmCommand extends ProcessCommand {
final bool needsDFERunner;
VmCommand._(String executable, List<String> arguments,
Map<String, String> environmentOverrides,
bool this.needsDFERunner)
Map<String, String> environmentOverrides)
: super._("vm", executable, arguments, environmentOverrides);

void _buildHashCode(HashCodeBuilder builder) {
super._buildHashCode(builder);
builder.add(needsDFERunner);
}

bool _equal(VmCommand other) =>
super._equal(other) && needsDFERunner == other.needsDFERunner;
}

class VmBatchCommand extends ProcessCommand implements VmCommand {
final String dartFile;
final bool checked;
final needsDFERunner = false;

VmBatchCommand._(String executable, String dartFile, List<String> arguments,
Map<String, String> environmentOverrides, {this.checked: true})
Expand Down Expand Up @@ -651,8 +640,8 @@ class CommandBuilder {
}

VmCommand getVmCommand(String executable, List<String> arguments,
Map<String, String> environmentOverrides, {bool needsDFERunner: false}) {
var command = new VmCommand._(executable, arguments, environmentOverrides, needsDFERunner);
Map<String, String> environmentOverrides) {
var command = new VmCommand._(executable, arguments, environmentOverrides);
return _getUniqueCommand(command);
}

Expand Down Expand Up @@ -1901,12 +1890,10 @@ class RunningProcess {
bool compilationSkipped = false;
Completer<CommandOutput> completer;
Map configuration;
List<String> preArguments;

RunningProcess(this.command,
this.timeout,
{this.configuration,
this.preArguments});
{this.configuration});

Future<CommandOutput> run() {
completer = new Completer<CommandOutput>();
Expand All @@ -1923,9 +1910,6 @@ class RunningProcess {
} else {
var processEnvironment = _createProcessEnvironment();
var args = command.arguments;
if (preArguments != null) {
args = []..addAll(preArguments)..addAll(args);
}
Future processFuture = io.Process.start(
command.executable, args,
environment: processEnvironment,
Expand Down Expand Up @@ -2333,102 +2317,6 @@ class BatchRunnerProcess {
}
}

class BatchDFEProcess {
io.Process _process;
int _port = -1;
Function _processExitHandler;

Completer terminating = null;

bool locked = false;

Future<int> acquire() async {
try {
assert(!locked);
locked = true;
if (_process == null) {
await _startProcess();
}
return _port;
} catch(e) {
locked = false;
rethrow;
}
}

void release() {
locked = false;
}

Future terminate() {
locked = true;
if (_process == null) {
return new Future.value(true);
}
if (terminating == null) {
terminating = new Completer();
_process.kill();
}
return terminating.future;
}

_onExit(exitCode) {
if (terminating != null) {
terminating.complete();
return;
}

_process = null;
locked = false;
_port = -1;
}

static Future<String> _firstLine(stream) {
var completer = new Completer<String>();
stream.transform(UTF8.decoder)
.transform(new LineSplitter())
.listen((line) {
if (!completer.isCompleted) {
completer.complete(line);
}
// We need to drain a pipe continuously.
}, onDone: () {
if (!completer.isCompleted) {
completer.completeError(
"DFE kernel compiler server did not sucessfully start up");
}
});
return completer.future;
}

Future _startProcess() async {
final executable = io.Platform.executable;
final arguments = ['utils/kernel-service/kernel-service.dart', '--batch'];

try {
_port = -1;
_process = await io.Process.start(executable, arguments);
_process.exitCode.then(_onExit);
_process.stderr.transform(UTF8.decoder).listen(DebugLogger.error);

final readyMsg = await _firstLine(_process.stdout);
final data = readyMsg.split(' ');
assert(data[0] == 'READY');

_port = int.parse(data[1]);
} catch (e) {
print("Process error:");
print(" Command: $executable ${arguments.join(' ')}");
print(" Error: $e");
// If there is an error starting a batch process, chances are that
// it will always fail. So rather than re-trying a 1000+ times, we
// exit.
io.exit(1);
return true;
}
}
}

/**
* [TestCaseEnqueuer] takes a list of TestSuites, generates TestCases and
* builds a dependency graph of all commands in every TestSuite.
Expand Down Expand Up @@ -2737,8 +2625,6 @@ class CommandExecutorImpl implements CommandExecutor {
// We keep a BrowserTestRunner for every configuration.
final _browserTestRunners = new Map<Map, BrowserTestRunner>();

List<BatchDFEProcess> _dfeProcesses = null;

bool _finishing = false;

CommandExecutorImpl(
Expand All @@ -2763,13 +2649,9 @@ class CommandExecutorImpl implements CommandExecutor {
return Future.wait(futures);
}

Future _terminateDFEWorkers() =>
Future.wait((_dfeProcesses ?? <BatchDFEProcess>[]).map((p) => p.terminate()));

return Future.wait([
_terminateBatchRunners(),
_terminateBrowserRunners(),
_terminateDFEWorkers()
]);
}

Expand Down Expand Up @@ -2818,13 +2700,6 @@ class CommandExecutorImpl implements CommandExecutor {
adbDevicePool.releaseDevice(device);
});
});
} else if (command is VmCommand && command.needsDFERunner) {
final runner = _getDFEProcess();
return runner.acquire().then((port) {
return new RunningProcess(command, timeout,
configuration: globalConfiguration,
preArguments: ['-DDFE_WORKER_PORT=${port}']).run();
}).whenComplete(() => runner.release());
} else if (command is VmBatchCommand) {
var name = command.displayName;
return _getBatchRunner(command.displayName + command.dartFile)
Expand Down Expand Up @@ -2928,12 +2803,6 @@ class CommandExecutorImpl implements CommandExecutor {
throw new Exception('Unable to find inactive batch runner.');
}

BatchDFEProcess _getDFEProcess() {
_dfeProcesses ??= new List<BatchDFEProcess>.generate(maxProcesses,
(_) => new BatchDFEProcess());
return _dfeProcesses.firstWhere((runner) => !runner.locked);
}

Future<CommandOutput> _startBrowserControllerTest(
BrowserTestCommand browserCommand, int timeout) {
var completer = new Completer<CommandOutput>();
Expand Down
Loading

0 comments on commit b026aed

Please sign in to comment.