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

Unified Diff: pkg/compiler/lib/src/js_backend/codegen/task.dart

Issue 1616673002: dart2js cps: Debugging utility and fix idempotency in shrinking reducer. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Do not run the same Pass instance twice Created 4 years, 11 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
« no previous file with comments | « pkg/compiler/lib/src/cps_ir/type_propagation.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/js_backend/codegen/task.dart
diff --git a/pkg/compiler/lib/src/js_backend/codegen/task.dart b/pkg/compiler/lib/src/js_backend/codegen/task.dart
index a53a89ad056776b14338612b0a793dca8302e2ea..6e0619bc044ae3a8c74d8fc0dcd3058f30cb63c1 100644
--- a/pkg/compiler/lib/src/js_backend/codegen/task.dart
+++ b/pkg/compiler/lib/src/js_backend/codegen/task.dart
@@ -103,7 +103,7 @@ class CpsFunctionCompiler implements FunctionCompiler {
}
if (tracer != null) {
- tracer.traceCompilation(element.name, null);
+ tracer.traceCompilation('$element', null);
}
cps.FunctionDefinition cpsFunction = compileToCpsIr(element);
optimizeCpsBeforeInlining(cpsFunction);
@@ -131,6 +131,49 @@ class CpsFunctionCompiler implements FunctionCompiler {
}
}
+ String stringify(cps.FunctionDefinition node) {
+ return new SExpressionStringifier().withTypes().visit(node);
+ }
+
+ /// For debugging purposes, replace a call to [applyCpsPass] with a call
+ /// to [debugCpsPass] to check that this pass is idempotent.
+ ///
+ /// This runs [pass] followed by shrinking reductions, and then checks that
+ /// one more run of [pass] does not change the IR. The intermediate shrinking
+ /// reductions pass is omitted if [pass] itself is shrinking reductions.
+ ///
+ /// If [targetName] is given, functions whose name contains that substring
+ /// will be dumped out if the idempotency test fails.
+ void debugCpsPass(cps_opt.Pass makePass(),
+ cps.FunctionDefinition cpsFunction,
+ [String targetName]) {
+ String original = stringify(cpsFunction);
+ cps_opt.Pass pass = makePass();
+ pass.rewrite(cpsFunction);
+ assert(checkCpsIntegrity(cpsFunction, pass.passName));
+ if (pass is! ShrinkingReducer) {
+ new ShrinkingReducer().rewrite(cpsFunction);
+ }
+ String before = stringify(cpsFunction);
+ makePass().rewrite(cpsFunction);
+ String after = stringify(cpsFunction);
+ if (before != after) {
+ print('SExpression changed for ${cpsFunction.element}');
+ if (targetName != null && '${cpsFunction.element}'.contains(targetName)) {
+ print(original);
+ print('\n-->\n');
+ print(before);
+ print('\n-->\n');
+ print(after);
+ compiler.outputProvider('original', 'dump')..add(original)..close();
+ compiler.outputProvider('before', 'dump')..add(before)..close();
+ compiler.outputProvider('after', 'dump')..add(after)..close();
+ }
+ }
+ traceGraph(pass.passName, cpsFunction);
+ dumpTypedIr(pass.passName, cpsFunction);
+ }
+
void applyCpsPass(cps_opt.Pass pass, cps.FunctionDefinition cpsFunction) {
cpsOptimizationTask.measureSubtask(pass.passName, () {
pass.rewrite(cpsFunction);
« no previous file with comments | « pkg/compiler/lib/src/cps_ir/type_propagation.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698