mirror of
https://github.com/dart-lang/sdk
synced 2024-10-14 13:08:10 +00:00
Remove one-phase summary logic.
This experiment didn't work out--it turns out that too many clients were relying on the performance characteristics of unlinked summaries. Change-Id: I3e7c54c18b5b02ee0df17ef5d62e1f6a7e35da68 Reviewed-on: https://dart-review.googlesource.com/c/79144 Commit-Queue: Paul Berry <paulberry@google.com> Commit-Queue: Konstantin Shcheglov <scheglov@google.com> Auto-Submit: Paul Berry <paulberry@google.com> Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
parent
b9dd229e35
commit
c47879d354
|
@ -11,7 +11,6 @@ import 'package:analyzer/dart/ast/token.dart';
|
|||
import 'package:analyzer/error/listener.dart';
|
||||
import 'package:analyzer/file_system/file_system.dart';
|
||||
import 'package:analyzer/src/dart/analysis/defined_names.dart';
|
||||
import 'package:analyzer/src/dart/analysis/one_phase_summaries_selector.dart';
|
||||
import 'package:analyzer/src/dart/analysis/referenced_names.dart';
|
||||
import 'package:analyzer/src/dart/analysis/top_level_declaration.dart';
|
||||
import 'package:analyzer/src/dart/analysis/unlinked_api_signature.dart';
|
||||
|
@ -432,8 +431,7 @@ class FileState {
|
|||
_fsState._byteStore.put(apiSignatureKey, apiSignatureBytes);
|
||||
}
|
||||
if (unlinkedUnitBytes == null) {
|
||||
var unlinkedUnit = serializeAstUnlinked(unit,
|
||||
serializeInferrableFields: !enableOnePhaseSummaries);
|
||||
var unlinkedUnit = serializeAstUnlinked(unit);
|
||||
var definedNames = computeDefinedNames(unit);
|
||||
var referencedNames = computeReferencedNames(unit).toList();
|
||||
var subtypedNames = computeSubtypedNames(unit).toList();
|
||||
|
|
|
@ -3,13 +3,13 @@
|
|||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'package:analyzer/dart/analysis/declared_variables.dart';
|
||||
import 'package:analyzer/dart/ast/ast.dart' show CompilationUnit;
|
||||
import 'package:analyzer/dart/element/element.dart'
|
||||
show CompilationUnitElement, LibraryElement;
|
||||
import 'package:analyzer/src/context/context.dart';
|
||||
import 'package:analyzer/src/dart/analysis/byte_store.dart';
|
||||
import 'package:analyzer/src/dart/analysis/driver.dart';
|
||||
import 'package:analyzer/src/dart/analysis/file_state.dart';
|
||||
import 'package:analyzer/src/dart/analysis/one_phase_summaries_selector.dart';
|
||||
import 'package:analyzer/src/dart/analysis/performance_logger.dart';
|
||||
import 'package:analyzer/src/dart/element/element.dart';
|
||||
import 'package:analyzer/src/dart/element/handle.dart';
|
||||
import 'package:analyzer/src/generated/engine.dart'
|
||||
|
@ -18,11 +18,7 @@ import 'package:analyzer/src/generated/source.dart';
|
|||
import 'package:analyzer/src/summary/format.dart';
|
||||
import 'package:analyzer/src/summary/idl.dart';
|
||||
import 'package:analyzer/src/summary/link.dart';
|
||||
import 'package:analyzer/src/summary/one_phase.dart';
|
||||
import 'package:analyzer/src/summary/package_bundle_reader.dart';
|
||||
import 'package:analyzer/src/summary/summarize_elements.dart';
|
||||
import 'package:analyzer/src/dart/analysis/byte_store.dart';
|
||||
import 'package:analyzer/src/dart/analysis/performance_logger.dart';
|
||||
|
||||
/**
|
||||
* Context information necessary to analyze one or more libraries within an
|
||||
|
@ -118,47 +114,16 @@ class LibraryContext {
|
|||
});
|
||||
|
||||
Map<String, LinkedLibraryBuilder> linkedLibraries = {};
|
||||
if (enableOnePhaseSummaries) {
|
||||
var uriToUnit = <String, CompilationUnit>{};
|
||||
logger.run('Parse files', () {
|
||||
for (var library in libraryFilesToLink) {
|
||||
for (var file in library.libraryFiles) {
|
||||
uriToUnit[file.uriStr] = file.parse();
|
||||
}
|
||||
}
|
||||
logger.writeln('Parsed ${uriToUnit.length} files.');
|
||||
});
|
||||
|
||||
logger.run('Link libraries', () {
|
||||
var assembler = new PackageBundleAssembler();
|
||||
summarize(uriToUnit, store, assembler, (_) => null, true);
|
||||
|
||||
var bundle = assembler.assemble();
|
||||
for (int i = 0; i < bundle.linkedLibraryUris.length; i++) {
|
||||
var uri = bundle.linkedLibraryUris[i];
|
||||
|
||||
// TODO(scheglov) At the moment we might get parts here.
|
||||
if (!libraries.containsKey(uri)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
linkedLibraries[uri] = bundle.linkedLibraries[i];
|
||||
}
|
||||
|
||||
logger.writeln('Linked ${linkedLibraries.length} libraries.');
|
||||
});
|
||||
} else {
|
||||
logger.run('Link libraries', () {
|
||||
linkedLibraries = link(libraryUrisToLink, (String uri) {
|
||||
LinkedLibrary linkedLibrary = store.linkedMap[uri];
|
||||
return linkedLibrary;
|
||||
}, (String uri) {
|
||||
UnlinkedUnit unlinkedUnit = store.unlinkedMap[uri];
|
||||
return unlinkedUnit;
|
||||
}, (_) => null);
|
||||
logger.writeln('Linked ${linkedLibraries.length} libraries.');
|
||||
});
|
||||
}
|
||||
logger.run('Link libraries', () {
|
||||
linkedLibraries = link(libraryUrisToLink, (String uri) {
|
||||
LinkedLibrary linkedLibrary = store.linkedMap[uri];
|
||||
return linkedLibrary;
|
||||
}, (String uri) {
|
||||
UnlinkedUnit unlinkedUnit = store.unlinkedMap[uri];
|
||||
return unlinkedUnit;
|
||||
}, (_) => null);
|
||||
logger.writeln('Linked ${linkedLibraries.length} libraries.');
|
||||
});
|
||||
|
||||
for (String uri in linkedLibraries.keys) {
|
||||
LinkedLibraryBuilder linkedBuilder = linkedLibraries[uri];
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
// Copyright (c) 2018, 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.
|
||||
|
||||
/// A flag indicating whether analysis driver should work using one-phase,
|
||||
/// unresolved AST based summaries, or using old unlinked / link process.
|
||||
const bool enableOnePhaseSummaries =
|
||||
const bool.fromEnvironment('enableOnePhaseSummaries', defaultValue: false);
|
|
@ -1,76 +0,0 @@
|
|||
// Copyright (c) 2018, 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 'package:analyzer/dart/ast/ast.dart';
|
||||
import 'package:analyzer/src/summary/format.dart';
|
||||
import 'package:analyzer/src/summary/idl.dart';
|
||||
import 'package:analyzer/src/summary/link.dart';
|
||||
import 'package:analyzer/src/summary/package_bundle_reader.dart';
|
||||
import 'package:analyzer/src/summary/prelink.dart';
|
||||
import 'package:analyzer/src/summary/summarize_ast.dart';
|
||||
import 'package:analyzer/src/summary/summarize_elements.dart';
|
||||
|
||||
/// Builds the summary for a build unit based on unresolved ASTs of its
|
||||
/// compilation units.
|
||||
///
|
||||
/// The compilation units in [uriToUnit] are summarized, and the results are
|
||||
/// stored in [assembler]. References to other compilation units are resolved
|
||||
/// using the summaries stored in [dependencies].
|
||||
///
|
||||
/// [getDeclaredVariable] is used to resolve configurable imports. If
|
||||
/// [allowMissingFiles] is `false`, then failure to resolve an import will
|
||||
/// result in an exception being thrown; otherwise unresolved imports will be
|
||||
/// silently recovered from.
|
||||
void summarize(
|
||||
Map<String, CompilationUnit> uriToUnit,
|
||||
SummaryDataStore dependencies,
|
||||
PackageBundleAssembler assembler,
|
||||
GetDeclaredVariable getDeclaredVariable,
|
||||
bool allowMissingFiles) {
|
||||
var uriToUnlinked = <String, UnlinkedUnitBuilder>{};
|
||||
uriToUnit.forEach((uri, compilationUnit) {
|
||||
var unlinkedUnit =
|
||||
serializeAstUnlinked(compilationUnit, serializeInferrableFields: false);
|
||||
uriToUnlinked[uri] = unlinkedUnit;
|
||||
assembler.addUnlinkedUnitViaUri(uri, unlinkedUnit);
|
||||
});
|
||||
|
||||
LinkedLibrary getDependency(String absoluteUri) {
|
||||
var dependency = dependencies.linkedMap[absoluteUri];
|
||||
if (dependency == null && !allowMissingFiles) {
|
||||
throw new StateError('Missing dependency $absoluteUri');
|
||||
}
|
||||
return dependency;
|
||||
}
|
||||
|
||||
UnlinkedUnit getUnit(String absoluteUri) {
|
||||
if (absoluteUri == null) {
|
||||
return null;
|
||||
}
|
||||
var unlinkedUnit =
|
||||
uriToUnlinked[absoluteUri] ?? dependencies.unlinkedMap[absoluteUri];
|
||||
if (unlinkedUnit == null && !allowMissingFiles) {
|
||||
throw new StateError('Missing unit $absoluteUri');
|
||||
}
|
||||
return unlinkedUnit;
|
||||
}
|
||||
|
||||
CompilationUnit getAst(String absoluteUri) {
|
||||
if (absoluteUri == null) {
|
||||
return null;
|
||||
}
|
||||
var compilationUnit = uriToUnit[absoluteUri];
|
||||
if (compilationUnit == null && !allowMissingFiles) {
|
||||
throw new StateError('Missing unit $absoluteUri');
|
||||
}
|
||||
return compilationUnit;
|
||||
}
|
||||
|
||||
// TODO(paulberry): is this bad? Are we passing parts to link that we
|
||||
// shouldn't?
|
||||
var linkedLibraries = link(uriToUnlinked.keys.toSet(), getDependency, getUnit,
|
||||
getDeclaredVariable, getAst);
|
||||
|
||||
linkedLibraries.forEach(assembler.addLinkedLibrary);
|
||||
}
|
|
@ -1,84 +0,0 @@
|
|||
// Copyright (c) 2018, 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 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
import 'summary_common.dart';
|
||||
import 'test_strategies.dart';
|
||||
|
||||
main() {
|
||||
defineReflectiveSuite(() {
|
||||
defineReflectiveTests(SummarizeAstOnePhaseTest);
|
||||
});
|
||||
}
|
||||
|
||||
@reflectiveTest
|
||||
class SummarizeAstOnePhaseTest extends SummaryBlackBoxTestStrategyOnePhase
|
||||
with SummaryTestCases {
|
||||
@override
|
||||
@failingTest
|
||||
test_closure_executable_with_bottom_return_type() {
|
||||
super.test_closure_executable_with_bottom_return_type();
|
||||
}
|
||||
|
||||
@override
|
||||
@failingTest
|
||||
test_closure_executable_with_imported_return_type() {
|
||||
super.test_closure_executable_with_imported_return_type();
|
||||
}
|
||||
|
||||
@override
|
||||
@failingTest
|
||||
test_closure_executable_with_return_type_from_closure() {
|
||||
super.test_closure_executable_with_return_type_from_closure();
|
||||
}
|
||||
|
||||
@override
|
||||
@failingTest
|
||||
test_closure_executable_with_unimported_return_type() {
|
||||
super.test_closure_executable_with_unimported_return_type();
|
||||
}
|
||||
|
||||
@override
|
||||
@failingTest
|
||||
test_initializer_executable_with_bottom_return_type() {
|
||||
super.test_initializer_executable_with_bottom_return_type();
|
||||
}
|
||||
|
||||
@override
|
||||
@failingTest
|
||||
test_initializer_executable_with_imported_return_type() {
|
||||
super.test_initializer_executable_with_imported_return_type();
|
||||
}
|
||||
|
||||
@override
|
||||
@failingTest
|
||||
test_initializer_executable_with_return_type_from_closure() {
|
||||
super.test_initializer_executable_with_return_type_from_closure();
|
||||
}
|
||||
|
||||
@override
|
||||
@failingTest
|
||||
test_initializer_executable_with_return_type_from_closure_field() {
|
||||
super.test_initializer_executable_with_return_type_from_closure_field();
|
||||
}
|
||||
|
||||
@override
|
||||
@failingTest
|
||||
test_initializer_executable_with_unimported_return_type() {
|
||||
super.test_initializer_executable_with_unimported_return_type();
|
||||
}
|
||||
|
||||
@override
|
||||
@failingTest
|
||||
test_syntheticFunctionType_genericClosure() {
|
||||
super.test_syntheticFunctionType_genericClosure();
|
||||
}
|
||||
|
||||
@override
|
||||
@failingTest
|
||||
test_syntheticFunctionType_inGenericClass() {
|
||||
super.test_syntheticFunctionType_inGenericClass();
|
||||
}
|
||||
}
|
|
@ -11,7 +11,6 @@ import 'name_filter_test.dart' as name_filter_test;
|
|||
import 'package_bundle_reader_test.dart' as package_bundle_reader_test;
|
||||
import 'prelinker_test.dart' as prelinker_test;
|
||||
import 'resynthesize_ast_test.dart' as resynthesize_ast_test;
|
||||
import 'summarize_ast_one_phase_test.dart' as summarize_ast_one_phase_test;
|
||||
import 'summarize_ast_strong_test.dart' as summarize_ast_strong_test;
|
||||
import 'top_level_inference_test.dart' as top_level_inference_test;
|
||||
|
||||
|
@ -24,7 +23,6 @@ main() {
|
|||
package_bundle_reader_test.main();
|
||||
prelinker_test.main();
|
||||
resynthesize_ast_test.main();
|
||||
summarize_ast_one_phase_test.main();
|
||||
summarize_ast_strong_test.main();
|
||||
top_level_inference_test.main();
|
||||
}, name: 'summary');
|
||||
|
|
|
@ -17,7 +17,6 @@ import 'package:analyzer/src/generated/utilities_dart.dart';
|
|||
import 'package:analyzer/src/summary/format.dart';
|
||||
import 'package:analyzer/src/summary/idl.dart';
|
||||
import 'package:analyzer/src/summary/link.dart';
|
||||
import 'package:analyzer/src/summary/one_phase.dart';
|
||||
import 'package:analyzer/src/summary/package_bundle_reader.dart';
|
||||
import 'package:analyzer/src/summary/prelink.dart';
|
||||
import 'package:analyzer/src/summary/summarize_ast.dart';
|
||||
|
@ -320,99 +319,6 @@ abstract class SummaryBlackBoxTestStrategy extends SummaryBaseTestStrategy {
|
|||
void serializeLibraryText(String text, {bool allowErrors: false});
|
||||
}
|
||||
|
||||
/// Implementation of [SummaryBlackBoxTestStrategy] that drives summary
|
||||
/// generation using the new one-phase API.
|
||||
class SummaryBlackBoxTestStrategyOnePhase
|
||||
implements SummaryBlackBoxTestStrategy {
|
||||
/// Information about the files to be summarized.
|
||||
final _filesToSummarize = _FilesToLink<CompilationUnit>();
|
||||
|
||||
final _testUriString = absUri('/test.dart');
|
||||
|
||||
bool _allowMissingFiles = false;
|
||||
|
||||
@override
|
||||
LinkedLibrary linked;
|
||||
|
||||
@override
|
||||
List<UnlinkedUnit> unlinkedUnits;
|
||||
|
||||
SummaryBlackBoxTestStrategyOnePhase() {
|
||||
// TODO(paulberry): cache the bundle?
|
||||
_filesToSummarize.summaryDataStore
|
||||
.addBundle(null, new MockSdk().getLinkedBundle());
|
||||
}
|
||||
|
||||
@override
|
||||
void set allowMissingFiles(bool value) {
|
||||
_allowMissingFiles = value;
|
||||
}
|
||||
|
||||
@override
|
||||
bool get containsNonConstExprs => false;
|
||||
|
||||
@override
|
||||
bool get skipFullyLinkedData => false;
|
||||
|
||||
@override
|
||||
void addNamedSource(String filePath, String contents) {
|
||||
_filesToSummarize.uriToUnit[absUri(filePath)] = _parseText(contents);
|
||||
}
|
||||
|
||||
@override
|
||||
void serializeLibraryText(String text, {bool allowErrors = false}) {
|
||||
addNamedSource('/test.dart', text);
|
||||
var assembler = PackageBundleAssembler();
|
||||
summarize(_filesToSummarize.uriToUnit, _filesToSummarize.summaryDataStore,
|
||||
assembler, (name) => null, _allowMissingFiles);
|
||||
var result = assembler.assemble();
|
||||
linked = _findLinkedLibrary(result, _testUriString);
|
||||
unlinkedUnits =
|
||||
_findUnlinkedUnits(result, _testUriString, _allowMissingFiles);
|
||||
}
|
||||
|
||||
static LinkedLibrary _findLinkedLibrary(
|
||||
PackageBundle bundle, String uriString) {
|
||||
for (int i = 0; i < bundle.linkedLibraryUris.length; i++) {
|
||||
if (bundle.linkedLibraryUris[i] == uriString) {
|
||||
return bundle.linkedLibraries[i];
|
||||
}
|
||||
}
|
||||
throw new StateError('LinkedLibrary $uriString not found in bundle');
|
||||
}
|
||||
|
||||
static List<UnlinkedUnit> _findUnlinkedUnits(
|
||||
PackageBundle bundle, String uriString, bool allowMissingFiles) {
|
||||
var uriToUnlinkedUnit = <String, UnlinkedUnit>{};
|
||||
for (int i = 0; i < bundle.unlinkedUnitUris.length; i++) {
|
||||
uriToUnlinkedUnit[bundle.unlinkedUnitUris[i]] = bundle.unlinkedUnits[i];
|
||||
}
|
||||
var unlinkedDefiningUnit = uriToUnlinkedUnit[uriString];
|
||||
var unlinkedUnits = <UnlinkedUnit>[unlinkedDefiningUnit];
|
||||
var definingUnitUri = Uri.parse(uriString);
|
||||
for (String relativeUriStr in unlinkedDefiningUnit.publicNamespace.parts) {
|
||||
Uri relativeUri;
|
||||
try {
|
||||
relativeUri = Uri.parse(relativeUriStr);
|
||||
} on FormatException {
|
||||
unlinkedUnits.add(new UnlinkedUnitBuilder());
|
||||
continue;
|
||||
}
|
||||
|
||||
UnlinkedUnit unit = uriToUnlinkedUnit[
|
||||
resolveRelativeUri(definingUnitUri, relativeUri).toString()];
|
||||
if (unit == null) {
|
||||
if (!allowMissingFiles) {
|
||||
fail('Test referred to unknown unit $relativeUriStr');
|
||||
}
|
||||
} else {
|
||||
unlinkedUnits.add(unit);
|
||||
}
|
||||
}
|
||||
return unlinkedUnits;
|
||||
}
|
||||
}
|
||||
|
||||
/// Implementation of [SummaryBlackBoxTestStrategy] that drives summary
|
||||
/// generation using the old two-phase API, and exercises the pre-linker only.
|
||||
class SummaryBlackBoxTestStrategyPrelink
|
||||
|
|
Loading…
Reference in a new issue