Remove astBytes from linker and bundles.

Change-Id: If7adbe45379acf397a58e8915afb54bfbe72d491
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/201340
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
Konstantin Shcheglov 2021-05-26 01:47:11 +00:00 committed by commit-bot@chromium.org
parent 7e76ac60b2
commit 987ab6a815
9 changed files with 10 additions and 27 deletions

View file

@ -116,7 +116,6 @@ class _Builder {
);
}
return bundleBuilder.finish(
astBytes: linkResult.astBytes,
resolutionBytes: linkResult.resolutionBytes,
sdk: PackageBundleSdk(
languageVersionMajor: languageVersion.major,

View file

@ -81,7 +81,7 @@ import 'package:meta/meta.dart';
/// TODO(scheglov) Clean up the list of implicitly analyzed files.
class AnalysisDriver implements AnalysisDriverGeneric {
/// The version of data format, should be incremented on every format change.
static const int DATA_VERSION = 140;
static const int DATA_VERSION = 141;
/// The length of the list returned by [_computeDeclaredVariablesSignature].
static const int _declaredVariablesSignatureLength = 4;

View file

@ -124,7 +124,7 @@ class FileState {
Set<String>? _referencedNames;
List<int>? _unlinkedSignature;
String? _unlinkedKey;
String? _astKey;
String? _informativeKey;
AnalysisDriverUnlinkedUnit? _driverUnlinkedUnit;
List<int>? _apiSignature;
@ -375,12 +375,12 @@ class FileState {
return other is FileState && other.uri == uri;
}
Uint8List getAstBytes({CompilationUnit? unit}) {
var bytes = _fsState._byteStore.get(_astKey!) as Uint8List?;
Uint8List getInformativeBytes({CompilationUnit? unit}) {
var bytes = _fsState._byteStore.get(_informativeKey!) as Uint8List?;
if (bytes == null) {
unit ??= parse();
bytes = writeUnitInformative(unit);
_fsState._byteStore.put(_astKey!, bytes);
_fsState._byteStore.put(_informativeKey!, bytes);
}
return bytes;
}
@ -443,7 +443,7 @@ class FileState {
var signatureHex = hex.encode(_unlinkedSignature!);
_unlinkedKey = '$signatureHex.unlinked2';
// TODO(scheglov) Use the path as the key, and store the signature.
_astKey = '$signatureHex.ast';
_informativeKey = '$signatureHex.ast';
}
// Prepare bytes of the unlinked bundle - existing or new.

View file

@ -112,7 +112,7 @@ class LibraryContext {
var unitsInformativeBytes = <Uri, Uint8List>{};
for (var library in cycle.libraries) {
for (var file in library.libraryFiles) {
unitsInformativeBytes[file.uri] = file.getAstBytes();
unitsInformativeBytes[file.uri] = file.getInformativeBytes();
}
}

View file

@ -34,10 +34,8 @@ class BundleReader {
final Map<String, LibraryReader> libraryMap = {};
/// TODO(scheglov) Remove [astBytes].
BundleReader({
required LinkedElementFactory elementFactory,
Uint8List? astBytes, // ignore: avoid_unused_constructor_parameters
required Uint8List resolutionBytes,
Map<Uri, Uint8List> unitsInformativeBytes = const {},
}) : _reader = SummaryDataReader(resolutionBytes),

View file

@ -87,7 +87,6 @@ class BundleWriter {
var bytes = _sink.flushAndTake();
return BundleWriterResult(
astBytes: Uint8List(0),
resolutionBytes: bytes,
);
}
@ -482,11 +481,9 @@ class BundleWriter {
}
class BundleWriterResult {
final Uint8List astBytes;
final Uint8List resolutionBytes;
BundleWriterResult({
required this.astBytes,
required this.resolutionBytes,
});
}

View file

@ -34,7 +34,6 @@ LinkResult link(
var linker = Linker(elementFactory);
linker.link(inputLibraries);
return LinkResult(
astBytes: linker.astBytes,
resolutionBytes: linker.resolutionBytes,
);
}
@ -49,7 +48,6 @@ class Linker {
late InheritanceManager3 inheritance; // TODO(scheglov) cache it
late Uint8List astBytes;
late Uint8List resolutionBytes;
Linker(this.elementFactory);
@ -229,7 +227,6 @@ class Linker {
}
var writeWriterResult = bundleWriter.finish();
astBytes = writeWriterResult.astBytes;
resolutionBytes = writeWriterResult.resolutionBytes;
}
}
@ -280,11 +277,11 @@ class LinkInputUnit {
}
class LinkResult {
final Uint8List astBytes;
@Deprecated('This field is not used anymore')
final Uint8List astBytes = Uint8List(0);
final Uint8List resolutionBytes;
LinkResult({
required this.astBytes,
required this.resolutionBytes,
});
}

View file

@ -21,7 +21,7 @@ class PackageBundleBuilder {
}
Uint8List finish({
required Uint8List astBytes,
@Deprecated('This parameter is not used anymore') Uint8List? astBytes,
required Uint8List resolutionBytes,
PackageBundleSdk? sdk,
}) {
@ -43,7 +43,6 @@ class PackageBundleBuilder {
);
});
sink.writeUint8List(astBytes);
sink.writeUint8List(resolutionBytes);
return sink.flushAndTake();
@ -84,13 +83,9 @@ class PackageBundleReader {
);
}
reader.readUint8List(); // astBytes
_resolutionBytes = reader.readUint8List();
}
@Deprecated('The linker does not need it anymore')
Uint8List get astBytes => Uint8List(0);
Uint8List get resolutionBytes => _resolutionBytes;
PackageBundleSdk? get sdk => _sdk;

View file

@ -81,7 +81,6 @@ class ResynthesizeAst2Test extends AbstractResynthesizeTest
var sdkLinkResult = link(elementFactory, inputLibraries, true);
return _sdkBundle = _SdkBundle(
astBytes: sdkLinkResult.astBytes,
resolutionBytes: sdkLinkResult.resolutionBytes,
);
}
@ -244,11 +243,9 @@ class _AnalysisSessionForLinking implements AnalysisSessionImpl {
}
class _SdkBundle {
final Uint8List astBytes;
final Uint8List resolutionBytes;
_SdkBundle({
required this.astBytes,
required this.resolutionBytes,
});
}