diff --git a/pkg/frontend_server/lib/frontend_server.dart b/pkg/frontend_server/lib/frontend_server.dart index 205d9417b15..b60277fedca 100644 --- a/pkg/frontend_server/lib/frontend_server.dart +++ b/pkg/frontend_server/lib/frontend_server.dart @@ -336,7 +336,6 @@ class FrontendCompiler implements CompilerInterface { IncrementalCompiler _generator; JavaScriptBundler _bundler; - Component _component; String _kernelBinaryFilename; String _kernelBinaryFilenameIncremental; @@ -349,6 +348,30 @@ class FrontendCompiler implements CompilerInterface { final List errors = List(); + _onDiagnostic(DiagnosticMessage message) { + bool printMessage; + switch (message.severity) { + case Severity.error: + case Severity.internalProblem: + printMessage = true; + errors.addAll(message.plainTextFormatted); + break; + case Severity.warning: + printMessage = true; + break; + case Severity.context: + case Severity.ignored: + throw 'Unexpected severity: ${message.severity}'; + } + if (printMessage) { + printDiagnosticMessage(message, _outputStream.writeln); + } + } + + void _installDartdevcTarget() { + targets['dartdevc'] = (TargetFlags flags) => DevCompilerTarget(flags); + } + @override Future compile( String entryPoint, @@ -387,25 +410,7 @@ class FrontendCompiler implements CompilerInterface { onError: (msg) => errors.add(msg)) ..nnbdMode = (options['null-safety'] == true) ? NnbdMode.Strong : NnbdMode.Weak - ..onDiagnostic = (DiagnosticMessage message) { - bool printMessage; - switch (message.severity) { - case Severity.error: - case Severity.internalProblem: - printMessage = true; - errors.addAll(message.plainTextFormatted); - break; - case Severity.warning: - printMessage = true; - break; - case Severity.context: - case Severity.ignored: - throw 'Unexpected severity: ${message.severity}'; - } - if (printMessage) { - printDiagnosticMessage(message, _outputStream.writeln); - } - }; + ..onDiagnostic = _onDiagnostic; if (options.wasParsed('libraries-spec')) { compilerOptions.librariesSpecificationUri = @@ -461,7 +466,7 @@ class FrontendCompiler implements CompilerInterface { )..parseCommandLineFlags(options['bytecode-options']); // Initialize additional supported kernel targets. - targets['dartdevc'] = (TargetFlags flags) => DevCompilerTarget(flags); + _installDartdevcTarget(); compilerOptions.target = createFrontEndTarget( options['target'], trackWidgetCreation: options['track-widget-creation'], @@ -510,8 +515,6 @@ class FrontendCompiler implements CompilerInterface { component.uriToSource.keys); incrementalSerializer = _generator.incrementalSerializer; - _component = component; - _component.computeCanonicalNames(); } else { if (options['link-platform']) { // TODO(aam): Remove linkedDependencies once platform is directly embedded @@ -554,8 +557,10 @@ class FrontendCompiler implements CompilerInterface { } _kernelBinaryFilename = _kernelBinaryFilenameIncremental; - } else + } else { _outputStream.writeln(boundaryKey); + } + results = null; // Fix leak: Probably variation of http://dartbug.com/36983. return errors.isEmpty; } @@ -935,9 +940,10 @@ class FrontendCompiler implements CompilerInterface { _outputStream.writeln('result $boundaryKey'); var kernel2jsCompiler = _bundler.compilers[moduleName]; - + Component component = _generator.lastKnownGoodComponent; + component.computeCanonicalNames(); var evaluator = new ExpressionCompiler( - _generator.generator, kernel2jsCompiler, _component, + _generator.generator, kernel2jsCompiler, component, verbose: _compilerOptions.verbose, onDiagnostic: _compilerOptions.onDiagnostic); diff --git a/pkg/vm/lib/incremental_compiler.dart b/pkg/vm/lib/incremental_compiler.dart index 841f84bcacf..a16953298c4 100644 --- a/pkg/vm/lib/incremental_compiler.dart +++ b/pkg/vm/lib/incremental_compiler.dart @@ -34,6 +34,7 @@ class IncrementalCompiler { Uri get entryPoint => _entryPoint; IncrementalKernelGenerator get generator => _generator; + Component get lastKnownGoodComponent => _lastKnownGood; IncrementalCompiler(this._compilerOptions, this._entryPoint, {this.initializeFromDillUri, bool incrementalSerialization: true})