Skip to content

Commit b3a688a

Browse files
jcollins-gcommit-bot@chromium.org
authored and
commit-bot@chromium.org
committed
Revert "Keep libraries after linking, don't reload from bytes."
This reverts commit fa303eb. Reason for revert: This breaks dartdoc until dart-lang/dartdoc#2687 can roll to analyzer. Original change's description: > Keep libraries after linking, don't reload from bytes. > > Presubmit in google3 looks green. > https://test.corp.google.com/ui#id=OCL:376412203:BASE:379875911:1623903883365:2a59d852 > > Change-Id: I344d49fa12e2f07aa00623ea08e7530872ca2eec > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/201661 > Reviewed-by: Samuel Rawlins <srawlins@google.com> > Commit-Queue: Konstantin Shcheglov <scheglov@google.com> # Not skipping CQ checks because original CL landed > 1 day ago. Change-Id: I6eeee8b6f480a6ac5c2665e5844f04788c1174a4 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/204263 Commit-Queue: Janice Collins <jcollins@google.com> Commit-Queue: Devon Carew <devoncarew@google.com> Auto-Submit: Janice Collins <jcollins@google.com> Reviewed-by: Devon Carew <devoncarew@google.com>
1 parent 685a078 commit b3a688a

File tree

4 files changed

+36
-46
lines changed

4 files changed

+36
-46
lines changed

pkg/analyzer/lib/src/dart/analysis/library_context.dart

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -183,18 +183,21 @@ class LibraryContext {
183183
counterUnlinkedLinkedBytes += resolutionBytes.length;
184184

185185
librariesLinkedTimer.stop();
186+
// TODO(scheglov) Uncomment to keep linking elements.
187+
// return;
186188
} else {
187189
// TODO(scheglov) Take / clear parsed units in files.
188190
bytesGet += resolutionBytes.length;
189191
librariesLoaded += cycle.libraries.length;
190-
elementFactory.addBundle(
191-
BundleReader(
192-
elementFactory: elementFactory,
193-
unitsInformativeBytes: unitsInformativeBytes,
194-
resolutionBytes: resolutionBytes,
195-
),
196-
);
197192
}
193+
194+
elementFactory.addBundle(
195+
BundleReader(
196+
elementFactory: elementFactory,
197+
unitsInformativeBytes: unitsInformativeBytes,
198+
resolutionBytes: resolutionBytes,
199+
),
200+
);
198201
}
199202

200203
logger.run('Prepare linked bundles', () {

pkg/analyzer/lib/src/dart/micro/resolve_file.dart

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -908,16 +908,17 @@ class _LibraryContext {
908908
} else {
909909
performance.getDataInt('bytesGet').add(resolutionBytes.length);
910910
performance.getDataInt('libraryLoadCount').add(cycle.libraries.length);
911-
elementFactory.addBundle(
912-
BundleReader(
913-
elementFactory: elementFactory,
914-
unitsInformativeBytes: unitsInformativeBytes,
915-
resolutionBytes: resolutionBytes as Uint8List,
916-
),
917-
);
918911
}
919912
cycle.resolutionId = resolutionData!.id;
920913

914+
elementFactory.addBundle(
915+
BundleReader(
916+
elementFactory: elementFactory,
917+
unitsInformativeBytes: unitsInformativeBytes,
918+
resolutionBytes: resolutionBytes as Uint8List,
919+
),
920+
);
921+
921922
// We might have just linked dart:core, ensure the type provider.
922923
_createElementFactoryTypeProvider();
923924
}

pkg/analyzer/lib/src/summary2/link.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import 'package:analyzer/src/summary2/types_builder.dart';
2424
import 'package:analyzer/src/summary2/variance_builder.dart';
2525

2626
var timerLinkingLinkingBundle = Stopwatch();
27+
var timerLinkingRemoveBundle = Stopwatch();
2728

2829
/// Note that AST units and tokens of [inputLibraries] will be damaged.
2930
///
@@ -80,6 +81,13 @@ class Linker {
8081
timerLinkingLinkingBundle.start();
8182
_writeLibraries();
8283
timerLinkingLinkingBundle.stop();
84+
85+
// TODO(scheglov) Remove to keep linking elements.
86+
timerLinkingRemoveBundle.start();
87+
elementFactory.removeBundle(
88+
inputLibraries.map((e) => e.uriStr).toSet(),
89+
);
90+
timerLinkingRemoveBundle.stop();
8391
}
8492

8593
void _buildEnumChildren() {

pkg/analyzer/test/src/summary/resynthesize_ast2_test.dart

Lines changed: 10 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ import 'test_strategies.dart';
2626

2727
main() {
2828
defineReflectiveSuite(() {
29-
defineReflectiveTests(ResynthesizeAstKeepLinkingTest);
30-
defineReflectiveTests(ResynthesizeAstFromBytesTest);
29+
defineReflectiveTests(ResynthesizeAst2Test);
3130
// defineReflectiveTests(ApplyCheckElementTextReplacements);
3231
});
3332
}
@@ -40,16 +39,11 @@ class ApplyCheckElementTextReplacements {
4039
}
4140

4241
@reflectiveTest
43-
abstract class ResynthesizeAst2Test extends AbstractResynthesizeTest
42+
class ResynthesizeAst2Test extends AbstractResynthesizeTest
4443
with ResynthesizeTestCases {
4544
/// The shared SDK bundle, computed once and shared among test invocations.
4645
static _SdkBundle? _sdkBundle;
4746

48-
/// We need to test both cases - when we keep linking libraries (happens for
49-
/// new or invalidated libraries), and when we load libraries from bytes
50-
/// (happens internally in Blaze or when we have cached summaries).
51-
bool get keepLinkingLibraries;
52-
5347
_SdkBundle get sdkBundle {
5448
if (_sdkBundle != null) {
5549
return _sdkBundle!;
@@ -130,18 +124,14 @@ abstract class ResynthesizeAst2Test extends AbstractResynthesizeTest
130124

131125
var linkResult = link(elementFactory, inputLibraries, true);
132126

133-
if (!keepLinkingLibraries) {
134-
elementFactory.removeBundle(
135-
inputLibraries.map((e) => e.uriStr).toSet(),
136-
);
137-
elementFactory.addBundle(
138-
BundleReader(
139-
elementFactory: elementFactory,
140-
unitsInformativeBytes: unitsInformativeBytes,
141-
resolutionBytes: linkResult.resolutionBytes,
142-
),
143-
);
144-
}
127+
// TODO(scheglov) Remove to keep linking elements.
128+
elementFactory.addBundle(
129+
BundleReader(
130+
elementFactory: elementFactory,
131+
unitsInformativeBytes: unitsInformativeBytes,
132+
resolutionBytes: linkResult.resolutionBytes,
133+
),
134+
);
145135

146136
return elementFactory.libraryOfUri('${source.uri}')!;
147137
}
@@ -242,18 +232,6 @@ abstract class ResynthesizeAst2Test extends AbstractResynthesizeTest
242232
}
243233
}
244234

245-
@reflectiveTest
246-
class ResynthesizeAstFromBytesTest extends ResynthesizeAst2Test {
247-
@override
248-
bool get keepLinkingLibraries => false;
249-
}
250-
251-
@reflectiveTest
252-
class ResynthesizeAstKeepLinkingTest extends ResynthesizeAst2Test {
253-
@override
254-
bool get keepLinkingLibraries => true;
255-
}
256-
257235
class _AnalysisSessionForLinking implements AnalysisSessionImpl {
258236
@override
259237
final ClassHierarchy classHierarchy = ClassHierarchy();

0 commit comments

Comments
 (0)