Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(396)

Unified Diff: tests/compiler/dart2js/serialization/model_test_helper.dart

Issue 2194173002: Include constants in deferred computation. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Rebased Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: tests/compiler/dart2js/serialization/model_test_helper.dart
diff --git a/tests/compiler/dart2js/serialization/model_test_helper.dart b/tests/compiler/dart2js/serialization/model_test_helper.dart
index daf68663177fd4c55a56c4ba08079e99c6522688..18fd88cee59456e2bfe05381f085ef5f44d8f5ca 100644
--- a/tests/compiler/dart2js/serialization/model_test_helper.dart
+++ b/tests/compiler/dart2js/serialization/model_test_helper.dart
@@ -11,6 +11,7 @@ import 'package:expect/expect.dart';
import 'package:compiler/src/closure.dart';
import 'package:compiler/src/commandline_options.dart';
import 'package:compiler/src/common.dart';
+import 'package:compiler/src/constants/values.dart';
import 'package:compiler/src/compiler.dart';
import 'package:compiler/src/deferred_load.dart';
import 'package:compiler/src/elements/elements.dart';
@@ -161,6 +162,38 @@ Future checkModels(
compilerNormal.deferredLoadTask.isProgramSplit,
compilerDeserialized.deferredLoadTask.isProgramSplit,
"isProgramSplit mismatch");
+
+ Map<ConstantValue, OutputUnit> constants1 =
+ compilerNormal.deferredLoadTask.outputUnitForConstantsForTesting;
+ Map<ConstantValue, OutputUnit> constants2 =
+ compilerDeserialized.deferredLoadTask.outputUnitForConstantsForTesting;
+ checkSets(
+ constants1.keys,
+ constants2.keys,
+ 'deferredLoadTask._outputUnitForConstants.keys',
+ areConstantValuesEquivalent,
+ failOnUnfound: false,
+ failOnExtra: false,
+ onSameElement: (ConstantValue value1, ConstantValue value2) {
+ OutputUnit outputUnit1 = constants1[value1];
+ OutputUnit outputUnit2 = constants2[value2];
+ checkOutputUnits(outputUnit1, outputUnit2,
+ 'for ${value1.toStructuredText()} '
+ 'vs ${value2.toStructuredText()}');
+ },
+ onUnfoundElement: (ConstantValue value1) {
+ OutputUnit outputUnit1 = constants1[value1];
+ Expect.isTrue(outputUnit1.isMainOutput,
+ "Missing deferred constant: ${value1.toStructuredText()}");
+ },
+ onExtraElement: (ConstantValue value2) {
+ OutputUnit outputUnit2 = constants2[value2];
+ Expect.isTrue(outputUnit2.isMainOutput,
+ "Extra deferred constant: ${value2.toStructuredText()}");
+ },
+ elementToString: (a) {
+ return '${a.toStructuredText()} -> ${constants1[a]}/${constants2[a]}';
+ });
});
}
@@ -244,7 +277,7 @@ void checkElements(
backend2.inlineCache.getCurrentCacheDecisionForTesting(element2),
"Inline cache decision mismatch for $element1 vs $element2");
- checkOutputUnits(compiler1, compiler2, element1, element2);
+ checkElementOutputUnits(compiler1, compiler2, element1, element2);
}
void checkMixinUses(
@@ -360,17 +393,24 @@ String nodeToString(Node node) {
return '(${node.runtimeType}) $text';
}
-void checkOutputUnits(Compiler compiler1, Compiler compiler2, Element element1,
- Element element2) {
+void checkElementOutputUnits(
+ Compiler compiler1, Compiler compiler2,
+ Element element1, Element element2) {
OutputUnit outputUnit1 =
- compiler1.deferredLoadTask.outputUnitForElement(element1);
+ compiler1.deferredLoadTask.getOutputUnitForElementForTesting(element1);
OutputUnit outputUnit2 =
- compiler2.deferredLoadTask.outputUnitForElement(element2);
+ compiler2.deferredLoadTask.getOutputUnitForElementForTesting(element2);
+ checkOutputUnits(outputUnit1, outputUnit2, 'for $element1 vs $element2');
+}
+
+void checkOutputUnits(
+ OutputUnit outputUnit1, OutputUnit outputUnit2, String message) {
+ if (outputUnit1 == null && outputUnit2 == null) return;
check(outputUnit1, outputUnit2,
- 'OutputUnit.isMainOutput for $element1 vs $element2',
+ 'OutputUnit.isMainOutput $message',
outputUnit1.isMainOutput, outputUnit2.isMainOutput);
checkSetEquivalence(outputUnit1, outputUnit2,
- 'OutputUnit.imports for $element1 vs $element2',
+ 'OutputUnit.imports $message',
outputUnit1.imports, outputUnit2.imports,
(a, b) => areElementsEquivalent(a.declaration, b.declaration));
}
« no previous file with comments | « pkg/compiler/lib/src/serialization/equivalence.dart ('k') | tests/compiler/dart2js/serialization/test_data.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698